UNPKG

solidity-antlr4

Version:

Solidity Lang Lexer and Parser by official ANTLR4 grammar

67 lines (66 loc) 2.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VariableDeclaration = exports.StateVariableDeclaration = exports.ParameterDeclaration = exports.EventParameter = exports.ErrorParameter = exports.ConstantVariableDeclaration = void 0; var _base = require("../base.cjs"); var _antlr = require("../../antlr4/index.cjs"); class VariableDeclaration extends _base.BaseNode { type = "VariableDeclaration"; name = null; typeName; dataLocation = null; stateVariable = false; parameter = false; public = false; private = false; internal = false; constant = false; immutable = false; indexed = false; override = null; expression = null; constructor(ctx, visitor) { super(ctx, visitor); if (ctx instanceof _antlr.VariableDeclarationContext) { this.parameter = true; this.name = ctx.identifier()?.accept(visitor) ?? null; this.typeName = ctx.typeName().accept(visitor); this.dataLocation = ctx.dataLocation()?.accept(visitor) ?? null; this.stateVariable = false; this.constant = false; this.indexed = false; } else if (ctx instanceof _antlr.ParameterDeclarationContext) { this.parameter = true; this.name = ctx.identifier()?.accept(visitor) ?? null; this.typeName = ctx.typeName().accept(visitor); this.dataLocation = ctx.dataLocation()?.accept(visitor) ?? null; } else if (ctx instanceof _antlr.StateVariableDeclarationContext) { this.stateVariable = true; this.name = ctx.identifier()?.accept(visitor) ?? null; this.typeName = ctx.typeName().accept(visitor); this.public = !!ctx.Public().length; this.private = !!ctx.Private().length; this.internal = !!ctx.Internal().length; this.constant = !!ctx.Constant().length; this.immutable = !!ctx.Immutable().length; this.override = ctx.overrideSpecifier(0)?.accept(visitor) ?? null; this.expression = ctx.expression()?.accept(visitor) ?? null; } else if (ctx instanceof _antlr.ConstantVariableDeclarationContext) { this.name = ctx.identifier()?.accept(visitor) ?? null; this.typeName = ctx.typeName().accept(visitor); this.constant = true; this.expression = ctx.expression().accept(visitor); } else if (ctx instanceof _antlr.ErrorParameterContext) { this.parameter = true; this.name = ctx.identifier()?.accept(visitor) ?? null; this.typeName = ctx.typeName().accept(visitor); } else if (ctx instanceof _antlr.EventParameterContext) { this.parameter = true; this.name = ctx.identifier()?.accept(visitor) ?? null; this.typeName = ctx.typeName().accept(visitor); this.indexed = !!ctx.Indexed(); } } } exports.EventParameter = exports.ErrorParameter = exports.ConstantVariableDeclaration = exports.StateVariableDeclaration = exports.ParameterDeclaration = exports.VariableDeclaration = VariableDeclaration;