diff options
| author | Baitinq <[email protected]> | 2025-05-28 00:11:06 +0200 |
|---|---|---|
| committer | Baitinq <[email protected]> | 2025-05-28 00:11:06 +0200 |
| commit | 48958afe4e187ce496d3445ee622ec3bc7bc8453 (patch) | |
| tree | bf6c0ead8240a27e150e9e81dd9207cee4dbe211 /grammar.ebnf | |
| parent | Feature: Finish adding struct support :^) (diff) | |
| download | pry-lang-48958afe4e187ce496d3445ee622ec3bc7bc8453.tar.gz pry-lang-48958afe4e187ce496d3445ee622ec3bc7bc8453.tar.bz2 pry-lang-48958afe4e187ce496d3445ee622ec3bc7bc8453.zip | |
Feature: Add sizeof builtin function
Diffstat (limited to 'grammar.ebnf')
| -rw-r--r-- | grammar.ebnf | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/grammar.ebnf b/grammar.ebnf index 78101f1..cecc65e 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -1,6 +1,6 @@ Program ::= Statement+ -Statement ::= (AssignmentStatement | ImportDeclaration | ExternDeclaration | CastStatement| FunctionCallStatement | IfStatement | WhileStatement | ReturnStatement | "break" | "continue") SEMICOLON +Statement ::= (AssignmentStatement | ImportDeclaration | ExternDeclaration | CastStatement | SizeOfStatement | FunctionCallStatement | IfStatement | WhileStatement | ReturnStatement | "break" | "continue") SEMICOLON AssignmentStatement ::= ("let")? ("*")? Expression EQUALS Expression @@ -21,6 +21,8 @@ FunctionArguments ::= Expression ("," Expression)* Expression ::= EqualityExpression | AdditiveExpression CastStatement ::= "cast" LPAREN TYPE "," Expression RPAREN + +SizeOfStatement ::= "sizeof" LPAREN TYPE RPAREN EqualityExpression ::= AdditiveExpression ("==" | "!=" | "<=" | ">=" | "<" | ">") AdditiveExpression @@ -30,7 +32,7 @@ MultiplicativeExpression ::= UnaryExpression (("*" | "/" | "%") UnaryExpression) UnaryExpression ::= ("!" | "-" | "*") UnaryExpression | PostfixExpression -PostfixExpression ::= PrimaryExpression (FieldAccess | FunctionCallStatement | CastStatement)* +PostfixExpression ::= PrimaryExpression (FieldAccess | FunctionCallStatement | CastStatement | SizeOfStatement)* PrimaryExpression ::= NULL | NUMBER | BOOLEAN | CHAR | STRING | IDENTIFIER | FunctionDefinition | StructDefinition | StructInstantiation | FieldAccess | LPAREN Expression RPAREN |