diff options
| author | Baitinq <[email protected]> | 2025-01-18 23:29:31 +0100 |
|---|---|---|
| committer | Baitinq <[email protected]> | 2025-01-18 23:29:31 +0100 |
| commit | 79c0f45847dee608747eca6b8e36e68cb9c881e3 (patch) | |
| tree | 3c651c35d9de5e2897b9a1225d7965b8d3071feb /grammar.ebnf | |
| parent | Examples: add future examples :^) (diff) | |
| download | pry-lang-79c0f45847dee608747eca6b8e36e68cb9c881e3.tar.gz pry-lang-79c0f45847dee608747eca6b8e36e68cb9c881e3.tar.bz2 pry-lang-79c0f45847dee608747eca6b8e36e68cb9c881e3.zip | |
Feature: Add basic support for if statements
Diffstat (limited to 'grammar.ebnf')
| -rw-r--r-- | grammar.ebnf | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/grammar.ebnf b/grammar.ebnf index 35a7079..caf8c73 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -1,21 +1,26 @@ Program ::= Statement+ -Statement ::= (AssignmentStatement | FunctionCallStatement) SEMICOLON +Statement ::= (AssignmentStatement | FunctionCallStatement | IfStatement | ReturnStatement) SEMICOLON AssignmentStatement ::= "let" IDENTIFIER EQUALS Expression FunctionCallStatement ::= IDENTIFIER LPAREN FunctionArguments? RPAREN +IfStatement ::= "if" Expression LBRACE Statement* RBRACE -- TODO: Should function definitions be allowed? + +ReturnStatement ::= RETURN Expression + FunctionArguments ::= Expression ("," Expression)* +--TODO: == + Expression ::= AdditiveExpression | FunctionDefinition AdditiveExpression ::= PrimaryExpression ("+" AdditiveExpression) PrimaryExpression ::= NUMBER | IDENTIFIER | FunctionCallStatement -FunctionDefinition ::= LPAREN FunctionParamters? RPAREN ARROW LBRACE Statement* ReturnStatement RBRACE +FunctionDefinition ::= LPAREN FunctionParamters? RPAREN ARROW LBRACE Statement* ReturnStatement SEMICOLON RBRACE FunctionParameters ::= IDENTIFIER ("," IDENTIFIER)* -ReturnStatement ::= RETURN Expression SEMICOLON --TODO: I dont like this |