From b077169bc8249e4cff08eaf20d2423760f3005c2 Mon Sep 17 00:00:00 2001 From: Kyryl Riabov Date: Sat, 3 Aug 2024 17:55:39 +0300 Subject: [PATCH] Fixed grammar (hanging comma) --- grammar/Circom.g4 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/grammar/Circom.g4 b/grammar/Circom.g4 index d6cd3e7..6f96e8b 100644 --- a/grammar/Circom.g4 +++ b/grammar/Circom.g4 @@ -43,7 +43,7 @@ templateDeclaration ; componentMainDeclaration - : 'component' 'main' ('{' 'public' '[' args ']' '}')? '=' ID '(' (expression ','?)* ')' ';' + : 'component' 'main' ('{' 'public' '[' args ']' '}')? '=' ID '(' expressionList? ')' ';' ; statement @@ -80,7 +80,7 @@ expression | blockInstantiation | expression '.' ID ('[' expression ']')? | expression '?' expression ':' expression - | ('~' | '!' | '-') expression + | ('~' | '!') expression | expression '**' expression | expression ('*' | '/' | '\\' | '%') expression | expression ('+' | '-') expression @@ -91,7 +91,7 @@ expression primary : '(' expression ')' - | '[' (expression ','?)+ ']' + | '[' expressionList ']' | NUMBER | identifier | args @@ -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* ; \ No newline at end of file