Skip to content

Commit

Permalink
Fixed grammar (hanging comma)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrylR committed Aug 3, 2024
1 parent 3fde741 commit b077169
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions grammar/Circom.g4
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ templateDeclaration
;

componentMainDeclaration
: 'component' 'main' ('{' 'public' '[' args ']' '}')? '=' ID '(' (expression ','?)* ')' ';'
: 'component' 'main' ('{' 'public' '[' args ']' '}')? '=' ID '(' expressionList? ')' ';'
;

statement
Expand Down Expand Up @@ -80,7 +80,7 @@ expression
| blockInstantiation
| expression '.' ID ('[' expression ']')?
| expression '?' expression ':' expression
| ('~' | '!' | '-') expression
| ('~' | '!') expression
| expression '**' expression
| expression ('*' | '/' | '\\' | '%') expression
| expression ('+' | '-') expression
Expand All @@ -91,7 +91,7 @@ expression

primary
: '(' expression ')'
| '[' (expression ','?)+ ']'
| '[' expressionList ']'
| NUMBER
| identifier
| args
Expand Down Expand Up @@ -121,19 +121,21 @@ varDeclaration
rhsValue: expression | blockInstantiation ;

componentCall
: '(' (expression ','?)* ')'
| '(' (ID LEFT_ASSIGNMENT expression ','?)* ')'
| '(' (expression RIGHT_ASSIGNMENT ID ','?)* ')'
: '(' expressionList? ')'
| '(' ID LEFT_ASSIGNMENT expression (',' ID LEFT_ASSIGNMENT expression)* ')'
| '(' expression RIGHT_ASSIGNMENT ID (',' expression RIGHT_ASSIGNMENT ID)* ')'
;

blockInstantiation: ID '(' (expression ','?)* ')' componentCall? ;
blockInstantiation: ID '(' expressionList? ')' componentCall? ;

arrayDimension: '[' (NUMBER | ID | expression) ']' ;

argsWithUnderscore: ('_' | ID) (',' ('_' | ID) )* ;

args: (ID ','?)+ ;
args: ID (',' ID)* ;

numSequence: (NUMBER ','?)+ ;
numSequence: NUMBER (',' NUMBER)* ;

expressionList: expression (',' expression)* ;

identifier: ID arrayDimension* ;

0 comments on commit b077169

Please sign in to comment.