diff --git a/circom-g4-grammar b/circom-g4-grammar index 6b24f90..7cb6d98 160000 --- a/circom-g4-grammar +++ b/circom-g4-grammar @@ -1 +1 @@ -Subproject commit 6b24f905b19ad7be14c36e9bcfa0863e0c2bcc54 +Subproject commit 7cb6d989b49502097c8a294a887bf17e4f1fdcca diff --git a/package-lock.json b/package-lock.json index cf1831c..89ce670 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@distributedlab/circom-parser", - "version": "0.2.5", + "version": "0.2.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@distributedlab/circom-parser", - "version": "0.2.5", + "version": "0.2.6", "license": "MIT", "dependencies": { "antlr4": "4.13.1-patch-1", diff --git a/package.json b/package.json index 61e5dac..c9561cb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@distributedlab/circom-parser", "description": "Circom circuit parser built with ANTLR4", - "version": "0.2.5", + "version": "0.2.6", "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ diff --git a/src/generated/CircomParser.ts b/src/generated/CircomParser.ts index ab1b9da..f16341b 100644 --- a/src/generated/CircomParser.ts +++ b/src/generated/CircomParser.ts @@ -145,7 +145,7 @@ export default class CircomParser extends Parser { public static readonly RULE_identifier = 35; public static readonly RULE_identifierList = 36; public static readonly RULE_simpleIdentifierList = 37; - public static readonly RULE_idetifierAccess = 38; + public static readonly RULE_identifierAccess = 38; public static readonly RULE_arrayDimension = 39; public static readonly RULE_identifierReferance = 40; public static readonly RULE_expressionOrString = 41; @@ -338,7 +338,7 @@ export default class CircomParser extends Parser { "identifier", "identifierList", "simpleIdentifierList", - "idetifierAccess", + "identifierAccess", "arrayDimension", "identifierReferance", "expressionOrString", @@ -2931,7 +2931,7 @@ export default class CircomParser extends Parser { { { this.state = 568; - this.idetifierAccess(); + this.identifierAccess(); } } } @@ -3088,13 +3088,13 @@ export default class CircomParser extends Parser { return localctx; } // @RuleVersion(0) - public idetifierAccess(): IdetifierAccessContext { - let localctx: IdetifierAccessContext = new IdetifierAccessContext( + public identifierAccess(): IdentifierAccessContext { + let localctx: IdentifierAccessContext = new IdentifierAccessContext( this, this._ctx, this.state, ); - this.enterRule(localctx, 76, CircomParser.RULE_idetifierAccess); + this.enterRule(localctx, 76, CircomParser.RULE_identifierAccess); try { this.state = 602; this._errHandler.sync(this); @@ -6464,16 +6464,16 @@ export class IdentifierStatementContext extends ParserRuleContext { public ID(): TerminalNode { return this.getToken(CircomParser.ID, 0); } - public idetifierAccess_list(): IdetifierAccessContext[] { + public identifierAccess_list(): IdentifierAccessContext[] { return this.getTypedRuleContexts( - IdetifierAccessContext, - ) as IdetifierAccessContext[]; + IdentifierAccessContext, + ) as IdentifierAccessContext[]; } - public idetifierAccess(i: number): IdetifierAccessContext { + public identifierAccess(i: number): IdentifierAccessContext { return this.getTypedRuleContext( - IdetifierAccessContext, + IdentifierAccessContext, i, - ) as IdetifierAccessContext; + ) as IdentifierAccessContext; } public get ruleIndex(): number { return CircomParser.RULE_identifierStatement; @@ -6632,7 +6632,7 @@ export class SimpleIdentifierListContext extends ParserRuleContext { } } -export class IdetifierAccessContext extends ParserRuleContext { +export class IdentifierAccessContext extends ParserRuleContext { constructor( parser?: CircomParser, parent?: ParserRuleContext, @@ -6654,22 +6654,22 @@ export class IdetifierAccessContext extends ParserRuleContext { ) as IdentifierReferanceContext; } public get ruleIndex(): number { - return CircomParser.RULE_idetifierAccess; + return CircomParser.RULE_identifierAccess; } public enterRule(listener: CircomParserListener): void { - if (listener.enterIdetifierAccess) { - listener.enterIdetifierAccess(this); + if (listener.enterIdentifierAccess) { + listener.enterIdentifierAccess(this); } } public exitRule(listener: CircomParserListener): void { - if (listener.exitIdetifierAccess) { - listener.exitIdetifierAccess(this); + if (listener.exitIdentifierAccess) { + listener.exitIdentifierAccess(this); } } // @Override public accept(visitor: CircomParserVisitor): Result { - if (visitor.visitIdetifierAccess) { - return visitor.visitIdetifierAccess(this); + if (visitor.visitIdentifierAccess) { + return visitor.visitIdentifierAccess(this); } else { return visitor.visitChildren(this); } diff --git a/src/generated/CircomParserListener.ts b/src/generated/CircomParserListener.ts index 834fd18..2381315 100644 --- a/src/generated/CircomParserListener.ts +++ b/src/generated/CircomParserListener.ts @@ -65,7 +65,7 @@ import { IdentifierStatementContext } from "./CircomParser"; import { IdentifierContext } from "./CircomParser"; import { IdentifierListContext } from "./CircomParser"; import { SimpleIdentifierListContext } from "./CircomParser"; -import { IdetifierAccessContext } from "./CircomParser"; +import { IdentifierAccessContext } from "./CircomParser"; import { ArrayDimensionContext } from "./CircomParser"; import { IdentifierReferanceContext } from "./CircomParser"; import { ExpressionOrStringContext } from "./CircomParser"; @@ -797,15 +797,15 @@ export default class CircomParserListener extends ParseTreeListener { */ exitSimpleIdentifierList?: (ctx: SimpleIdentifierListContext) => void; /** - * Enter a parse tree produced by `CircomParser.idetifierAccess`. + * Enter a parse tree produced by `CircomParser.identifierAccess`. * @param ctx the parse tree */ - enterIdetifierAccess?: (ctx: IdetifierAccessContext) => void; + enterIdentifierAccess?: (ctx: IdentifierAccessContext) => void; /** - * Exit a parse tree produced by `CircomParser.idetifierAccess`. + * Exit a parse tree produced by `CircomParser.identifierAccess`. * @param ctx the parse tree */ - exitIdetifierAccess?: (ctx: IdetifierAccessContext) => void; + exitIdentifierAccess?: (ctx: IdentifierAccessContext) => void; /** * Enter a parse tree produced by `CircomParser.arrayDimension`. * @param ctx the parse tree diff --git a/src/generated/CircomParserVisitor.ts b/src/generated/CircomParserVisitor.ts index 8da901d..efd4d48 100644 --- a/src/generated/CircomParserVisitor.ts +++ b/src/generated/CircomParserVisitor.ts @@ -65,7 +65,7 @@ import { IdentifierStatementContext } from "./CircomParser"; import { IdentifierContext } from "./CircomParser"; import { IdentifierListContext } from "./CircomParser"; import { SimpleIdentifierListContext } from "./CircomParser"; -import { IdetifierAccessContext } from "./CircomParser"; +import { IdentifierAccessContext } from "./CircomParser"; import { ArrayDimensionContext } from "./CircomParser"; import { IdentifierReferanceContext } from "./CircomParser"; import { ExpressionOrStringContext } from "./CircomParser"; @@ -512,11 +512,11 @@ export default class CircomParserVisitor< */ visitSimpleIdentifierList?: (ctx: SimpleIdentifierListContext) => Result; /** - * Visit a parse tree produced by `CircomParser.idetifierAccess`. + * Visit a parse tree produced by `CircomParser.identifierAccess`. * @param ctx the parse tree * @return the visitor result */ - visitIdetifierAccess?: (ctx: IdetifierAccessContext) => Result; + visitIdentifierAccess?: (ctx: IdentifierAccessContext) => Result; /** * Visit a parse tree produced by `CircomParser.arrayDimension`. * @param ctx the parse tree diff --git a/src/utils/ExpressionHelper.ts b/src/utils/ExpressionHelper.ts index e64e20e..285b0a8 100644 --- a/src/utils/ExpressionHelper.ts +++ b/src/utils/ExpressionHelper.ts @@ -120,7 +120,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor { visitPIdentifierStatement = ( ctx: PIdentifierStatementContext, ): CircomValueType | null => { - if (ctx.identifierStatement().idetifierAccess_list().length == 0) { + if (ctx.identifierStatement().identifierAccess_list().length == 0) { const variableValue = this.variableContext[ctx.identifierStatement().ID().getText()]; @@ -138,7 +138,7 @@ class ExpressionVisitor extends ExtendedCircomVisitor { const reference = ctx .identifierStatement() - .idetifierAccess_list() + .identifierAccess_list() .map((access) => access.getText()) .join(""); diff --git a/test/mocks/CircomTemplateInputsVisitor.ts b/test/mocks/CircomTemplateInputsVisitor.ts index 8df0514..3e3e1b1 100644 --- a/test/mocks/CircomTemplateInputsVisitor.ts +++ b/test/mocks/CircomTemplateInputsVisitor.ts @@ -333,7 +333,7 @@ export class CircomTemplateInputsVisitor extends CircomVisitor { const identifierStatement = primaryExpression.identifierStatement(); - if (identifierStatement.idetifierAccess_list().length > 0) { + if (identifierStatement.identifierAccess_list().length > 0) { this.errors.push({ type: ErrorType.ComplexAccessNotSupported, context: ctx, @@ -384,7 +384,7 @@ export class CircomTemplateInputsVisitor extends CircomVisitor { ) => { const identifierStatement = ctx.identifierStatement(); - if (identifierStatement.idetifierAccess_list().length > 0) { + if (identifierStatement.identifierAccess_list().length > 0) { this.errors.push({ type: ErrorType.ComplexAccessNotSupported, context: ctx, @@ -518,7 +518,7 @@ export class CircomTemplateInputsVisitor extends CircomVisitor { visitSubsIcnDecOperation = (ctx: SubsIcnDecOperationContext) => { const identifierStatement = ctx.identifierStatement(); - if (identifierStatement.idetifierAccess_list().length > 0) { + if (identifierStatement.identifierAccess_list().length > 0) { this.errors.push({ type: ErrorType.ComplexAccessNotSupported, context: ctx,