Skip to content

Commit

Permalink
Merge branch 'feature/refactor-if'
Browse files Browse the repository at this point in the history
  • Loading branch information
asosnoviy committed Aug 20, 2019
2 parents cbdb6ff + f8a9686 commit 8b04d29
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/antlr/BSLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ options {
}

// ROOT
file: shebang? preprocessor* moduleVars? preprocessor* codeBlockBeforeSub subs? codeBlock EOF;
file: shebang? preprocessor* moduleVars? preprocessor* fileCodeBlockBeforeSub subs? fileCodeBlock EOF;

// preprocessor
shebang : HASH PREPROC_EXCLAMATION_MARK (PREPROC_ANY | PREPROC_IDENTIFIER)*;
Expand Down Expand Up @@ -153,8 +153,18 @@ subCodeBlock : subVars? codeBlock;
continueStatement : CONTINUE_KEYWORD;
breakStatement : BREAK_KEYWORD;
raiseStatement : RAISE_KEYWORD expression?;
ifStatement : IF_KEYWORD expression THEN_KEYWORD codeBlock
(ELSIF_KEYWORD expression THEN_KEYWORD codeBlock)* (ELSE_KEYWORD codeBlock)? ENDIF_KEYWORD;
ifStatement
: ifBranch elsifBranch* elseBranch? ENDIF_KEYWORD
;
ifBranch
: IF_KEYWORD expression THEN_KEYWORD codeBlock
;
elsifBranch
: ELSIF_KEYWORD expression THEN_KEYWORD codeBlock
;
elseBranch
: ELSE_KEYWORD codeBlock
;
whileStatement : WHILE_KEYWORD expression DO_KEYWORD codeBlock ENDDO_KEYWORD;
forStatement : FOR_KEYWORD IDENTIFIER ASSIGN expression TO_KEYWORD expression DO_KEYWORD codeBlock ENDDO_KEYWORD;
forEachStatement : FOR_KEYWORD EACH_KEYWORD IDENTIFIER IN_KEYWORD expression DO_KEYWORD codeBlock ENDDO_KEYWORD;
Expand Down Expand Up @@ -187,7 +197,10 @@ removeHandlerStatement
ternaryOperator : QUESTION LPAREN expression COMMA expression COMMA expression RPAREN;

// main
codeBlockBeforeSub
fileCodeBlockBeforeSub
: codeBlock
;
fileCodeBlock
: codeBlock
;
codeBlock : (statement | preprocessor)*;
Expand Down

0 comments on commit 8b04d29

Please sign in to comment.