Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tuple grammar. #79

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions amarna/grammars/cairo.lark
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ _NEQ: "!="
_ARROW: "->"
_AT: "@"

comma: ","
_expr_sep: (comma | nonempty_notes)+
comma_separated_with_notes{item}: notes item? (_expr_sep item)* _expr_sep?


// Types.
type: "felt" -> type_felt
| identifier -> type_struct
| type "*" -> type_pointer
| type _DBL_STAR -> type_pointer2
| "(" ((type ",")* type ","?)? ")" -> type_tuple
// Types.
named_type: identifier (":" type)? | non_identifier_type
non_identifier_type: "felt" -> type_felt
| "codeoffset" -> type_codeoffset
| type "*" -> type_pointer
| type _DBL_STAR -> type_pointer2
| "(" comma_separated_with_notes{named_type} ")" -> type_tuple
?type: non_identifier_type
| identifier -> type_struct

// Expressions.
expr_assignment: expr | identifier_def "=" expr
Expand All @@ -31,8 +40,7 @@ non_def_expr_assignment: expr | named_identifier "=" expr
?arg_list_item: expr_assignment
?non_def_arg_list_item: non_def_expr_assignment

comma: ","
_expr_sep: (comma | nonempty_notes)+

arg_list: (notes arg_list_item? (_expr_sep arg_list_item)* _expr_sep?)
non_def_arg_list: (notes non_def_arg_list_item? (_expr_sep non_def_arg_list_item)* _expr_sep?)

Expand Down