@solidity-parser/parser
Advanced tools
Comparing version 0.13.1 to 0.13.2
@@ -47,3 +47,5 @@ interface Location { | ||
unitAlias: string | null; | ||
unitAliasIdentifier: Identifier | null; | ||
symbolAliases: Array<[string, string | null]> | null; | ||
symbolAliasesIdentifiers: Array<[Identifier, Identifier | null]> | null; | ||
} | ||
@@ -131,2 +133,3 @@ export interface StateVariableDeclaration extends BaseASTNode { | ||
name: string | null; | ||
identifier: Identifier | null; | ||
isDeclaredConst?: boolean; | ||
@@ -250,2 +253,3 @@ storageLocation: string | null; | ||
names: string[]; | ||
identifiers: Identifier[]; | ||
} | ||
@@ -412,2 +416,3 @@ export interface AssemblyBlock extends BaseASTNode { | ||
names: string[]; | ||
identifiers: Identifier[]; | ||
arguments: Expression[]; | ||
@@ -414,0 +419,0 @@ } |
{ | ||
"name": "@solidity-parser/parser", | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"description": "A Solidity parser built from a robust ANTLR 4 grammar", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
@@ -135,3 +135,5 @@ // Base on the original type definitions for solidity-parser-antlr 0.2 | ||
unitAlias: string | null | ||
unitAliasIdentifier: Identifier | null | ||
symbolAliases: Array<[string, string | null]> | null | ||
symbolAliasesIdentifiers: Array<[Identifier, Identifier | null]> | null | ||
} | ||
@@ -219,2 +221,3 @@ export interface StateVariableDeclaration extends BaseASTNode { | ||
name: string | null | ||
identifier: Identifier | null | ||
isDeclaredConst?: boolean | ||
@@ -339,2 +342,3 @@ storageLocation: string | null | ||
names: string[] | ||
identifiers: Identifier[] | ||
} | ||
@@ -501,3 +505,3 @@ export interface AssemblyBlock extends BaseASTNode { | ||
'|', | ||
'|=' | ||
'|=', | ||
] as const | ||
@@ -563,2 +567,3 @@ export type BinOp = typeof binaryOpValues[number] | ||
names: string[] | ||
identifiers: Identifier[] | ||
arguments: Expression[] | ||
@@ -683,10 +688,13 @@ } | ||
type ASTMap<U> = { [K in ASTNodeTypeString]: U extends { type: K } ? U : never }; | ||
type ASTTypeMap = ASTMap<ASTNode>; | ||
type ASTMap<U> = { [K in ASTNodeTypeString]: U extends { type: K } ? U : never } | ||
type ASTTypeMap = ASTMap<ASTNode> | ||
type ASTVisitorEnter = { | ||
[K in keyof ASTTypeMap]?: (ast: ASTTypeMap[K], parent?: ASTNode) => any | ||
}; | ||
} | ||
type ASTVisitorExit = { | ||
[K in keyof ASTTypeMap as `${K}:exit`]?: (ast: ASTTypeMap[K], parent?: ASTNode) => any | ||
}; | ||
[K in keyof ASTTypeMap as `${K}:exit`]?: ( | ||
ast: ASTTypeMap[K], | ||
parent?: ASTNode | ||
) => any | ||
} | ||
@@ -693,0 +701,0 @@ export type ASTVisitor = ASTVisitorEnter & ASTVisitorExit |
@@ -132,2 +132,3 @@ import { ParserRuleContext } from 'antlr4ts' | ||
name, | ||
identifier: this.visitIdentifier(iden), | ||
expression, | ||
@@ -161,6 +162,9 @@ visibility, | ||
const identifierCtx = ctx.identifier() | ||
const node: AST.VariableDeclaration = { | ||
type: 'VariableDeclaration', | ||
typeName: this.visitTypeName(ctx.typeName()), | ||
name: this._toText(ctx.identifier()), | ||
name: this._toText(identifierCtx), | ||
identifier: this.visitIdentifier(identifierCtx), | ||
storageLocation, | ||
@@ -229,2 +233,6 @@ isStateVar: false, | ||
name, | ||
identifier: | ||
paramCtxIdentifier !== undefined | ||
? this.visitIdentifier(paramCtxIdentifier) | ||
: null, | ||
isStateVar: false, | ||
@@ -274,2 +282,6 @@ isIndexed: paramCtx.IndexedKeyword() !== undefined, | ||
name, | ||
identifier: | ||
ctxIdentifier !== undefined | ||
? this.visitIdentifier(ctxIdentifier) | ||
: null, | ||
storageLocation, | ||
@@ -366,7 +378,2 @@ isStateVar: false, | ||
// check if function is virtual | ||
if (ctx.modifierList().VirtualKeyword().length > 0) { | ||
isVirtual = true | ||
} | ||
isConstructor = name === this._currentContract | ||
@@ -378,2 +385,7 @@ isFallback = name === '' | ||
// check if function is virtual | ||
if (ctx.modifierList().VirtualKeyword().length > 0) { | ||
isVirtual = true | ||
} | ||
let override: AST.UserDefinedTypeName[] | null | ||
@@ -537,3 +549,3 @@ const overrideSpecifier = ctx.modifierList().overrideSpecifier() | ||
let value = '' | ||
let value = this._toText(ctx.pragmaValue()) | ||
if (versionContext?.children !== undefined) { | ||
@@ -668,2 +680,3 @@ value = versionContext.children.map((x) => this._toText(x)).join(' ') | ||
name: null, | ||
identifier: null, | ||
storageLocation, | ||
@@ -744,2 +757,3 @@ isStateVar: false, | ||
const names = [] | ||
const identifiers = [] | ||
@@ -757,2 +771,3 @@ const ctxArgs = ctx.functionCallArguments() | ||
names.push(this._toText(nameValue.identifier())) | ||
identifiers.push(this.visitIdentifier(nameValue.identifier())) | ||
} | ||
@@ -766,2 +781,3 @@ } | ||
names, | ||
identifiers, | ||
} | ||
@@ -1097,2 +1113,3 @@ | ||
const names = [] | ||
const identifiers = [] | ||
@@ -1109,2 +1126,3 @@ const ctxArgs = ctx.functionCallArguments()! | ||
names.push(this._toText(nameValue.identifier())) | ||
identifiers.push(this.visitIdentifier(nameValue.identifier())) | ||
} | ||
@@ -1118,2 +1136,3 @@ } | ||
names, | ||
identifiers, | ||
} | ||
@@ -1233,2 +1252,3 @@ | ||
const names: string[] = [] | ||
const identifiers: AST.Identifier[] = [] | ||
const args: AST.Expression[] = [] | ||
@@ -1238,2 +1258,3 @@ | ||
names.push(this._toText(nameValue.identifier())) | ||
identifiers.push(this.visitIdentifier(nameValue.identifier())) | ||
args.push(this.visitExpression(nameValue.expression())) | ||
@@ -1245,2 +1266,3 @@ } | ||
names, | ||
identifiers, | ||
arguments: args, | ||
@@ -1449,2 +1471,3 @@ } | ||
name: this._toText(iden), | ||
identifier: this.visitIdentifier(iden), | ||
isStateVar: false, | ||
@@ -1482,5 +1505,8 @@ isIndexed: false, | ||
const identifierCtx = decl.identifier() | ||
const result: AST.VariableDeclaration = { | ||
type: 'VariableDeclaration', | ||
name: this._toText(decl.identifier()), | ||
name: this._toText(identifierCtx), | ||
identifier: this.visitIdentifier(identifierCtx), | ||
typeName: this.visitTypeName(decl.typeName()), | ||
@@ -1500,3 +1526,5 @@ storageLocation, | ||
let unitAlias = null | ||
let unitAliasIdentifier = null | ||
let symbolAliases = null | ||
let symbolAliasesIdentifiers = null | ||
@@ -1512,7 +1540,34 @@ if (ctx.importDeclaration().length > 0) { | ||
}) | ||
} else if (ctx.children!.length === 7) { | ||
unitAlias = this._toText(ctx.getChild(3)) | ||
} else if (ctx.children!.length === 5) { | ||
unitAlias = this._toText(ctx.getChild(3)) | ||
symbolAliasesIdentifiers = ctx.importDeclaration().map((decl) => { | ||
const symbolIdentifier = this.visitIdentifier(decl.identifier(0)) | ||
let aliasIdentifier = null | ||
if (decl.identifier().length > 1) { | ||
aliasIdentifier = this.visitIdentifier(decl.identifier(1)) | ||
} | ||
return [symbolIdentifier, aliasIdentifier] as [ | ||
AST.Identifier, | ||
AST.Identifier | null | ||
] | ||
}) | ||
} else { | ||
const identifierCtxList = ctx.identifier() | ||
if (identifierCtxList.length === 0) { | ||
// nothing to do | ||
} else if (identifierCtxList.length === 1) { | ||
const aliasIdentifierCtx = ctx.identifier(0) | ||
unitAlias = this._toText(aliasIdentifierCtx) | ||
unitAliasIdentifier = this.visitIdentifier(aliasIdentifierCtx) | ||
} else if (identifierCtxList.length === 2) { | ||
const aliasIdentifierCtx = ctx.identifier(1) | ||
unitAlias = this._toText(aliasIdentifierCtx) | ||
unitAliasIdentifier = this.visitIdentifier(aliasIdentifierCtx) | ||
} else { | ||
throw new Error( | ||
'Assertion error: an import should have one or two identifiers' | ||
) | ||
} | ||
} | ||
// else if (ctx.children!.length === 5) { | ||
// unitAlias = this._toText(ctx.getChild(3)) | ||
// } | ||
@@ -1523,3 +1578,5 @@ const node: AST.ImportDirective = { | ||
unitAlias, | ||
unitAliasIdentifier, | ||
symbolAliases, | ||
symbolAliasesIdentifiers, | ||
} | ||
@@ -1526,0 +1583,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9153531
97453