This shows you the differences between two versions of the page.
|
alf:teme:tema3_en [2020/03/20 18:02] diana.ghindaoanu created |
alf:teme:tema3_en [2020/04/07 20:06] (current) alexandru.radovici |
||
|---|---|---|---|
| Line 4: | Line 4: | ||
| <note important> | <note important> | ||
| - | Deadline: **7th of April, 23:55**\\ | + | Deadline: **12th of April, 23:55**\\ |
| Points: **2 points** out of the final grade\\ | Points: **2 points** out of the final grade\\ | ||
| Upload the homework: [[https://vmchecker.cs.pub.ro|vmchecker.cs.pub.ro]]\\ | Upload the homework: [[https://vmchecker.cs.pub.ro|vmchecker.cs.pub.ro]]\\ | ||
| Line 31: | Line 31: | ||
| Try running small scripts to test every feature. | Try running small scripts to test every feature. | ||
| + | |||
| + | A useful debugging too is [[https://nolanlawson.github.io/jison-debugger|jison-debugger]] | ||
| ===== AST Format ===== | ===== AST Format ===== | ||
| Line 48: | Line 50: | ||
| The list of the node ids is: | The list of the node ids is: | ||
| - | * program - the actual program | + | * script - the actual program |
| * var - variable definition | * var - variable definition | ||
| * expr - any expression | * expr - any expression | ||
| Line 56: | Line 58: | ||
| * prop - a property of a class | * prop - a property of a class | ||
| * vector - array definition | * vector - array definition | ||
| - | * element - an element of an array | + | * element_of_vector - an element of an array |
| * if_then - if statement | * if_then - if statement | ||
| - | * loop_while - while statement | + | * loop_when - while statement |
| - | * loop_for - for statement | + | * loop_go - for statement |
| - | * function_run - call (run) a function | + | * function_call - call (run) a function |
| * return - value of a function | * return - value of a function | ||
| - | * value - a value (integer, logic, float, string, user_defined) | + | * value - a value (int, bool, float, string, character, user_defined) |
| ===== Questions ===== | ===== Questions ===== | ||
| Line 243: | Line 245: | ||
| </code> | </code> | ||
| - | [[https://github.com/upb-fils/alf/tree/master/Devoir/alf/verify/alf/6_class|Example]] | + | [[https://github.com/upb-fils/alf/tree/master/Devoir/alf/verify/alf/6_struct|Example]] |
| === Property access === | === Property access === | ||
| Line 266: | Line 268: | ||
| </code> | </code> | ||
| - | [[https://github.com/upb-fils/alf/tree/master/Devoir/alf/verify/alf/6_class|Example]] | + | [[https://github.com/upb-fils/alf/tree/master/Devoir/alf/verify/alf/6_struct|Example]] |
| Line 275: | Line 277: | ||
| == Language == | == Language == | ||
| <code> | <code> | ||
| - | vector_name:elements_data_type[integer_number : integer_number] | + | vector_name:elements_data_type[integer_number -- integer_number] |
| <note> | <note> | ||
| [] are actual brackets and are mandatory | [] are actual brackets and are mandatory | ||
| Line 302: | Line 304: | ||
| <code javascript> | <code javascript> | ||
| { | { | ||
| - | id:"vector_element", | + | id:"element_of_vector", |
| vector:{ | vector:{ | ||
| expression for array | expression for array | ||
| Line 401: | Line 403: | ||
| <code> | <code> | ||
| - | function function_name:return_type (parameter1:[parameter1_type][<-value], ...) -> expression; | + | function function_name (parameter1:[parameter1_type][<-value], ...):return_type -> expression; |
| </code> | </code> | ||
| <code> | <code> | ||
| - | function function_name:return_type (parameter1:[parameter1_type][<-value], ...) | + | function function_name (parameter1:[parameter1_type][<-value], ...):return_type |
| start | start | ||
| ... | ... | ||
| Line 420: | Line 422: | ||
| <code> | <code> | ||
| - | function sum:int (a:int, b:int) -> a+b; | + | function sum (a:int, b:int):int -> a+b; |
| </code> | </code> | ||
| <code> | <code> | ||
| - | function power:int (a:int, n:int) | + | function power (a:int, n:int):int |
| start | start | ||
| @var p:int; | @var p:int; | ||
| Line 456: | Line 458: | ||
| </code> | </code> | ||
| - | [[https://github.com/upb-fils/alf/tree/master/Devoir/alf/verify/alf/4_messages|Example]] | + | [[https://github.com/UPB-FILS/alf/tree/master/Devoir/alf/verify/alf/4_function|Example]] |
| === Return === | === Return === | ||
| Line 600: | Line 602: | ||
| <code> | <code> | ||
| - | for variable_name between expression go | + | for variable_name of expression go |
| ... | ... | ||
| end; | end; | ||
| Line 623: | Line 625: | ||
| <code javascript> | <code javascript> | ||
| { | { | ||
| - | id:"loop_for", | + | id:"for", |
| variable:variable_name, | variable:variable_name, | ||
| exp:{ | exp:{ | ||
| Line 639: | Line 641: | ||
| <code javascript> | <code javascript> | ||
| { | { | ||
| - | id:"loop_for", | + | id:"for", |
| variable:variable_name, | variable:variable_name, | ||
| from: { expression }, | from: { expression }, | ||
| Line 703: | Line 705: | ||
| <code> | <code> | ||
| - | #register identifier value | + | ®ister identifier value |
| </code> | </code> | ||
| Line 712: | Line 714: | ||
| <code> | <code> | ||
| - | #register platform ... | + | ®ister platform ... |
| ... | ... | ||
| - | #if platform = windows | + | &if platform = windows |
| p <- "Windows" #this source is ignored if platform is not windows# | p <- "Windows" #this source is ignored if platform is not windows# | ||
| - | #else | + | &else |
| p <- "Linux" #this source code is ignored if platform is not linux# | p <- "Linux" #this source code is ignored if platform is not linux# | ||
| - | #endif | + | &endif |
| </code> | </code> | ||
| Line 727: | Line 729: | ||
| <code> | <code> | ||
| - | #register N value | + | ®ister N value |
| ... | ... | ||
| - | #unregister N | + | &unregister N |
| #N is undefined# | #N is undefined# | ||