From 44c6e7d074a63e9b976dd39b043dcca589a24869 Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Tue, 2 Jul 2024 19:24:30 +0800 Subject: [PATCH 01/15] First draft for precondition parsing --- src/kontrol/prove.py | 5 ++ src/kontrol/solc_to_k.py | 117 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/src/kontrol/prove.py b/src/kontrol/prove.py index ddbf043a0..c2b6ea774 100644 --- a/src/kontrol/prove.py +++ b/src/kontrol/prove.py @@ -941,6 +941,11 @@ def _init_cterm( for constraint in storage_constraints: init_cterm = init_cterm.add_constraint(constraint) + # TODO(palina): add constraints corresponding to the user-provided preconditions + if method.preconditions is not None: + for precondition in method.preconditions: + init_cterm = init_cterm.add_constraint(mlEqualsTrue(precondition.to_kapply)) + # The calling contract is assumed to be in the present accounts for non-tests if not (config_type == ConfigType.TEST_CONFIG or active_symbolik): init_cterm.add_constraint( diff --git a/src/kontrol/solc_to_k.py b/src/kontrol/solc_to_k.py index 1edb4d589..76dd77625 100644 --- a/src/kontrol/solc_to_k.py +++ b/src/kontrol/solc_to_k.py @@ -322,6 +322,47 @@ def parse_devdoc(tag: str, devdoc: dict | None) -> dict: return natspecs +def parse_preconditions(devdoc: str | None, method: Contract.Method | Contract.Constructor) -> tuple[str, ...]: + """ + Parse developer documentation (devdoc) to extract user-provided preconditions. + + Returns a tuple of Precondition objects, each representing a single precondition. + This function currently supports a simple grammar allowing expressions of the form 'LHS operator RHS'. + The following operators are supported: '==', '!=', '<=', '>=', '<', '>'. + RHS and LHS can include input or storage variables, as well as int constants. + + Example: + If devdoc for the function contains { '@custom:kontrol-precondition': ' x <= 14,x >= 2,'}, it would return: + [Precondition(operator='<=', rhs=14, lhs='x'), Precondition(operator='>=', rhs=2, lhs='x')] + """ + + if devdoc is None: + return None + + preconditions: list[Precondition] = [] + for precondition in devdoc.split(','): + # Trim whitespace and skip if empty + precondition = precondition.strip() + if not precondition: + continue + + parts = precondition.split() + if len(parts) != 3: + raise ValueError(f"Invalid precondition expression format: {precondition}, please use 'LHS operator RHS'") + + lhs, operator, rhs = parts + + # Convert lhs and rhs to int if they represent numbers, otherwise keep as string + lhs = int(lhs) if lhs.isdigit() else lhs + rhs = int(rhs) if rhs.isdigit() else rhs + + # Create a Precondition object and add it to the list + precondition = Precondition(operator, lhs, rhs, method) + preconditions.append(precondition) + + return tuple(preconditions) + + class StorageField(NamedTuple): label: str data_type: str @@ -330,6 +371,76 @@ class StorageField(NamedTuple): linked_interface: str | None +@dataclass +class Precondition: + operator: str + rhs: str | int + lhs: str | int + method: Contract.Method | Contract.Constructor + + def __init__(self, operator, lhs, rhs, method): + """ + Initializes a new instance of the Precondition class. + + :param operator: The boolean operator as a string (e.g., '==', '!=', '<=', '>=', '<', '>'). + :param lhs: The left-hand side operand, which can be an input or storage variable (str) or a constant (int). + :param rhs: The left-hand side operand, which can be an input or storage variable (str) or a constant (int). + """ + self.operator = operator + self.lhs = lhs + self.rhs = rhs + self.method = method + + @cached_property + def to_kapply(self) -> KApply: + """ + Converts the precondition to a KApply term. + + - Constants are translated into `intToken` terms + - Variables should be searched in method's inputs or in the contract's storage fields + - Operators are translated into the corresponding KLabel application, e.g., `leInt`, `eqInt`, etc. + """ + + # Helper function to determine if a term is a constant or a variable and convert accordingly + def convert_term(term): + if isinstance(term, int): + return intToken(term) + else: + for input in self.method.inputs: + if input.name == term: + # TODO(palina): add support for complex types + return abstract_term_safely( + KVariable('_###SOLIDITY_ARG_VAR###_'), base_name=f'V{input.arg_name}' + ) + else: + for field in self.method.contract.storage_fields: + if field.name == term: + # Perform the necessary action for a matching storage field + break # Exit the loop once the matching field is found + else: + raise ValueError(f"Unknown term: {term}") + + # Map operators to KLabel applications + operator_mapping = { + '<=': '_<=Int_', + '>=': '_>=Int_', + '==': '_==Int_', + '!=': '_=/=Int_', + '<': '_': '_>Int_', + } + + if self.operator in operator_mapping: + operator_label = operator_mapping[self.operator] + else: + raise ValueError(f"Unsupported operator in a precondition: {self.operator}") + + lhs_converted = convert_term(self.lhs) + rhs_converted = convert_term(self.rhs) + + return KApply(operator_label, lhs_converted, rhs_converted) + + @dataclass class Contract: @dataclass @@ -469,6 +580,7 @@ class Method: ast: dict | None natspec_values: dict | None function_calls: tuple[str, ...] | None + preconditions: tuple[Precondition, ...] | None def __init__( self, @@ -499,6 +611,11 @@ def __init__( natspec_tags = ['custom:kontrol-array-length-equals', 'custom:kontrol-bytes-length-equals'] self.natspec_values = {tag.split(':')[1]: parse_devdoc(tag, devdoc) for tag in natspec_tags} self.inputs = tuple(inputs_from_abi(abi['inputs'], self.natspec_values)) + self.preconditions = ( + parse_preconditions(devdoc.get('custom:kontrol-precondition', None), self) + if devdoc is not None + else None + ) self.function_calls = tuple(function_calls) if function_calls is not None else None @property From 5049c82aef63aaee38a3c0a764ad7bbfb10f3225 Mon Sep 17 00:00:00 2001 From: devops Date: Tue, 2 Jul 2024 11:25:35 +0000 Subject: [PATCH 02/15] Set Version: 0.1.332 --- package/version | 2 +- pyproject.toml | 2 +- src/kontrol/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package/version b/package/version index 29ba87d86..6728c0070 100644 --- a/package/version +++ b/package/version @@ -1 +1 @@ -0.1.330 +0.1.332 diff --git a/pyproject.toml b/pyproject.toml index fb8e39e53..28a34608a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "kontrol" -version = "0.1.330" +version = "0.1.332" description = "Foundry integration for KEVM" authors = [ "Runtime Verification, Inc. ", diff --git a/src/kontrol/__init__.py b/src/kontrol/__init__.py index a7b13e17c..59b1db5ad 100644 --- a/src/kontrol/__init__.py +++ b/src/kontrol/__init__.py @@ -5,4 +5,4 @@ if TYPE_CHECKING: from typing import Final -VERSION: Final = '0.1.330' +VERSION: Final = '0.1.332' From b024611ffcffc2c9f631e97022c7bd7e0b95137e Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Tue, 2 Jul 2024 20:32:12 +0800 Subject: [PATCH 03/15] Fixing some code quality issues --- src/kontrol/solc_to_k.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/kontrol/solc_to_k.py b/src/kontrol/solc_to_k.py index 76dd77625..d4a7cb235 100644 --- a/src/kontrol/solc_to_k.py +++ b/src/kontrol/solc_to_k.py @@ -322,7 +322,7 @@ def parse_devdoc(tag: str, devdoc: dict | None) -> dict: return natspecs -def parse_preconditions(devdoc: str | None, method: Contract.Method | Contract.Constructor) -> tuple[str, ...]: +def parse_preconditions(devdoc: str | None, method: Contract.Method | Contract.Constructor) -> tuple[Precondition, ...] | None: """ Parse developer documentation (devdoc) to extract user-provided preconditions. @@ -353,12 +353,12 @@ def parse_preconditions(devdoc: str | None, method: Contract.Method | Contract.C lhs, operator, rhs = parts # Convert lhs and rhs to int if they represent numbers, otherwise keep as string - lhs = int(lhs) if lhs.isdigit() else lhs - rhs = int(rhs) if rhs.isdigit() else rhs + lhs = int(lhs) if lhs.isdigit() else str(lhs) + rhs = int(rhs) if rhs.isdigit() else str(lhs) # Create a Precondition object and add it to the list - precondition = Precondition(operator, lhs, rhs, method) - preconditions.append(precondition) + new_precondition = Precondition(operator, lhs, rhs, method) + preconditions.append(new_precondition) return tuple(preconditions) @@ -378,7 +378,7 @@ class Precondition: lhs: str | int method: Contract.Method | Contract.Constructor - def __init__(self, operator, lhs, rhs, method): + def __init__(self, operator: str, lhs: str | int, rhs: str | int, method: Contract.Method | Contract.Constructor): """ Initializes a new instance of the Precondition class. @@ -402,7 +402,7 @@ def to_kapply(self) -> KApply: """ # Helper function to determine if a term is a constant or a variable and convert accordingly - def convert_term(term): + def convert_term(term: str | int) -> KInner: if isinstance(term, int): return intToken(term) else: @@ -417,8 +417,8 @@ def convert_term(term): if field.name == term: # Perform the necessary action for a matching storage field break # Exit the loop once the matching field is found - else: - raise ValueError(f"Unknown term: {term}") + + raise ValueError(f"Unknown term: {term}") # Map operators to KLabel applications operator_mapping = { @@ -452,6 +452,7 @@ class Constructor: contract_storage_digest: str payable: bool signature: str + preconditions: tuple[Precondition, ...] | None def __init__( self, @@ -465,7 +466,7 @@ def __init__( self.contract_name = contract_name self.contract_digest = contract_digest self.contract_storage_digest = contract_storage_digest - # TODO: support NatSpec comments for dynamic types + # TODO: support NatSpec comments for dynamic types, including preconditions self.inputs = tuple(inputs_from_abi(abi['inputs'], None)) self.sort = sort # TODO: Check that we're handling all state mutability cases From d92e45cc35849df531f19d0d3419f61c9f0b67eb Mon Sep 17 00:00:00 2001 From: devops Date: Wed, 3 Jul 2024 07:02:39 +0000 Subject: [PATCH 04/15] Set Version: 0.1.334 --- package/version | 2 +- pyproject.toml | 2 +- src/kontrol/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package/version b/package/version index 0d8cb7fe8..c11aa5dec 100644 --- a/package/version +++ b/package/version @@ -1 +1 @@ -0.1.333 +0.1.334 diff --git a/pyproject.toml b/pyproject.toml index 387624455..05d4dcdf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "kontrol" -version = "0.1.333" +version = "0.1.334" description = "Foundry integration for KEVM" authors = [ "Runtime Verification, Inc. ", diff --git a/src/kontrol/__init__.py b/src/kontrol/__init__.py index 8eeebef22..c9ddf1177 100644 --- a/src/kontrol/__init__.py +++ b/src/kontrol/__init__.py @@ -5,4 +5,4 @@ if TYPE_CHECKING: from typing import Final -VERSION: Final = '0.1.333' +VERSION: Final = '0.1.334' From be44d64bbdf9c8b78a157cb01f94bb884c6f44c0 Mon Sep 17 00:00:00 2001 From: devops Date: Fri, 5 Jul 2024 11:58:58 +0000 Subject: [PATCH 05/15] Set Version: 0.1.341 --- package/version | 2 +- pyproject.toml | 2 +- src/kontrol/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package/version b/package/version index 5a002f41e..464d50765 100644 --- a/package/version +++ b/package/version @@ -1 +1 @@ -0.1.340 +0.1.341 diff --git a/pyproject.toml b/pyproject.toml index 864a87e63..9a5d4fcbb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "kontrol" -version = "0.1.340" +version = "0.1.341" description = "Foundry integration for KEVM" authors = [ "Runtime Verification, Inc. ", diff --git a/src/kontrol/__init__.py b/src/kontrol/__init__.py index e7f1f87a3..8d5986481 100644 --- a/src/kontrol/__init__.py +++ b/src/kontrol/__init__.py @@ -5,4 +5,4 @@ if TYPE_CHECKING: from typing import Final -VERSION: Final = '0.1.340' +VERSION: Final = '0.1.341' From b66afd859c642e50949413ad44afae2c4fc0731b Mon Sep 17 00:00:00 2001 From: devops Date: Mon, 8 Jul 2024 09:18:12 +0000 Subject: [PATCH 06/15] Set Version: 0.1.345 --- package/version | 2 +- pyproject.toml | 2 +- src/kontrol/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package/version b/package/version index cba7147d8..7ea3e8bb0 100644 --- a/package/version +++ b/package/version @@ -1 +1 @@ -0.1.344 +0.1.345 diff --git a/pyproject.toml b/pyproject.toml index accb21911..ee0049209 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "kontrol" -version = "0.1.344" +version = "0.1.345" description = "Foundry integration for KEVM" authors = [ "Runtime Verification, Inc. ", diff --git a/src/kontrol/__init__.py b/src/kontrol/__init__.py index 77ca72a16..80d44c268 100644 --- a/src/kontrol/__init__.py +++ b/src/kontrol/__init__.py @@ -5,4 +5,4 @@ if TYPE_CHECKING: from typing import Final -VERSION: Final = '0.1.344' +VERSION: Final = '0.1.345' From 200c627049da75d3ea790cd709a64d097e832d8c Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Thu, 1 Aug 2024 19:10:39 +0800 Subject: [PATCH 07/15] Init antlr4 grammar for parsing annotations --- poetry.lock | 13 +- pyproject.toml | 1 + src/kontrol/solc_to_k.py | 187 ++- src/kontrol/solidity/Solidity.g4 | 53 + src/kontrol/solidity/Solidity.interp | 57 + src/kontrol/solidity/Solidity.tokens | 30 + src/kontrol/solidity/SolidityLexer.interp | 80 + src/kontrol/solidity/SolidityLexer.py | 1633 +++++++++++++++++++++ src/kontrol/solidity/SolidityLexer.tokens | 30 + src/kontrol/solidity/SolidityListener.py | 182 +++ src/kontrol/solidity/SolidityParser.py | 1625 ++++++++++++++++++++ src/kontrol/solidity/SolidityVisitor.py | 99 ++ 12 files changed, 3928 insertions(+), 62 deletions(-) create mode 100644 src/kontrol/solidity/Solidity.g4 create mode 100644 src/kontrol/solidity/Solidity.interp create mode 100644 src/kontrol/solidity/Solidity.tokens create mode 100644 src/kontrol/solidity/SolidityLexer.interp create mode 100644 src/kontrol/solidity/SolidityLexer.py create mode 100644 src/kontrol/solidity/SolidityLexer.tokens create mode 100644 src/kontrol/solidity/SolidityListener.py create mode 100644 src/kontrol/solidity/SolidityParser.py create mode 100644 src/kontrol/solidity/SolidityVisitor.py diff --git a/poetry.lock b/poetry.lock index 7d13bd0bb..8e86314f5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,5 +1,16 @@ # This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +[[package]] +name = "antlr4-python3-runtime" +version = "4.13.1" +description = "ANTLR 4.13.1 runtime for Python 3" +optional = false +python-versions = "*" +files = [ + {file = "antlr4-python3-runtime-4.13.1.tar.gz", hash = "sha256:3cd282f5ea7cfb841537fe01f143350fdb1c0b1ce7981443a2fa8513fddb6d1a"}, + {file = "antlr4_python3_runtime-4.13.1-py3-none-any.whl", hash = "sha256:78ec57aad12c97ac039ca27403ad61cb98aaec8a3f9bb8144f889aa0fa28b943"}, +] + [[package]] name = "attrs" version = "23.2.0" @@ -1383,4 +1394,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "8dfae0ba7a90ef262cce898e40d4f5c272e31a70e0d66b1d8d2cf85d4aaca26f" +content-hash = "abbda6d4fb0b185c225ab1a436aa202f205ade7cb0524513a99431304281a391" diff --git a/pyproject.toml b/pyproject.toml index 98cbd4161..f15730234 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,7 @@ python = "^3.10" kevm-pyk = { git = "https://github.com/runtimeverification/evm-semantics.git", tag = "v1.0.659", subdirectory = "kevm-pyk" } eth-utils = "^4.1.1" pycryptodome = "^3.20.0" +antlr4-python3-runtime = "^4.13.1" [tool.poetry.group.dev.dependencies] autoflake = "*" diff --git a/src/kontrol/solc_to_k.py b/src/kontrol/solc_to_k.py index cad317ef8..f41575a26 100644 --- a/src/kontrol/solc_to_k.py +++ b/src/kontrol/solc_to_k.py @@ -8,6 +8,7 @@ from subprocess import CalledProcessError from typing import TYPE_CHECKING, NamedTuple +from antlr4 import CommonTokenStream, InputStream from kevm_pyk.kevm import KEVM from pyk.kast.att import Atts, KAtt from pyk.kast.inner import KApply, KLabel, KRewrite, KSort, KVariable @@ -19,6 +20,10 @@ from pyk.prelude.string import stringToken from pyk.utils import hash_str, run_process_2, single +from .solidity.SolidityLexer import SolidityLexer +from .solidity.SolidityParser import SolidityParser +from .solidity.SolidityVisitor import SolidityVisitor + if TYPE_CHECKING: from collections.abc import Iterable from pathlib import Path @@ -335,7 +340,9 @@ def parse_devdoc(tag: str, devdoc: dict | None) -> dict: return natspecs -def parse_preconditions(devdoc: str | None, method: Contract.Method | Contract.Constructor) -> tuple[Precondition, ...] | None: +def parse_annotations( + devdoc: str | None, method: Contract.Method | Contract.Constructor +) -> tuple[Precondition, ...] | None: """ Parse developer documentation (devdoc) to extract user-provided preconditions. @@ -359,18 +366,8 @@ def parse_preconditions(devdoc: str | None, method: Contract.Method | Contract.C if not precondition: continue - parts = precondition.split() - if len(parts) != 3: - raise ValueError(f"Invalid precondition expression format: {precondition}, please use 'LHS operator RHS'") - - lhs, operator, rhs = parts - - # Convert lhs and rhs to int if they represent numbers, otherwise keep as string - lhs = int(lhs) if lhs.isdigit() else str(lhs) - rhs = int(rhs) if rhs.isdigit() else str(lhs) - # Create a Precondition object and add it to the list - new_precondition = Precondition(operator, lhs, rhs, method) + new_precondition = Precondition(precondition, method) preconditions.append(new_precondition) return tuple(preconditions) @@ -386,22 +383,14 @@ class StorageField(NamedTuple): @dataclass class Precondition: - operator: str - rhs: str | int - lhs: str | int + precondition: str method: Contract.Method | Contract.Constructor - def __init__(self, operator: str, lhs: str | int, rhs: str | int, method: Contract.Method | Contract.Constructor): + def __init__(self, precondition: str, method: Contract.Method | Contract.Constructor): """ Initializes a new instance of the Precondition class. - - :param operator: The boolean operator as a string (e.g., '==', '!=', '<=', '>=', '<', '>'). - :param lhs: The left-hand side operand, which can be an input or storage variable (str) or a constant (int). - :param rhs: The left-hand side operand, which can be an input or storage variable (str) or a constant (int). """ - self.operator = operator - self.lhs = lhs - self.rhs = rhs + self.precondition = precondition self.method = method @cached_property @@ -414,44 +403,19 @@ def to_kapply(self) -> KApply: - Operators are translated into the corresponding KLabel application, e.g., `leInt`, `eqInt`, etc. """ - # Helper function to determine if a term is a constant or a variable and convert accordingly - def convert_term(term: str | int) -> KInner: - if isinstance(term, int): - return intToken(term) - else: - for input in self.method.inputs: - if input.name == term: - # TODO(palina): add support for complex types - return abstract_term_safely( - KVariable('_###SOLIDITY_ARG_VAR###_'), base_name=f'V{input.arg_name}' - ) - else: - for field in self.method.contract.storage_fields: - if field.name == term: - # Perform the necessary action for a matching storage field - break # Exit the loop once the matching field is found - - raise ValueError(f"Unknown term: {term}") - - # Map operators to KLabel applications - operator_mapping = { - '<=': '_<=Int_', - '>=': '_>=Int_', - '==': '_==Int_', - '!=': '_=/=Int_', - '<': '_': '_>Int_', - } + # Parse the input expression + input_stream = InputStream(self.precondition) + lexer = SolidityLexer(input_stream) - if self.operator in operator_mapping: - operator_label = operator_mapping[self.operator] - else: - raise ValueError(f"Unsupported operator in a precondition: {self.operator}") + stream = CommonTokenStream(lexer) + parser = SolidityParser(stream) + tree = parser.expression() - lhs_converted = convert_term(self.lhs) - rhs_converted = convert_term(self.rhs) + # Evaluate the expression + evaluator = AnnotationVisitor(self.method) + result = evaluator.visit(tree) - return KApply(operator_label, lhs_converted, rhs_converted) + return result @dataclass @@ -640,9 +604,7 @@ def __init__( self.natspec_values = {tag.split(':')[1]: parse_devdoc(tag, devdoc) for tag in natspec_tags} self.inputs = tuple(inputs_from_abi(abi['inputs'], self.natspec_values)) self.preconditions = ( - parse_preconditions(devdoc.get('custom:kontrol-precondition', None), self) - if devdoc is not None - else None + parse_annotations(devdoc.get('custom:kontrol-precondition', None), self) if devdoc is not None else None ) self.function_calls = tuple(function_calls) if function_calls is not None else None @@ -1565,3 +1527,106 @@ def process_storage_layout(storage_layout: dict, interface_annotations: dict) -> _LOGGER.error(f'Error processing field {field}: {e}') return tuple(fields_list) + + +class AnnotationVisitor(SolidityVisitor): + def __init__(self, method: Contract.Method | Contract.Constructor): + self.method = method + + # def visitAndExpression(self, ctx: SolidityParser.AndExpressionContext): + # left = self.visit(ctx.booleanExpression(0)) + # right = self.visit(ctx.booleanExpression(1)) + # return left and right + + # def visitOrExpression(self, ctx: SolidityParser.OrExpressionContext): + # left = self.visit(ctx.booleanExpression(0)) + # right = self.visit(ctx.booleanExpression(1)) + # return left or right + + # def visitNotExpression(self, ctx: SolidityParser.NotExpressionContext): + # value = self.visit(ctx.booleanExpression()) + # return not value + + def visitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionContext) -> KApply: + left = self.visit(ctx.arithmeticExpression(0)) + right = self.visit(ctx.arithmeticExpression(1)) + + if left is None or right is None: + return None # Handle None cases appropriately + + op = ctx.RelOp().getText() + + # Map operators to KLabel applications + operator_mapping = { + '<=': '_<=Int_', + '>=': '_>=Int_', + '==': '_==Int_', + '!=': '_=/=Int_', + '<': '_': '_>Int_', + } + + if op in operator_mapping: + operator_label = operator_mapping[op] + else: + raise ValueError(f"Unsupported operator in a precondition: {op}") + + return KApply(operator_label, left, right) + + def visitBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext) -> KInner: + return TRUE if ctx.getText() == 'true' else FALSE + + # def visitAddExpression(self, ctx: SolidityParser.AddExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left + right + + # def visitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left - right + + # def visitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left * right + + # def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + return left / right + + def visitVariable(self, ctx: SolidityParser.VariableContext) -> KInner: + var_name = ctx.getText() + for input in self.method.inputs: + if input.name == var_name: + # TODO(palina): add support for complex types + return abstract_term_safely(KVariable('_###SOLIDITY_ARG_VAR###_'), base_name=f'V{input.arg_name}') + else: + for field in self.method.contract.storage_fields: + if field.name == var_name: + # Perform the necessary action for a matching storage field + break # Exit the loop once the matching field is found + raise ValueError(f"Not implemented yet: {var_name}") + + raise ValueError(f"Unknown term: {var_name}") + + # def visitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): + # var_name = ctx.variableName().getText() + # return len(self.context.get(var_name, "")) + + # def visitArrayElement(self, ctx: SolidityParser.ArrayElementContext): + # var_name = ctx.variableName().getText() + # index = int(ctx.INTEGER().getText()) + # return self.context.get(var_name, [])[index] + + # def visitMappingElement(self, ctx: SolidityParser.MappingElementContext): + # var_name = ctx.variableName().getText() + # key = ctx.variableName().getText() + # return self.context.get(var_name, {}).get(key, 0) + + # def visitAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): + # return ctx.getText() + + def visitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext) -> KInner: + return intToken(ctx.getText()) diff --git a/src/kontrol/solidity/Solidity.g4 b/src/kontrol/solidity/Solidity.g4 new file mode 100644 index 000000000..258ff6c59 --- /dev/null +++ b/src/kontrol/solidity/Solidity.g4 @@ -0,0 +1,53 @@ +grammar Solidity; + +// Parser rules +expression + : booleanExpression + ; + +booleanExpression + : booleanExpression '&&' booleanExpression # AndExpression + | booleanExpression '||' booleanExpression # OrExpression + | '!' booleanExpression # NotExpression + | arithmeticExpression RelOp arithmeticExpression # RelationalExpression + | BOOLEAN_LITERAL # BooleanLiteral + | '(' booleanExpression ')' # ParenthesizedBooleanExpression + ; + +arithmeticExpression + : arithmeticExpression '+' arithmeticExpression # AddExpression + | arithmeticExpression '-' arithmeticExpression # SubtractExpression + | arithmeticExpression '*' arithmeticExpression # MultiplyExpression + | arithmeticExpression '/' arithmeticExpression # DivideExpression + | atom # AtomExpression + ; + +atom + : VariableName # Variable + | LengthAccess # LengthAccess + | ArrayElement # ArrayElement + | MappingElement # MappingElement + | AddressLiteral # AddressLiteral + | INTEGER # IntegerLiteral + | '(' arithmeticExpression ')' # ParenthesizedArithmeticExpression + | BlockAccess # BlockAccess + | MsgAccess # MsgAccess + ; + +// Lexer rules +BOOLEAN_LITERAL: 'true' | 'false'; +INTEGER: [0-9]+; +ADDRESS: '0x' [0-9a-fA-F]+; + +VariableName: [a-zA-Z_][a-zA-Z0-9_]*; +LengthAccess: VariableName '.length'; +ArrayElement: VariableName '[' INTEGER ']'; +MappingElement: VariableName '[' VariableName ']'; +AddressLiteral: ADDRESS; +BlockAccess: 'block.' ('timestamp' | 'number'); +MsgAccess: 'msg.' ('sender'); + +RelOp: '<' | '<=' | '>' | '>=' | '==' | '!='; + +// Whitespace and comments +WS: [ \t\r\n]+ -> skip; \ No newline at end of file diff --git a/src/kontrol/solidity/Solidity.interp b/src/kontrol/solidity/Solidity.interp new file mode 100644 index 000000000..dabd25df8 --- /dev/null +++ b/src/kontrol/solidity/Solidity.interp @@ -0,0 +1,57 @@ +token literal names: +null +'&&' +'||' +'!' +'(' +')' +'+' +'-' +'*' +'/' +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +BOOLEAN_LITERAL +INTEGER +ADDRESS +VariableName +LengthAccess +ArrayElement +MappingElement +AddressLiteral +BlockAccess +MsgAccess +RelOp +WS + +rule names: +expression +booleanExpression +arithmeticExpression +atom + + +atn: +[4, 1, 21, 70, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 23, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 31, 8, 1, 10, 1, 12, 1, 34, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 51, 8, 2, 10, 2, 12, 2, 54, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 68, 8, 3, 1, 3, 0, 2, 2, 4, 4, 0, 2, 4, 6, 0, 0, 82, 0, 8, 1, 0, 0, 0, 2, 22, 1, 0, 0, 0, 4, 35, 1, 0, 0, 0, 6, 67, 1, 0, 0, 0, 8, 9, 3, 2, 1, 0, 9, 1, 1, 0, 0, 0, 10, 11, 6, 1, -1, 0, 11, 12, 5, 3, 0, 0, 12, 23, 3, 2, 1, 4, 13, 14, 3, 4, 2, 0, 14, 15, 5, 20, 0, 0, 15, 16, 3, 4, 2, 0, 16, 23, 1, 0, 0, 0, 17, 23, 5, 10, 0, 0, 18, 19, 5, 4, 0, 0, 19, 20, 3, 2, 1, 0, 20, 21, 5, 5, 0, 0, 21, 23, 1, 0, 0, 0, 22, 10, 1, 0, 0, 0, 22, 13, 1, 0, 0, 0, 22, 17, 1, 0, 0, 0, 22, 18, 1, 0, 0, 0, 23, 32, 1, 0, 0, 0, 24, 25, 10, 6, 0, 0, 25, 26, 5, 1, 0, 0, 26, 31, 3, 2, 1, 7, 27, 28, 10, 5, 0, 0, 28, 29, 5, 2, 0, 0, 29, 31, 3, 2, 1, 6, 30, 24, 1, 0, 0, 0, 30, 27, 1, 0, 0, 0, 31, 34, 1, 0, 0, 0, 32, 30, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 3, 1, 0, 0, 0, 34, 32, 1, 0, 0, 0, 35, 36, 6, 2, -1, 0, 36, 37, 3, 6, 3, 0, 37, 52, 1, 0, 0, 0, 38, 39, 10, 5, 0, 0, 39, 40, 5, 6, 0, 0, 40, 51, 3, 4, 2, 6, 41, 42, 10, 4, 0, 0, 42, 43, 5, 7, 0, 0, 43, 51, 3, 4, 2, 5, 44, 45, 10, 3, 0, 0, 45, 46, 5, 8, 0, 0, 46, 51, 3, 4, 2, 4, 47, 48, 10, 2, 0, 0, 48, 49, 5, 9, 0, 0, 49, 51, 3, 4, 2, 3, 50, 38, 1, 0, 0, 0, 50, 41, 1, 0, 0, 0, 50, 44, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 5, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 68, 5, 13, 0, 0, 56, 68, 5, 14, 0, 0, 57, 68, 5, 15, 0, 0, 58, 68, 5, 16, 0, 0, 59, 68, 5, 17, 0, 0, 60, 68, 5, 11, 0, 0, 61, 62, 5, 4, 0, 0, 62, 63, 3, 4, 2, 0, 63, 64, 5, 5, 0, 0, 64, 68, 1, 0, 0, 0, 65, 68, 5, 18, 0, 0, 66, 68, 5, 19, 0, 0, 67, 55, 1, 0, 0, 0, 67, 56, 1, 0, 0, 0, 67, 57, 1, 0, 0, 0, 67, 58, 1, 0, 0, 0, 67, 59, 1, 0, 0, 0, 67, 60, 1, 0, 0, 0, 67, 61, 1, 0, 0, 0, 67, 65, 1, 0, 0, 0, 67, 66, 1, 0, 0, 0, 68, 7, 1, 0, 0, 0, 6, 22, 30, 32, 50, 52, 67] \ No newline at end of file diff --git a/src/kontrol/solidity/Solidity.tokens b/src/kontrol/solidity/Solidity.tokens new file mode 100644 index 000000000..309be27ac --- /dev/null +++ b/src/kontrol/solidity/Solidity.tokens @@ -0,0 +1,30 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +T__7=8 +T__8=9 +BOOLEAN_LITERAL=10 +INTEGER=11 +ADDRESS=12 +VariableName=13 +LengthAccess=14 +ArrayElement=15 +MappingElement=16 +AddressLiteral=17 +BlockAccess=18 +MsgAccess=19 +RelOp=20 +WS=21 +'&&'=1 +'||'=2 +'!'=3 +'('=4 +')'=5 +'+'=6 +'-'=7 +'*'=8 +'/'=9 diff --git a/src/kontrol/solidity/SolidityLexer.interp b/src/kontrol/solidity/SolidityLexer.interp new file mode 100644 index 000000000..968e16476 --- /dev/null +++ b/src/kontrol/solidity/SolidityLexer.interp @@ -0,0 +1,80 @@ +token literal names: +null +'&&' +'||' +'!' +'(' +')' +'+' +'-' +'*' +'/' +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +BOOLEAN_LITERAL +INTEGER +ADDRESS +VariableName +LengthAccess +ArrayElement +MappingElement +AddressLiteral +BlockAccess +MsgAccess +RelOp +WS + +rule names: +T__0 +T__1 +T__2 +T__3 +T__4 +T__5 +T__6 +T__7 +T__8 +BOOLEAN_LITERAL +INTEGER +ADDRESS +VariableName +LengthAccess +ArrayElement +MappingElement +AddressLiteral +BlockAccess +MsgAccess +RelOp +WS + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 21, 170, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 73, 8, 9, 1, 10, 4, 10, 76, 8, 10, 11, 10, 12, 10, 77, 1, 11, 1, 11, 1, 11, 1, 11, 4, 11, 84, 8, 11, 11, 11, 12, 11, 85, 1, 12, 1, 12, 5, 12, 90, 8, 12, 10, 12, 12, 12, 93, 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 138, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 162, 8, 19, 1, 20, 4, 20, 165, 8, 20, 11, 20, 12, 20, 166, 1, 20, 1, 20, 0, 0, 21, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 1, 0, 5, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 180, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 1, 43, 1, 0, 0, 0, 3, 46, 1, 0, 0, 0, 5, 49, 1, 0, 0, 0, 7, 51, 1, 0, 0, 0, 9, 53, 1, 0, 0, 0, 11, 55, 1, 0, 0, 0, 13, 57, 1, 0, 0, 0, 15, 59, 1, 0, 0, 0, 17, 61, 1, 0, 0, 0, 19, 72, 1, 0, 0, 0, 21, 75, 1, 0, 0, 0, 23, 79, 1, 0, 0, 0, 25, 87, 1, 0, 0, 0, 27, 94, 1, 0, 0, 0, 29, 103, 1, 0, 0, 0, 31, 108, 1, 0, 0, 0, 33, 113, 1, 0, 0, 0, 35, 115, 1, 0, 0, 0, 37, 139, 1, 0, 0, 0, 39, 161, 1, 0, 0, 0, 41, 164, 1, 0, 0, 0, 43, 44, 5, 38, 0, 0, 44, 45, 5, 38, 0, 0, 45, 2, 1, 0, 0, 0, 46, 47, 5, 124, 0, 0, 47, 48, 5, 124, 0, 0, 48, 4, 1, 0, 0, 0, 49, 50, 5, 33, 0, 0, 50, 6, 1, 0, 0, 0, 51, 52, 5, 40, 0, 0, 52, 8, 1, 0, 0, 0, 53, 54, 5, 41, 0, 0, 54, 10, 1, 0, 0, 0, 55, 56, 5, 43, 0, 0, 56, 12, 1, 0, 0, 0, 57, 58, 5, 45, 0, 0, 58, 14, 1, 0, 0, 0, 59, 60, 5, 42, 0, 0, 60, 16, 1, 0, 0, 0, 61, 62, 5, 47, 0, 0, 62, 18, 1, 0, 0, 0, 63, 64, 5, 116, 0, 0, 64, 65, 5, 114, 0, 0, 65, 66, 5, 117, 0, 0, 66, 73, 5, 101, 0, 0, 67, 68, 5, 102, 0, 0, 68, 69, 5, 97, 0, 0, 69, 70, 5, 108, 0, 0, 70, 71, 5, 115, 0, 0, 71, 73, 5, 101, 0, 0, 72, 63, 1, 0, 0, 0, 72, 67, 1, 0, 0, 0, 73, 20, 1, 0, 0, 0, 74, 76, 7, 0, 0, 0, 75, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 22, 1, 0, 0, 0, 79, 80, 5, 48, 0, 0, 80, 81, 5, 120, 0, 0, 81, 83, 1, 0, 0, 0, 82, 84, 7, 1, 0, 0, 83, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 24, 1, 0, 0, 0, 87, 91, 7, 2, 0, 0, 88, 90, 7, 3, 0, 0, 89, 88, 1, 0, 0, 0, 90, 93, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 26, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 94, 95, 3, 25, 12, 0, 95, 96, 5, 46, 0, 0, 96, 97, 5, 108, 0, 0, 97, 98, 5, 101, 0, 0, 98, 99, 5, 110, 0, 0, 99, 100, 5, 103, 0, 0, 100, 101, 5, 116, 0, 0, 101, 102, 5, 104, 0, 0, 102, 28, 1, 0, 0, 0, 103, 104, 3, 25, 12, 0, 104, 105, 5, 91, 0, 0, 105, 106, 3, 21, 10, 0, 106, 107, 5, 93, 0, 0, 107, 30, 1, 0, 0, 0, 108, 109, 3, 25, 12, 0, 109, 110, 5, 91, 0, 0, 110, 111, 3, 25, 12, 0, 111, 112, 5, 93, 0, 0, 112, 32, 1, 0, 0, 0, 113, 114, 3, 23, 11, 0, 114, 34, 1, 0, 0, 0, 115, 116, 5, 98, 0, 0, 116, 117, 5, 108, 0, 0, 117, 118, 5, 111, 0, 0, 118, 119, 5, 99, 0, 0, 119, 120, 5, 107, 0, 0, 120, 121, 5, 46, 0, 0, 121, 137, 1, 0, 0, 0, 122, 123, 5, 116, 0, 0, 123, 124, 5, 105, 0, 0, 124, 125, 5, 109, 0, 0, 125, 126, 5, 101, 0, 0, 126, 127, 5, 115, 0, 0, 127, 128, 5, 116, 0, 0, 128, 129, 5, 97, 0, 0, 129, 130, 5, 109, 0, 0, 130, 138, 5, 112, 0, 0, 131, 132, 5, 110, 0, 0, 132, 133, 5, 117, 0, 0, 133, 134, 5, 109, 0, 0, 134, 135, 5, 98, 0, 0, 135, 136, 5, 101, 0, 0, 136, 138, 5, 114, 0, 0, 137, 122, 1, 0, 0, 0, 137, 131, 1, 0, 0, 0, 138, 36, 1, 0, 0, 0, 139, 140, 5, 109, 0, 0, 140, 141, 5, 115, 0, 0, 141, 142, 5, 103, 0, 0, 142, 143, 5, 46, 0, 0, 143, 144, 1, 0, 0, 0, 144, 145, 5, 115, 0, 0, 145, 146, 5, 101, 0, 0, 146, 147, 5, 110, 0, 0, 147, 148, 5, 100, 0, 0, 148, 149, 5, 101, 0, 0, 149, 150, 5, 114, 0, 0, 150, 38, 1, 0, 0, 0, 151, 162, 5, 60, 0, 0, 152, 153, 5, 60, 0, 0, 153, 162, 5, 61, 0, 0, 154, 162, 5, 62, 0, 0, 155, 156, 5, 62, 0, 0, 156, 162, 5, 61, 0, 0, 157, 158, 5, 61, 0, 0, 158, 162, 5, 61, 0, 0, 159, 160, 5, 33, 0, 0, 160, 162, 5, 61, 0, 0, 161, 151, 1, 0, 0, 0, 161, 152, 1, 0, 0, 0, 161, 154, 1, 0, 0, 0, 161, 155, 1, 0, 0, 0, 161, 157, 1, 0, 0, 0, 161, 159, 1, 0, 0, 0, 162, 40, 1, 0, 0, 0, 163, 165, 7, 4, 0, 0, 164, 163, 1, 0, 0, 0, 165, 166, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 166, 167, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 169, 6, 20, 0, 0, 169, 42, 1, 0, 0, 0, 8, 0, 72, 77, 85, 91, 137, 161, 166, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/kontrol/solidity/SolidityLexer.py b/src/kontrol/solidity/SolidityLexer.py new file mode 100644 index 000000000..56d5c5cb4 --- /dev/null +++ b/src/kontrol/solidity/SolidityLexer.py @@ -0,0 +1,1633 @@ +# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.1 +import sys + +from antlr4 import DFA, ATNDeserializer, Lexer, LexerATNSimulator, PredictionContextCache + +if sys.version_info[1] > 5: + from typing import TextIO +else: + from typing.io import TextIO + + +def serializedATN(): + return [ + 4, + 0, + 21, + 170, + 6, + -1, + 2, + 0, + 7, + 0, + 2, + 1, + 7, + 1, + 2, + 2, + 7, + 2, + 2, + 3, + 7, + 3, + 2, + 4, + 7, + 4, + 2, + 5, + 7, + 5, + 2, + 6, + 7, + 6, + 2, + 7, + 7, + 7, + 2, + 8, + 7, + 8, + 2, + 9, + 7, + 9, + 2, + 10, + 7, + 10, + 2, + 11, + 7, + 11, + 2, + 12, + 7, + 12, + 2, + 13, + 7, + 13, + 2, + 14, + 7, + 14, + 2, + 15, + 7, + 15, + 2, + 16, + 7, + 16, + 2, + 17, + 7, + 17, + 2, + 18, + 7, + 18, + 2, + 19, + 7, + 19, + 2, + 20, + 7, + 20, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 2, + 1, + 3, + 1, + 3, + 1, + 4, + 1, + 4, + 1, + 5, + 1, + 5, + 1, + 6, + 1, + 6, + 1, + 7, + 1, + 7, + 1, + 8, + 1, + 8, + 1, + 9, + 1, + 9, + 1, + 9, + 1, + 9, + 1, + 9, + 1, + 9, + 1, + 9, + 1, + 9, + 1, + 9, + 3, + 9, + 73, + 8, + 9, + 1, + 10, + 4, + 10, + 76, + 8, + 10, + 11, + 10, + 12, + 10, + 77, + 1, + 11, + 1, + 11, + 1, + 11, + 1, + 11, + 4, + 11, + 84, + 8, + 11, + 11, + 11, + 12, + 11, + 85, + 1, + 12, + 1, + 12, + 5, + 12, + 90, + 8, + 12, + 10, + 12, + 12, + 12, + 93, + 9, + 12, + 1, + 13, + 1, + 13, + 1, + 13, + 1, + 13, + 1, + 13, + 1, + 13, + 1, + 13, + 1, + 13, + 1, + 13, + 1, + 14, + 1, + 14, + 1, + 14, + 1, + 14, + 1, + 14, + 1, + 15, + 1, + 15, + 1, + 15, + 1, + 15, + 1, + 15, + 1, + 16, + 1, + 16, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 1, + 17, + 3, + 17, + 138, + 8, + 17, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 18, + 1, + 19, + 1, + 19, + 1, + 19, + 1, + 19, + 1, + 19, + 1, + 19, + 1, + 19, + 1, + 19, + 1, + 19, + 1, + 19, + 3, + 19, + 162, + 8, + 19, + 1, + 20, + 4, + 20, + 165, + 8, + 20, + 11, + 20, + 12, + 20, + 166, + 1, + 20, + 1, + 20, + 0, + 0, + 21, + 1, + 1, + 3, + 2, + 5, + 3, + 7, + 4, + 9, + 5, + 11, + 6, + 13, + 7, + 15, + 8, + 17, + 9, + 19, + 10, + 21, + 11, + 23, + 12, + 25, + 13, + 27, + 14, + 29, + 15, + 31, + 16, + 33, + 17, + 35, + 18, + 37, + 19, + 39, + 20, + 41, + 21, + 1, + 0, + 5, + 1, + 0, + 48, + 57, + 3, + 0, + 48, + 57, + 65, + 70, + 97, + 102, + 3, + 0, + 65, + 90, + 95, + 95, + 97, + 122, + 4, + 0, + 48, + 57, + 65, + 90, + 95, + 95, + 97, + 122, + 3, + 0, + 9, + 10, + 13, + 13, + 32, + 32, + 180, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 5, + 1, + 0, + 0, + 0, + 0, + 7, + 1, + 0, + 0, + 0, + 0, + 9, + 1, + 0, + 0, + 0, + 0, + 11, + 1, + 0, + 0, + 0, + 0, + 13, + 1, + 0, + 0, + 0, + 0, + 15, + 1, + 0, + 0, + 0, + 0, + 17, + 1, + 0, + 0, + 0, + 0, + 19, + 1, + 0, + 0, + 0, + 0, + 21, + 1, + 0, + 0, + 0, + 0, + 23, + 1, + 0, + 0, + 0, + 0, + 25, + 1, + 0, + 0, + 0, + 0, + 27, + 1, + 0, + 0, + 0, + 0, + 29, + 1, + 0, + 0, + 0, + 0, + 31, + 1, + 0, + 0, + 0, + 0, + 33, + 1, + 0, + 0, + 0, + 0, + 35, + 1, + 0, + 0, + 0, + 0, + 37, + 1, + 0, + 0, + 0, + 0, + 39, + 1, + 0, + 0, + 0, + 0, + 41, + 1, + 0, + 0, + 0, + 1, + 43, + 1, + 0, + 0, + 0, + 3, + 46, + 1, + 0, + 0, + 0, + 5, + 49, + 1, + 0, + 0, + 0, + 7, + 51, + 1, + 0, + 0, + 0, + 9, + 53, + 1, + 0, + 0, + 0, + 11, + 55, + 1, + 0, + 0, + 0, + 13, + 57, + 1, + 0, + 0, + 0, + 15, + 59, + 1, + 0, + 0, + 0, + 17, + 61, + 1, + 0, + 0, + 0, + 19, + 72, + 1, + 0, + 0, + 0, + 21, + 75, + 1, + 0, + 0, + 0, + 23, + 79, + 1, + 0, + 0, + 0, + 25, + 87, + 1, + 0, + 0, + 0, + 27, + 94, + 1, + 0, + 0, + 0, + 29, + 103, + 1, + 0, + 0, + 0, + 31, + 108, + 1, + 0, + 0, + 0, + 33, + 113, + 1, + 0, + 0, + 0, + 35, + 115, + 1, + 0, + 0, + 0, + 37, + 139, + 1, + 0, + 0, + 0, + 39, + 161, + 1, + 0, + 0, + 0, + 41, + 164, + 1, + 0, + 0, + 0, + 43, + 44, + 5, + 38, + 0, + 0, + 44, + 45, + 5, + 38, + 0, + 0, + 45, + 2, + 1, + 0, + 0, + 0, + 46, + 47, + 5, + 124, + 0, + 0, + 47, + 48, + 5, + 124, + 0, + 0, + 48, + 4, + 1, + 0, + 0, + 0, + 49, + 50, + 5, + 33, + 0, + 0, + 50, + 6, + 1, + 0, + 0, + 0, + 51, + 52, + 5, + 40, + 0, + 0, + 52, + 8, + 1, + 0, + 0, + 0, + 53, + 54, + 5, + 41, + 0, + 0, + 54, + 10, + 1, + 0, + 0, + 0, + 55, + 56, + 5, + 43, + 0, + 0, + 56, + 12, + 1, + 0, + 0, + 0, + 57, + 58, + 5, + 45, + 0, + 0, + 58, + 14, + 1, + 0, + 0, + 0, + 59, + 60, + 5, + 42, + 0, + 0, + 60, + 16, + 1, + 0, + 0, + 0, + 61, + 62, + 5, + 47, + 0, + 0, + 62, + 18, + 1, + 0, + 0, + 0, + 63, + 64, + 5, + 116, + 0, + 0, + 64, + 65, + 5, + 114, + 0, + 0, + 65, + 66, + 5, + 117, + 0, + 0, + 66, + 73, + 5, + 101, + 0, + 0, + 67, + 68, + 5, + 102, + 0, + 0, + 68, + 69, + 5, + 97, + 0, + 0, + 69, + 70, + 5, + 108, + 0, + 0, + 70, + 71, + 5, + 115, + 0, + 0, + 71, + 73, + 5, + 101, + 0, + 0, + 72, + 63, + 1, + 0, + 0, + 0, + 72, + 67, + 1, + 0, + 0, + 0, + 73, + 20, + 1, + 0, + 0, + 0, + 74, + 76, + 7, + 0, + 0, + 0, + 75, + 74, + 1, + 0, + 0, + 0, + 76, + 77, + 1, + 0, + 0, + 0, + 77, + 75, + 1, + 0, + 0, + 0, + 77, + 78, + 1, + 0, + 0, + 0, + 78, + 22, + 1, + 0, + 0, + 0, + 79, + 80, + 5, + 48, + 0, + 0, + 80, + 81, + 5, + 120, + 0, + 0, + 81, + 83, + 1, + 0, + 0, + 0, + 82, + 84, + 7, + 1, + 0, + 0, + 83, + 82, + 1, + 0, + 0, + 0, + 84, + 85, + 1, + 0, + 0, + 0, + 85, + 83, + 1, + 0, + 0, + 0, + 85, + 86, + 1, + 0, + 0, + 0, + 86, + 24, + 1, + 0, + 0, + 0, + 87, + 91, + 7, + 2, + 0, + 0, + 88, + 90, + 7, + 3, + 0, + 0, + 89, + 88, + 1, + 0, + 0, + 0, + 90, + 93, + 1, + 0, + 0, + 0, + 91, + 89, + 1, + 0, + 0, + 0, + 91, + 92, + 1, + 0, + 0, + 0, + 92, + 26, + 1, + 0, + 0, + 0, + 93, + 91, + 1, + 0, + 0, + 0, + 94, + 95, + 3, + 25, + 12, + 0, + 95, + 96, + 5, + 46, + 0, + 0, + 96, + 97, + 5, + 108, + 0, + 0, + 97, + 98, + 5, + 101, + 0, + 0, + 98, + 99, + 5, + 110, + 0, + 0, + 99, + 100, + 5, + 103, + 0, + 0, + 100, + 101, + 5, + 116, + 0, + 0, + 101, + 102, + 5, + 104, + 0, + 0, + 102, + 28, + 1, + 0, + 0, + 0, + 103, + 104, + 3, + 25, + 12, + 0, + 104, + 105, + 5, + 91, + 0, + 0, + 105, + 106, + 3, + 21, + 10, + 0, + 106, + 107, + 5, + 93, + 0, + 0, + 107, + 30, + 1, + 0, + 0, + 0, + 108, + 109, + 3, + 25, + 12, + 0, + 109, + 110, + 5, + 91, + 0, + 0, + 110, + 111, + 3, + 25, + 12, + 0, + 111, + 112, + 5, + 93, + 0, + 0, + 112, + 32, + 1, + 0, + 0, + 0, + 113, + 114, + 3, + 23, + 11, + 0, + 114, + 34, + 1, + 0, + 0, + 0, + 115, + 116, + 5, + 98, + 0, + 0, + 116, + 117, + 5, + 108, + 0, + 0, + 117, + 118, + 5, + 111, + 0, + 0, + 118, + 119, + 5, + 99, + 0, + 0, + 119, + 120, + 5, + 107, + 0, + 0, + 120, + 121, + 5, + 46, + 0, + 0, + 121, + 137, + 1, + 0, + 0, + 0, + 122, + 123, + 5, + 116, + 0, + 0, + 123, + 124, + 5, + 105, + 0, + 0, + 124, + 125, + 5, + 109, + 0, + 0, + 125, + 126, + 5, + 101, + 0, + 0, + 126, + 127, + 5, + 115, + 0, + 0, + 127, + 128, + 5, + 116, + 0, + 0, + 128, + 129, + 5, + 97, + 0, + 0, + 129, + 130, + 5, + 109, + 0, + 0, + 130, + 138, + 5, + 112, + 0, + 0, + 131, + 132, + 5, + 110, + 0, + 0, + 132, + 133, + 5, + 117, + 0, + 0, + 133, + 134, + 5, + 109, + 0, + 0, + 134, + 135, + 5, + 98, + 0, + 0, + 135, + 136, + 5, + 101, + 0, + 0, + 136, + 138, + 5, + 114, + 0, + 0, + 137, + 122, + 1, + 0, + 0, + 0, + 137, + 131, + 1, + 0, + 0, + 0, + 138, + 36, + 1, + 0, + 0, + 0, + 139, + 140, + 5, + 109, + 0, + 0, + 140, + 141, + 5, + 115, + 0, + 0, + 141, + 142, + 5, + 103, + 0, + 0, + 142, + 143, + 5, + 46, + 0, + 0, + 143, + 144, + 1, + 0, + 0, + 0, + 144, + 145, + 5, + 115, + 0, + 0, + 145, + 146, + 5, + 101, + 0, + 0, + 146, + 147, + 5, + 110, + 0, + 0, + 147, + 148, + 5, + 100, + 0, + 0, + 148, + 149, + 5, + 101, + 0, + 0, + 149, + 150, + 5, + 114, + 0, + 0, + 150, + 38, + 1, + 0, + 0, + 0, + 151, + 162, + 5, + 60, + 0, + 0, + 152, + 153, + 5, + 60, + 0, + 0, + 153, + 162, + 5, + 61, + 0, + 0, + 154, + 162, + 5, + 62, + 0, + 0, + 155, + 156, + 5, + 62, + 0, + 0, + 156, + 162, + 5, + 61, + 0, + 0, + 157, + 158, + 5, + 61, + 0, + 0, + 158, + 162, + 5, + 61, + 0, + 0, + 159, + 160, + 5, + 33, + 0, + 0, + 160, + 162, + 5, + 61, + 0, + 0, + 161, + 151, + 1, + 0, + 0, + 0, + 161, + 152, + 1, + 0, + 0, + 0, + 161, + 154, + 1, + 0, + 0, + 0, + 161, + 155, + 1, + 0, + 0, + 0, + 161, + 157, + 1, + 0, + 0, + 0, + 161, + 159, + 1, + 0, + 0, + 0, + 162, + 40, + 1, + 0, + 0, + 0, + 163, + 165, + 7, + 4, + 0, + 0, + 164, + 163, + 1, + 0, + 0, + 0, + 165, + 166, + 1, + 0, + 0, + 0, + 166, + 164, + 1, + 0, + 0, + 0, + 166, + 167, + 1, + 0, + 0, + 0, + 167, + 168, + 1, + 0, + 0, + 0, + 168, + 169, + 6, + 20, + 0, + 0, + 169, + 42, + 1, + 0, + 0, + 0, + 8, + 0, + 72, + 77, + 85, + 91, + 137, + 161, + 166, + 1, + 6, + 0, + 0, + ] + + +class SolidityLexer(Lexer): + + atn = ATNDeserializer().deserialize(serializedATN()) + + decisionsToDFA = [DFA(ds, i) for i, ds in enumerate(atn.decisionToState)] + + T__0 = 1 + T__1 = 2 + T__2 = 3 + T__3 = 4 + T__4 = 5 + T__5 = 6 + T__6 = 7 + T__7 = 8 + T__8 = 9 + BOOLEAN_LITERAL = 10 + INTEGER = 11 + ADDRESS = 12 + VariableName = 13 + LengthAccess = 14 + ArrayElement = 15 + MappingElement = 16 + AddressLiteral = 17 + BlockAccess = 18 + MsgAccess = 19 + RelOp = 20 + WS = 21 + + channelNames = [u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN"] + + modeNames = ["DEFAULT_MODE"] + + literalNames = ["", "'&&'", "'||'", "'!'", "'('", "')'", "'+'", "'-'", "'*'", "'/'"] + + symbolicNames = [ + "", + "BOOLEAN_LITERAL", + "INTEGER", + "ADDRESS", + "VariableName", + "LengthAccess", + "ArrayElement", + "MappingElement", + "AddressLiteral", + "BlockAccess", + "MsgAccess", + "RelOp", + "WS", + ] + + ruleNames = [ + "T__0", + "T__1", + "T__2", + "T__3", + "T__4", + "T__5", + "T__6", + "T__7", + "T__8", + "BOOLEAN_LITERAL", + "INTEGER", + "ADDRESS", + "VariableName", + "LengthAccess", + "ArrayElement", + "MappingElement", + "AddressLiteral", + "BlockAccess", + "MsgAccess", + "RelOp", + "WS", + ] + + grammarFileName = "Solidity.g4" + + def __init__(self, input=None, output: TextIO = sys.stdout): + super().__init__(input, output) + self.checkVersion("4.13.1") + self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) + self._actions = None + self._predicates = None diff --git a/src/kontrol/solidity/SolidityLexer.tokens b/src/kontrol/solidity/SolidityLexer.tokens new file mode 100644 index 000000000..309be27ac --- /dev/null +++ b/src/kontrol/solidity/SolidityLexer.tokens @@ -0,0 +1,30 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +T__7=8 +T__8=9 +BOOLEAN_LITERAL=10 +INTEGER=11 +ADDRESS=12 +VariableName=13 +LengthAccess=14 +ArrayElement=15 +MappingElement=16 +AddressLiteral=17 +BlockAccess=18 +MsgAccess=19 +RelOp=20 +WS=21 +'&&'=1 +'||'=2 +'!'=3 +'('=4 +')'=5 +'+'=6 +'-'=7 +'*'=8 +'/'=9 diff --git a/src/kontrol/solidity/SolidityListener.py b/src/kontrol/solidity/SolidityListener.py new file mode 100644 index 000000000..9f311dbe6 --- /dev/null +++ b/src/kontrol/solidity/SolidityListener.py @@ -0,0 +1,182 @@ +# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.1 +from antlr4 import * + +if "." in __name__: + from .SolidityParser import SolidityParser +else: + from SolidityParser import SolidityParser + + +# This class defines a complete listener for a parse tree produced by SolidityParser. +class SolidityListener(ParseTreeListener): + + # Enter a parse tree produced by SolidityParser#expression. + def enterExpression(self, ctx: SolidityParser.ExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#expression. + def exitExpression(self, ctx: SolidityParser.ExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#RelationalExpression. + def enterRelationalExpression(self, ctx: SolidityParser.RelationalExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#RelationalExpression. + def exitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#AndExpression. + def enterAndExpression(self, ctx: SolidityParser.AndExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#AndExpression. + def exitAndExpression(self, ctx: SolidityParser.AndExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#BooleanLiteral. + def enterBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext): + pass + + # Exit a parse tree produced by SolidityParser#BooleanLiteral. + def exitBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext): + pass + + # Enter a parse tree produced by SolidityParser#NotExpression. + def enterNotExpression(self, ctx: SolidityParser.NotExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#NotExpression. + def exitNotExpression(self, ctx: SolidityParser.NotExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#OrExpression. + def enterOrExpression(self, ctx: SolidityParser.OrExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#OrExpression. + def exitOrExpression(self, ctx: SolidityParser.OrExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#ParenthesizedBooleanExpression. + def enterParenthesizedBooleanExpression(self, ctx: SolidityParser.ParenthesizedBooleanExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#ParenthesizedBooleanExpression. + def exitParenthesizedBooleanExpression(self, ctx: SolidityParser.ParenthesizedBooleanExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#SubtractExpression. + def enterSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#SubtractExpression. + def exitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#DivideExpression. + def enterDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#DivideExpression. + def exitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#AddExpression. + def enterAddExpression(self, ctx: SolidityParser.AddExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#AddExpression. + def exitAddExpression(self, ctx: SolidityParser.AddExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#MultiplyExpression. + def enterMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#MultiplyExpression. + def exitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#AtomExpression. + def enterAtomExpression(self, ctx: SolidityParser.AtomExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#AtomExpression. + def exitAtomExpression(self, ctx: SolidityParser.AtomExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#Variable. + def enterVariable(self, ctx: SolidityParser.VariableContext): + pass + + # Exit a parse tree produced by SolidityParser#Variable. + def exitVariable(self, ctx: SolidityParser.VariableContext): + pass + + # Enter a parse tree produced by SolidityParser#LengthAccess. + def enterLengthAccess(self, ctx: SolidityParser.LengthAccessContext): + pass + + # Exit a parse tree produced by SolidityParser#LengthAccess. + def exitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): + pass + + # Enter a parse tree produced by SolidityParser#ArrayElement. + def enterArrayElement(self, ctx: SolidityParser.ArrayElementContext): + pass + + # Exit a parse tree produced by SolidityParser#ArrayElement. + def exitArrayElement(self, ctx: SolidityParser.ArrayElementContext): + pass + + # Enter a parse tree produced by SolidityParser#MappingElement. + def enterMappingElement(self, ctx: SolidityParser.MappingElementContext): + pass + + # Exit a parse tree produced by SolidityParser#MappingElement. + def exitMappingElement(self, ctx: SolidityParser.MappingElementContext): + pass + + # Enter a parse tree produced by SolidityParser#AddressLiteral. + def enterAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): + pass + + # Exit a parse tree produced by SolidityParser#AddressLiteral. + def exitAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): + pass + + # Enter a parse tree produced by SolidityParser#IntegerLiteral. + def enterIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext): + pass + + # Exit a parse tree produced by SolidityParser#IntegerLiteral. + def exitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext): + pass + + # Enter a parse tree produced by SolidityParser#ParenthesizedArithmeticExpression. + def enterParenthesizedArithmeticExpression(self, ctx: SolidityParser.ParenthesizedArithmeticExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#ParenthesizedArithmeticExpression. + def exitParenthesizedArithmeticExpression(self, ctx: SolidityParser.ParenthesizedArithmeticExpressionContext): + pass + + # Enter a parse tree produced by SolidityParser#BlockAccess. + def enterBlockAccess(self, ctx: SolidityParser.BlockAccessContext): + pass + + # Exit a parse tree produced by SolidityParser#BlockAccess. + def exitBlockAccess(self, ctx: SolidityParser.BlockAccessContext): + pass + + # Enter a parse tree produced by SolidityParser#MsgAccess. + def enterMsgAccess(self, ctx: SolidityParser.MsgAccessContext): + pass + + # Exit a parse tree produced by SolidityParser#MsgAccess. + def exitMsgAccess(self, ctx: SolidityParser.MsgAccessContext): + pass + + +del SolidityParser diff --git a/src/kontrol/solidity/SolidityParser.py b/src/kontrol/solidity/SolidityParser.py new file mode 100644 index 000000000..408a1fcbf --- /dev/null +++ b/src/kontrol/solidity/SolidityParser.py @@ -0,0 +1,1625 @@ +# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.1 +# encoding: utf-8 +import sys + +from antlr4 import ( + ATN, + DFA, + ATNDeserializer, + NoViableAltException, + Parser, + ParserATNSimulator, + ParserRuleContext, + ParseTreeListener, + ParseTreeVisitor, + PredictionContextCache, + RecognitionException, + RuleContext, + Token, + TokenStream, +) + +if sys.version_info[1] > 5: + from typing import TextIO +else: + from typing.io import TextIO + + +def serializedATN(): + return [ + 4, + 1, + 21, + 70, + 2, + 0, + 7, + 0, + 2, + 1, + 7, + 1, + 2, + 2, + 7, + 2, + 2, + 3, + 7, + 3, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 3, + 1, + 23, + 8, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 5, + 1, + 31, + 8, + 1, + 10, + 1, + 12, + 1, + 34, + 9, + 1, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 2, + 5, + 2, + 51, + 8, + 2, + 10, + 2, + 12, + 2, + 54, + 9, + 2, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 3, + 3, + 68, + 8, + 3, + 1, + 3, + 0, + 2, + 2, + 4, + 4, + 0, + 2, + 4, + 6, + 0, + 0, + 82, + 0, + 8, + 1, + 0, + 0, + 0, + 2, + 22, + 1, + 0, + 0, + 0, + 4, + 35, + 1, + 0, + 0, + 0, + 6, + 67, + 1, + 0, + 0, + 0, + 8, + 9, + 3, + 2, + 1, + 0, + 9, + 1, + 1, + 0, + 0, + 0, + 10, + 11, + 6, + 1, + -1, + 0, + 11, + 12, + 5, + 3, + 0, + 0, + 12, + 23, + 3, + 2, + 1, + 4, + 13, + 14, + 3, + 4, + 2, + 0, + 14, + 15, + 5, + 20, + 0, + 0, + 15, + 16, + 3, + 4, + 2, + 0, + 16, + 23, + 1, + 0, + 0, + 0, + 17, + 23, + 5, + 10, + 0, + 0, + 18, + 19, + 5, + 4, + 0, + 0, + 19, + 20, + 3, + 2, + 1, + 0, + 20, + 21, + 5, + 5, + 0, + 0, + 21, + 23, + 1, + 0, + 0, + 0, + 22, + 10, + 1, + 0, + 0, + 0, + 22, + 13, + 1, + 0, + 0, + 0, + 22, + 17, + 1, + 0, + 0, + 0, + 22, + 18, + 1, + 0, + 0, + 0, + 23, + 32, + 1, + 0, + 0, + 0, + 24, + 25, + 10, + 6, + 0, + 0, + 25, + 26, + 5, + 1, + 0, + 0, + 26, + 31, + 3, + 2, + 1, + 7, + 27, + 28, + 10, + 5, + 0, + 0, + 28, + 29, + 5, + 2, + 0, + 0, + 29, + 31, + 3, + 2, + 1, + 6, + 30, + 24, + 1, + 0, + 0, + 0, + 30, + 27, + 1, + 0, + 0, + 0, + 31, + 34, + 1, + 0, + 0, + 0, + 32, + 30, + 1, + 0, + 0, + 0, + 32, + 33, + 1, + 0, + 0, + 0, + 33, + 3, + 1, + 0, + 0, + 0, + 34, + 32, + 1, + 0, + 0, + 0, + 35, + 36, + 6, + 2, + -1, + 0, + 36, + 37, + 3, + 6, + 3, + 0, + 37, + 52, + 1, + 0, + 0, + 0, + 38, + 39, + 10, + 5, + 0, + 0, + 39, + 40, + 5, + 6, + 0, + 0, + 40, + 51, + 3, + 4, + 2, + 6, + 41, + 42, + 10, + 4, + 0, + 0, + 42, + 43, + 5, + 7, + 0, + 0, + 43, + 51, + 3, + 4, + 2, + 5, + 44, + 45, + 10, + 3, + 0, + 0, + 45, + 46, + 5, + 8, + 0, + 0, + 46, + 51, + 3, + 4, + 2, + 4, + 47, + 48, + 10, + 2, + 0, + 0, + 48, + 49, + 5, + 9, + 0, + 0, + 49, + 51, + 3, + 4, + 2, + 3, + 50, + 38, + 1, + 0, + 0, + 0, + 50, + 41, + 1, + 0, + 0, + 0, + 50, + 44, + 1, + 0, + 0, + 0, + 50, + 47, + 1, + 0, + 0, + 0, + 51, + 54, + 1, + 0, + 0, + 0, + 52, + 50, + 1, + 0, + 0, + 0, + 52, + 53, + 1, + 0, + 0, + 0, + 53, + 5, + 1, + 0, + 0, + 0, + 54, + 52, + 1, + 0, + 0, + 0, + 55, + 68, + 5, + 13, + 0, + 0, + 56, + 68, + 5, + 14, + 0, + 0, + 57, + 68, + 5, + 15, + 0, + 0, + 58, + 68, + 5, + 16, + 0, + 0, + 59, + 68, + 5, + 17, + 0, + 0, + 60, + 68, + 5, + 11, + 0, + 0, + 61, + 62, + 5, + 4, + 0, + 0, + 62, + 63, + 3, + 4, + 2, + 0, + 63, + 64, + 5, + 5, + 0, + 0, + 64, + 68, + 1, + 0, + 0, + 0, + 65, + 68, + 5, + 18, + 0, + 0, + 66, + 68, + 5, + 19, + 0, + 0, + 67, + 55, + 1, + 0, + 0, + 0, + 67, + 56, + 1, + 0, + 0, + 0, + 67, + 57, + 1, + 0, + 0, + 0, + 67, + 58, + 1, + 0, + 0, + 0, + 67, + 59, + 1, + 0, + 0, + 0, + 67, + 60, + 1, + 0, + 0, + 0, + 67, + 61, + 1, + 0, + 0, + 0, + 67, + 65, + 1, + 0, + 0, + 0, + 67, + 66, + 1, + 0, + 0, + 0, + 68, + 7, + 1, + 0, + 0, + 0, + 6, + 22, + 30, + 32, + 50, + 52, + 67, + ] + + +class SolidityParser(Parser): + + grammarFileName = "Solidity.g4" + + atn = ATNDeserializer().deserialize(serializedATN()) + + decisionsToDFA = [DFA(ds, i) for i, ds in enumerate(atn.decisionToState)] + + sharedContextCache = PredictionContextCache() + + literalNames = ["", "'&&'", "'||'", "'!'", "'('", "')'", "'+'", "'-'", "'*'", "'/'"] + + symbolicNames = [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "BOOLEAN_LITERAL", + "INTEGER", + "ADDRESS", + "VariableName", + "LengthAccess", + "ArrayElement", + "MappingElement", + "AddressLiteral", + "BlockAccess", + "MsgAccess", + "RelOp", + "WS", + ] + + RULE_expression = 0 + RULE_booleanExpression = 1 + RULE_arithmeticExpression = 2 + RULE_atom = 3 + + ruleNames = ["expression", "booleanExpression", "arithmeticExpression", "atom"] + + EOF = Token.EOF + T__0 = 1 + T__1 = 2 + T__2 = 3 + T__3 = 4 + T__4 = 5 + T__5 = 6 + T__6 = 7 + T__7 = 8 + T__8 = 9 + BOOLEAN_LITERAL = 10 + INTEGER = 11 + ADDRESS = 12 + VariableName = 13 + LengthAccess = 14 + ArrayElement = 15 + MappingElement = 16 + AddressLiteral = 17 + BlockAccess = 18 + MsgAccess = 19 + RelOp = 20 + WS = 21 + + def __init__(self, input: TokenStream, output: TextIO = sys.stdout): + super().__init__(input, output) + self.checkVersion("4.13.1") + self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache) + self._predicates = None + + class ExpressionContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + super().__init__(parent, invokingState) + self.parser = parser + + def booleanExpression(self): + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, 0) + + def getRuleIndex(self): + return SolidityParser.RULE_expression + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterExpression"): + listener.enterExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitExpression"): + listener.exitExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitExpression"): + return visitor.visitExpression(self) + else: + return visitor.visitChildren(self) + + def expression(self): + + localctx = SolidityParser.ExpressionContext(self, self._ctx, self.state) + self.enterRule(localctx, 0, self.RULE_expression) + try: + self.enterOuterAlt(localctx, 1) + self.state = 8 + self.booleanExpression(0) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class BooleanExpressionContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + super().__init__(parent, invokingState) + self.parser = parser + + def getRuleIndex(self): + return SolidityParser.RULE_booleanExpression + + def copyFrom(self, ctx: ParserRuleContext): + super().copyFrom(ctx) + + class RelationalExpressionContext(BooleanExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def arithmeticExpression(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) + else: + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + + def RelOp(self): + return self.getToken(SolidityParser.RelOp, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterRelationalExpression"): + listener.enterRelationalExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitRelationalExpression"): + listener.exitRelationalExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitRelationalExpression"): + return visitor.visitRelationalExpression(self) + else: + return visitor.visitChildren(self) + + class AndExpressionContext(BooleanExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def booleanExpression(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(SolidityParser.BooleanExpressionContext) + else: + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, i) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterAndExpression"): + listener.enterAndExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitAndExpression"): + listener.exitAndExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitAndExpression"): + return visitor.visitAndExpression(self) + else: + return visitor.visitChildren(self) + + class BooleanLiteralContext(BooleanExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def BOOLEAN_LITERAL(self): + return self.getToken(SolidityParser.BOOLEAN_LITERAL, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterBooleanLiteral"): + listener.enterBooleanLiteral(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitBooleanLiteral"): + listener.exitBooleanLiteral(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitBooleanLiteral"): + return visitor.visitBooleanLiteral(self) + else: + return visitor.visitChildren(self) + + class NotExpressionContext(BooleanExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def booleanExpression(self): + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterNotExpression"): + listener.enterNotExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitNotExpression"): + listener.exitNotExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitNotExpression"): + return visitor.visitNotExpression(self) + else: + return visitor.visitChildren(self) + + class OrExpressionContext(BooleanExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def booleanExpression(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(SolidityParser.BooleanExpressionContext) + else: + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, i) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterOrExpression"): + listener.enterOrExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitOrExpression"): + listener.exitOrExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitOrExpression"): + return visitor.visitOrExpression(self) + else: + return visitor.visitChildren(self) + + class ParenthesizedBooleanExpressionContext(BooleanExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def booleanExpression(self): + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterParenthesizedBooleanExpression"): + listener.enterParenthesizedBooleanExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitParenthesizedBooleanExpression"): + listener.exitParenthesizedBooleanExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitParenthesizedBooleanExpression"): + return visitor.visitParenthesizedBooleanExpression(self) + else: + return visitor.visitChildren(self) + + def booleanExpression(self, _p: int = 0): + _parentctx = self._ctx + _parentState = self.state + localctx = SolidityParser.BooleanExpressionContext(self, self._ctx, _parentState) + _startState = 2 + self.enterRecursionRule(localctx, 2, self.RULE_booleanExpression, _p) + try: + self.enterOuterAlt(localctx, 1) + self.state = 22 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input, 0, self._ctx) + if la_ == 1: + localctx = SolidityParser.NotExpressionContext(self, localctx) + self._ctx = localctx + + self.state = 11 + self.match(SolidityParser.T__2) + self.state = 12 + self.booleanExpression(4) + + elif la_ == 2: + localctx = SolidityParser.RelationalExpressionContext(self, localctx) + self._ctx = localctx + self.state = 13 + self.arithmeticExpression(0) + self.state = 14 + self.match(SolidityParser.RelOp) + self.state = 15 + self.arithmeticExpression(0) + + elif la_ == 3: + localctx = SolidityParser.BooleanLiteralContext(self, localctx) + self._ctx = localctx + self.state = 17 + self.match(SolidityParser.BOOLEAN_LITERAL) + + elif la_ == 4: + localctx = SolidityParser.ParenthesizedBooleanExpressionContext(self, localctx) + self._ctx = localctx + self.state = 18 + self.match(SolidityParser.T__3) + self.state = 19 + self.booleanExpression(0) + self.state = 20 + self.match(SolidityParser.T__4) + + self._ctx.stop = self._input.LT(-1) + self.state = 32 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input, 2, self._ctx) + while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER: + if _alt == 1: + if self._parseListeners is not None: + self.triggerExitRuleEvent() + self.state = 30 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input, 1, self._ctx) + if la_ == 1: + localctx = SolidityParser.AndExpressionContext( + self, SolidityParser.BooleanExpressionContext(self, _parentctx, _parentState) + ) + self.pushNewRecursionContext(localctx, _startState, self.RULE_booleanExpression) + self.state = 24 + if not self.precpred(self._ctx, 6): + from antlr4.error.Errors import FailedPredicateException + + raise FailedPredicateException(self, "self.precpred(self._ctx, 6)") + self.state = 25 + self.match(SolidityParser.T__0) + self.state = 26 + self.booleanExpression(7) + + elif la_ == 2: + localctx = SolidityParser.OrExpressionContext( + self, SolidityParser.BooleanExpressionContext(self, _parentctx, _parentState) + ) + self.pushNewRecursionContext(localctx, _startState, self.RULE_booleanExpression) + self.state = 27 + if not self.precpred(self._ctx, 5): + from antlr4.error.Errors import FailedPredicateException + + raise FailedPredicateException(self, "self.precpred(self._ctx, 5)") + self.state = 28 + self.match(SolidityParser.T__1) + self.state = 29 + self.booleanExpression(6) + + self.state = 34 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input, 2, self._ctx) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.unrollRecursionContexts(_parentctx) + return localctx + + class ArithmeticExpressionContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + super().__init__(parent, invokingState) + self.parser = parser + + def getRuleIndex(self): + return SolidityParser.RULE_arithmeticExpression + + def copyFrom(self, ctx: ParserRuleContext): + super().copyFrom(ctx) + + class SubtractExpressionContext(ArithmeticExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def arithmeticExpression(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) + else: + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterSubtractExpression"): + listener.enterSubtractExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitSubtractExpression"): + listener.exitSubtractExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitSubtractExpression"): + return visitor.visitSubtractExpression(self) + else: + return visitor.visitChildren(self) + + class DivideExpressionContext(ArithmeticExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def arithmeticExpression(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) + else: + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterDivideExpression"): + listener.enterDivideExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitDivideExpression"): + listener.exitDivideExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitDivideExpression"): + return visitor.visitDivideExpression(self) + else: + return visitor.visitChildren(self) + + class AddExpressionContext(ArithmeticExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def arithmeticExpression(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) + else: + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterAddExpression"): + listener.enterAddExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitAddExpression"): + listener.exitAddExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitAddExpression"): + return visitor.visitAddExpression(self) + else: + return visitor.visitChildren(self) + + class MultiplyExpressionContext(ArithmeticExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def arithmeticExpression(self, i: int = None): + if i is None: + return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) + else: + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterMultiplyExpression"): + listener.enterMultiplyExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitMultiplyExpression"): + listener.exitMultiplyExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitMultiplyExpression"): + return visitor.visitMultiplyExpression(self) + else: + return visitor.visitChildren(self) + + class AtomExpressionContext(ArithmeticExpressionContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def atom(self): + return self.getTypedRuleContext(SolidityParser.AtomContext, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterAtomExpression"): + listener.enterAtomExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitAtomExpression"): + listener.exitAtomExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitAtomExpression"): + return visitor.visitAtomExpression(self) + else: + return visitor.visitChildren(self) + + def arithmeticExpression(self, _p: int = 0): + _parentctx = self._ctx + _parentState = self.state + localctx = SolidityParser.ArithmeticExpressionContext(self, self._ctx, _parentState) + _startState = 4 + self.enterRecursionRule(localctx, 4, self.RULE_arithmeticExpression, _p) + try: + self.enterOuterAlt(localctx, 1) + localctx = SolidityParser.AtomExpressionContext(self, localctx) + self._ctx = localctx + + self.state = 36 + self.atom() + self._ctx.stop = self._input.LT(-1) + self.state = 52 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input, 4, self._ctx) + while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER: + if _alt == 1: + if self._parseListeners is not None: + self.triggerExitRuleEvent() + self.state = 50 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input, 3, self._ctx) + if la_ == 1: + localctx = SolidityParser.AddExpressionContext( + self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) + ) + self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) + self.state = 38 + if not self.precpred(self._ctx, 5): + from antlr4.error.Errors import FailedPredicateException + + raise FailedPredicateException(self, "self.precpred(self._ctx, 5)") + self.state = 39 + self.match(SolidityParser.T__5) + self.state = 40 + self.arithmeticExpression(6) + + elif la_ == 2: + localctx = SolidityParser.SubtractExpressionContext( + self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) + ) + self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) + self.state = 41 + if not self.precpred(self._ctx, 4): + from antlr4.error.Errors import FailedPredicateException + + raise FailedPredicateException(self, "self.precpred(self._ctx, 4)") + self.state = 42 + self.match(SolidityParser.T__6) + self.state = 43 + self.arithmeticExpression(5) + + elif la_ == 3: + localctx = SolidityParser.MultiplyExpressionContext( + self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) + ) + self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) + self.state = 44 + if not self.precpred(self._ctx, 3): + from antlr4.error.Errors import FailedPredicateException + + raise FailedPredicateException(self, "self.precpred(self._ctx, 3)") + self.state = 45 + self.match(SolidityParser.T__7) + self.state = 46 + self.arithmeticExpression(4) + + elif la_ == 4: + localctx = SolidityParser.DivideExpressionContext( + self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) + ) + self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) + self.state = 47 + if not self.precpred(self._ctx, 2): + from antlr4.error.Errors import FailedPredicateException + + raise FailedPredicateException(self, "self.precpred(self._ctx, 2)") + self.state = 48 + self.match(SolidityParser.T__8) + self.state = 49 + self.arithmeticExpression(3) + + self.state = 54 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input, 4, self._ctx) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.unrollRecursionContexts(_parentctx) + return localctx + + class AtomContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + super().__init__(parent, invokingState) + self.parser = parser + + def getRuleIndex(self): + return SolidityParser.RULE_atom + + def copyFrom(self, ctx: ParserRuleContext): + super().copyFrom(ctx) + + class ParenthesizedArithmeticExpressionContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def arithmeticExpression(self): + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterParenthesizedArithmeticExpression"): + listener.enterParenthesizedArithmeticExpression(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitParenthesizedArithmeticExpression"): + listener.exitParenthesizedArithmeticExpression(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitParenthesizedArithmeticExpression"): + return visitor.visitParenthesizedArithmeticExpression(self) + else: + return visitor.visitChildren(self) + + class LengthAccessContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def LengthAccess(self): + return self.getToken(SolidityParser.LengthAccess, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterLengthAccess"): + listener.enterLengthAccess(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitLengthAccess"): + listener.exitLengthAccess(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitLengthAccess"): + return visitor.visitLengthAccess(self) + else: + return visitor.visitChildren(self) + + class VariableContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def VariableName(self): + return self.getToken(SolidityParser.VariableName, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterVariable"): + listener.enterVariable(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitVariable"): + listener.exitVariable(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitVariable"): + return visitor.visitVariable(self) + else: + return visitor.visitChildren(self) + + class MappingElementContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def MappingElement(self): + return self.getToken(SolidityParser.MappingElement, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterMappingElement"): + listener.enterMappingElement(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitMappingElement"): + listener.exitMappingElement(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitMappingElement"): + return visitor.visitMappingElement(self) + else: + return visitor.visitChildren(self) + + class BlockAccessContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def BlockAccess(self): + return self.getToken(SolidityParser.BlockAccess, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterBlockAccess"): + listener.enterBlockAccess(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitBlockAccess"): + listener.exitBlockAccess(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitBlockAccess"): + return visitor.visitBlockAccess(self) + else: + return visitor.visitChildren(self) + + class AddressLiteralContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def AddressLiteral(self): + return self.getToken(SolidityParser.AddressLiteral, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterAddressLiteral"): + listener.enterAddressLiteral(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitAddressLiteral"): + listener.exitAddressLiteral(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitAddressLiteral"): + return visitor.visitAddressLiteral(self) + else: + return visitor.visitChildren(self) + + class ArrayElementContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def ArrayElement(self): + return self.getToken(SolidityParser.ArrayElement, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterArrayElement"): + listener.enterArrayElement(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitArrayElement"): + listener.exitArrayElement(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitArrayElement"): + return visitor.visitArrayElement(self) + else: + return visitor.visitChildren(self) + + class IntegerLiteralContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def INTEGER(self): + return self.getToken(SolidityParser.INTEGER, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterIntegerLiteral"): + listener.enterIntegerLiteral(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitIntegerLiteral"): + listener.exitIntegerLiteral(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitIntegerLiteral"): + return visitor.visitIntegerLiteral(self) + else: + return visitor.visitChildren(self) + + class MsgAccessContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def MsgAccess(self): + return self.getToken(SolidityParser.MsgAccess, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterMsgAccess"): + listener.enterMsgAccess(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitMsgAccess"): + listener.exitMsgAccess(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitMsgAccess"): + return visitor.visitMsgAccess(self) + else: + return visitor.visitChildren(self) + + def atom(self): + + localctx = SolidityParser.AtomContext(self, self._ctx, self.state) + self.enterRule(localctx, 6, self.RULE_atom) + try: + self.state = 67 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [13]: + localctx = SolidityParser.VariableContext(self, localctx) + self.enterOuterAlt(localctx, 1) + self.state = 55 + self.match(SolidityParser.VariableName) + elif token in [14]: + localctx = SolidityParser.LengthAccessContext(self, localctx) + self.enterOuterAlt(localctx, 2) + self.state = 56 + self.match(SolidityParser.LengthAccess) + elif token in [15]: + localctx = SolidityParser.ArrayElementContext(self, localctx) + self.enterOuterAlt(localctx, 3) + self.state = 57 + self.match(SolidityParser.ArrayElement) + elif token in [16]: + localctx = SolidityParser.MappingElementContext(self, localctx) + self.enterOuterAlt(localctx, 4) + self.state = 58 + self.match(SolidityParser.MappingElement) + elif token in [17]: + localctx = SolidityParser.AddressLiteralContext(self, localctx) + self.enterOuterAlt(localctx, 5) + self.state = 59 + self.match(SolidityParser.AddressLiteral) + elif token in [11]: + localctx = SolidityParser.IntegerLiteralContext(self, localctx) + self.enterOuterAlt(localctx, 6) + self.state = 60 + self.match(SolidityParser.INTEGER) + elif token in [4]: + localctx = SolidityParser.ParenthesizedArithmeticExpressionContext(self, localctx) + self.enterOuterAlt(localctx, 7) + self.state = 61 + self.match(SolidityParser.T__3) + self.state = 62 + self.arithmeticExpression(0) + self.state = 63 + self.match(SolidityParser.T__4) + elif token in [18]: + localctx = SolidityParser.BlockAccessContext(self, localctx) + self.enterOuterAlt(localctx, 8) + self.state = 65 + self.match(SolidityParser.BlockAccess) + elif token in [19]: + localctx = SolidityParser.MsgAccessContext(self, localctx) + self.enterOuterAlt(localctx, 9) + self.state = 66 + self.match(SolidityParser.MsgAccess) + else: + raise NoViableAltException(self) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + def sempred(self, localctx: RuleContext, ruleIndex: int, predIndex: int): + if self._predicates == None: + self._predicates = dict() + self._predicates[1] = self.booleanExpression_sempred + self._predicates[2] = self.arithmeticExpression_sempred + pred = self._predicates.get(ruleIndex, None) + if pred is None: + raise Exception("No predicate with index:" + str(ruleIndex)) + else: + return pred(localctx, predIndex) + + def booleanExpression_sempred(self, localctx: BooleanExpressionContext, predIndex: int): + if predIndex == 0: + return self.precpred(self._ctx, 6) + + if predIndex == 1: + return self.precpred(self._ctx, 5) + + def arithmeticExpression_sempred(self, localctx: ArithmeticExpressionContext, predIndex: int): + if predIndex == 2: + return self.precpred(self._ctx, 5) + + if predIndex == 3: + return self.precpred(self._ctx, 4) + + if predIndex == 4: + return self.precpred(self._ctx, 3) + + if predIndex == 5: + return self.precpred(self._ctx, 2) diff --git a/src/kontrol/solidity/SolidityVisitor.py b/src/kontrol/solidity/SolidityVisitor.py new file mode 100644 index 000000000..547b55af5 --- /dev/null +++ b/src/kontrol/solidity/SolidityVisitor.py @@ -0,0 +1,99 @@ +# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.1 +from antlr4 import * + +if "." in __name__: + from .SolidityParser import SolidityParser +else: + from SolidityParser import SolidityParser + +# This class defines a complete generic visitor for a parse tree produced by SolidityParser. + + +class SolidityVisitor(ParseTreeVisitor): + + # Visit a parse tree produced by SolidityParser#expression. + def visitExpression(self, ctx: SolidityParser.ExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#RelationalExpression. + def visitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#AndExpression. + def visitAndExpression(self, ctx: SolidityParser.AndExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#BooleanLiteral. + def visitBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#NotExpression. + def visitNotExpression(self, ctx: SolidityParser.NotExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#OrExpression. + def visitOrExpression(self, ctx: SolidityParser.OrExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#ParenthesizedBooleanExpression. + def visitParenthesizedBooleanExpression(self, ctx: SolidityParser.ParenthesizedBooleanExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#SubtractExpression. + def visitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#DivideExpression. + def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#AddExpression. + def visitAddExpression(self, ctx: SolidityParser.AddExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#MultiplyExpression. + def visitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#AtomExpression. + def visitAtomExpression(self, ctx: SolidityParser.AtomExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#Variable. + def visitVariable(self, ctx: SolidityParser.VariableContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#LengthAccess. + def visitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#ArrayElement. + def visitArrayElement(self, ctx: SolidityParser.ArrayElementContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#MappingElement. + def visitMappingElement(self, ctx: SolidityParser.MappingElementContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#AddressLiteral. + def visitAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#IntegerLiteral. + def visitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#ParenthesizedArithmeticExpression. + def visitParenthesizedArithmeticExpression(self, ctx: SolidityParser.ParenthesizedArithmeticExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#BlockAccess. + def visitBlockAccess(self, ctx: SolidityParser.BlockAccessContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#MsgAccess. + def visitMsgAccess(self, ctx: SolidityParser.MsgAccessContext): + return self.visitChildren(ctx) + + +del SolidityParser From ce6ae3db53bc46bd5e07a061702fce6d626e67bc Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Thu, 1 Aug 2024 19:42:58 +0800 Subject: [PATCH 08/15] Update `poetry.lock`, silence mypy warnings --- poetry.lock | 2 +- pyproject.toml | 2 +- src/kontrol/solc_to_k.py | 23 ++++++++++------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/poetry.lock b/poetry.lock index 3e54561f7..05aece5be 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1394,4 +1394,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "abbda6d4fb0b185c225ab1a436aa202f205ade7cb0524513a99431304281a391" +content-hash = "527c4b8a4a50d7670cc8beb40e1a7a2db538fee1c5efbe1d1b82a2f6e69bdb25" diff --git a/pyproject.toml b/pyproject.toml index 4cde6e26f..cd1d258d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,4 +60,4 @@ skip-string-normalization = true [tool.mypy] disallow_untyped_defs = true -exclude = "src/tests/integration/test-data" +exclude = "^src/tests/integration/test-data/|^src/kontrol/solidity/" diff --git a/src/kontrol/solc_to_k.py b/src/kontrol/solc_to_k.py index f41575a26..d09a0a711 100644 --- a/src/kontrol/solc_to_k.py +++ b/src/kontrol/solc_to_k.py @@ -8,14 +8,14 @@ from subprocess import CalledProcessError from typing import TYPE_CHECKING, NamedTuple -from antlr4 import CommonTokenStream, InputStream +from antlr4 import CommonTokenStream, InputStream # type: ignore from kevm_pyk.kevm import KEVM from pyk.kast.att import Atts, KAtt from pyk.kast.inner import KApply, KLabel, KRewrite, KSort, KVariable from pyk.kast.manip import abstract_term_safely from pyk.kast.outer import KDefinition, KFlatModule, KImport, KNonTerminal, KProduction, KRequire, KRule, KTerminal from pyk.kdist import kdist -from pyk.prelude.kbool import TRUE, andBool +from pyk.prelude.kbool import TRUE, FALSE, andBool from pyk.prelude.kint import eqInt, intToken, ltInt from pyk.prelude.string import stringToken from pyk.utils import hash_str, run_process_2, single @@ -1551,9 +1551,6 @@ def visitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionCont left = self.visit(ctx.arithmeticExpression(0)) right = self.visit(ctx.arithmeticExpression(1)) - if left is None or right is None: - return None # Handle None cases appropriately - op = ctx.RelOp().getText() # Map operators to KLabel applications @@ -1594,7 +1591,7 @@ def visitBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext) -> KInn # def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): # left = self.visit(ctx.arithmeticExpression(0)) # right = self.visit(ctx.arithmeticExpression(1)) - return left / right + # return left / right def visitVariable(self, ctx: SolidityParser.VariableContext) -> KInner: var_name = ctx.getText() @@ -1603,14 +1600,14 @@ def visitVariable(self, ctx: SolidityParser.VariableContext) -> KInner: # TODO(palina): add support for complex types return abstract_term_safely(KVariable('_###SOLIDITY_ARG_VAR###_'), base_name=f'V{input.arg_name}') else: - for field in self.method.contract.storage_fields: - if field.name == var_name: + # TODO: add support for storage fields + # for field in self.method.contract.storage_fields: + # if field.name == var_name: # Perform the necessary action for a matching storage field - break # Exit the loop once the matching field is found - raise ValueError(f"Not implemented yet: {var_name}") - - raise ValueError(f"Unknown term: {var_name}") - + # break # Exit the loop once the matching field is found + raise ValueError(f"Not implemented yet: {var_name}") + raise ValueError(f"Not implemented yet: {var_name}") + # def visitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): # var_name = ctx.variableName().getText() # return len(self.context.get(var_name, "")) From 5444f37328acb1a023230a699d0bdf3514c83959 Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Thu, 1 Aug 2024 19:48:28 +0800 Subject: [PATCH 09/15] Add a simple precondition test --- .../integration/test-data/foundry-prove-all | 1 + .../test-data/foundry-prove-skip-legacy | 1 + .../foundry/test/PreconditionTest.t.sol | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 src/tests/integration/test-data/foundry/test/PreconditionTest.t.sol diff --git a/src/tests/integration/test-data/foundry-prove-all b/src/tests/integration/test-data/foundry-prove-all index 8f79dad6f..d7f9de07b 100644 --- a/src/tests/integration/test-data/foundry-prove-all +++ b/src/tests/integration/test-data/foundry-prove-all @@ -205,6 +205,7 @@ PrankTest.testSubtractFail(uint256) PrankTest.testSubtractStartPrank(uint256,uint256) PrankTestMsgSender.test_msgsender_setup() PrankTestOrigin.test_origin_setup() +PreconditionTest.testPrecondition(uint256) RecordLogsTest.testRecordLogs() RollTest.test_roll_setup() SafeTest.testWithdraw() diff --git a/src/tests/integration/test-data/foundry-prove-skip-legacy b/src/tests/integration/test-data/foundry-prove-skip-legacy index 4096951c6..21b5adce2 100644 --- a/src/tests/integration/test-data/foundry-prove-skip-legacy +++ b/src/tests/integration/test-data/foundry-prove-skip-legacy @@ -202,6 +202,7 @@ PrankTest.testFailAddPrank(uint256) PrankTest.testSubtractAsTxOrigin(uint256,uint256) PrankTest.testSubtractFail(uint256) PrankTest.testSubtractStartPrank(uint256,uint256) +PreconditionTest.testPrecondition(uint256) RecordLogsTest.testRecordLogs() RollTest.test_roll_setup() SafeTest.testWithdraw() diff --git a/src/tests/integration/test-data/foundry/test/PreconditionTest.t.sol b/src/tests/integration/test-data/foundry/test/PreconditionTest.t.sol new file mode 100644 index 000000000..bdf51792d --- /dev/null +++ b/src/tests/integration/test-data/foundry/test/PreconditionTest.t.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import {Test, console} from "forge-std/Test.sol"; + + +contract Precondition { + /// @custom:kontrol-precondition x >= 2, + function totalSupply(uint256 x) public pure returns (uint256) { return x; } +} + +contract PreconditionTest is Test { + /// @custom:kontrol-precondition x <= 14, + function testPrecondition(uint256 x) public { + Precondition p = new Precondition(); + uint256 r = p.totalSupply(x); + assert(r <= 14); + } +} \ No newline at end of file From 3d54e0d4cafd17e5cac63e788d8208c8fbe519be Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Thu, 1 Aug 2024 19:56:43 +0800 Subject: [PATCH 10/15] More code quality fixes --- pyproject.toml | 13 +++++++++++-- src/kontrol/solc_to_k.py | 23 +++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cd1d258d8..db880baf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,12 +52,21 @@ remove-all-unused-imports = true ignore-init-module-imports = true remove-duplicate-keys = true remove-unused-variables = true -exclude = "src/tests/integration/test-data" +exclude = [ + "src/tests/integration/test-data", + "src/kontrol/solidity", +] [tool.black] line-length = 120 skip-string-normalization = true +[tool.flake8] +exclude = "src/kontrol/solidity" + [tool.mypy] disallow_untyped_defs = true -exclude = "^src/tests/integration/test-data/|^src/kontrol/solidity/" +exclude = [ + "src/tests/integration/test-data", + "src/kontrol/solidity", +] \ No newline at end of file diff --git a/src/kontrol/solc_to_k.py b/src/kontrol/solc_to_k.py index d09a0a711..55bcc9eae 100644 --- a/src/kontrol/solc_to_k.py +++ b/src/kontrol/solc_to_k.py @@ -8,14 +8,14 @@ from subprocess import CalledProcessError from typing import TYPE_CHECKING, NamedTuple -from antlr4 import CommonTokenStream, InputStream # type: ignore +from antlr4 import CommonTokenStream, InputStream # type: ignore from kevm_pyk.kevm import KEVM from pyk.kast.att import Atts, KAtt from pyk.kast.inner import KApply, KLabel, KRewrite, KSort, KVariable from pyk.kast.manip import abstract_term_safely from pyk.kast.outer import KDefinition, KFlatModule, KImport, KNonTerminal, KProduction, KRequire, KRule, KTerminal from pyk.kdist import kdist -from pyk.prelude.kbool import TRUE, FALSE, andBool +from pyk.prelude.kbool import FALSE, TRUE, andBool from pyk.prelude.kint import eqInt, intToken, ltInt from pyk.prelude.string import stringToken from pyk.utils import hash_str, run_process_2, single @@ -1566,7 +1566,7 @@ def visitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionCont if op in operator_mapping: operator_label = operator_mapping[op] else: - raise ValueError(f"Unsupported operator in a precondition: {op}") + raise ValueError(f'Unsupported operator in a precondition: {op}') return KApply(operator_label, left, right) @@ -1599,15 +1599,14 @@ def visitVariable(self, ctx: SolidityParser.VariableContext) -> KInner: if input.name == var_name: # TODO(palina): add support for complex types return abstract_term_safely(KVariable('_###SOLIDITY_ARG_VAR###_'), base_name=f'V{input.arg_name}') - else: - # TODO: add support for storage fields - # for field in self.method.contract.storage_fields: - # if field.name == var_name: - # Perform the necessary action for a matching storage field - # break # Exit the loop once the matching field is found - raise ValueError(f"Not implemented yet: {var_name}") - raise ValueError(f"Not implemented yet: {var_name}") - + + # TODO: add support for storage fields + # for field in self.method.contract.storage_fields: + # if field.name == var_name: + # Perform the necessary action for a matching storage field + # break # Exit the loop once the matching field is found + raise ValueError(f'Not implemented yet: {var_name}') + # def visitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): # var_name = ctx.variableName().getText() # return len(self.context.get(var_name, "")) From a49c2fafe4f65f3344131fbab6fb8979b500ef70 Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Fri, 2 Aug 2024 17:49:34 +0800 Subject: [PATCH 11/15] Minor comment cleanup --- src/kontrol/prove.py | 1 - src/kontrol/solc_to_k.py | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/kontrol/prove.py b/src/kontrol/prove.py index 4ce33f316..e82a9c4a6 100644 --- a/src/kontrol/prove.py +++ b/src/kontrol/prove.py @@ -991,7 +991,6 @@ def _init_cterm( for constraint in storage_constraints: init_cterm = init_cterm.add_constraint(constraint) - # TODO(palina): add constraints corresponding to the user-provided preconditions if method.preconditions is not None: for precondition in method.preconditions: init_cterm = init_cterm.add_constraint(mlEqualsTrue(precondition.to_kapply)) diff --git a/src/kontrol/solc_to_k.py b/src/kontrol/solc_to_k.py index 55bcc9eae..5546b8fe0 100644 --- a/src/kontrol/solc_to_k.py +++ b/src/kontrol/solc_to_k.py @@ -346,14 +346,7 @@ def parse_annotations( """ Parse developer documentation (devdoc) to extract user-provided preconditions. - Returns a tuple of Precondition objects, each representing a single precondition. - This function currently supports a simple grammar allowing expressions of the form 'LHS operator RHS'. - The following operators are supported: '==', '!=', '<=', '>=', '<', '>'. - RHS and LHS can include input or storage variables, as well as int constants. - - Example: - If devdoc for the function contains { '@custom:kontrol-precondition': ' x <= 14,x >= 2,'}, it would return: - [Precondition(operator='<=', rhs=14, lhs='x'), Precondition(operator='>=', rhs=2, lhs='x')] + Returns a tuple of Precondition objects, each representing a single precondition and a method to which it belongs. """ if devdoc is None: From efdbded7a34ab005ed9cd3e0be22de7132477105 Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Wed, 7 Aug 2024 21:30:13 +0800 Subject: [PATCH 12/15] Updated grammar to include `contractName.varName`; moved annotation processing to `_create_cse_accounts` --- poetry.lock | 2 +- src/kontrol/prove.py | 43 +- src/kontrol/solc_to_k.py | 129 +--- src/kontrol/solidity/AnnotationVisitor.py | 134 ++++ src/kontrol/solidity/Solidity.g4 | 6 +- src/kontrol/solidity/Solidity.interp | 6 +- src/kontrol/solidity/Solidity.tokens | 6 +- src/kontrol/solidity/SolidityLexer.interp | 8 +- src/kontrol/solidity/SolidityLexer.py | 823 +++++++++++++--------- src/kontrol/solidity/SolidityLexer.tokens | 6 +- src/kontrol/solidity/SolidityListener.py | 18 +- src/kontrol/solidity/SolidityParser.py | 194 +++-- src/kontrol/solidity/SolidityVisitor.py | 10 +- 13 files changed, 874 insertions(+), 511 deletions(-) create mode 100644 src/kontrol/solidity/AnnotationVisitor.py diff --git a/poetry.lock b/poetry.lock index 001e5751d..75908b161 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1414,4 +1414,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "63ee568a2a6e7aecb2f9d671d5cae0ff6e47ed2bdfc562fc971a16fa70812e19" +content-hash = "deaf5e5c753ac249dfc1fed3bd939dcbd4a13a48df5c76d00074537a0f5f55c3" diff --git a/src/kontrol/prove.py b/src/kontrol/prove.py index 752ca9485..4a23fddf5 100644 --- a/src/kontrol/prove.py +++ b/src/kontrol/prove.py @@ -9,6 +9,7 @@ from subprocess import CalledProcessError from typing import TYPE_CHECKING, Any, ContextManager, NamedTuple +from antlr4 import CommonTokenStream, InputStream # type: ignore from kevm_pyk.kevm import KEVM, KEVMSemantics, _process_jumpdests from kevm_pyk.utils import KDefinition__expand_macros, abstract_cell_vars, run_prover from multiprocess.pool import Pool # type: ignore @@ -34,6 +35,9 @@ from .hevm import Hevm from .options import ConfigType, TraceOptions from .solc_to_k import Contract, hex_string_to_int +from .solidity.AnnotationVisitor import AnnotationVisitor +from .solidity.SolidityLexer import SolidityLexer +from .solidity.SolidityParser import SolidityParser from .state_record import StateDiffEntry, StateDumpEntry from .utils import console, parse_test_version_tuple @@ -1031,7 +1035,7 @@ def _init_cterm( else: # Symbolic accounts of all relevant contracts accounts, storage_constraints = _create_cse_accounts( - foundry, storage_fields, contract_account_name, contract_code + foundry, storage_fields, contract_account_name, contract_code, method ) accounts.append(KVariable('ACCOUNTS_REST', sort=KSort('AccountCellMap'))) @@ -1075,9 +1079,10 @@ def _init_cterm( for constraint in storage_constraints: init_cterm = init_cterm.add_constraint(constraint) - if method.preconditions is not None: - for precondition in method.preconditions: - init_cterm = init_cterm.add_constraint(mlEqualsTrue(precondition.to_kapply)) + # TODO(palina): we don't need that as long as we're doing it in _cse_... + # if method.preconditions is not None: + # for precondition in method.preconditions: + # init_cterm = init_cterm.add_constraint(mlEqualsTrue(precondition.to_kapply)) # The calling contract is assumed to be in the present accounts for non-tests if not (config_type == ConfigType.TEST_CONFIG or active_symbolik): @@ -1126,6 +1131,7 @@ def _create_cse_accounts( storage_fields: tuple[StorageField, ...], contract_name: str, contract_code: KInner, + method: Contract.Method, ) -> tuple[list[KInner], list[KApply]]: """ Recursively generates a list of new accounts corresponding to `contract` fields, each having and cell (partially) set up. @@ -1146,6 +1152,33 @@ def extend_storage(map: KInner, slot: int, value: KInner) -> KInner: new_accounts: list[KInner] = [] new_account_constraints: list[KApply] = [] + # TODO(palina): add a method processing preconditions + def precondition_to_kapply(precondition: str) -> KApply: + """ + Converts the precondition to a KApply term. + + - Constants are translated into `intToken` terms + - Variables should be searched in method's inputs or in the contract's storage fields + - Operators are translated into the corresponding KLabel application, e.g., `leInt`, `eqInt`, etc. + """ + + # Parse the input expression + input_stream = InputStream(precondition) + lexer = SolidityLexer(input_stream) + + stream = CommonTokenStream(lexer) + parser = SolidityParser(stream) + tree = parser.expression() + + # Evaluate the expression + evaluator = AnnotationVisitor(method, foundry, storage_fields, contract_name) + result = evaluator.visit(tree) + + return result + + for p in method.preconditions: + new_account_constraints.append(mlEqualsTrue(precondition_to_kapply(p.precondition))) + storage_map: KInner = KVariable(contract_name + '_STORAGE', sort=KSort('Map')) singly_occupied_slots = [ @@ -1294,7 +1327,7 @@ def extend_storage(map: KInner, slot: int, value: KInner) -> KInner: ) contract_accounts, contract_constraints = _create_cse_accounts( - foundry, contract_obj.fields, field_name, contract_account_code + foundry, contract_obj.fields, field_name, contract_account_code, method ) new_accounts.extend(contract_accounts) new_account_constraints.extend(contract_constraints) diff --git a/src/kontrol/solc_to_k.py b/src/kontrol/solc_to_k.py index 57a5146e9..0fb86642b 100644 --- a/src/kontrol/solc_to_k.py +++ b/src/kontrol/solc_to_k.py @@ -8,21 +8,17 @@ from subprocess import CalledProcessError from typing import TYPE_CHECKING, NamedTuple -from antlr4 import CommonTokenStream, InputStream # type: ignore from kevm_pyk.kevm import KEVM from pyk.kast.att import Atts, KAtt from pyk.kast.inner import KApply, KLabel, KRewrite, KSort, KVariable from pyk.kast.manip import abstract_term_safely from pyk.kast.outer import KDefinition, KFlatModule, KImport, KNonTerminal, KProduction, KRequire, KRule, KTerminal from pyk.kdist import kdist -from pyk.prelude.kbool import FALSE, TRUE, andBool +from pyk.prelude.kbool import TRUE, andBool from pyk.prelude.kint import eqInt, intToken, ltInt from pyk.prelude.string import stringToken from pyk.utils import hash_str, run_process_2, single -from .solidity.SolidityLexer import SolidityLexer -from .solidity.SolidityParser import SolidityParser -from .solidity.SolidityVisitor import SolidityVisitor from .utils import _read_digest_file if TYPE_CHECKING: @@ -387,30 +383,6 @@ def __init__(self, precondition: str, method: Contract.Method | Contract.Constru self.precondition = precondition self.method = method - @cached_property - def to_kapply(self) -> KApply: - """ - Converts the precondition to a KApply term. - - - Constants are translated into `intToken` terms - - Variables should be searched in method's inputs or in the contract's storage fields - - Operators are translated into the corresponding KLabel application, e.g., `leInt`, `eqInt`, etc. - """ - - # Parse the input expression - input_stream = InputStream(self.precondition) - lexer = SolidityLexer(input_stream) - - stream = CommonTokenStream(lexer) - parser = SolidityParser(stream) - tree = parser.expression() - - # Evaluate the expression - evaluator = AnnotationVisitor(self.method) - result = evaluator.visit(tree) - - return result - @dataclass class Contract: @@ -1494,102 +1466,3 @@ def process_storage_layout(storage_layout: dict, interface_annotations: dict) -> _LOGGER.error(f'Error processing field {field}: {e}') return tuple(fields_list) - - -class AnnotationVisitor(SolidityVisitor): - def __init__(self, method: Contract.Method | Contract.Constructor): - self.method = method - - # def visitAndExpression(self, ctx: SolidityParser.AndExpressionContext): - # left = self.visit(ctx.booleanExpression(0)) - # right = self.visit(ctx.booleanExpression(1)) - # return left and right - - # def visitOrExpression(self, ctx: SolidityParser.OrExpressionContext): - # left = self.visit(ctx.booleanExpression(0)) - # right = self.visit(ctx.booleanExpression(1)) - # return left or right - - # def visitNotExpression(self, ctx: SolidityParser.NotExpressionContext): - # value = self.visit(ctx.booleanExpression()) - # return not value - - def visitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionContext) -> KApply: - left = self.visit(ctx.arithmeticExpression(0)) - right = self.visit(ctx.arithmeticExpression(1)) - - op = ctx.RelOp().getText() - - # Map operators to KLabel applications - operator_mapping = { - '<=': '_<=Int_', - '>=': '_>=Int_', - '==': '_==Int_', - '!=': '_=/=Int_', - '<': '_': '_>Int_', - } - - if op in operator_mapping: - operator_label = operator_mapping[op] - else: - raise ValueError(f'Unsupported operator in a precondition: {op}') - - return KApply(operator_label, left, right) - - def visitBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext) -> KInner: - return TRUE if ctx.getText() == 'true' else FALSE - - # def visitAddExpression(self, ctx: SolidityParser.AddExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left + right - - # def visitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left - right - - # def visitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left * right - - # def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left / right - - def visitVariable(self, ctx: SolidityParser.VariableContext) -> KInner: - var_name = ctx.getText() - for input in self.method.inputs: - if input.name == var_name: - # TODO(palina): add support for complex types - return abstract_term_safely(KVariable('_###SOLIDITY_ARG_VAR###_'), base_name=f'V{input.arg_name}') - - # TODO: add support for storage fields - # for field in self.method.contract.storage_fields: - # if field.name == var_name: - # Perform the necessary action for a matching storage field - # break # Exit the loop once the matching field is found - raise ValueError(f'Not implemented yet: {var_name}') - - # def visitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): - # var_name = ctx.variableName().getText() - # return len(self.context.get(var_name, "")) - - # def visitArrayElement(self, ctx: SolidityParser.ArrayElementContext): - # var_name = ctx.variableName().getText() - # index = int(ctx.INTEGER().getText()) - # return self.context.get(var_name, [])[index] - - # def visitMappingElement(self, ctx: SolidityParser.MappingElementContext): - # var_name = ctx.variableName().getText() - # key = ctx.variableName().getText() - # return self.context.get(var_name, {}).get(key, 0) - - # def visitAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): - # return ctx.getText() - - def visitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext) -> KInner: - return intToken(ctx.getText()) diff --git a/src/kontrol/solidity/AnnotationVisitor.py b/src/kontrol/solidity/AnnotationVisitor.py new file mode 100644 index 000000000..a6ea14071 --- /dev/null +++ b/src/kontrol/solidity/AnnotationVisitor.py @@ -0,0 +1,134 @@ +from kevm_pyk.kevm import KEVM +from pyk.kast import KInner +from pyk.kast.inner import KApply, KSort, KVariable +from pyk.kast.manip import abstract_term_safely +from pyk.prelude.kbool import FALSE, TRUE +from pyk.prelude.kint import intToken + +from ..foundry import Foundry +from ..solc_to_k import Contract, StorageField +from .SolidityParser import SolidityParser +from .SolidityVisitor import SolidityVisitor + + +class AnnotationVisitor(SolidityVisitor): + def __init__( + self, + method: Contract.Method | Contract.Constructor, + foundry: Foundry, + storage_fields: tuple[StorageField, ...], + contract_name: str, + ): + self.method = method + self.foundry = foundry + self.storage_fields = storage_fields + self.contract_name = contract_name + + # def visitAndExpression(self, ctx: SolidityParser.AndExpressionContext): + # left = self.visit(ctx.booleanExpression(0)) + # right = self.visit(ctx.booleanExpression(1)) + # return left and right + + # def visitOrExpression(self, ctx: SolidityParser.OrExpressionContext): + # left = self.visit(ctx.booleanExpression(0)) + # right = self.visit(ctx.booleanExpression(1)) + # return left or right + + # def visitNotExpression(self, ctx: SolidityParser.NotExpressionContext): + # value = self.visit(ctx.booleanExpression()) + # return not value + + def visitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionContext) -> KApply: + left = self.visit(ctx.arithmeticExpression(0)) + right = self.visit(ctx.arithmeticExpression(1)) + + op = ctx.RelOp().getText() + + # Map operators to KLabel applications + operator_mapping = { + '<=': '_<=Int_', + '>=': '_>=Int_', + '==': '_==Int_', + '!=': '_=/=Int_', + '<': '_': '_>Int_', + } + + if op in operator_mapping: + operator_label = operator_mapping[op] + else: + raise ValueError(f'Unsupported operator in a precondition: {op}') + + return KApply(operator_label, left, right) + + def visitBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext) -> KInner: + return TRUE if ctx.getText() == 'true' else FALSE + + # def visitAddExpression(self, ctx: SolidityParser.AddExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left + right + + # def visitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left - right + + # def visitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left * right + + # def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left / right + + def visitVariable(self, ctx: SolidityParser.VariableContext) -> KInner: + var_name = ctx.getText() + for input in self.method.inputs: + if input.name == var_name: + # TODO(palina): add support for complex types + return abstract_term_safely(KVariable('_###SOLIDITY_ARG_VAR###_'), base_name=f'V{input.arg_name}') + + # TODO: add support for storage fields + for field in self.storage_fields: + if field.label == var_name: + storage_map: KInner = KVariable(self.contract_name + '_STORAGE', sort=KSort('Map')) + return KEVM.lookup(storage_map, intToken(field.slot)) + # return abstract_term_safely(KVariable('_###SOLIDITY_STORAGE_VAR###_'), base_name=f'V{field.name}') + # for field in self.method.contract.storage_fields: + # if field.name == var_name: + # Perform the necessary action for a matching storage field + # break # Exit the loop once the matching field is found + raise ValueError(f'Not implemented yet: {var_name}') + + # def visitContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccessContext): + # contract_name = ctx.VariableName(0).getText() + # var_name = ctx.VariableName(1).getText() + + # TODO (palina): add support for contract variables + # - find contract + # - find variables + # - lookup + # return self.contracts.get(contract_name, {}).get(var_name, 0) + + # def visitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): + # var_name = ctx.variableName().getText() + # return len(self.context.get(var_name, "")) + + # def visitArrayElement(self, ctx: SolidityParser.ArrayElementContext): + # var_name = ctx.variableName().getText() + # index = int(ctx.INTEGER().getText()) + # return self.context.get(var_name, [])[index] + + # def visitMappingElement(self, ctx: SolidityParser.MappingElementContext): + # var_name = ctx.variableName().getText() + # key = ctx.variableName().getText() + # return self.context.get(var_name, {}).get(key, 0) + + # def visitAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): + # return ctx.getText() + + def visitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext) -> KInner: + return intToken(ctx.getText()) diff --git a/src/kontrol/solidity/Solidity.g4 b/src/kontrol/solidity/Solidity.g4 index 258ff6c59..f1f485d25 100644 --- a/src/kontrol/solidity/Solidity.g4 +++ b/src/kontrol/solidity/Solidity.g4 @@ -32,6 +32,8 @@ atom | '(' arithmeticExpression ')' # ParenthesizedArithmeticExpression | BlockAccess # BlockAccess | MsgAccess # MsgAccess + | ContractVariableAccess # ContractVariableAccess + | ContractVariableArrayElement # ContractVariableArrayElement ; // Lexer rules @@ -46,8 +48,10 @@ MappingElement: VariableName '[' VariableName ']'; AddressLiteral: ADDRESS; BlockAccess: 'block.' ('timestamp' | 'number'); MsgAccess: 'msg.' ('sender'); +ContractVariableAccess: VariableName '.' VariableName; +ContractVariableArrayElement: VariableName '.' VariableName '[' (VariableName | INTEGER | ADDRESS) ']'; RelOp: '<' | '<=' | '>' | '>=' | '==' | '!='; // Whitespace and comments -WS: [ \t\r\n]+ -> skip; \ No newline at end of file +WS: [ \t\r\n]+ -> skip; diff --git a/src/kontrol/solidity/Solidity.interp b/src/kontrol/solidity/Solidity.interp index dabd25df8..67363299c 100644 --- a/src/kontrol/solidity/Solidity.interp +++ b/src/kontrol/solidity/Solidity.interp @@ -21,6 +21,8 @@ null null null null +null +null token symbolic names: null @@ -43,6 +45,8 @@ MappingElement AddressLiteral BlockAccess MsgAccess +ContractVariableAccess +ContractVariableArrayElement RelOp WS @@ -54,4 +58,4 @@ atom atn: -[4, 1, 21, 70, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 23, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 31, 8, 1, 10, 1, 12, 1, 34, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 51, 8, 2, 10, 2, 12, 2, 54, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 68, 8, 3, 1, 3, 0, 2, 2, 4, 4, 0, 2, 4, 6, 0, 0, 82, 0, 8, 1, 0, 0, 0, 2, 22, 1, 0, 0, 0, 4, 35, 1, 0, 0, 0, 6, 67, 1, 0, 0, 0, 8, 9, 3, 2, 1, 0, 9, 1, 1, 0, 0, 0, 10, 11, 6, 1, -1, 0, 11, 12, 5, 3, 0, 0, 12, 23, 3, 2, 1, 4, 13, 14, 3, 4, 2, 0, 14, 15, 5, 20, 0, 0, 15, 16, 3, 4, 2, 0, 16, 23, 1, 0, 0, 0, 17, 23, 5, 10, 0, 0, 18, 19, 5, 4, 0, 0, 19, 20, 3, 2, 1, 0, 20, 21, 5, 5, 0, 0, 21, 23, 1, 0, 0, 0, 22, 10, 1, 0, 0, 0, 22, 13, 1, 0, 0, 0, 22, 17, 1, 0, 0, 0, 22, 18, 1, 0, 0, 0, 23, 32, 1, 0, 0, 0, 24, 25, 10, 6, 0, 0, 25, 26, 5, 1, 0, 0, 26, 31, 3, 2, 1, 7, 27, 28, 10, 5, 0, 0, 28, 29, 5, 2, 0, 0, 29, 31, 3, 2, 1, 6, 30, 24, 1, 0, 0, 0, 30, 27, 1, 0, 0, 0, 31, 34, 1, 0, 0, 0, 32, 30, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 3, 1, 0, 0, 0, 34, 32, 1, 0, 0, 0, 35, 36, 6, 2, -1, 0, 36, 37, 3, 6, 3, 0, 37, 52, 1, 0, 0, 0, 38, 39, 10, 5, 0, 0, 39, 40, 5, 6, 0, 0, 40, 51, 3, 4, 2, 6, 41, 42, 10, 4, 0, 0, 42, 43, 5, 7, 0, 0, 43, 51, 3, 4, 2, 5, 44, 45, 10, 3, 0, 0, 45, 46, 5, 8, 0, 0, 46, 51, 3, 4, 2, 4, 47, 48, 10, 2, 0, 0, 48, 49, 5, 9, 0, 0, 49, 51, 3, 4, 2, 3, 50, 38, 1, 0, 0, 0, 50, 41, 1, 0, 0, 0, 50, 44, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 5, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 68, 5, 13, 0, 0, 56, 68, 5, 14, 0, 0, 57, 68, 5, 15, 0, 0, 58, 68, 5, 16, 0, 0, 59, 68, 5, 17, 0, 0, 60, 68, 5, 11, 0, 0, 61, 62, 5, 4, 0, 0, 62, 63, 3, 4, 2, 0, 63, 64, 5, 5, 0, 0, 64, 68, 1, 0, 0, 0, 65, 68, 5, 18, 0, 0, 66, 68, 5, 19, 0, 0, 67, 55, 1, 0, 0, 0, 67, 56, 1, 0, 0, 0, 67, 57, 1, 0, 0, 0, 67, 58, 1, 0, 0, 0, 67, 59, 1, 0, 0, 0, 67, 60, 1, 0, 0, 0, 67, 61, 1, 0, 0, 0, 67, 65, 1, 0, 0, 0, 67, 66, 1, 0, 0, 0, 68, 7, 1, 0, 0, 0, 6, 22, 30, 32, 50, 52, 67] \ No newline at end of file +[4, 1, 23, 72, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 23, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 31, 8, 1, 10, 1, 12, 1, 34, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 51, 8, 2, 10, 2, 12, 2, 54, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 70, 8, 3, 1, 3, 0, 2, 2, 4, 4, 0, 2, 4, 6, 0, 0, 86, 0, 8, 1, 0, 0, 0, 2, 22, 1, 0, 0, 0, 4, 35, 1, 0, 0, 0, 6, 69, 1, 0, 0, 0, 8, 9, 3, 2, 1, 0, 9, 1, 1, 0, 0, 0, 10, 11, 6, 1, -1, 0, 11, 12, 5, 3, 0, 0, 12, 23, 3, 2, 1, 4, 13, 14, 3, 4, 2, 0, 14, 15, 5, 22, 0, 0, 15, 16, 3, 4, 2, 0, 16, 23, 1, 0, 0, 0, 17, 23, 5, 10, 0, 0, 18, 19, 5, 4, 0, 0, 19, 20, 3, 2, 1, 0, 20, 21, 5, 5, 0, 0, 21, 23, 1, 0, 0, 0, 22, 10, 1, 0, 0, 0, 22, 13, 1, 0, 0, 0, 22, 17, 1, 0, 0, 0, 22, 18, 1, 0, 0, 0, 23, 32, 1, 0, 0, 0, 24, 25, 10, 6, 0, 0, 25, 26, 5, 1, 0, 0, 26, 31, 3, 2, 1, 7, 27, 28, 10, 5, 0, 0, 28, 29, 5, 2, 0, 0, 29, 31, 3, 2, 1, 6, 30, 24, 1, 0, 0, 0, 30, 27, 1, 0, 0, 0, 31, 34, 1, 0, 0, 0, 32, 30, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 3, 1, 0, 0, 0, 34, 32, 1, 0, 0, 0, 35, 36, 6, 2, -1, 0, 36, 37, 3, 6, 3, 0, 37, 52, 1, 0, 0, 0, 38, 39, 10, 5, 0, 0, 39, 40, 5, 6, 0, 0, 40, 51, 3, 4, 2, 6, 41, 42, 10, 4, 0, 0, 42, 43, 5, 7, 0, 0, 43, 51, 3, 4, 2, 5, 44, 45, 10, 3, 0, 0, 45, 46, 5, 8, 0, 0, 46, 51, 3, 4, 2, 4, 47, 48, 10, 2, 0, 0, 48, 49, 5, 9, 0, 0, 49, 51, 3, 4, 2, 3, 50, 38, 1, 0, 0, 0, 50, 41, 1, 0, 0, 0, 50, 44, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 5, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 70, 5, 13, 0, 0, 56, 70, 5, 14, 0, 0, 57, 70, 5, 15, 0, 0, 58, 70, 5, 16, 0, 0, 59, 70, 5, 17, 0, 0, 60, 70, 5, 11, 0, 0, 61, 62, 5, 4, 0, 0, 62, 63, 3, 4, 2, 0, 63, 64, 5, 5, 0, 0, 64, 70, 1, 0, 0, 0, 65, 70, 5, 18, 0, 0, 66, 70, 5, 19, 0, 0, 67, 70, 5, 20, 0, 0, 68, 70, 5, 21, 0, 0, 69, 55, 1, 0, 0, 0, 69, 56, 1, 0, 0, 0, 69, 57, 1, 0, 0, 0, 69, 58, 1, 0, 0, 0, 69, 59, 1, 0, 0, 0, 69, 60, 1, 0, 0, 0, 69, 61, 1, 0, 0, 0, 69, 65, 1, 0, 0, 0, 69, 66, 1, 0, 0, 0, 69, 67, 1, 0, 0, 0, 69, 68, 1, 0, 0, 0, 70, 7, 1, 0, 0, 0, 6, 22, 30, 32, 50, 52, 69] \ No newline at end of file diff --git a/src/kontrol/solidity/Solidity.tokens b/src/kontrol/solidity/Solidity.tokens index 309be27ac..dc4b88e6b 100644 --- a/src/kontrol/solidity/Solidity.tokens +++ b/src/kontrol/solidity/Solidity.tokens @@ -17,8 +17,10 @@ MappingElement=16 AddressLiteral=17 BlockAccess=18 MsgAccess=19 -RelOp=20 -WS=21 +ContractVariableAccess=20 +ContractVariableArrayElement=21 +RelOp=22 +WS=23 '&&'=1 '||'=2 '!'=3 diff --git a/src/kontrol/solidity/SolidityLexer.interp b/src/kontrol/solidity/SolidityLexer.interp index 968e16476..71e2dbeae 100644 --- a/src/kontrol/solidity/SolidityLexer.interp +++ b/src/kontrol/solidity/SolidityLexer.interp @@ -21,6 +21,8 @@ null null null null +null +null token symbolic names: null @@ -43,6 +45,8 @@ MappingElement AddressLiteral BlockAccess MsgAccess +ContractVariableAccess +ContractVariableArrayElement RelOp WS @@ -66,6 +70,8 @@ MappingElement AddressLiteral BlockAccess MsgAccess +ContractVariableAccess +ContractVariableArrayElement RelOp WS @@ -77,4 +83,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 21, 170, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 73, 8, 9, 1, 10, 4, 10, 76, 8, 10, 11, 10, 12, 10, 77, 1, 11, 1, 11, 1, 11, 1, 11, 4, 11, 84, 8, 11, 11, 11, 12, 11, 85, 1, 12, 1, 12, 5, 12, 90, 8, 12, 10, 12, 12, 12, 93, 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 138, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 162, 8, 19, 1, 20, 4, 20, 165, 8, 20, 11, 20, 12, 20, 166, 1, 20, 1, 20, 0, 0, 21, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 1, 0, 5, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 180, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 1, 43, 1, 0, 0, 0, 3, 46, 1, 0, 0, 0, 5, 49, 1, 0, 0, 0, 7, 51, 1, 0, 0, 0, 9, 53, 1, 0, 0, 0, 11, 55, 1, 0, 0, 0, 13, 57, 1, 0, 0, 0, 15, 59, 1, 0, 0, 0, 17, 61, 1, 0, 0, 0, 19, 72, 1, 0, 0, 0, 21, 75, 1, 0, 0, 0, 23, 79, 1, 0, 0, 0, 25, 87, 1, 0, 0, 0, 27, 94, 1, 0, 0, 0, 29, 103, 1, 0, 0, 0, 31, 108, 1, 0, 0, 0, 33, 113, 1, 0, 0, 0, 35, 115, 1, 0, 0, 0, 37, 139, 1, 0, 0, 0, 39, 161, 1, 0, 0, 0, 41, 164, 1, 0, 0, 0, 43, 44, 5, 38, 0, 0, 44, 45, 5, 38, 0, 0, 45, 2, 1, 0, 0, 0, 46, 47, 5, 124, 0, 0, 47, 48, 5, 124, 0, 0, 48, 4, 1, 0, 0, 0, 49, 50, 5, 33, 0, 0, 50, 6, 1, 0, 0, 0, 51, 52, 5, 40, 0, 0, 52, 8, 1, 0, 0, 0, 53, 54, 5, 41, 0, 0, 54, 10, 1, 0, 0, 0, 55, 56, 5, 43, 0, 0, 56, 12, 1, 0, 0, 0, 57, 58, 5, 45, 0, 0, 58, 14, 1, 0, 0, 0, 59, 60, 5, 42, 0, 0, 60, 16, 1, 0, 0, 0, 61, 62, 5, 47, 0, 0, 62, 18, 1, 0, 0, 0, 63, 64, 5, 116, 0, 0, 64, 65, 5, 114, 0, 0, 65, 66, 5, 117, 0, 0, 66, 73, 5, 101, 0, 0, 67, 68, 5, 102, 0, 0, 68, 69, 5, 97, 0, 0, 69, 70, 5, 108, 0, 0, 70, 71, 5, 115, 0, 0, 71, 73, 5, 101, 0, 0, 72, 63, 1, 0, 0, 0, 72, 67, 1, 0, 0, 0, 73, 20, 1, 0, 0, 0, 74, 76, 7, 0, 0, 0, 75, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 22, 1, 0, 0, 0, 79, 80, 5, 48, 0, 0, 80, 81, 5, 120, 0, 0, 81, 83, 1, 0, 0, 0, 82, 84, 7, 1, 0, 0, 83, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 24, 1, 0, 0, 0, 87, 91, 7, 2, 0, 0, 88, 90, 7, 3, 0, 0, 89, 88, 1, 0, 0, 0, 90, 93, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 26, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 94, 95, 3, 25, 12, 0, 95, 96, 5, 46, 0, 0, 96, 97, 5, 108, 0, 0, 97, 98, 5, 101, 0, 0, 98, 99, 5, 110, 0, 0, 99, 100, 5, 103, 0, 0, 100, 101, 5, 116, 0, 0, 101, 102, 5, 104, 0, 0, 102, 28, 1, 0, 0, 0, 103, 104, 3, 25, 12, 0, 104, 105, 5, 91, 0, 0, 105, 106, 3, 21, 10, 0, 106, 107, 5, 93, 0, 0, 107, 30, 1, 0, 0, 0, 108, 109, 3, 25, 12, 0, 109, 110, 5, 91, 0, 0, 110, 111, 3, 25, 12, 0, 111, 112, 5, 93, 0, 0, 112, 32, 1, 0, 0, 0, 113, 114, 3, 23, 11, 0, 114, 34, 1, 0, 0, 0, 115, 116, 5, 98, 0, 0, 116, 117, 5, 108, 0, 0, 117, 118, 5, 111, 0, 0, 118, 119, 5, 99, 0, 0, 119, 120, 5, 107, 0, 0, 120, 121, 5, 46, 0, 0, 121, 137, 1, 0, 0, 0, 122, 123, 5, 116, 0, 0, 123, 124, 5, 105, 0, 0, 124, 125, 5, 109, 0, 0, 125, 126, 5, 101, 0, 0, 126, 127, 5, 115, 0, 0, 127, 128, 5, 116, 0, 0, 128, 129, 5, 97, 0, 0, 129, 130, 5, 109, 0, 0, 130, 138, 5, 112, 0, 0, 131, 132, 5, 110, 0, 0, 132, 133, 5, 117, 0, 0, 133, 134, 5, 109, 0, 0, 134, 135, 5, 98, 0, 0, 135, 136, 5, 101, 0, 0, 136, 138, 5, 114, 0, 0, 137, 122, 1, 0, 0, 0, 137, 131, 1, 0, 0, 0, 138, 36, 1, 0, 0, 0, 139, 140, 5, 109, 0, 0, 140, 141, 5, 115, 0, 0, 141, 142, 5, 103, 0, 0, 142, 143, 5, 46, 0, 0, 143, 144, 1, 0, 0, 0, 144, 145, 5, 115, 0, 0, 145, 146, 5, 101, 0, 0, 146, 147, 5, 110, 0, 0, 147, 148, 5, 100, 0, 0, 148, 149, 5, 101, 0, 0, 149, 150, 5, 114, 0, 0, 150, 38, 1, 0, 0, 0, 151, 162, 5, 60, 0, 0, 152, 153, 5, 60, 0, 0, 153, 162, 5, 61, 0, 0, 154, 162, 5, 62, 0, 0, 155, 156, 5, 62, 0, 0, 156, 162, 5, 61, 0, 0, 157, 158, 5, 61, 0, 0, 158, 162, 5, 61, 0, 0, 159, 160, 5, 33, 0, 0, 160, 162, 5, 61, 0, 0, 161, 151, 1, 0, 0, 0, 161, 152, 1, 0, 0, 0, 161, 154, 1, 0, 0, 0, 161, 155, 1, 0, 0, 0, 161, 157, 1, 0, 0, 0, 161, 159, 1, 0, 0, 0, 162, 40, 1, 0, 0, 0, 163, 165, 7, 4, 0, 0, 164, 163, 1, 0, 0, 0, 165, 166, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 166, 167, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 169, 6, 20, 0, 0, 169, 42, 1, 0, 0, 0, 8, 0, 72, 77, 85, 91, 137, 161, 166, 1, 6, 0, 0] \ No newline at end of file +[4, 0, 23, 189, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 77, 8, 9, 1, 10, 4, 10, 80, 8, 10, 11, 10, 12, 10, 81, 1, 11, 1, 11, 1, 11, 1, 11, 4, 11, 88, 8, 11, 11, 11, 12, 11, 89, 1, 12, 1, 12, 5, 12, 94, 8, 12, 10, 12, 12, 12, 97, 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 142, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 167, 8, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 181, 8, 21, 1, 22, 4, 22, 184, 8, 22, 11, 22, 12, 22, 185, 1, 22, 1, 22, 0, 0, 23, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 1, 0, 5, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 201, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 1, 47, 1, 0, 0, 0, 3, 50, 1, 0, 0, 0, 5, 53, 1, 0, 0, 0, 7, 55, 1, 0, 0, 0, 9, 57, 1, 0, 0, 0, 11, 59, 1, 0, 0, 0, 13, 61, 1, 0, 0, 0, 15, 63, 1, 0, 0, 0, 17, 65, 1, 0, 0, 0, 19, 76, 1, 0, 0, 0, 21, 79, 1, 0, 0, 0, 23, 83, 1, 0, 0, 0, 25, 91, 1, 0, 0, 0, 27, 98, 1, 0, 0, 0, 29, 107, 1, 0, 0, 0, 31, 112, 1, 0, 0, 0, 33, 117, 1, 0, 0, 0, 35, 119, 1, 0, 0, 0, 37, 143, 1, 0, 0, 0, 39, 155, 1, 0, 0, 0, 41, 159, 1, 0, 0, 0, 43, 180, 1, 0, 0, 0, 45, 183, 1, 0, 0, 0, 47, 48, 5, 38, 0, 0, 48, 49, 5, 38, 0, 0, 49, 2, 1, 0, 0, 0, 50, 51, 5, 124, 0, 0, 51, 52, 5, 124, 0, 0, 52, 4, 1, 0, 0, 0, 53, 54, 5, 33, 0, 0, 54, 6, 1, 0, 0, 0, 55, 56, 5, 40, 0, 0, 56, 8, 1, 0, 0, 0, 57, 58, 5, 41, 0, 0, 58, 10, 1, 0, 0, 0, 59, 60, 5, 43, 0, 0, 60, 12, 1, 0, 0, 0, 61, 62, 5, 45, 0, 0, 62, 14, 1, 0, 0, 0, 63, 64, 5, 42, 0, 0, 64, 16, 1, 0, 0, 0, 65, 66, 5, 47, 0, 0, 66, 18, 1, 0, 0, 0, 67, 68, 5, 116, 0, 0, 68, 69, 5, 114, 0, 0, 69, 70, 5, 117, 0, 0, 70, 77, 5, 101, 0, 0, 71, 72, 5, 102, 0, 0, 72, 73, 5, 97, 0, 0, 73, 74, 5, 108, 0, 0, 74, 75, 5, 115, 0, 0, 75, 77, 5, 101, 0, 0, 76, 67, 1, 0, 0, 0, 76, 71, 1, 0, 0, 0, 77, 20, 1, 0, 0, 0, 78, 80, 7, 0, 0, 0, 79, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 22, 1, 0, 0, 0, 83, 84, 5, 48, 0, 0, 84, 85, 5, 120, 0, 0, 85, 87, 1, 0, 0, 0, 86, 88, 7, 1, 0, 0, 87, 86, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 24, 1, 0, 0, 0, 91, 95, 7, 2, 0, 0, 92, 94, 7, 3, 0, 0, 93, 92, 1, 0, 0, 0, 94, 97, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 26, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, 99, 3, 25, 12, 0, 99, 100, 5, 46, 0, 0, 100, 101, 5, 108, 0, 0, 101, 102, 5, 101, 0, 0, 102, 103, 5, 110, 0, 0, 103, 104, 5, 103, 0, 0, 104, 105, 5, 116, 0, 0, 105, 106, 5, 104, 0, 0, 106, 28, 1, 0, 0, 0, 107, 108, 3, 25, 12, 0, 108, 109, 5, 91, 0, 0, 109, 110, 3, 21, 10, 0, 110, 111, 5, 93, 0, 0, 111, 30, 1, 0, 0, 0, 112, 113, 3, 25, 12, 0, 113, 114, 5, 91, 0, 0, 114, 115, 3, 25, 12, 0, 115, 116, 5, 93, 0, 0, 116, 32, 1, 0, 0, 0, 117, 118, 3, 23, 11, 0, 118, 34, 1, 0, 0, 0, 119, 120, 5, 98, 0, 0, 120, 121, 5, 108, 0, 0, 121, 122, 5, 111, 0, 0, 122, 123, 5, 99, 0, 0, 123, 124, 5, 107, 0, 0, 124, 125, 5, 46, 0, 0, 125, 141, 1, 0, 0, 0, 126, 127, 5, 116, 0, 0, 127, 128, 5, 105, 0, 0, 128, 129, 5, 109, 0, 0, 129, 130, 5, 101, 0, 0, 130, 131, 5, 115, 0, 0, 131, 132, 5, 116, 0, 0, 132, 133, 5, 97, 0, 0, 133, 134, 5, 109, 0, 0, 134, 142, 5, 112, 0, 0, 135, 136, 5, 110, 0, 0, 136, 137, 5, 117, 0, 0, 137, 138, 5, 109, 0, 0, 138, 139, 5, 98, 0, 0, 139, 140, 5, 101, 0, 0, 140, 142, 5, 114, 0, 0, 141, 126, 1, 0, 0, 0, 141, 135, 1, 0, 0, 0, 142, 36, 1, 0, 0, 0, 143, 144, 5, 109, 0, 0, 144, 145, 5, 115, 0, 0, 145, 146, 5, 103, 0, 0, 146, 147, 5, 46, 0, 0, 147, 148, 1, 0, 0, 0, 148, 149, 5, 115, 0, 0, 149, 150, 5, 101, 0, 0, 150, 151, 5, 110, 0, 0, 151, 152, 5, 100, 0, 0, 152, 153, 5, 101, 0, 0, 153, 154, 5, 114, 0, 0, 154, 38, 1, 0, 0, 0, 155, 156, 3, 25, 12, 0, 156, 157, 5, 46, 0, 0, 157, 158, 3, 25, 12, 0, 158, 40, 1, 0, 0, 0, 159, 160, 3, 25, 12, 0, 160, 161, 5, 46, 0, 0, 161, 162, 3, 25, 12, 0, 162, 166, 5, 91, 0, 0, 163, 167, 3, 25, 12, 0, 164, 167, 3, 21, 10, 0, 165, 167, 3, 23, 11, 0, 166, 163, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 166, 165, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 169, 5, 93, 0, 0, 169, 42, 1, 0, 0, 0, 170, 181, 5, 60, 0, 0, 171, 172, 5, 60, 0, 0, 172, 181, 5, 61, 0, 0, 173, 181, 5, 62, 0, 0, 174, 175, 5, 62, 0, 0, 175, 181, 5, 61, 0, 0, 176, 177, 5, 61, 0, 0, 177, 181, 5, 61, 0, 0, 178, 179, 5, 33, 0, 0, 179, 181, 5, 61, 0, 0, 180, 170, 1, 0, 0, 0, 180, 171, 1, 0, 0, 0, 180, 173, 1, 0, 0, 0, 180, 174, 1, 0, 0, 0, 180, 176, 1, 0, 0, 0, 180, 178, 1, 0, 0, 0, 181, 44, 1, 0, 0, 0, 182, 184, 7, 4, 0, 0, 183, 182, 1, 0, 0, 0, 184, 185, 1, 0, 0, 0, 185, 183, 1, 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 188, 6, 22, 0, 0, 188, 46, 1, 0, 0, 0, 9, 0, 76, 81, 89, 95, 141, 166, 180, 185, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/kontrol/solidity/SolidityLexer.py b/src/kontrol/solidity/SolidityLexer.py index 56d5c5cb4..fa775ebd2 100644 --- a/src/kontrol/solidity/SolidityLexer.py +++ b/src/kontrol/solidity/SolidityLexer.py @@ -1,7 +1,8 @@ -# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.1 +# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.2 import sys +from io import StringIO -from antlr4 import DFA, ATNDeserializer, Lexer, LexerATNSimulator, PredictionContextCache +from antlr4 import * if sys.version_info[1] > 5: from typing import TextIO @@ -13,8 +14,8 @@ def serializedATN(): return [ 4, 0, - 21, - 170, + 23, + 189, 6, -1, 2, @@ -101,6 +102,14 @@ def serializedATN(): 20, 7, 20, + 2, + 21, + 7, + 21, + 2, + 22, + 7, + 22, 1, 0, 1, @@ -161,21 +170,21 @@ def serializedATN(): 9, 3, 9, - 73, + 77, 8, 9, 1, 10, 4, 10, - 76, + 80, 8, 10, 11, 10, 12, 10, - 77, + 81, 1, 11, 1, @@ -186,28 +195,28 @@ def serializedATN(): 11, 4, 11, - 84, + 88, 8, 11, 11, 11, 12, 11, - 85, + 89, 1, 12, 1, 12, 5, 12, - 90, + 94, 8, 12, 10, 12, 12, 12, - 93, + 97, 9, 12, 1, @@ -298,7 +307,7 @@ def serializedATN(): 17, 3, 17, - 138, + 142, 8, 17, 1, @@ -334,41 +343,72 @@ def serializedATN(): 1, 19, 1, - 19, + 20, 1, - 19, + 20, 1, - 19, + 20, 1, - 19, + 20, 1, - 19, + 20, 1, - 19, + 20, + 1, + 20, 3, - 19, - 162, + 20, + 167, 8, - 19, + 20, 1, 20, - 4, + 1, 20, - 165, + 1, + 21, + 1, + 21, + 1, + 21, + 1, + 21, + 1, + 21, + 1, + 21, + 1, + 21, + 1, + 21, + 1, + 21, + 1, + 21, + 3, + 21, + 181, 8, - 20, + 21, + 1, + 22, + 4, + 22, + 184, + 8, + 22, 11, - 20, + 22, 12, - 20, - 166, + 22, + 185, 1, - 20, + 22, 1, - 20, + 22, 0, 0, - 21, + 23, 1, 1, 3, @@ -411,6 +451,10 @@ def serializedATN(): 20, 41, 21, + 43, + 22, + 45, + 23, 1, 0, 5, @@ -452,7 +496,7 @@ def serializedATN(): 13, 32, 32, - 180, + 201, 0, 1, 1, @@ -579,188 +623,188 @@ def serializedATN(): 0, 0, 0, - 1, + 0, 43, 1, 0, 0, 0, + 0, + 45, + 1, + 0, + 0, + 0, + 1, + 47, + 1, + 0, + 0, + 0, 3, - 46, + 50, 1, 0, 0, 0, 5, - 49, + 53, 1, 0, 0, 0, 7, - 51, + 55, 1, 0, 0, 0, 9, - 53, + 57, 1, 0, 0, 0, 11, - 55, + 59, 1, 0, 0, 0, 13, - 57, + 61, 1, 0, 0, 0, 15, - 59, + 63, 1, 0, 0, 0, 17, - 61, + 65, 1, 0, 0, 0, 19, - 72, + 76, 1, 0, 0, 0, 21, - 75, + 79, 1, 0, 0, 0, 23, - 79, + 83, 1, 0, 0, 0, 25, - 87, + 91, 1, 0, 0, 0, 27, - 94, + 98, 1, 0, 0, 0, 29, - 103, + 107, 1, 0, 0, 0, 31, - 108, + 112, 1, 0, 0, 0, 33, - 113, + 117, 1, 0, 0, 0, 35, - 115, + 119, 1, 0, 0, 0, 37, - 139, + 143, 1, 0, 0, 0, 39, - 161, + 155, 1, 0, 0, 0, 41, - 164, + 159, 1, 0, 0, 0, 43, - 44, - 5, - 38, - 0, + 180, + 1, 0, - 44, - 45, - 5, - 38, 0, 0, 45, - 2, + 183, 1, 0, 0, 0, - 46, 47, + 48, 5, - 124, + 38, 0, 0, - 47, 48, + 49, 5, - 124, + 38, 0, 0, - 48, - 4, + 49, + 2, 1, 0, 0, 0, - 49, 50, + 51, 5, - 33, - 0, - 0, - 50, - 6, - 1, - 0, + 124, 0, 0, 51, 52, 5, - 40, + 124, 0, 0, 52, - 8, + 4, 1, 0, 0, @@ -768,11 +812,11 @@ def serializedATN(): 53, 54, 5, - 41, + 33, 0, 0, 54, - 10, + 6, 1, 0, 0, @@ -780,11 +824,11 @@ def serializedATN(): 55, 56, 5, - 43, + 40, 0, 0, 56, - 12, + 8, 1, 0, 0, @@ -792,11 +836,11 @@ def serializedATN(): 57, 58, 5, - 45, + 41, 0, 0, 58, - 14, + 10, 1, 0, 0, @@ -804,11 +848,11 @@ def serializedATN(): 59, 60, 5, - 42, + 43, 0, 0, 60, - 16, + 12, 1, 0, 0, @@ -816,11 +860,11 @@ def serializedATN(): 61, 62, 5, - 47, + 45, 0, 0, 62, - 18, + 14, 1, 0, 0, @@ -828,720 +872,847 @@ def serializedATN(): 63, 64, 5, - 116, + 42, 0, 0, 64, - 65, - 5, - 114, + 16, + 1, + 0, 0, 0, 65, 66, 5, - 117, + 47, 0, 0, 66, - 73, - 5, - 101, + 18, + 1, + 0, 0, 0, 67, 68, 5, - 102, + 116, 0, 0, 68, 69, 5, - 97, + 114, 0, 0, 69, 70, 5, - 108, + 117, 0, 0, 70, - 71, - 5, - 115, - 0, - 0, - 71, - 73, + 77, 5, 101, 0, 0, + 71, 72, - 63, - 1, - 0, + 5, + 102, 0, 0, 72, - 67, - 1, - 0, + 73, + 5, + 97, 0, 0, 73, - 20, - 1, - 0, + 74, + 5, + 108, 0, 0, 74, - 76, - 7, - 0, + 75, + 5, + 115, 0, 0, 75, - 74, + 77, + 5, + 101, + 0, + 0, + 76, + 67, 1, 0, 0, 0, 76, - 77, + 71, 1, 0, 0, 0, 77, - 75, + 20, 1, 0, 0, 0, - 77, 78, - 1, + 80, + 7, 0, 0, 0, + 79, 78, - 22, 1, 0, 0, 0, - 79, 80, - 5, - 48, + 81, + 1, + 0, 0, 0, - 80, 81, - 5, - 120, + 79, + 1, + 0, 0, 0, 81, - 83, + 82, 1, 0, 0, 0, 82, + 22, + 1, + 0, + 0, + 0, + 83, + 84, + 5, + 48, + 0, + 0, 84, + 85, + 5, + 120, + 0, + 0, + 85, + 87, + 1, + 0, + 0, + 0, + 86, + 88, 7, 1, 0, 0, - 83, - 82, + 87, + 86, 1, 0, 0, 0, - 84, - 85, + 88, + 89, 1, 0, 0, 0, - 85, - 83, + 89, + 87, 1, 0, 0, 0, - 85, - 86, + 89, + 90, 1, 0, 0, 0, - 86, + 90, 24, 1, 0, 0, 0, - 87, 91, + 95, 7, 2, 0, 0, - 88, - 90, + 92, + 94, 7, 3, 0, 0, - 89, - 88, + 93, + 92, 1, 0, 0, 0, - 90, - 93, + 94, + 97, 1, 0, 0, 0, - 91, - 89, + 95, + 93, 1, 0, 0, 0, - 91, - 92, + 95, + 96, 1, 0, 0, 0, - 92, + 96, 26, 1, 0, 0, 0, - 93, - 91, + 97, + 95, 1, 0, 0, 0, - 94, - 95, + 98, + 99, 3, 25, 12, 0, - 95, - 96, + 99, + 100, 5, 46, 0, 0, - 96, - 97, + 100, + 101, 5, 108, 0, 0, - 97, - 98, + 101, + 102, 5, 101, 0, 0, - 98, - 99, + 102, + 103, 5, 110, 0, 0, - 99, - 100, + 103, + 104, 5, 103, 0, 0, - 100, - 101, + 104, + 105, 5, 116, 0, 0, - 101, - 102, + 105, + 106, 5, 104, 0, 0, - 102, + 106, 28, 1, 0, 0, 0, - 103, - 104, + 107, + 108, 3, 25, 12, 0, - 104, - 105, + 108, + 109, 5, 91, 0, 0, - 105, - 106, + 109, + 110, 3, 21, 10, 0, - 106, - 107, + 110, + 111, 5, 93, 0, 0, - 107, + 111, 30, 1, 0, 0, 0, - 108, - 109, + 112, + 113, 3, 25, 12, 0, - 109, - 110, + 113, + 114, 5, 91, 0, 0, - 110, - 111, + 114, + 115, 3, 25, 12, 0, - 111, - 112, + 115, + 116, 5, 93, 0, 0, - 112, + 116, 32, 1, 0, 0, 0, - 113, - 114, + 117, + 118, 3, 23, 11, 0, - 114, + 118, 34, 1, 0, 0, 0, - 115, - 116, + 119, + 120, 5, 98, 0, 0, - 116, - 117, + 120, + 121, 5, 108, 0, 0, - 117, - 118, + 121, + 122, 5, 111, 0, 0, - 118, - 119, + 122, + 123, 5, 99, 0, 0, - 119, - 120, + 123, + 124, 5, 107, 0, 0, - 120, - 121, + 124, + 125, 5, 46, 0, 0, - 121, - 137, + 125, + 141, 1, 0, 0, 0, - 122, - 123, + 126, + 127, 5, 116, 0, 0, - 123, - 124, + 127, + 128, 5, 105, 0, 0, - 124, - 125, + 128, + 129, 5, 109, 0, 0, - 125, - 126, + 129, + 130, 5, 101, 0, 0, - 126, - 127, + 130, + 131, 5, 115, 0, 0, - 127, - 128, + 131, + 132, 5, 116, 0, 0, - 128, - 129, + 132, + 133, 5, 97, 0, 0, - 129, - 130, + 133, + 134, 5, 109, 0, 0, - 130, - 138, + 134, + 142, 5, 112, 0, 0, - 131, - 132, + 135, + 136, 5, 110, 0, 0, - 132, - 133, + 136, + 137, 5, 117, 0, 0, - 133, - 134, + 137, + 138, 5, 109, 0, 0, - 134, - 135, + 138, + 139, 5, 98, 0, 0, - 135, - 136, + 139, + 140, 5, 101, 0, 0, - 136, - 138, + 140, + 142, 5, 114, 0, 0, - 137, - 122, + 141, + 126, 1, 0, 0, 0, - 137, - 131, + 141, + 135, 1, 0, 0, 0, - 138, + 142, 36, 1, 0, 0, 0, - 139, - 140, + 143, + 144, 5, 109, 0, 0, - 140, - 141, + 144, + 145, 5, 115, 0, 0, - 141, - 142, + 145, + 146, 5, 103, 0, 0, - 142, - 143, + 146, + 147, 5, 46, 0, 0, - 143, - 144, + 147, + 148, 1, 0, 0, 0, - 144, - 145, + 148, + 149, 5, 115, 0, 0, - 145, - 146, + 149, + 150, 5, 101, 0, 0, - 146, - 147, + 150, + 151, 5, 110, 0, 0, - 147, - 148, + 151, + 152, 5, 100, 0, 0, - 148, - 149, + 152, + 153, 5, 101, 0, 0, - 149, - 150, + 153, + 154, 5, 114, 0, 0, - 150, + 154, 38, 1, 0, 0, 0, - 151, + 155, + 156, + 3, + 25, + 12, + 0, + 156, + 157, + 5, + 46, + 0, + 0, + 157, + 158, + 3, + 25, + 12, + 0, + 158, + 40, + 1, + 0, + 0, + 0, + 159, + 160, + 3, + 25, + 12, + 0, + 160, + 161, + 5, + 46, + 0, + 0, + 161, + 162, + 3, + 25, + 12, + 0, 162, + 166, + 5, + 91, + 0, + 0, + 163, + 167, + 3, + 25, + 12, + 0, + 164, + 167, + 3, + 21, + 10, + 0, + 165, + 167, + 3, + 23, + 11, + 0, + 166, + 163, + 1, + 0, + 0, + 0, + 166, + 164, + 1, + 0, + 0, + 0, + 166, + 165, + 1, + 0, + 0, + 0, + 167, + 168, + 1, + 0, + 0, + 0, + 168, + 169, + 5, + 93, + 0, + 0, + 169, + 42, + 1, + 0, + 0, + 0, + 170, + 181, 5, 60, 0, 0, - 152, - 153, + 171, + 172, 5, 60, 0, 0, - 153, - 162, + 172, + 181, 5, 61, 0, 0, - 154, - 162, + 173, + 181, 5, 62, 0, 0, - 155, - 156, + 174, + 175, 5, 62, 0, 0, - 156, - 162, + 175, + 181, 5, 61, 0, 0, - 157, - 158, + 176, + 177, 5, 61, 0, 0, - 158, - 162, + 177, + 181, 5, 61, 0, 0, - 159, - 160, + 178, + 179, 5, 33, 0, 0, - 160, - 162, + 179, + 181, 5, 61, 0, 0, - 161, - 151, + 180, + 170, 1, 0, 0, 0, - 161, - 152, + 180, + 171, 1, 0, 0, 0, - 161, - 154, + 180, + 173, 1, 0, 0, 0, - 161, - 155, + 180, + 174, 1, 0, 0, 0, - 161, - 157, + 180, + 176, 1, 0, 0, 0, - 161, - 159, + 180, + 178, 1, 0, 0, 0, - 162, - 40, + 181, + 44, 1, 0, 0, 0, - 163, - 165, + 182, + 184, 7, 4, 0, 0, - 164, - 163, + 183, + 182, 1, 0, 0, 0, - 165, - 166, + 184, + 185, 1, 0, 0, 0, - 166, - 164, + 185, + 183, 1, 0, 0, 0, - 166, - 167, + 185, + 186, 1, 0, 0, 0, - 167, - 168, + 186, + 187, 1, 0, 0, 0, - 168, - 169, + 187, + 188, 6, - 20, + 22, 0, 0, - 169, - 42, + 188, + 46, 1, 0, 0, 0, - 8, + 9, 0, - 72, - 77, - 85, - 91, - 137, - 161, + 76, + 81, + 89, + 95, + 141, 166, + 180, + 185, 1, 6, 0, @@ -1574,8 +1745,10 @@ class SolidityLexer(Lexer): AddressLiteral = 17 BlockAccess = 18 MsgAccess = 19 - RelOp = 20 - WS = 21 + ContractVariableAccess = 20 + ContractVariableArrayElement = 21 + RelOp = 22 + WS = 23 channelNames = [u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN"] @@ -1595,6 +1768,8 @@ class SolidityLexer(Lexer): "AddressLiteral", "BlockAccess", "MsgAccess", + "ContractVariableAccess", + "ContractVariableArrayElement", "RelOp", "WS", ] @@ -1619,6 +1794,8 @@ class SolidityLexer(Lexer): "AddressLiteral", "BlockAccess", "MsgAccess", + "ContractVariableAccess", + "ContractVariableArrayElement", "RelOp", "WS", ] @@ -1627,7 +1804,7 @@ class SolidityLexer(Lexer): def __init__(self, input=None, output: TextIO = sys.stdout): super().__init__(input, output) - self.checkVersion("4.13.1") + self.checkVersion("4.13.2") self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) self._actions = None self._predicates = None diff --git a/src/kontrol/solidity/SolidityLexer.tokens b/src/kontrol/solidity/SolidityLexer.tokens index 309be27ac..dc4b88e6b 100644 --- a/src/kontrol/solidity/SolidityLexer.tokens +++ b/src/kontrol/solidity/SolidityLexer.tokens @@ -17,8 +17,10 @@ MappingElement=16 AddressLiteral=17 BlockAccess=18 MsgAccess=19 -RelOp=20 -WS=21 +ContractVariableAccess=20 +ContractVariableArrayElement=21 +RelOp=22 +WS=23 '&&'=1 '||'=2 '!'=3 diff --git a/src/kontrol/solidity/SolidityListener.py b/src/kontrol/solidity/SolidityListener.py index 9f311dbe6..0161baadf 100644 --- a/src/kontrol/solidity/SolidityListener.py +++ b/src/kontrol/solidity/SolidityListener.py @@ -1,4 +1,4 @@ -# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.1 +# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.2 from antlr4 import * if "." in __name__: @@ -178,5 +178,21 @@ def enterMsgAccess(self, ctx: SolidityParser.MsgAccessContext): def exitMsgAccess(self, ctx: SolidityParser.MsgAccessContext): pass + # Enter a parse tree produced by SolidityParser#ContractVariableAccess. + def enterContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccessContext): + pass + + # Exit a parse tree produced by SolidityParser#ContractVariableAccess. + def exitContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccessContext): + pass + + # Enter a parse tree produced by SolidityParser#ContractVariableArrayElement. + def enterContractVariableArrayElement(self, ctx: SolidityParser.ContractVariableArrayElementContext): + pass + + # Exit a parse tree produced by SolidityParser#ContractVariableArrayElement. + def exitContractVariableArrayElement(self, ctx: SolidityParser.ContractVariableArrayElementContext): + pass + del SolidityParser diff --git a/src/kontrol/solidity/SolidityParser.py b/src/kontrol/solidity/SolidityParser.py index 408a1fcbf..a665d48bb 100644 --- a/src/kontrol/solidity/SolidityParser.py +++ b/src/kontrol/solidity/SolidityParser.py @@ -1,23 +1,9 @@ -# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.1 +# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.2 # encoding: utf-8 import sys +from io import StringIO -from antlr4 import ( - ATN, - DFA, - ATNDeserializer, - NoViableAltException, - Parser, - ParserATNSimulator, - ParserRuleContext, - ParseTreeListener, - ParseTreeVisitor, - PredictionContextCache, - RecognitionException, - RuleContext, - Token, - TokenStream, -) +from antlr4 import * if sys.version_info[1] > 5: from typing import TextIO @@ -29,8 +15,8 @@ def serializedATN(): return [ 4, 1, - 21, - 70, + 23, + 72, 2, 0, 7, @@ -170,9 +156,13 @@ def serializedATN(): 3, 1, 3, + 1, 3, + 1, 3, - 68, + 3, + 3, + 70, 8, 3, 1, @@ -188,7 +178,7 @@ def serializedATN(): 6, 0, 0, - 82, + 86, 0, 8, 1, @@ -208,7 +198,7 @@ def serializedATN(): 0, 0, 6, - 67, + 69, 1, 0, 0, @@ -252,7 +242,7 @@ def serializedATN(): 14, 15, 5, - 20, + 22, 0, 0, 15, @@ -550,37 +540,37 @@ def serializedATN(): 0, 0, 55, - 68, + 70, 5, 13, 0, 0, 56, - 68, + 70, 5, 14, 0, 0, 57, - 68, + 70, 5, 15, 0, 0, 58, - 68, + 70, 5, 16, 0, 0, 59, - 68, + 70, 5, 17, 0, 0, 60, - 68, + 70, 5, 11, 0, @@ -604,78 +594,102 @@ def serializedATN(): 0, 0, 64, - 68, + 70, 1, 0, 0, 0, 65, - 68, + 70, 5, 18, 0, 0, 66, - 68, + 70, 5, 19, 0, 0, 67, + 70, + 5, + 20, + 0, + 0, + 68, + 70, + 5, + 21, + 0, + 0, + 69, 55, 1, 0, 0, 0, - 67, + 69, 56, 1, 0, 0, 0, - 67, + 69, 57, 1, 0, 0, 0, - 67, + 69, 58, 1, 0, 0, 0, - 67, + 69, 59, 1, 0, 0, 0, - 67, + 69, 60, 1, 0, 0, 0, - 67, + 69, 61, 1, 0, 0, 0, - 67, + 69, 65, 1, 0, 0, 0, - 67, + 69, 66, 1, 0, 0, 0, + 69, + 67, + 1, + 0, + 0, + 0, + 69, 68, + 1, + 0, + 0, + 0, + 70, 7, 1, 0, @@ -687,7 +701,7 @@ def serializedATN(): 32, 50, 52, - 67, + 69, ] @@ -724,6 +738,8 @@ class SolidityParser(Parser): "AddressLiteral", "BlockAccess", "MsgAccess", + "ContractVariableAccess", + "ContractVariableArrayElement", "RelOp", "WS", ] @@ -755,12 +771,14 @@ class SolidityParser(Parser): AddressLiteral = 17 BlockAccess = 18 MsgAccess = 19 - RelOp = 20 - WS = 21 + ContractVariableAccess = 20 + ContractVariableArrayElement = 21 + RelOp = 22 + WS = 23 def __init__(self, input: TokenStream, output: TextIO = sys.stdout): super().__init__(input, output) - self.checkVersion("4.13.1") + self.checkVersion("4.13.2") self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache) self._predicates = None @@ -974,6 +992,7 @@ def booleanExpression(self, _p: int = 0): _parentctx = self._ctx _parentState = self.state localctx = SolidityParser.BooleanExpressionContext(self, self._ctx, _parentState) + _prevctx = localctx _startState = 2 self.enterRecursionRule(localctx, 2, self.RULE_booleanExpression, _p) try: @@ -984,37 +1003,45 @@ def booleanExpression(self, _p: int = 0): if la_ == 1: localctx = SolidityParser.NotExpressionContext(self, localctx) self._ctx = localctx + _prevctx = localctx self.state = 11 self.match(SolidityParser.T__2) self.state = 12 self.booleanExpression(4) + pass elif la_ == 2: localctx = SolidityParser.RelationalExpressionContext(self, localctx) self._ctx = localctx + _prevctx = localctx self.state = 13 self.arithmeticExpression(0) self.state = 14 self.match(SolidityParser.RelOp) self.state = 15 self.arithmeticExpression(0) + pass elif la_ == 3: localctx = SolidityParser.BooleanLiteralContext(self, localctx) self._ctx = localctx + _prevctx = localctx self.state = 17 self.match(SolidityParser.BOOLEAN_LITERAL) + pass elif la_ == 4: localctx = SolidityParser.ParenthesizedBooleanExpressionContext(self, localctx) self._ctx = localctx + _prevctx = localctx self.state = 18 self.match(SolidityParser.T__3) self.state = 19 self.booleanExpression(0) self.state = 20 self.match(SolidityParser.T__4) + pass self._ctx.stop = self._input.LT(-1) self.state = 32 @@ -1024,6 +1051,7 @@ def booleanExpression(self, _p: int = 0): if _alt == 1: if self._parseListeners is not None: self.triggerExitRuleEvent() + _prevctx = localctx self.state = 30 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input, 1, self._ctx) @@ -1041,6 +1069,7 @@ def booleanExpression(self, _p: int = 0): self.match(SolidityParser.T__0) self.state = 26 self.booleanExpression(7) + pass elif la_ == 2: localctx = SolidityParser.OrExpressionContext( @@ -1056,6 +1085,7 @@ def booleanExpression(self, _p: int = 0): self.match(SolidityParser.T__1) self.state = 29 self.booleanExpression(6) + pass self.state = 34 self._errHandler.sync(self) @@ -1213,12 +1243,14 @@ def arithmeticExpression(self, _p: int = 0): _parentctx = self._ctx _parentState = self.state localctx = SolidityParser.ArithmeticExpressionContext(self, self._ctx, _parentState) + _prevctx = localctx _startState = 4 self.enterRecursionRule(localctx, 4, self.RULE_arithmeticExpression, _p) try: self.enterOuterAlt(localctx, 1) localctx = SolidityParser.AtomExpressionContext(self, localctx) self._ctx = localctx + _prevctx = localctx self.state = 36 self.atom() @@ -1230,6 +1262,7 @@ def arithmeticExpression(self, _p: int = 0): if _alt == 1: if self._parseListeners is not None: self.triggerExitRuleEvent() + _prevctx = localctx self.state = 50 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input, 3, self._ctx) @@ -1247,6 +1280,7 @@ def arithmeticExpression(self, _p: int = 0): self.match(SolidityParser.T__5) self.state = 40 self.arithmeticExpression(6) + pass elif la_ == 2: localctx = SolidityParser.SubtractExpressionContext( @@ -1262,6 +1296,7 @@ def arithmeticExpression(self, _p: int = 0): self.match(SolidityParser.T__6) self.state = 43 self.arithmeticExpression(5) + pass elif la_ == 3: localctx = SolidityParser.MultiplyExpressionContext( @@ -1277,6 +1312,7 @@ def arithmeticExpression(self, _p: int = 0): self.match(SolidityParser.T__7) self.state = 46 self.arithmeticExpression(4) + pass elif la_ == 4: localctx = SolidityParser.DivideExpressionContext( @@ -1292,6 +1328,7 @@ def arithmeticExpression(self, _p: int = 0): self.match(SolidityParser.T__8) self.state = 49 self.arithmeticExpression(3) + pass self.state = 54 self._errHandler.sync(self) @@ -1364,6 +1401,29 @@ def accept(self, visitor: ParseTreeVisitor): else: return visitor.visitChildren(self) + class ContractVariableAccessContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def ContractVariableAccess(self): + return self.getToken(SolidityParser.ContractVariableAccess, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterContractVariableAccess"): + listener.enterContractVariableAccess(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitContractVariableAccess"): + listener.exitContractVariableAccess(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitContractVariableAccess"): + return visitor.visitContractVariableAccess(self) + else: + return visitor.visitChildren(self) + class VariableContext(AtomContext): def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext @@ -1456,6 +1516,29 @@ def accept(self, visitor: ParseTreeVisitor): else: return visitor.visitChildren(self) + class ContractVariableArrayElementContext(AtomContext): + + def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + super().__init__(parser) + self.copyFrom(ctx) + + def ContractVariableArrayElement(self): + return self.getToken(SolidityParser.ContractVariableArrayElement, 0) + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterContractVariableArrayElement"): + listener.enterContractVariableArrayElement(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitContractVariableArrayElement"): + listener.exitContractVariableArrayElement(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitContractVariableArrayElement"): + return visitor.visitContractVariableArrayElement(self) + else: + return visitor.visitChildren(self) + class ArrayElementContext(AtomContext): def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext @@ -1530,7 +1613,7 @@ def atom(self): localctx = SolidityParser.AtomContext(self, self._ctx, self.state) self.enterRule(localctx, 6, self.RULE_atom) try: - self.state = 67 + self.state = 69 self._errHandler.sync(self) token = self._input.LA(1) if token in [13]: @@ -1538,31 +1621,37 @@ def atom(self): self.enterOuterAlt(localctx, 1) self.state = 55 self.match(SolidityParser.VariableName) + pass elif token in [14]: localctx = SolidityParser.LengthAccessContext(self, localctx) self.enterOuterAlt(localctx, 2) self.state = 56 self.match(SolidityParser.LengthAccess) + pass elif token in [15]: localctx = SolidityParser.ArrayElementContext(self, localctx) self.enterOuterAlt(localctx, 3) self.state = 57 self.match(SolidityParser.ArrayElement) + pass elif token in [16]: localctx = SolidityParser.MappingElementContext(self, localctx) self.enterOuterAlt(localctx, 4) self.state = 58 self.match(SolidityParser.MappingElement) + pass elif token in [17]: localctx = SolidityParser.AddressLiteralContext(self, localctx) self.enterOuterAlt(localctx, 5) self.state = 59 self.match(SolidityParser.AddressLiteral) + pass elif token in [11]: localctx = SolidityParser.IntegerLiteralContext(self, localctx) self.enterOuterAlt(localctx, 6) self.state = 60 self.match(SolidityParser.INTEGER) + pass elif token in [4]: localctx = SolidityParser.ParenthesizedArithmeticExpressionContext(self, localctx) self.enterOuterAlt(localctx, 7) @@ -1572,16 +1661,31 @@ def atom(self): self.arithmeticExpression(0) self.state = 63 self.match(SolidityParser.T__4) + pass elif token in [18]: localctx = SolidityParser.BlockAccessContext(self, localctx) self.enterOuterAlt(localctx, 8) self.state = 65 self.match(SolidityParser.BlockAccess) + pass elif token in [19]: localctx = SolidityParser.MsgAccessContext(self, localctx) self.enterOuterAlt(localctx, 9) self.state = 66 self.match(SolidityParser.MsgAccess) + pass + elif token in [20]: + localctx = SolidityParser.ContractVariableAccessContext(self, localctx) + self.enterOuterAlt(localctx, 10) + self.state = 67 + self.match(SolidityParser.ContractVariableAccess) + pass + elif token in [21]: + localctx = SolidityParser.ContractVariableArrayElementContext(self, localctx) + self.enterOuterAlt(localctx, 11) + self.state = 68 + self.match(SolidityParser.ContractVariableArrayElement) + pass else: raise NoViableAltException(self) diff --git a/src/kontrol/solidity/SolidityVisitor.py b/src/kontrol/solidity/SolidityVisitor.py index 547b55af5..509734071 100644 --- a/src/kontrol/solidity/SolidityVisitor.py +++ b/src/kontrol/solidity/SolidityVisitor.py @@ -1,4 +1,4 @@ -# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.1 +# Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.2 from antlr4 import * if "." in __name__: @@ -95,5 +95,13 @@ def visitBlockAccess(self, ctx: SolidityParser.BlockAccessContext): def visitMsgAccess(self, ctx: SolidityParser.MsgAccessContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#ContractVariableAccess. + def visitContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccessContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#ContractVariableArrayElement. + def visitContractVariableArrayElement(self, ctx: SolidityParser.ContractVariableArrayElementContext): + return self.visitChildren(ctx) + del SolidityParser From 94c48735afec7918a381ac1cdbd0182644688ce3 Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Wed, 7 Aug 2024 23:02:50 +0800 Subject: [PATCH 13/15] Support `contractName.variableName` constraints --- src/kontrol/prove.py | 64 +- src/kontrol/solidity/AnnotationVisitor.py | 91 +- src/kontrol/solidity/Solidity.g4 | 14 +- src/kontrol/solidity/Solidity.interp | 14 +- src/kontrol/solidity/Solidity.tokens | 32 +- src/kontrol/solidity/SolidityLexer.interp | 17 +- src/kontrol/solidity/SolidityLexer.py | 972 ++++++++++------------ src/kontrol/solidity/SolidityLexer.tokens | 32 +- src/kontrol/solidity/SolidityListener.py | 16 + src/kontrol/solidity/SolidityParser.py | 807 +++++++++++------- src/kontrol/solidity/SolidityVisitor.py | 8 + 11 files changed, 1161 insertions(+), 906 deletions(-) diff --git a/src/kontrol/prove.py b/src/kontrol/prove.py index 4a23fddf5..0635d584a 100644 --- a/src/kontrol/prove.py +++ b/src/kontrol/prove.py @@ -1038,6 +1038,11 @@ def _init_cterm( foundry, storage_fields, contract_account_name, contract_code, method ) + # Add precondition constraints + storage_constraints.extend( + _create_precondition_constraints(foundry, storage_fields, contract_account_name, method) + ) + accounts.append(KVariable('ACCOUNTS_REST', sort=KSort('AccountCellMap'))) init_subst_accounts = {'ACCOUNTS_CELL': KEVM.accounts(accounts)} @@ -1126,33 +1131,15 @@ def _create_initial_account_list( return init_account_list -def _create_cse_accounts( +def _create_precondition_constraints( foundry: Foundry, storage_fields: tuple[StorageField, ...], contract_name: str, - contract_code: KInner, method: Contract.Method, -) -> tuple[list[KInner], list[KApply]]: - """ - Recursively generates a list of new accounts corresponding to `contract` fields, each having and cell (partially) set up. - Args: - foundry (Foundry): The Foundry object containing the information about contracts in the project. - storage_fields (tuple[StorageField, ...]): A tuple of StorageField objects representing the contract's storage fields. - contract_name (str): The name of the contract being executed to be used in the account-related symbolic variables. - contract_code (KInner): The KInner object representing the contract's runtime bytecode. - Returns: - tuple[list[KInner], list[KApply]]: - - A list of accounts to be included in the initial configuration. - - A list of constraints on symbolic account IDs. - """ - - def extend_storage(map: KInner, slot: int, value: KInner) -> KInner: - return KApply('_Map_', [map_item(intToken(slot), value), map]) +) -> list[KApply]: - new_accounts: list[KInner] = [] - new_account_constraints: list[KApply] = [] + precondition_constraints: list[KApply] = [] - # TODO(palina): add a method processing preconditions def precondition_to_kapply(precondition: str) -> KApply: """ Converts the precondition to a KApply term. @@ -1160,6 +1147,7 @@ def precondition_to_kapply(precondition: str) -> KApply: - Constants are translated into `intToken` terms - Variables should be searched in method's inputs or in the contract's storage fields - Operators are translated into the corresponding KLabel application, e.g., `leInt`, `eqInt`, etc. + TBD """ # Parse the input expression @@ -1176,8 +1164,38 @@ def precondition_to_kapply(precondition: str) -> KApply: return result - for p in method.preconditions: - new_account_constraints.append(mlEqualsTrue(precondition_to_kapply(p.precondition))) + if method.preconditions is not None: + for p in method.preconditions: + precondition_constraints.append(mlEqualsTrue(precondition_to_kapply(p.precondition))) + + return precondition_constraints + + +def _create_cse_accounts( + foundry: Foundry, + storage_fields: tuple[StorageField, ...], + contract_name: str, + contract_code: KInner, + method: Contract.Method, +) -> tuple[list[KInner], list[KApply]]: + """ + Recursively generates a list of new accounts corresponding to `contract` fields, each having and cell (partially) set up. + Args: + foundry (Foundry): The Foundry object containing the information about contracts in the project. + storage_fields (tuple[StorageField, ...]): A tuple of StorageField objects representing the contract's storage fields. + contract_name (str): The name of the contract being executed to be used in the account-related symbolic variables. + contract_code (KInner): The KInner object representing the contract's runtime bytecode. + Returns: + tuple[list[KInner], list[KApply]]: + - A list of accounts to be included in the initial configuration. + - A list of constraints on symbolic account IDs. + """ + + def extend_storage(map: KInner, slot: int, value: KInner) -> KInner: + return KApply('_Map_', [map_item(intToken(slot), value), map]) + + new_accounts: list[KInner] = [] + new_account_constraints: list[KApply] = [] storage_map: KInner = KVariable(contract_name + '_STORAGE', sort=KSort('Map')) diff --git a/src/kontrol/solidity/AnnotationVisitor.py b/src/kontrol/solidity/AnnotationVisitor.py index a6ea14071..aa89d9bb1 100644 --- a/src/kontrol/solidity/AnnotationVisitor.py +++ b/src/kontrol/solidity/AnnotationVisitor.py @@ -64,54 +64,66 @@ def visitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionCont def visitBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext) -> KInner: return TRUE if ctx.getText() == 'true' else FALSE - # def visitAddExpression(self, ctx: SolidityParser.AddExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left + right - - # def visitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left - right - - # def visitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left * right - - # def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left / right - def visitVariable(self, ctx: SolidityParser.VariableContext) -> KInner: var_name = ctx.getText() + # Search for matches in function inputs for input in self.method.inputs: if input.name == var_name: - # TODO(palina): add support for complex types + # TODO: add support for complex types return abstract_term_safely(KVariable('_###SOLIDITY_ARG_VAR###_'), base_name=f'V{input.arg_name}') - # TODO: add support for storage fields + # Search for matches in contract storage fields for field in self.storage_fields: if field.label == var_name: storage_map: KInner = KVariable(self.contract_name + '_STORAGE', sort=KSort('Map')) return KEVM.lookup(storage_map, intToken(field.slot)) - # return abstract_term_safely(KVariable('_###SOLIDITY_STORAGE_VAR###_'), base_name=f'V{field.name}') - # for field in self.method.contract.storage_fields: - # if field.name == var_name: - # Perform the necessary action for a matching storage field - # break # Exit the loop once the matching field is found - raise ValueError(f'Not implemented yet: {var_name}') - - # def visitContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccessContext): - # contract_name = ctx.VariableName(0).getText() - # var_name = ctx.VariableName(1).getText() - - # TODO (palina): add support for contract variables - # - find contract - # - find variables - # - lookup - # return self.contracts.get(contract_name, {}).get(var_name, 0) + + raise ValueError(f'Variable {var_name} not found in function inputs or storage fields of {self.method.name}.') + + def visitContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccessContext): + contract_field_name: str = ctx.contractVariableAccessExpr().VariableName(0).getText() + var_name: str = ctx.contractVariableAccessExpr().VariableName(1).getText() + + for field in self.storage_fields: + if field.data_type.startswith('contract ') and field.label == contract_field_name: + contract_type = field.data_type.split(' ')[1] + + # TODO: it is possible for a contact to have an interface annotation, `linked_interface` + for full_contract_name, contract_obj in self.foundry.contracts.items(): + # TODO: this is not enough, it is possible that the same contract comes with + # src% and test%, in which case we don't know automatically which one to choose + if full_contract_name.split('%')[-1] == contract_type: + for field in contract_obj.fields: + if field.label == var_name: + storage_map: KInner = KVariable( + self.contract_name + '_' + contract_field_name.upper() + '_STORAGE', sort=KSort('Map') + ) + return KEVM.lookup(storage_map, intToken(field.slot)) + + raise ValueError(f'Variable {contract_field_name}.{var_name} not found.') + + def visitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext) -> KInner: + return intToken(ctx.getText()) + + # def visitAddExpression(self, ctx: SolidityParser.AddExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left + right + + # def visitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left - right + + # def visitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left * right + + # def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + # left = self.visit(ctx.arithmeticExpression(0)) + # right = self.visit(ctx.arithmeticExpression(1)) + # return left / right # def visitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): # var_name = ctx.variableName().getText() @@ -129,6 +141,3 @@ def visitVariable(self, ctx: SolidityParser.VariableContext) -> KInner: # def visitAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): # return ctx.getText() - - def visitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext) -> KInner: - return intToken(ctx.getText()) diff --git a/src/kontrol/solidity/Solidity.g4 b/src/kontrol/solidity/Solidity.g4 index f1f485d25..4304c36fa 100644 --- a/src/kontrol/solidity/Solidity.g4 +++ b/src/kontrol/solidity/Solidity.g4 @@ -32,8 +32,16 @@ atom | '(' arithmeticExpression ')' # ParenthesizedArithmeticExpression | BlockAccess # BlockAccess | MsgAccess # MsgAccess - | ContractVariableAccess # ContractVariableAccess - | ContractVariableArrayElement # ContractVariableArrayElement + | contractVariableAccessExpr # ContractVariableAccess + | contractVariableArrayElemExpr # ContractVariableArrayElement + ; + +contractVariableAccessExpr + : VariableName '.' VariableName + ; + +contractVariableArrayElemExpr + : VariableName '.' VariableName '[' (VariableName | INTEGER | ADDRESS) ']' ; // Lexer rules @@ -48,8 +56,6 @@ MappingElement: VariableName '[' VariableName ']'; AddressLiteral: ADDRESS; BlockAccess: 'block.' ('timestamp' | 'number'); MsgAccess: 'msg.' ('sender'); -ContractVariableAccess: VariableName '.' VariableName; -ContractVariableArrayElement: VariableName '.' VariableName '[' (VariableName | INTEGER | ADDRESS) ']'; RelOp: '<' | '<=' | '>' | '>=' | '==' | '!='; diff --git a/src/kontrol/solidity/Solidity.interp b/src/kontrol/solidity/Solidity.interp index 67363299c..669dc9bb1 100644 --- a/src/kontrol/solidity/Solidity.interp +++ b/src/kontrol/solidity/Solidity.interp @@ -9,8 +9,9 @@ null '-' '*' '/' -null -null +'.' +'[' +']' null null null @@ -35,6 +36,9 @@ null null null null +null +null +null BOOLEAN_LITERAL INTEGER ADDRESS @@ -45,8 +49,6 @@ MappingElement AddressLiteral BlockAccess MsgAccess -ContractVariableAccess -ContractVariableArrayElement RelOp WS @@ -55,7 +57,9 @@ expression booleanExpression arithmeticExpression atom +contractVariableAccessExpr +contractVariableArrayElemExpr atn: -[4, 1, 23, 72, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 23, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 31, 8, 1, 10, 1, 12, 1, 34, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 51, 8, 2, 10, 2, 12, 2, 54, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 70, 8, 3, 1, 3, 0, 2, 2, 4, 4, 0, 2, 4, 6, 0, 0, 86, 0, 8, 1, 0, 0, 0, 2, 22, 1, 0, 0, 0, 4, 35, 1, 0, 0, 0, 6, 69, 1, 0, 0, 0, 8, 9, 3, 2, 1, 0, 9, 1, 1, 0, 0, 0, 10, 11, 6, 1, -1, 0, 11, 12, 5, 3, 0, 0, 12, 23, 3, 2, 1, 4, 13, 14, 3, 4, 2, 0, 14, 15, 5, 22, 0, 0, 15, 16, 3, 4, 2, 0, 16, 23, 1, 0, 0, 0, 17, 23, 5, 10, 0, 0, 18, 19, 5, 4, 0, 0, 19, 20, 3, 2, 1, 0, 20, 21, 5, 5, 0, 0, 21, 23, 1, 0, 0, 0, 22, 10, 1, 0, 0, 0, 22, 13, 1, 0, 0, 0, 22, 17, 1, 0, 0, 0, 22, 18, 1, 0, 0, 0, 23, 32, 1, 0, 0, 0, 24, 25, 10, 6, 0, 0, 25, 26, 5, 1, 0, 0, 26, 31, 3, 2, 1, 7, 27, 28, 10, 5, 0, 0, 28, 29, 5, 2, 0, 0, 29, 31, 3, 2, 1, 6, 30, 24, 1, 0, 0, 0, 30, 27, 1, 0, 0, 0, 31, 34, 1, 0, 0, 0, 32, 30, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 3, 1, 0, 0, 0, 34, 32, 1, 0, 0, 0, 35, 36, 6, 2, -1, 0, 36, 37, 3, 6, 3, 0, 37, 52, 1, 0, 0, 0, 38, 39, 10, 5, 0, 0, 39, 40, 5, 6, 0, 0, 40, 51, 3, 4, 2, 6, 41, 42, 10, 4, 0, 0, 42, 43, 5, 7, 0, 0, 43, 51, 3, 4, 2, 5, 44, 45, 10, 3, 0, 0, 45, 46, 5, 8, 0, 0, 46, 51, 3, 4, 2, 4, 47, 48, 10, 2, 0, 0, 48, 49, 5, 9, 0, 0, 49, 51, 3, 4, 2, 3, 50, 38, 1, 0, 0, 0, 50, 41, 1, 0, 0, 0, 50, 44, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 5, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 70, 5, 13, 0, 0, 56, 70, 5, 14, 0, 0, 57, 70, 5, 15, 0, 0, 58, 70, 5, 16, 0, 0, 59, 70, 5, 17, 0, 0, 60, 70, 5, 11, 0, 0, 61, 62, 5, 4, 0, 0, 62, 63, 3, 4, 2, 0, 63, 64, 5, 5, 0, 0, 64, 70, 1, 0, 0, 0, 65, 70, 5, 18, 0, 0, 66, 70, 5, 19, 0, 0, 67, 70, 5, 20, 0, 0, 68, 70, 5, 21, 0, 0, 69, 55, 1, 0, 0, 0, 69, 56, 1, 0, 0, 0, 69, 57, 1, 0, 0, 0, 69, 58, 1, 0, 0, 0, 69, 59, 1, 0, 0, 0, 69, 60, 1, 0, 0, 0, 69, 61, 1, 0, 0, 0, 69, 65, 1, 0, 0, 0, 69, 66, 1, 0, 0, 0, 69, 67, 1, 0, 0, 0, 69, 68, 1, 0, 0, 0, 70, 7, 1, 0, 0, 0, 6, 22, 30, 32, 50, 52, 69] \ No newline at end of file +[4, 1, 24, 87, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 27, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 35, 8, 1, 10, 1, 12, 1, 38, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 55, 8, 2, 10, 2, 12, 2, 58, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 74, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 0, 2, 2, 4, 6, 0, 2, 4, 6, 8, 10, 0, 1, 1, 0, 14, 16, 99, 0, 12, 1, 0, 0, 0, 2, 26, 1, 0, 0, 0, 4, 39, 1, 0, 0, 0, 6, 73, 1, 0, 0, 0, 8, 75, 1, 0, 0, 0, 10, 79, 1, 0, 0, 0, 12, 13, 3, 2, 1, 0, 13, 1, 1, 0, 0, 0, 14, 15, 6, 1, -1, 0, 15, 16, 5, 3, 0, 0, 16, 27, 3, 2, 1, 4, 17, 18, 3, 4, 2, 0, 18, 19, 5, 23, 0, 0, 19, 20, 3, 4, 2, 0, 20, 27, 1, 0, 0, 0, 21, 27, 5, 13, 0, 0, 22, 23, 5, 4, 0, 0, 23, 24, 3, 2, 1, 0, 24, 25, 5, 5, 0, 0, 25, 27, 1, 0, 0, 0, 26, 14, 1, 0, 0, 0, 26, 17, 1, 0, 0, 0, 26, 21, 1, 0, 0, 0, 26, 22, 1, 0, 0, 0, 27, 36, 1, 0, 0, 0, 28, 29, 10, 6, 0, 0, 29, 30, 5, 1, 0, 0, 30, 35, 3, 2, 1, 7, 31, 32, 10, 5, 0, 0, 32, 33, 5, 2, 0, 0, 33, 35, 3, 2, 1, 6, 34, 28, 1, 0, 0, 0, 34, 31, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, 34, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 3, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 40, 6, 2, -1, 0, 40, 41, 3, 6, 3, 0, 41, 56, 1, 0, 0, 0, 42, 43, 10, 5, 0, 0, 43, 44, 5, 6, 0, 0, 44, 55, 3, 4, 2, 6, 45, 46, 10, 4, 0, 0, 46, 47, 5, 7, 0, 0, 47, 55, 3, 4, 2, 5, 48, 49, 10, 3, 0, 0, 49, 50, 5, 8, 0, 0, 50, 55, 3, 4, 2, 4, 51, 52, 10, 2, 0, 0, 52, 53, 5, 9, 0, 0, 53, 55, 3, 4, 2, 3, 54, 42, 1, 0, 0, 0, 54, 45, 1, 0, 0, 0, 54, 48, 1, 0, 0, 0, 54, 51, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 5, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 74, 5, 16, 0, 0, 60, 74, 5, 17, 0, 0, 61, 74, 5, 18, 0, 0, 62, 74, 5, 19, 0, 0, 63, 74, 5, 20, 0, 0, 64, 74, 5, 14, 0, 0, 65, 66, 5, 4, 0, 0, 66, 67, 3, 4, 2, 0, 67, 68, 5, 5, 0, 0, 68, 74, 1, 0, 0, 0, 69, 74, 5, 21, 0, 0, 70, 74, 5, 22, 0, 0, 71, 74, 3, 8, 4, 0, 72, 74, 3, 10, 5, 0, 73, 59, 1, 0, 0, 0, 73, 60, 1, 0, 0, 0, 73, 61, 1, 0, 0, 0, 73, 62, 1, 0, 0, 0, 73, 63, 1, 0, 0, 0, 73, 64, 1, 0, 0, 0, 73, 65, 1, 0, 0, 0, 73, 69, 1, 0, 0, 0, 73, 70, 1, 0, 0, 0, 73, 71, 1, 0, 0, 0, 73, 72, 1, 0, 0, 0, 74, 7, 1, 0, 0, 0, 75, 76, 5, 16, 0, 0, 76, 77, 5, 10, 0, 0, 77, 78, 5, 16, 0, 0, 78, 9, 1, 0, 0, 0, 79, 80, 5, 16, 0, 0, 80, 81, 5, 10, 0, 0, 81, 82, 5, 16, 0, 0, 82, 83, 5, 11, 0, 0, 83, 84, 7, 0, 0, 0, 84, 85, 5, 12, 0, 0, 85, 11, 1, 0, 0, 0, 6, 26, 34, 36, 54, 56, 73] \ No newline at end of file diff --git a/src/kontrol/solidity/Solidity.tokens b/src/kontrol/solidity/Solidity.tokens index dc4b88e6b..3a8d82041 100644 --- a/src/kontrol/solidity/Solidity.tokens +++ b/src/kontrol/solidity/Solidity.tokens @@ -7,20 +7,21 @@ T__5=6 T__6=7 T__7=8 T__8=9 -BOOLEAN_LITERAL=10 -INTEGER=11 -ADDRESS=12 -VariableName=13 -LengthAccess=14 -ArrayElement=15 -MappingElement=16 -AddressLiteral=17 -BlockAccess=18 -MsgAccess=19 -ContractVariableAccess=20 -ContractVariableArrayElement=21 -RelOp=22 -WS=23 +T__9=10 +T__10=11 +T__11=12 +BOOLEAN_LITERAL=13 +INTEGER=14 +ADDRESS=15 +VariableName=16 +LengthAccess=17 +ArrayElement=18 +MappingElement=19 +AddressLiteral=20 +BlockAccess=21 +MsgAccess=22 +RelOp=23 +WS=24 '&&'=1 '||'=2 '!'=3 @@ -30,3 +31,6 @@ WS=23 '-'=7 '*'=8 '/'=9 +'.'=10 +'['=11 +']'=12 diff --git a/src/kontrol/solidity/SolidityLexer.interp b/src/kontrol/solidity/SolidityLexer.interp index 71e2dbeae..066d32c00 100644 --- a/src/kontrol/solidity/SolidityLexer.interp +++ b/src/kontrol/solidity/SolidityLexer.interp @@ -9,8 +9,9 @@ null '-' '*' '/' -null -null +'.' +'[' +']' null null null @@ -35,6 +36,9 @@ null null null null +null +null +null BOOLEAN_LITERAL INTEGER ADDRESS @@ -45,8 +49,6 @@ MappingElement AddressLiteral BlockAccess MsgAccess -ContractVariableAccess -ContractVariableArrayElement RelOp WS @@ -60,6 +62,9 @@ T__5 T__6 T__7 T__8 +T__9 +T__10 +T__11 BOOLEAN_LITERAL INTEGER ADDRESS @@ -70,8 +75,6 @@ MappingElement AddressLiteral BlockAccess MsgAccess -ContractVariableAccess -ContractVariableArrayElement RelOp WS @@ -83,4 +86,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 23, 189, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 77, 8, 9, 1, 10, 4, 10, 80, 8, 10, 11, 10, 12, 10, 81, 1, 11, 1, 11, 1, 11, 1, 11, 4, 11, 88, 8, 11, 11, 11, 12, 11, 89, 1, 12, 1, 12, 5, 12, 94, 8, 12, 10, 12, 12, 12, 97, 9, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 142, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 167, 8, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 181, 8, 21, 1, 22, 4, 22, 184, 8, 22, 11, 22, 12, 22, 185, 1, 22, 1, 22, 0, 0, 23, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 1, 0, 5, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 201, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 1, 47, 1, 0, 0, 0, 3, 50, 1, 0, 0, 0, 5, 53, 1, 0, 0, 0, 7, 55, 1, 0, 0, 0, 9, 57, 1, 0, 0, 0, 11, 59, 1, 0, 0, 0, 13, 61, 1, 0, 0, 0, 15, 63, 1, 0, 0, 0, 17, 65, 1, 0, 0, 0, 19, 76, 1, 0, 0, 0, 21, 79, 1, 0, 0, 0, 23, 83, 1, 0, 0, 0, 25, 91, 1, 0, 0, 0, 27, 98, 1, 0, 0, 0, 29, 107, 1, 0, 0, 0, 31, 112, 1, 0, 0, 0, 33, 117, 1, 0, 0, 0, 35, 119, 1, 0, 0, 0, 37, 143, 1, 0, 0, 0, 39, 155, 1, 0, 0, 0, 41, 159, 1, 0, 0, 0, 43, 180, 1, 0, 0, 0, 45, 183, 1, 0, 0, 0, 47, 48, 5, 38, 0, 0, 48, 49, 5, 38, 0, 0, 49, 2, 1, 0, 0, 0, 50, 51, 5, 124, 0, 0, 51, 52, 5, 124, 0, 0, 52, 4, 1, 0, 0, 0, 53, 54, 5, 33, 0, 0, 54, 6, 1, 0, 0, 0, 55, 56, 5, 40, 0, 0, 56, 8, 1, 0, 0, 0, 57, 58, 5, 41, 0, 0, 58, 10, 1, 0, 0, 0, 59, 60, 5, 43, 0, 0, 60, 12, 1, 0, 0, 0, 61, 62, 5, 45, 0, 0, 62, 14, 1, 0, 0, 0, 63, 64, 5, 42, 0, 0, 64, 16, 1, 0, 0, 0, 65, 66, 5, 47, 0, 0, 66, 18, 1, 0, 0, 0, 67, 68, 5, 116, 0, 0, 68, 69, 5, 114, 0, 0, 69, 70, 5, 117, 0, 0, 70, 77, 5, 101, 0, 0, 71, 72, 5, 102, 0, 0, 72, 73, 5, 97, 0, 0, 73, 74, 5, 108, 0, 0, 74, 75, 5, 115, 0, 0, 75, 77, 5, 101, 0, 0, 76, 67, 1, 0, 0, 0, 76, 71, 1, 0, 0, 0, 77, 20, 1, 0, 0, 0, 78, 80, 7, 0, 0, 0, 79, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 22, 1, 0, 0, 0, 83, 84, 5, 48, 0, 0, 84, 85, 5, 120, 0, 0, 85, 87, 1, 0, 0, 0, 86, 88, 7, 1, 0, 0, 87, 86, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 24, 1, 0, 0, 0, 91, 95, 7, 2, 0, 0, 92, 94, 7, 3, 0, 0, 93, 92, 1, 0, 0, 0, 94, 97, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 26, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 98, 99, 3, 25, 12, 0, 99, 100, 5, 46, 0, 0, 100, 101, 5, 108, 0, 0, 101, 102, 5, 101, 0, 0, 102, 103, 5, 110, 0, 0, 103, 104, 5, 103, 0, 0, 104, 105, 5, 116, 0, 0, 105, 106, 5, 104, 0, 0, 106, 28, 1, 0, 0, 0, 107, 108, 3, 25, 12, 0, 108, 109, 5, 91, 0, 0, 109, 110, 3, 21, 10, 0, 110, 111, 5, 93, 0, 0, 111, 30, 1, 0, 0, 0, 112, 113, 3, 25, 12, 0, 113, 114, 5, 91, 0, 0, 114, 115, 3, 25, 12, 0, 115, 116, 5, 93, 0, 0, 116, 32, 1, 0, 0, 0, 117, 118, 3, 23, 11, 0, 118, 34, 1, 0, 0, 0, 119, 120, 5, 98, 0, 0, 120, 121, 5, 108, 0, 0, 121, 122, 5, 111, 0, 0, 122, 123, 5, 99, 0, 0, 123, 124, 5, 107, 0, 0, 124, 125, 5, 46, 0, 0, 125, 141, 1, 0, 0, 0, 126, 127, 5, 116, 0, 0, 127, 128, 5, 105, 0, 0, 128, 129, 5, 109, 0, 0, 129, 130, 5, 101, 0, 0, 130, 131, 5, 115, 0, 0, 131, 132, 5, 116, 0, 0, 132, 133, 5, 97, 0, 0, 133, 134, 5, 109, 0, 0, 134, 142, 5, 112, 0, 0, 135, 136, 5, 110, 0, 0, 136, 137, 5, 117, 0, 0, 137, 138, 5, 109, 0, 0, 138, 139, 5, 98, 0, 0, 139, 140, 5, 101, 0, 0, 140, 142, 5, 114, 0, 0, 141, 126, 1, 0, 0, 0, 141, 135, 1, 0, 0, 0, 142, 36, 1, 0, 0, 0, 143, 144, 5, 109, 0, 0, 144, 145, 5, 115, 0, 0, 145, 146, 5, 103, 0, 0, 146, 147, 5, 46, 0, 0, 147, 148, 1, 0, 0, 0, 148, 149, 5, 115, 0, 0, 149, 150, 5, 101, 0, 0, 150, 151, 5, 110, 0, 0, 151, 152, 5, 100, 0, 0, 152, 153, 5, 101, 0, 0, 153, 154, 5, 114, 0, 0, 154, 38, 1, 0, 0, 0, 155, 156, 3, 25, 12, 0, 156, 157, 5, 46, 0, 0, 157, 158, 3, 25, 12, 0, 158, 40, 1, 0, 0, 0, 159, 160, 3, 25, 12, 0, 160, 161, 5, 46, 0, 0, 161, 162, 3, 25, 12, 0, 162, 166, 5, 91, 0, 0, 163, 167, 3, 25, 12, 0, 164, 167, 3, 21, 10, 0, 165, 167, 3, 23, 11, 0, 166, 163, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 166, 165, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 169, 5, 93, 0, 0, 169, 42, 1, 0, 0, 0, 170, 181, 5, 60, 0, 0, 171, 172, 5, 60, 0, 0, 172, 181, 5, 61, 0, 0, 173, 181, 5, 62, 0, 0, 174, 175, 5, 62, 0, 0, 175, 181, 5, 61, 0, 0, 176, 177, 5, 61, 0, 0, 177, 181, 5, 61, 0, 0, 178, 179, 5, 33, 0, 0, 179, 181, 5, 61, 0, 0, 180, 170, 1, 0, 0, 0, 180, 171, 1, 0, 0, 0, 180, 173, 1, 0, 0, 0, 180, 174, 1, 0, 0, 0, 180, 176, 1, 0, 0, 0, 180, 178, 1, 0, 0, 0, 181, 44, 1, 0, 0, 0, 182, 184, 7, 4, 0, 0, 183, 182, 1, 0, 0, 0, 184, 185, 1, 0, 0, 0, 185, 183, 1, 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 188, 6, 22, 0, 0, 188, 46, 1, 0, 0, 0, 9, 0, 76, 81, 89, 95, 141, 166, 180, 185, 1, 6, 0, 0] \ No newline at end of file +[4, 0, 24, 182, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 85, 8, 12, 1, 13, 4, 13, 88, 8, 13, 11, 13, 12, 13, 89, 1, 14, 1, 14, 1, 14, 1, 14, 4, 14, 96, 8, 14, 11, 14, 12, 14, 97, 1, 15, 1, 15, 5, 15, 102, 8, 15, 10, 15, 12, 15, 105, 9, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 150, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 174, 8, 22, 1, 23, 4, 23, 177, 8, 23, 11, 23, 12, 23, 178, 1, 23, 1, 23, 0, 0, 24, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 1, 0, 5, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 192, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 1, 49, 1, 0, 0, 0, 3, 52, 1, 0, 0, 0, 5, 55, 1, 0, 0, 0, 7, 57, 1, 0, 0, 0, 9, 59, 1, 0, 0, 0, 11, 61, 1, 0, 0, 0, 13, 63, 1, 0, 0, 0, 15, 65, 1, 0, 0, 0, 17, 67, 1, 0, 0, 0, 19, 69, 1, 0, 0, 0, 21, 71, 1, 0, 0, 0, 23, 73, 1, 0, 0, 0, 25, 84, 1, 0, 0, 0, 27, 87, 1, 0, 0, 0, 29, 91, 1, 0, 0, 0, 31, 99, 1, 0, 0, 0, 33, 106, 1, 0, 0, 0, 35, 115, 1, 0, 0, 0, 37, 120, 1, 0, 0, 0, 39, 125, 1, 0, 0, 0, 41, 127, 1, 0, 0, 0, 43, 151, 1, 0, 0, 0, 45, 173, 1, 0, 0, 0, 47, 176, 1, 0, 0, 0, 49, 50, 5, 38, 0, 0, 50, 51, 5, 38, 0, 0, 51, 2, 1, 0, 0, 0, 52, 53, 5, 124, 0, 0, 53, 54, 5, 124, 0, 0, 54, 4, 1, 0, 0, 0, 55, 56, 5, 33, 0, 0, 56, 6, 1, 0, 0, 0, 57, 58, 5, 40, 0, 0, 58, 8, 1, 0, 0, 0, 59, 60, 5, 41, 0, 0, 60, 10, 1, 0, 0, 0, 61, 62, 5, 43, 0, 0, 62, 12, 1, 0, 0, 0, 63, 64, 5, 45, 0, 0, 64, 14, 1, 0, 0, 0, 65, 66, 5, 42, 0, 0, 66, 16, 1, 0, 0, 0, 67, 68, 5, 47, 0, 0, 68, 18, 1, 0, 0, 0, 69, 70, 5, 46, 0, 0, 70, 20, 1, 0, 0, 0, 71, 72, 5, 91, 0, 0, 72, 22, 1, 0, 0, 0, 73, 74, 5, 93, 0, 0, 74, 24, 1, 0, 0, 0, 75, 76, 5, 116, 0, 0, 76, 77, 5, 114, 0, 0, 77, 78, 5, 117, 0, 0, 78, 85, 5, 101, 0, 0, 79, 80, 5, 102, 0, 0, 80, 81, 5, 97, 0, 0, 81, 82, 5, 108, 0, 0, 82, 83, 5, 115, 0, 0, 83, 85, 5, 101, 0, 0, 84, 75, 1, 0, 0, 0, 84, 79, 1, 0, 0, 0, 85, 26, 1, 0, 0, 0, 86, 88, 7, 0, 0, 0, 87, 86, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 28, 1, 0, 0, 0, 91, 92, 5, 48, 0, 0, 92, 93, 5, 120, 0, 0, 93, 95, 1, 0, 0, 0, 94, 96, 7, 1, 0, 0, 95, 94, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 30, 1, 0, 0, 0, 99, 103, 7, 2, 0, 0, 100, 102, 7, 3, 0, 0, 101, 100, 1, 0, 0, 0, 102, 105, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 103, 104, 1, 0, 0, 0, 104, 32, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 106, 107, 3, 31, 15, 0, 107, 108, 5, 46, 0, 0, 108, 109, 5, 108, 0, 0, 109, 110, 5, 101, 0, 0, 110, 111, 5, 110, 0, 0, 111, 112, 5, 103, 0, 0, 112, 113, 5, 116, 0, 0, 113, 114, 5, 104, 0, 0, 114, 34, 1, 0, 0, 0, 115, 116, 3, 31, 15, 0, 116, 117, 5, 91, 0, 0, 117, 118, 3, 27, 13, 0, 118, 119, 5, 93, 0, 0, 119, 36, 1, 0, 0, 0, 120, 121, 3, 31, 15, 0, 121, 122, 5, 91, 0, 0, 122, 123, 3, 31, 15, 0, 123, 124, 5, 93, 0, 0, 124, 38, 1, 0, 0, 0, 125, 126, 3, 29, 14, 0, 126, 40, 1, 0, 0, 0, 127, 128, 5, 98, 0, 0, 128, 129, 5, 108, 0, 0, 129, 130, 5, 111, 0, 0, 130, 131, 5, 99, 0, 0, 131, 132, 5, 107, 0, 0, 132, 133, 5, 46, 0, 0, 133, 149, 1, 0, 0, 0, 134, 135, 5, 116, 0, 0, 135, 136, 5, 105, 0, 0, 136, 137, 5, 109, 0, 0, 137, 138, 5, 101, 0, 0, 138, 139, 5, 115, 0, 0, 139, 140, 5, 116, 0, 0, 140, 141, 5, 97, 0, 0, 141, 142, 5, 109, 0, 0, 142, 150, 5, 112, 0, 0, 143, 144, 5, 110, 0, 0, 144, 145, 5, 117, 0, 0, 145, 146, 5, 109, 0, 0, 146, 147, 5, 98, 0, 0, 147, 148, 5, 101, 0, 0, 148, 150, 5, 114, 0, 0, 149, 134, 1, 0, 0, 0, 149, 143, 1, 0, 0, 0, 150, 42, 1, 0, 0, 0, 151, 152, 5, 109, 0, 0, 152, 153, 5, 115, 0, 0, 153, 154, 5, 103, 0, 0, 154, 155, 5, 46, 0, 0, 155, 156, 1, 0, 0, 0, 156, 157, 5, 115, 0, 0, 157, 158, 5, 101, 0, 0, 158, 159, 5, 110, 0, 0, 159, 160, 5, 100, 0, 0, 160, 161, 5, 101, 0, 0, 161, 162, 5, 114, 0, 0, 162, 44, 1, 0, 0, 0, 163, 174, 5, 60, 0, 0, 164, 165, 5, 60, 0, 0, 165, 174, 5, 61, 0, 0, 166, 174, 5, 62, 0, 0, 167, 168, 5, 62, 0, 0, 168, 174, 5, 61, 0, 0, 169, 170, 5, 61, 0, 0, 170, 174, 5, 61, 0, 0, 171, 172, 5, 33, 0, 0, 172, 174, 5, 61, 0, 0, 173, 163, 1, 0, 0, 0, 173, 164, 1, 0, 0, 0, 173, 166, 1, 0, 0, 0, 173, 167, 1, 0, 0, 0, 173, 169, 1, 0, 0, 0, 173, 171, 1, 0, 0, 0, 174, 46, 1, 0, 0, 0, 175, 177, 7, 4, 0, 0, 176, 175, 1, 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 178, 179, 1, 0, 0, 0, 179, 180, 1, 0, 0, 0, 180, 181, 6, 23, 0, 0, 181, 48, 1, 0, 0, 0, 8, 0, 84, 89, 97, 103, 149, 173, 178, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/kontrol/solidity/SolidityLexer.py b/src/kontrol/solidity/SolidityLexer.py index fa775ebd2..35909f86d 100644 --- a/src/kontrol/solidity/SolidityLexer.py +++ b/src/kontrol/solidity/SolidityLexer.py @@ -14,8 +14,8 @@ def serializedATN(): return [ 4, 0, - 23, - 189, + 24, + 182, 6, -1, 2, @@ -110,6 +110,10 @@ def serializedATN(): 22, 7, 22, + 2, + 23, + 7, + 23, 1, 0, 1, @@ -155,88 +159,48 @@ def serializedATN(): 1, 9, 1, - 9, - 1, - 9, - 1, - 9, - 1, - 9, - 1, - 9, - 1, - 9, - 1, - 9, - 3, - 9, - 77, - 8, - 9, - 1, - 10, - 4, - 10, - 80, - 8, - 10, - 11, 10, - 12, + 1, 10, - 81, 1, 11, 1, 11, 1, - 11, + 12, 1, - 11, - 4, - 11, - 88, - 8, - 11, - 11, - 11, 12, - 11, - 89, 1, 12, 1, 12, - 5, + 1, 12, - 94, - 8, + 1, 12, - 10, + 1, 12, + 1, 12, + 1, 12, - 97, - 9, + 3, + 12, + 85, + 8, 12, 1, 13, - 1, - 13, - 1, - 13, - 1, - 13, - 1, - 13, - 1, + 4, 13, - 1, + 88, + 8, 13, - 1, + 11, 13, - 1, + 12, 13, + 89, 1, 14, 1, @@ -245,56 +209,50 @@ def serializedATN(): 14, 1, 14, - 1, + 4, + 14, + 96, + 8, + 14, + 11, 14, + 12, + 14, + 97, 1, 15, 1, 15, - 1, + 5, 15, - 1, + 102, + 8, 15, - 1, + 10, + 15, + 12, + 15, + 105, + 9, 15, 1, 16, 1, 16, 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, + 16, 1, - 17, + 16, 1, - 17, + 16, 1, - 17, + 16, 1, - 17, + 16, 1, - 17, + 16, 1, - 17, + 16, 1, 17, 1, @@ -305,11 +263,6 @@ def serializedATN(): 17, 1, 17, - 3, - 17, - 142, - 8, - 17, 1, 18, 1, @@ -321,27 +274,27 @@ def serializedATN(): 1, 18, 1, - 18, + 19, 1, - 18, + 19, 1, - 18, + 20, 1, - 18, + 20, 1, - 18, + 20, 1, - 18, + 20, 1, - 18, + 20, 1, - 19, + 20, 1, - 19, + 20, 1, - 19, + 20, 1, - 19, + 20, 1, 20, 1, @@ -356,15 +309,23 @@ def serializedATN(): 20, 1, 20, - 3, + 1, 20, - 167, - 8, + 1, + 20, + 1, + 20, + 1, 20, 1, 20, 1, 20, + 3, + 20, + 150, + 8, + 20, 1, 21, 1, @@ -385,30 +346,54 @@ def serializedATN(): 21, 1, 21, - 3, + 1, 21, - 181, - 8, + 1, 21, 1, 22, - 4, + 1, 22, - 184, - 8, + 1, 22, - 11, + 1, 22, - 12, + 1, + 22, + 1, + 22, + 1, + 22, + 1, 22, - 185, 1, 22, 1, 22, + 3, + 22, + 174, + 8, + 22, + 1, + 23, + 4, + 23, + 177, + 8, + 23, + 11, + 23, + 12, + 23, + 178, + 1, + 23, + 1, + 23, 0, 0, - 23, + 24, 1, 1, 3, @@ -455,6 +440,8 @@ def serializedATN(): 22, 45, 23, + 47, + 24, 1, 0, 5, @@ -496,7 +483,7 @@ def serializedATN(): 13, 32, 32, - 201, + 192, 0, 1, 1, @@ -635,188 +622,188 @@ def serializedATN(): 0, 0, 0, - 1, + 0, 47, 1, 0, 0, 0, + 1, + 49, + 1, + 0, + 0, + 0, 3, - 50, + 52, 1, 0, 0, 0, 5, - 53, + 55, 1, 0, 0, 0, 7, - 55, + 57, 1, 0, 0, 0, 9, - 57, + 59, 1, 0, 0, 0, 11, - 59, + 61, 1, 0, 0, 0, 13, - 61, + 63, 1, 0, 0, 0, 15, - 63, + 65, 1, 0, 0, 0, 17, - 65, + 67, 1, 0, 0, 0, 19, - 76, + 69, 1, 0, 0, 0, 21, - 79, + 71, 1, 0, 0, 0, 23, - 83, + 73, 1, 0, 0, 0, 25, - 91, + 84, 1, 0, 0, 0, 27, - 98, + 87, 1, 0, 0, 0, 29, - 107, + 91, 1, 0, 0, 0, 31, - 112, + 99, 1, 0, 0, 0, 33, - 117, + 106, 1, 0, 0, 0, 35, - 119, + 115, 1, 0, 0, 0, 37, - 143, + 120, 1, 0, 0, 0, 39, - 155, + 125, 1, 0, 0, 0, 41, - 159, + 127, 1, 0, 0, 0, 43, - 180, + 151, 1, 0, 0, 0, 45, - 183, + 173, 1, 0, 0, 0, 47, - 48, - 5, - 38, + 176, + 1, + 0, 0, 0, - 48, 49, + 50, 5, 38, 0, 0, - 49, - 2, - 1, - 0, - 0, - 0, 50, 51, 5, - 124, + 38, 0, 0, 51, - 52, - 5, - 124, + 2, + 1, 0, 0, - 52, - 4, - 1, 0, + 52, + 53, + 5, + 124, 0, 0, 53, 54, 5, - 33, + 124, 0, 0, 54, - 6, + 4, 1, 0, 0, @@ -824,11 +811,11 @@ def serializedATN(): 55, 56, 5, - 40, + 33, 0, 0, 56, - 8, + 6, 1, 0, 0, @@ -836,11 +823,11 @@ def serializedATN(): 57, 58, 5, - 41, + 40, 0, 0, 58, - 10, + 8, 1, 0, 0, @@ -848,11 +835,11 @@ def serializedATN(): 59, 60, 5, - 43, + 41, 0, 0, 60, - 12, + 10, 1, 0, 0, @@ -860,11 +847,11 @@ def serializedATN(): 61, 62, 5, - 45, + 43, 0, 0, 62, - 14, + 12, 1, 0, 0, @@ -872,11 +859,11 @@ def serializedATN(): 63, 64, 5, - 42, + 45, 0, 0, 64, - 16, + 14, 1, 0, 0, @@ -884,11 +871,11 @@ def serializedATN(): 65, 66, 5, - 47, + 42, 0, 0, 66, - 18, + 16, 1, 0, 0, @@ -896,125 +883,119 @@ def serializedATN(): 67, 68, 5, - 116, + 47, 0, 0, 68, - 69, - 5, - 114, + 18, + 1, + 0, 0, 0, 69, 70, 5, - 117, + 46, 0, 0, 70, - 77, - 5, - 101, + 20, + 1, + 0, 0, 0, 71, 72, 5, - 102, + 91, 0, 0, 72, - 73, - 5, - 97, + 22, + 1, + 0, 0, 0, 73, 74, 5, - 108, + 93, 0, 0, 74, - 75, - 5, - 115, - 0, + 24, + 1, 0, - 75, - 77, - 5, - 101, 0, 0, + 75, 76, - 67, - 1, - 0, + 5, + 116, 0, 0, 76, - 71, - 1, - 0, + 77, + 5, + 114, 0, 0, 77, - 20, - 1, - 0, + 78, + 5, + 117, 0, 0, 78, - 80, - 7, - 0, + 85, + 5, + 101, 0, 0, 79, - 78, - 1, - 0, + 80, + 5, + 102, 0, 0, 80, 81, - 1, - 0, + 5, + 97, 0, 0, 81, - 79, - 1, - 0, + 82, + 5, + 108, 0, 0, - 81, 82, - 1, + 83, + 5, + 115, 0, 0, + 83, + 85, + 5, + 101, 0, - 82, - 22, + 0, + 84, + 75, 1, 0, 0, 0, - 83, 84, - 5, - 48, - 0, + 79, + 1, 0, - 84, - 85, - 5, - 120, 0, 0, 85, - 87, + 26, 1, 0, 0, @@ -1022,7 +1003,7 @@ def serializedATN(): 86, 88, 7, - 1, + 0, 0, 0, 87, @@ -1050,669 +1031,620 @@ def serializedATN(): 0, 0, 90, - 24, + 28, 1, 0, 0, 0, 91, - 95, - 7, - 2, + 92, + 5, + 48, 0, 0, 92, - 94, - 7, - 3, + 93, + 5, + 120, 0, 0, 93, - 92, + 95, 1, 0, 0, 0, 94, - 97, + 96, + 7, 1, 0, 0, - 0, 95, - 93, + 94, 1, 0, 0, 0, - 95, 96, + 97, 1, 0, 0, 0, - 96, - 26, + 97, + 95, 1, 0, 0, 0, 97, - 95, + 98, 1, 0, 0, 0, 98, - 99, - 3, - 25, - 12, + 30, + 1, + 0, + 0, 0, 99, - 100, - 5, - 46, + 103, + 7, + 2, 0, 0, 100, - 101, - 5, - 108, + 102, + 7, + 3, 0, 0, 101, - 102, - 5, - 101, + 100, + 1, + 0, 0, 0, 102, - 103, - 5, - 110, + 105, + 1, + 0, 0, 0, 103, - 104, - 5, - 103, + 101, + 1, 0, 0, + 0, + 103, 104, - 105, - 5, - 116, + 1, + 0, 0, 0, - 105, - 106, - 5, 104, + 32, + 1, 0, 0, - 106, - 28, + 0, + 105, + 103, 1, 0, 0, 0, + 106, 107, - 108, 3, - 25, - 12, + 31, + 15, + 0, + 107, + 108, + 5, + 46, + 0, 0, 108, 109, 5, - 91, + 108, 0, 0, 109, 110, - 3, - 21, - 10, + 5, + 101, + 0, 0, 110, 111, 5, - 93, + 110, 0, 0, 111, - 30, - 1, - 0, + 112, + 5, + 103, 0, 0, 112, 113, - 3, - 25, - 12, + 5, + 116, + 0, 0, 113, 114, 5, - 91, + 104, 0, 0, 114, - 115, - 3, - 25, - 12, + 34, + 1, 0, - 115, - 116, - 5, - 93, 0, 0, + 115, 116, - 32, - 1, + 3, + 31, + 15, 0, + 116, + 117, + 5, + 91, 0, 0, 117, 118, 3, - 23, - 11, + 27, + 13, 0, 118, - 34, - 1, - 0, + 119, + 5, + 93, 0, 0, 119, - 120, - 5, - 98, + 36, + 1, + 0, 0, 0, 120, 121, - 5, - 108, - 0, + 3, + 31, + 15, 0, 121, 122, 5, - 111, + 91, 0, 0, 122, 123, - 5, - 99, - 0, + 3, + 31, + 15, 0, 123, 124, 5, - 107, + 93, 0, 0, 124, - 125, - 5, - 46, - 0, - 0, - 125, - 141, + 38, 1, 0, 0, 0, + 125, 126, - 127, - 5, - 116, + 3, + 29, + 14, + 0, + 126, + 40, + 1, + 0, 0, 0, 127, 128, 5, - 105, + 98, 0, 0, 128, 129, 5, - 109, + 108, 0, 0, 129, 130, 5, - 101, + 111, 0, 0, 130, 131, 5, - 115, + 99, 0, 0, 131, 132, 5, - 116, + 107, 0, 0, 132, 133, 5, - 97, + 46, 0, 0, 133, - 134, - 5, - 109, + 149, + 1, + 0, 0, 0, 134, - 142, + 135, 5, - 112, + 116, 0, 0, 135, 136, 5, - 110, + 105, 0, 0, 136, 137, 5, - 117, + 109, 0, 0, 137, 138, 5, - 109, + 101, 0, 0, 138, 139, 5, - 98, + 115, 0, 0, 139, 140, 5, - 101, + 116, 0, 0, 140, - 142, - 5, - 114, - 0, - 0, 141, - 126, - 1, - 0, + 5, + 97, 0, 0, 141, - 135, - 1, - 0, + 142, + 5, + 109, 0, 0, 142, - 36, - 1, - 0, + 150, + 5, + 112, 0, 0, 143, 144, 5, - 109, + 110, 0, 0, 144, 145, 5, - 115, + 117, 0, 0, 145, 146, 5, - 103, + 109, 0, 0, 146, 147, 5, - 46, + 98, 0, 0, 147, 148, - 1, - 0, + 5, + 101, 0, 0, 148, - 149, + 150, 5, - 115, + 114, 0, 0, 149, - 150, - 5, - 101, + 134, + 1, + 0, + 0, + 0, + 149, + 143, + 1, + 0, 0, 0, 150, - 151, - 5, - 110, + 42, + 1, + 0, 0, 0, 151, 152, 5, - 100, + 109, 0, 0, 152, 153, 5, - 101, + 115, 0, 0, 153, 154, 5, - 114, + 103, 0, 0, 154, - 38, - 1, - 0, + 155, + 5, + 46, 0, 0, 155, 156, - 3, - 25, - 12, + 1, + 0, + 0, 0, 156, 157, 5, - 46, + 115, 0, 0, 157, 158, - 3, - 25, - 12, + 5, + 101, 0, - 158, - 40, - 1, 0, + 158, + 159, + 5, + 110, 0, 0, 159, 160, - 3, - 25, - 12, + 5, + 100, + 0, 0, 160, 161, 5, - 46, + 101, 0, 0, 161, 162, - 3, - 25, - 12, - 0, - 162, - 166, 5, - 91, - 0, - 0, - 163, - 167, - 3, - 25, - 12, - 0, - 164, - 167, - 3, - 21, - 10, - 0, - 165, - 167, - 3, - 23, - 11, - 0, - 166, - 163, - 1, - 0, - 0, - 0, - 166, - 164, - 1, - 0, - 0, - 0, - 166, - 165, - 1, - 0, - 0, - 0, - 167, - 168, - 1, - 0, - 0, - 0, - 168, - 169, - 5, - 93, + 114, 0, 0, - 169, - 42, + 162, + 44, 1, 0, 0, 0, - 170, - 181, + 163, + 174, 5, 60, 0, 0, - 171, - 172, + 164, + 165, 5, 60, 0, 0, - 172, - 181, + 165, + 174, 5, 61, 0, 0, - 173, - 181, + 166, + 174, 5, 62, 0, 0, - 174, - 175, + 167, + 168, 5, 62, 0, 0, - 175, - 181, + 168, + 174, 5, 61, 0, 0, - 176, - 177, + 169, + 170, 5, 61, 0, 0, - 177, - 181, + 170, + 174, 5, 61, 0, 0, - 178, - 179, + 171, + 172, 5, 33, 0, 0, - 179, - 181, + 172, + 174, 5, 61, 0, 0, - 180, - 170, + 173, + 163, 1, 0, 0, 0, - 180, - 171, + 173, + 164, 1, 0, 0, 0, - 180, 173, + 166, 1, 0, 0, 0, - 180, - 174, + 173, + 167, 1, 0, 0, 0, - 180, - 176, + 173, + 169, 1, 0, 0, 0, - 180, - 178, + 173, + 171, 1, 0, 0, 0, - 181, - 44, + 174, + 46, 1, 0, 0, 0, - 182, - 184, + 175, + 177, 7, 4, 0, 0, - 183, - 182, + 176, + 175, 1, 0, 0, 0, - 184, - 185, + 177, + 178, 1, 0, 0, 0, - 185, - 183, + 178, + 176, 1, 0, 0, 0, - 185, - 186, + 178, + 179, 1, 0, 0, 0, - 186, - 187, + 179, + 180, 1, 0, 0, 0, - 187, - 188, + 180, + 181, 6, - 22, + 23, 0, 0, - 188, - 46, + 181, + 48, 1, 0, 0, 0, - 9, + 8, 0, - 76, - 81, + 84, 89, - 95, - 141, - 166, - 180, - 185, + 97, + 103, + 149, + 173, + 178, 1, 6, 0, @@ -1735,26 +1667,27 @@ class SolidityLexer(Lexer): T__6 = 7 T__7 = 8 T__8 = 9 - BOOLEAN_LITERAL = 10 - INTEGER = 11 - ADDRESS = 12 - VariableName = 13 - LengthAccess = 14 - ArrayElement = 15 - MappingElement = 16 - AddressLiteral = 17 - BlockAccess = 18 - MsgAccess = 19 - ContractVariableAccess = 20 - ContractVariableArrayElement = 21 - RelOp = 22 - WS = 23 + T__9 = 10 + T__10 = 11 + T__11 = 12 + BOOLEAN_LITERAL = 13 + INTEGER = 14 + ADDRESS = 15 + VariableName = 16 + LengthAccess = 17 + ArrayElement = 18 + MappingElement = 19 + AddressLiteral = 20 + BlockAccess = 21 + MsgAccess = 22 + RelOp = 23 + WS = 24 channelNames = [u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN"] modeNames = ["DEFAULT_MODE"] - literalNames = ["", "'&&'", "'||'", "'!'", "'('", "')'", "'+'", "'-'", "'*'", "'/'"] + literalNames = ["", "'&&'", "'||'", "'!'", "'('", "')'", "'+'", "'-'", "'*'", "'/'", "'.'", "'['", "']'"] symbolicNames = [ "", @@ -1768,8 +1701,6 @@ class SolidityLexer(Lexer): "AddressLiteral", "BlockAccess", "MsgAccess", - "ContractVariableAccess", - "ContractVariableArrayElement", "RelOp", "WS", ] @@ -1784,6 +1715,9 @@ class SolidityLexer(Lexer): "T__6", "T__7", "T__8", + "T__9", + "T__10", + "T__11", "BOOLEAN_LITERAL", "INTEGER", "ADDRESS", @@ -1794,8 +1728,6 @@ class SolidityLexer(Lexer): "AddressLiteral", "BlockAccess", "MsgAccess", - "ContractVariableAccess", - "ContractVariableArrayElement", "RelOp", "WS", ] diff --git a/src/kontrol/solidity/SolidityLexer.tokens b/src/kontrol/solidity/SolidityLexer.tokens index dc4b88e6b..3a8d82041 100644 --- a/src/kontrol/solidity/SolidityLexer.tokens +++ b/src/kontrol/solidity/SolidityLexer.tokens @@ -7,20 +7,21 @@ T__5=6 T__6=7 T__7=8 T__8=9 -BOOLEAN_LITERAL=10 -INTEGER=11 -ADDRESS=12 -VariableName=13 -LengthAccess=14 -ArrayElement=15 -MappingElement=16 -AddressLiteral=17 -BlockAccess=18 -MsgAccess=19 -ContractVariableAccess=20 -ContractVariableArrayElement=21 -RelOp=22 -WS=23 +T__9=10 +T__10=11 +T__11=12 +BOOLEAN_LITERAL=13 +INTEGER=14 +ADDRESS=15 +VariableName=16 +LengthAccess=17 +ArrayElement=18 +MappingElement=19 +AddressLiteral=20 +BlockAccess=21 +MsgAccess=22 +RelOp=23 +WS=24 '&&'=1 '||'=2 '!'=3 @@ -30,3 +31,6 @@ WS=23 '-'=7 '*'=8 '/'=9 +'.'=10 +'['=11 +']'=12 diff --git a/src/kontrol/solidity/SolidityListener.py b/src/kontrol/solidity/SolidityListener.py index 0161baadf..99cd558aa 100644 --- a/src/kontrol/solidity/SolidityListener.py +++ b/src/kontrol/solidity/SolidityListener.py @@ -194,5 +194,21 @@ def enterContractVariableArrayElement(self, ctx: SolidityParser.ContractVariable def exitContractVariableArrayElement(self, ctx: SolidityParser.ContractVariableArrayElementContext): pass + # Enter a parse tree produced by SolidityParser#contractVariableAccessExpr. + def enterContractVariableAccessExpr(self, ctx: SolidityParser.ContractVariableAccessExprContext): + pass + + # Exit a parse tree produced by SolidityParser#contractVariableAccessExpr. + def exitContractVariableAccessExpr(self, ctx: SolidityParser.ContractVariableAccessExprContext): + pass + + # Enter a parse tree produced by SolidityParser#contractVariableArrayElemExpr. + def enterContractVariableArrayElemExpr(self, ctx: SolidityParser.ContractVariableArrayElemExprContext): + pass + + # Exit a parse tree produced by SolidityParser#contractVariableArrayElemExpr. + def exitContractVariableArrayElemExpr(self, ctx: SolidityParser.ContractVariableArrayElemExprContext): + pass + del SolidityParser diff --git a/src/kontrol/solidity/SolidityParser.py b/src/kontrol/solidity/SolidityParser.py index a665d48bb..57b0a664b 100644 --- a/src/kontrol/solidity/SolidityParser.py +++ b/src/kontrol/solidity/SolidityParser.py @@ -15,8 +15,8 @@ def serializedATN(): return [ 4, 1, - 23, - 72, + 24, + 87, 2, 0, 7, @@ -33,6 +33,14 @@ def serializedATN(): 3, 7, 3, + 2, + 4, + 7, + 4, + 2, + 5, + 7, + 5, 1, 0, 1, @@ -63,7 +71,7 @@ def serializedATN(): 1, 3, 1, - 23, + 27, 8, 1, 1, @@ -80,14 +88,14 @@ def serializedATN(): 1, 5, 1, - 31, + 35, 8, 1, 10, 1, 12, 1, - 34, + 38, 9, 1, 1, @@ -122,14 +130,14 @@ def serializedATN(): 2, 5, 2, - 51, + 55, 8, 2, 10, 2, 12, 2, - 54, + 58, 9, 2, 1, @@ -162,546 +170,652 @@ def serializedATN(): 3, 3, 3, - 70, + 74, 8, 3, 1, - 3, + 4, + 1, + 4, + 1, + 4, + 1, + 4, + 1, + 5, + 1, + 5, + 1, + 5, + 1, + 5, + 1, + 5, + 1, + 5, + 1, + 5, + 1, + 5, 0, 2, 2, 4, - 4, + 6, 0, 2, 4, 6, + 8, + 10, 0, + 1, + 1, 0, - 86, + 14, + 16, + 99, 0, - 8, + 12, 1, 0, 0, 0, 2, - 22, + 26, 1, 0, 0, 0, 4, - 35, + 39, 1, 0, 0, 0, 6, - 69, + 73, 1, 0, 0, 0, 8, - 9, + 75, + 1, + 0, + 0, + 0, + 10, + 79, + 1, + 0, + 0, + 0, + 12, + 13, 3, 2, 1, 0, - 9, + 13, 1, 1, 0, 0, 0, - 10, - 11, + 14, + 15, 6, 1, -1, 0, - 11, - 12, + 15, + 16, 5, 3, 0, 0, - 12, - 23, + 16, + 27, 3, 2, 1, 4, - 13, - 14, + 17, + 18, 3, 4, 2, 0, - 14, - 15, + 18, + 19, 5, - 22, + 23, 0, 0, - 15, - 16, + 19, + 20, 3, 4, 2, 0, - 16, - 23, + 20, + 27, 1, 0, 0, 0, - 17, - 23, + 21, + 27, 5, - 10, + 13, 0, 0, - 18, - 19, + 22, + 23, 5, 4, 0, 0, - 19, - 20, + 23, + 24, 3, 2, 1, 0, - 20, - 21, + 24, + 25, 5, 5, 0, 0, - 21, - 23, + 25, + 27, 1, 0, 0, 0, - 22, - 10, + 26, + 14, 1, 0, 0, 0, - 22, - 13, + 26, + 17, 1, 0, 0, 0, - 22, - 17, + 26, + 21, 1, 0, 0, 0, + 26, 22, - 18, 1, 0, 0, 0, - 23, - 32, + 27, + 36, 1, 0, 0, 0, - 24, - 25, + 28, + 29, 10, 6, 0, 0, - 25, - 26, + 29, + 30, 5, 1, 0, 0, - 26, - 31, + 30, + 35, 3, 2, 1, 7, - 27, - 28, + 31, + 32, 10, 5, 0, 0, - 28, - 29, + 32, + 33, 5, 2, 0, 0, - 29, - 31, + 33, + 35, 3, 2, 1, 6, - 30, - 24, + 34, + 28, 1, 0, 0, 0, - 30, - 27, + 34, + 31, 1, 0, 0, 0, - 31, - 34, + 35, + 38, 1, 0, 0, 0, - 32, - 30, + 36, + 34, 1, 0, 0, 0, - 32, - 33, + 36, + 37, 1, 0, 0, 0, - 33, + 37, 3, 1, 0, 0, 0, - 34, - 32, + 38, + 36, 1, 0, 0, 0, - 35, - 36, + 39, + 40, 6, 2, -1, 0, - 36, - 37, + 40, + 41, 3, 6, 3, 0, - 37, - 52, + 41, + 56, 1, 0, 0, 0, - 38, - 39, + 42, + 43, 10, 5, 0, 0, - 39, - 40, + 43, + 44, 5, 6, 0, 0, - 40, - 51, + 44, + 55, 3, 4, 2, 6, - 41, - 42, + 45, + 46, 10, 4, 0, 0, - 42, - 43, + 46, + 47, 5, 7, 0, 0, - 43, - 51, + 47, + 55, 3, 4, 2, 5, - 44, - 45, + 48, + 49, 10, 3, 0, 0, - 45, - 46, + 49, + 50, 5, 8, 0, 0, - 46, - 51, + 50, + 55, 3, 4, 2, 4, - 47, - 48, + 51, + 52, 10, 2, 0, 0, - 48, - 49, + 52, + 53, 5, 9, 0, 0, - 49, - 51, + 53, + 55, 3, 4, 2, 3, - 50, - 38, + 54, + 42, 1, 0, 0, 0, - 50, - 41, + 54, + 45, 1, 0, 0, 0, - 50, - 44, + 54, + 48, 1, 0, 0, 0, - 50, - 47, + 54, + 51, 1, 0, 0, 0, - 51, - 54, + 55, + 58, 1, 0, 0, 0, - 52, - 50, + 56, + 54, 1, 0, 0, 0, - 52, - 53, + 56, + 57, 1, 0, 0, 0, - 53, + 57, 5, 1, 0, 0, 0, - 54, - 52, + 58, + 56, 1, 0, 0, 0, - 55, - 70, + 59, + 74, 5, - 13, + 16, 0, 0, - 56, - 70, + 60, + 74, 5, - 14, + 17, 0, 0, - 57, - 70, + 61, + 74, 5, - 15, + 18, 0, 0, - 58, - 70, + 62, + 74, 5, - 16, + 19, 0, 0, - 59, - 70, + 63, + 74, 5, - 17, + 20, 0, 0, - 60, - 70, + 64, + 74, 5, - 11, + 14, 0, 0, - 61, - 62, + 65, + 66, 5, 4, 0, 0, - 62, - 63, + 66, + 67, 3, 4, 2, 0, - 63, - 64, + 67, + 68, 5, 5, 0, 0, - 64, - 70, + 68, + 74, 1, 0, 0, 0, - 65, - 70, + 69, + 74, 5, - 18, + 21, 0, 0, - 66, 70, + 74, 5, - 19, + 22, 0, 0, - 67, - 70, + 71, + 74, + 3, + 8, + 4, + 0, + 72, + 74, + 3, + 10, 5, - 20, 0, + 73, + 59, + 1, 0, - 68, - 70, - 5, - 21, 0, 0, - 69, - 55, + 73, + 60, 1, 0, 0, 0, - 69, - 56, + 73, + 61, 1, 0, 0, 0, - 69, - 57, + 73, + 62, 1, 0, 0, 0, - 69, - 58, + 73, + 63, 1, 0, 0, 0, - 69, - 59, + 73, + 64, 1, 0, 0, 0, - 69, - 60, + 73, + 65, 1, 0, 0, 0, + 73, 69, - 61, 1, 0, 0, 0, - 69, - 65, + 73, + 70, 1, 0, 0, 0, - 69, - 66, + 73, + 71, 1, 0, 0, 0, - 69, - 67, + 73, + 72, 1, 0, 0, 0, - 69, - 68, + 74, + 7, 1, 0, 0, 0, - 70, + 75, + 76, + 5, + 16, + 0, + 0, + 76, + 77, + 5, + 10, + 0, + 0, + 77, + 78, + 5, + 16, + 0, + 0, + 78, + 9, + 1, + 0, + 0, + 0, + 79, + 80, + 5, + 16, + 0, + 0, + 80, + 81, + 5, + 10, + 0, + 0, + 81, + 82, + 5, + 16, + 0, + 0, + 82, + 83, + 5, + 11, + 0, + 0, + 83, + 84, 7, + 0, + 0, + 0, + 84, + 85, + 5, + 12, + 0, + 0, + 85, + 11, 1, 0, 0, 0, 6, - 22, - 30, - 32, - 50, - 52, - 69, + 26, + 34, + 36, + 54, + 56, + 73, ] @@ -715,7 +829,7 @@ class SolidityParser(Parser): sharedContextCache = PredictionContextCache() - literalNames = ["", "'&&'", "'||'", "'!'", "'('", "')'", "'+'", "'-'", "'*'", "'/'"] + literalNames = ["", "'&&'", "'||'", "'!'", "'('", "')'", "'+'", "'-'", "'*'", "'/'", "'.'", "'['", "']'"] symbolicNames = [ "", @@ -728,6 +842,9 @@ class SolidityParser(Parser): "", "", "", + "", + "", + "", "BOOLEAN_LITERAL", "INTEGER", "ADDRESS", @@ -738,8 +855,6 @@ class SolidityParser(Parser): "AddressLiteral", "BlockAccess", "MsgAccess", - "ContractVariableAccess", - "ContractVariableArrayElement", "RelOp", "WS", ] @@ -748,8 +863,17 @@ class SolidityParser(Parser): RULE_booleanExpression = 1 RULE_arithmeticExpression = 2 RULE_atom = 3 - - ruleNames = ["expression", "booleanExpression", "arithmeticExpression", "atom"] + RULE_contractVariableAccessExpr = 4 + RULE_contractVariableArrayElemExpr = 5 + + ruleNames = [ + "expression", + "booleanExpression", + "arithmeticExpression", + "atom", + "contractVariableAccessExpr", + "contractVariableArrayElemExpr", + ] EOF = Token.EOF T__0 = 1 @@ -761,20 +885,21 @@ class SolidityParser(Parser): T__6 = 7 T__7 = 8 T__8 = 9 - BOOLEAN_LITERAL = 10 - INTEGER = 11 - ADDRESS = 12 - VariableName = 13 - LengthAccess = 14 - ArrayElement = 15 - MappingElement = 16 - AddressLiteral = 17 - BlockAccess = 18 - MsgAccess = 19 - ContractVariableAccess = 20 - ContractVariableArrayElement = 21 - RelOp = 22 - WS = 23 + T__9 = 10 + T__10 = 11 + T__11 = 12 + BOOLEAN_LITERAL = 13 + INTEGER = 14 + ADDRESS = 15 + VariableName = 16 + LengthAccess = 17 + ArrayElement = 18 + MappingElement = 19 + AddressLiteral = 20 + BlockAccess = 21 + MsgAccess = 22 + RelOp = 23 + WS = 24 def __init__(self, input: TokenStream, output: TextIO = sys.stdout): super().__init__(input, output) @@ -815,7 +940,7 @@ def expression(self): self.enterRule(localctx, 0, self.RULE_expression) try: self.enterOuterAlt(localctx, 1) - self.state = 8 + self.state = 12 self.booleanExpression(0) except RecognitionException as re: localctx.exception = re @@ -997,7 +1122,7 @@ def booleanExpression(self, _p: int = 0): self.enterRecursionRule(localctx, 2, self.RULE_booleanExpression, _p) try: self.enterOuterAlt(localctx, 1) - self.state = 22 + self.state = 26 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input, 0, self._ctx) if la_ == 1: @@ -1005,9 +1130,9 @@ def booleanExpression(self, _p: int = 0): self._ctx = localctx _prevctx = localctx - self.state = 11 + self.state = 15 self.match(SolidityParser.T__2) - self.state = 12 + self.state = 16 self.booleanExpression(4) pass @@ -1015,11 +1140,11 @@ def booleanExpression(self, _p: int = 0): localctx = SolidityParser.RelationalExpressionContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 13 + self.state = 17 self.arithmeticExpression(0) - self.state = 14 + self.state = 18 self.match(SolidityParser.RelOp) - self.state = 15 + self.state = 19 self.arithmeticExpression(0) pass @@ -1027,7 +1152,7 @@ def booleanExpression(self, _p: int = 0): localctx = SolidityParser.BooleanLiteralContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 17 + self.state = 21 self.match(SolidityParser.BOOLEAN_LITERAL) pass @@ -1035,16 +1160,16 @@ def booleanExpression(self, _p: int = 0): localctx = SolidityParser.ParenthesizedBooleanExpressionContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 18 + self.state = 22 self.match(SolidityParser.T__3) - self.state = 19 + self.state = 23 self.booleanExpression(0) - self.state = 20 + self.state = 24 self.match(SolidityParser.T__4) pass self._ctx.stop = self._input.LT(-1) - self.state = 32 + self.state = 36 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input, 2, self._ctx) while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER: @@ -1052,7 +1177,7 @@ def booleanExpression(self, _p: int = 0): if self._parseListeners is not None: self.triggerExitRuleEvent() _prevctx = localctx - self.state = 30 + self.state = 34 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input, 1, self._ctx) if la_ == 1: @@ -1060,14 +1185,14 @@ def booleanExpression(self, _p: int = 0): self, SolidityParser.BooleanExpressionContext(self, _parentctx, _parentState) ) self.pushNewRecursionContext(localctx, _startState, self.RULE_booleanExpression) - self.state = 24 + self.state = 28 if not self.precpred(self._ctx, 6): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 6)") - self.state = 25 + self.state = 29 self.match(SolidityParser.T__0) - self.state = 26 + self.state = 30 self.booleanExpression(7) pass @@ -1076,18 +1201,18 @@ def booleanExpression(self, _p: int = 0): self, SolidityParser.BooleanExpressionContext(self, _parentctx, _parentState) ) self.pushNewRecursionContext(localctx, _startState, self.RULE_booleanExpression) - self.state = 27 + self.state = 31 if not self.precpred(self._ctx, 5): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 5)") - self.state = 28 + self.state = 32 self.match(SolidityParser.T__1) - self.state = 29 + self.state = 33 self.booleanExpression(6) pass - self.state = 34 + self.state = 38 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input, 2, self._ctx) @@ -1252,10 +1377,10 @@ def arithmeticExpression(self, _p: int = 0): self._ctx = localctx _prevctx = localctx - self.state = 36 + self.state = 40 self.atom() self._ctx.stop = self._input.LT(-1) - self.state = 52 + self.state = 56 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input, 4, self._ctx) while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER: @@ -1263,7 +1388,7 @@ def arithmeticExpression(self, _p: int = 0): if self._parseListeners is not None: self.triggerExitRuleEvent() _prevctx = localctx - self.state = 50 + self.state = 54 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input, 3, self._ctx) if la_ == 1: @@ -1271,14 +1396,14 @@ def arithmeticExpression(self, _p: int = 0): self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) ) self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) - self.state = 38 + self.state = 42 if not self.precpred(self._ctx, 5): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 5)") - self.state = 39 + self.state = 43 self.match(SolidityParser.T__5) - self.state = 40 + self.state = 44 self.arithmeticExpression(6) pass @@ -1287,14 +1412,14 @@ def arithmeticExpression(self, _p: int = 0): self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) ) self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) - self.state = 41 + self.state = 45 if not self.precpred(self._ctx, 4): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 4)") - self.state = 42 + self.state = 46 self.match(SolidityParser.T__6) - self.state = 43 + self.state = 47 self.arithmeticExpression(5) pass @@ -1303,14 +1428,14 @@ def arithmeticExpression(self, _p: int = 0): self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) ) self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) - self.state = 44 + self.state = 48 if not self.precpred(self._ctx, 3): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 3)") - self.state = 45 + self.state = 49 self.match(SolidityParser.T__7) - self.state = 46 + self.state = 50 self.arithmeticExpression(4) pass @@ -1319,18 +1444,18 @@ def arithmeticExpression(self, _p: int = 0): self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) ) self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) - self.state = 47 + self.state = 51 if not self.precpred(self._ctx, 2): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 2)") - self.state = 48 + self.state = 52 self.match(SolidityParser.T__8) - self.state = 49 + self.state = 53 self.arithmeticExpression(3) pass - self.state = 54 + self.state = 58 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input, 4, self._ctx) @@ -1407,8 +1532,8 @@ def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser super().__init__(parser) self.copyFrom(ctx) - def ContractVariableAccess(self): - return self.getToken(SolidityParser.ContractVariableAccess, 0) + def contractVariableAccessExpr(self): + return self.getTypedRuleContext(SolidityParser.ContractVariableAccessExprContext, 0) def enterRule(self, listener: ParseTreeListener): if hasattr(listener, "enterContractVariableAccess"): @@ -1522,8 +1647,8 @@ def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser super().__init__(parser) self.copyFrom(ctx) - def ContractVariableArrayElement(self): - return self.getToken(SolidityParser.ContractVariableArrayElement, 0) + def contractVariableArrayElemExpr(self): + return self.getTypedRuleContext(SolidityParser.ContractVariableArrayElemExprContext, 0) def enterRule(self, listener: ParseTreeListener): if hasattr(listener, "enterContractVariableArrayElement"): @@ -1613,82 +1738,208 @@ def atom(self): localctx = SolidityParser.AtomContext(self, self._ctx, self.state) self.enterRule(localctx, 6, self.RULE_atom) try: - self.state = 69 + self.state = 73 self._errHandler.sync(self) - token = self._input.LA(1) - if token in [13]: + la_ = self._interp.adaptivePredict(self._input, 5, self._ctx) + if la_ == 1: localctx = SolidityParser.VariableContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 55 + self.state = 59 self.match(SolidityParser.VariableName) pass - elif token in [14]: + + elif la_ == 2: localctx = SolidityParser.LengthAccessContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 56 + self.state = 60 self.match(SolidityParser.LengthAccess) pass - elif token in [15]: + + elif la_ == 3: localctx = SolidityParser.ArrayElementContext(self, localctx) self.enterOuterAlt(localctx, 3) - self.state = 57 + self.state = 61 self.match(SolidityParser.ArrayElement) pass - elif token in [16]: + + elif la_ == 4: localctx = SolidityParser.MappingElementContext(self, localctx) self.enterOuterAlt(localctx, 4) - self.state = 58 + self.state = 62 self.match(SolidityParser.MappingElement) pass - elif token in [17]: + + elif la_ == 5: localctx = SolidityParser.AddressLiteralContext(self, localctx) self.enterOuterAlt(localctx, 5) - self.state = 59 + self.state = 63 self.match(SolidityParser.AddressLiteral) pass - elif token in [11]: + + elif la_ == 6: localctx = SolidityParser.IntegerLiteralContext(self, localctx) self.enterOuterAlt(localctx, 6) - self.state = 60 + self.state = 64 self.match(SolidityParser.INTEGER) pass - elif token in [4]: + + elif la_ == 7: localctx = SolidityParser.ParenthesizedArithmeticExpressionContext(self, localctx) self.enterOuterAlt(localctx, 7) - self.state = 61 + self.state = 65 self.match(SolidityParser.T__3) - self.state = 62 + self.state = 66 self.arithmeticExpression(0) - self.state = 63 + self.state = 67 self.match(SolidityParser.T__4) pass - elif token in [18]: + + elif la_ == 8: localctx = SolidityParser.BlockAccessContext(self, localctx) self.enterOuterAlt(localctx, 8) - self.state = 65 + self.state = 69 self.match(SolidityParser.BlockAccess) pass - elif token in [19]: + + elif la_ == 9: localctx = SolidityParser.MsgAccessContext(self, localctx) self.enterOuterAlt(localctx, 9) - self.state = 66 + self.state = 70 self.match(SolidityParser.MsgAccess) pass - elif token in [20]: + + elif la_ == 10: localctx = SolidityParser.ContractVariableAccessContext(self, localctx) self.enterOuterAlt(localctx, 10) - self.state = 67 - self.match(SolidityParser.ContractVariableAccess) + self.state = 71 + self.contractVariableAccessExpr() pass - elif token in [21]: + + elif la_ == 11: localctx = SolidityParser.ContractVariableArrayElementContext(self, localctx) self.enterOuterAlt(localctx, 11) - self.state = 68 - self.match(SolidityParser.ContractVariableArrayElement) + self.state = 72 + self.contractVariableArrayElemExpr() pass + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ContractVariableAccessExprContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + super().__init__(parent, invokingState) + self.parser = parser + + def VariableName(self, i: int = None): + if i is None: + return self.getTokens(SolidityParser.VariableName) + else: + return self.getToken(SolidityParser.VariableName, i) + + def getRuleIndex(self): + return SolidityParser.RULE_contractVariableAccessExpr + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterContractVariableAccessExpr"): + listener.enterContractVariableAccessExpr(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitContractVariableAccessExpr"): + listener.exitContractVariableAccessExpr(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitContractVariableAccessExpr"): + return visitor.visitContractVariableAccessExpr(self) + else: + return visitor.visitChildren(self) + + def contractVariableAccessExpr(self): + + localctx = SolidityParser.ContractVariableAccessExprContext(self, self._ctx, self.state) + self.enterRule(localctx, 8, self.RULE_contractVariableAccessExpr) + try: + self.enterOuterAlt(localctx, 1) + self.state = 75 + self.match(SolidityParser.VariableName) + self.state = 76 + self.match(SolidityParser.T__9) + self.state = 77 + self.match(SolidityParser.VariableName) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ContractVariableArrayElemExprContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + super().__init__(parent, invokingState) + self.parser = parser + + def VariableName(self, i: int = None): + if i is None: + return self.getTokens(SolidityParser.VariableName) + else: + return self.getToken(SolidityParser.VariableName, i) + + def INTEGER(self): + return self.getToken(SolidityParser.INTEGER, 0) + + def ADDRESS(self): + return self.getToken(SolidityParser.ADDRESS, 0) + + def getRuleIndex(self): + return SolidityParser.RULE_contractVariableArrayElemExpr + + def enterRule(self, listener: ParseTreeListener): + if hasattr(listener, "enterContractVariableArrayElemExpr"): + listener.enterContractVariableArrayElemExpr(self) + + def exitRule(self, listener: ParseTreeListener): + if hasattr(listener, "exitContractVariableArrayElemExpr"): + listener.exitContractVariableArrayElemExpr(self) + + def accept(self, visitor: ParseTreeVisitor): + if hasattr(visitor, "visitContractVariableArrayElemExpr"): + return visitor.visitContractVariableArrayElemExpr(self) else: - raise NoViableAltException(self) + return visitor.visitChildren(self) + def contractVariableArrayElemExpr(self): + + localctx = SolidityParser.ContractVariableArrayElemExprContext(self, self._ctx, self.state) + self.enterRule(localctx, 10, self.RULE_contractVariableArrayElemExpr) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 79 + self.match(SolidityParser.VariableName) + self.state = 80 + self.match(SolidityParser.T__9) + self.state = 81 + self.match(SolidityParser.VariableName) + self.state = 82 + self.match(SolidityParser.T__10) + self.state = 83 + _la = self._input.LA(1) + if not ((((_la) & ~0x3F) == 0 and ((1 << _la) & 114688) != 0)): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 84 + self.match(SolidityParser.T__11) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) diff --git a/src/kontrol/solidity/SolidityVisitor.py b/src/kontrol/solidity/SolidityVisitor.py index 509734071..ce951efcd 100644 --- a/src/kontrol/solidity/SolidityVisitor.py +++ b/src/kontrol/solidity/SolidityVisitor.py @@ -103,5 +103,13 @@ def visitContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccess def visitContractVariableArrayElement(self, ctx: SolidityParser.ContractVariableArrayElementContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#contractVariableAccessExpr. + def visitContractVariableAccessExpr(self, ctx: SolidityParser.ContractVariableAccessExprContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#contractVariableArrayElemExpr. + def visitContractVariableArrayElemExpr(self, ctx: SolidityParser.ContractVariableArrayElemExprContext): + return self.visitChildren(ctx) + del SolidityParser From 92326a78c78dc321f6090ca37aa284c987de52be Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Wed, 7 Aug 2024 23:49:41 +0800 Subject: [PATCH 14/15] Added support for `**` and a few more arithmetic ops --- src/kontrol/solidity/AnnotationVisitor.py | 43 +- src/kontrol/solidity/Solidity.g4 | 1 + src/kontrol/solidity/Solidity.interp | 4 +- src/kontrol/solidity/Solidity.tokens | 32 +- src/kontrol/solidity/SolidityLexer.interp | 5 +- src/kontrol/solidity/SolidityLexer.py | 1810 ++------------------- src/kontrol/solidity/SolidityLexer.tokens | 32 +- src/kontrol/solidity/SolidityListener.py | 138 +- src/kontrol/solidity/SolidityParser.py | 1659 ++++++------------- src/kontrol/solidity/SolidityVisitor.py | 84 +- 10 files changed, 795 insertions(+), 3013 deletions(-) diff --git a/src/kontrol/solidity/AnnotationVisitor.py b/src/kontrol/solidity/AnnotationVisitor.py index aa89d9bb1..8baddb31e 100644 --- a/src/kontrol/solidity/AnnotationVisitor.py +++ b/src/kontrol/solidity/AnnotationVisitor.py @@ -105,25 +105,30 @@ def visitContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccess def visitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext) -> KInner: return intToken(ctx.getText()) - # def visitAddExpression(self, ctx: SolidityParser.AddExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left + right - - # def visitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left - right - - # def visitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left * right - - # def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): - # left = self.visit(ctx.arithmeticExpression(0)) - # right = self.visit(ctx.arithmeticExpression(1)) - # return left / right + def visitAddExpression(self, ctx: SolidityParser.AddExpressionContext): + left = self.visit(ctx.arithmeticExpression(0)) + right = self.visit(ctx.arithmeticExpression(1)) + return KApply('_+Int_', left, right) + + def visitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + left = self.visit(ctx.arithmeticExpression(0)) + right = self.visit(ctx.arithmeticExpression(1)) + return KApply('_-Int_', left, right) + + def visitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + left = self.visit(ctx.arithmeticExpression(0)) + right = self.visit(ctx.arithmeticExpression(1)) + return KApply('_*Int_', left, right) + + def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + left = self.visit(ctx.arithmeticExpression(0)) + right = self.visit(ctx.arithmeticExpression(1)) + return KApply('_/Int_', left, right) + + def visitPowExpression(self, ctx: SolidityParser.PowExpressionContext): + left = self.visit(ctx.arithmeticExpression(0)) + right = self.visit(ctx.arithmeticExpression(1)) + return KApply('_^Int_', left, right) # def visitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): # var_name = ctx.variableName().getText() diff --git a/src/kontrol/solidity/Solidity.g4 b/src/kontrol/solidity/Solidity.g4 index 4304c36fa..bf5a8302a 100644 --- a/src/kontrol/solidity/Solidity.g4 +++ b/src/kontrol/solidity/Solidity.g4 @@ -19,6 +19,7 @@ arithmeticExpression | arithmeticExpression '-' arithmeticExpression # SubtractExpression | arithmeticExpression '*' arithmeticExpression # MultiplyExpression | arithmeticExpression '/' arithmeticExpression # DivideExpression + | arithmeticExpression '**' arithmeticExpression # PowExpression | atom # AtomExpression ; diff --git a/src/kontrol/solidity/Solidity.interp b/src/kontrol/solidity/Solidity.interp index 669dc9bb1..a9fe426f0 100644 --- a/src/kontrol/solidity/Solidity.interp +++ b/src/kontrol/solidity/Solidity.interp @@ -9,6 +9,7 @@ null '-' '*' '/' +'**' '.' '[' ']' @@ -39,6 +40,7 @@ null null null null +null BOOLEAN_LITERAL INTEGER ADDRESS @@ -62,4 +64,4 @@ contractVariableArrayElemExpr atn: -[4, 1, 24, 87, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 27, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 35, 8, 1, 10, 1, 12, 1, 38, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 55, 8, 2, 10, 2, 12, 2, 58, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 74, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 0, 2, 2, 4, 6, 0, 2, 4, 6, 8, 10, 0, 1, 1, 0, 14, 16, 99, 0, 12, 1, 0, 0, 0, 2, 26, 1, 0, 0, 0, 4, 39, 1, 0, 0, 0, 6, 73, 1, 0, 0, 0, 8, 75, 1, 0, 0, 0, 10, 79, 1, 0, 0, 0, 12, 13, 3, 2, 1, 0, 13, 1, 1, 0, 0, 0, 14, 15, 6, 1, -1, 0, 15, 16, 5, 3, 0, 0, 16, 27, 3, 2, 1, 4, 17, 18, 3, 4, 2, 0, 18, 19, 5, 23, 0, 0, 19, 20, 3, 4, 2, 0, 20, 27, 1, 0, 0, 0, 21, 27, 5, 13, 0, 0, 22, 23, 5, 4, 0, 0, 23, 24, 3, 2, 1, 0, 24, 25, 5, 5, 0, 0, 25, 27, 1, 0, 0, 0, 26, 14, 1, 0, 0, 0, 26, 17, 1, 0, 0, 0, 26, 21, 1, 0, 0, 0, 26, 22, 1, 0, 0, 0, 27, 36, 1, 0, 0, 0, 28, 29, 10, 6, 0, 0, 29, 30, 5, 1, 0, 0, 30, 35, 3, 2, 1, 7, 31, 32, 10, 5, 0, 0, 32, 33, 5, 2, 0, 0, 33, 35, 3, 2, 1, 6, 34, 28, 1, 0, 0, 0, 34, 31, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, 34, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 3, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 40, 6, 2, -1, 0, 40, 41, 3, 6, 3, 0, 41, 56, 1, 0, 0, 0, 42, 43, 10, 5, 0, 0, 43, 44, 5, 6, 0, 0, 44, 55, 3, 4, 2, 6, 45, 46, 10, 4, 0, 0, 46, 47, 5, 7, 0, 0, 47, 55, 3, 4, 2, 5, 48, 49, 10, 3, 0, 0, 49, 50, 5, 8, 0, 0, 50, 55, 3, 4, 2, 4, 51, 52, 10, 2, 0, 0, 52, 53, 5, 9, 0, 0, 53, 55, 3, 4, 2, 3, 54, 42, 1, 0, 0, 0, 54, 45, 1, 0, 0, 0, 54, 48, 1, 0, 0, 0, 54, 51, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 5, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 74, 5, 16, 0, 0, 60, 74, 5, 17, 0, 0, 61, 74, 5, 18, 0, 0, 62, 74, 5, 19, 0, 0, 63, 74, 5, 20, 0, 0, 64, 74, 5, 14, 0, 0, 65, 66, 5, 4, 0, 0, 66, 67, 3, 4, 2, 0, 67, 68, 5, 5, 0, 0, 68, 74, 1, 0, 0, 0, 69, 74, 5, 21, 0, 0, 70, 74, 5, 22, 0, 0, 71, 74, 3, 8, 4, 0, 72, 74, 3, 10, 5, 0, 73, 59, 1, 0, 0, 0, 73, 60, 1, 0, 0, 0, 73, 61, 1, 0, 0, 0, 73, 62, 1, 0, 0, 0, 73, 63, 1, 0, 0, 0, 73, 64, 1, 0, 0, 0, 73, 65, 1, 0, 0, 0, 73, 69, 1, 0, 0, 0, 73, 70, 1, 0, 0, 0, 73, 71, 1, 0, 0, 0, 73, 72, 1, 0, 0, 0, 74, 7, 1, 0, 0, 0, 75, 76, 5, 16, 0, 0, 76, 77, 5, 10, 0, 0, 77, 78, 5, 16, 0, 0, 78, 9, 1, 0, 0, 0, 79, 80, 5, 16, 0, 0, 80, 81, 5, 10, 0, 0, 81, 82, 5, 16, 0, 0, 82, 83, 5, 11, 0, 0, 83, 84, 7, 0, 0, 0, 84, 85, 5, 12, 0, 0, 85, 11, 1, 0, 0, 0, 6, 26, 34, 36, 54, 56, 73] \ No newline at end of file +[4, 1, 25, 90, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 27, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 35, 8, 1, 10, 1, 12, 1, 38, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 58, 8, 2, 10, 2, 12, 2, 61, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 77, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 0, 2, 2, 4, 6, 0, 2, 4, 6, 8, 10, 0, 1, 1, 0, 15, 17, 103, 0, 12, 1, 0, 0, 0, 2, 26, 1, 0, 0, 0, 4, 39, 1, 0, 0, 0, 6, 76, 1, 0, 0, 0, 8, 78, 1, 0, 0, 0, 10, 82, 1, 0, 0, 0, 12, 13, 3, 2, 1, 0, 13, 1, 1, 0, 0, 0, 14, 15, 6, 1, -1, 0, 15, 16, 5, 3, 0, 0, 16, 27, 3, 2, 1, 4, 17, 18, 3, 4, 2, 0, 18, 19, 5, 24, 0, 0, 19, 20, 3, 4, 2, 0, 20, 27, 1, 0, 0, 0, 21, 27, 5, 14, 0, 0, 22, 23, 5, 4, 0, 0, 23, 24, 3, 2, 1, 0, 24, 25, 5, 5, 0, 0, 25, 27, 1, 0, 0, 0, 26, 14, 1, 0, 0, 0, 26, 17, 1, 0, 0, 0, 26, 21, 1, 0, 0, 0, 26, 22, 1, 0, 0, 0, 27, 36, 1, 0, 0, 0, 28, 29, 10, 6, 0, 0, 29, 30, 5, 1, 0, 0, 30, 35, 3, 2, 1, 7, 31, 32, 10, 5, 0, 0, 32, 33, 5, 2, 0, 0, 33, 35, 3, 2, 1, 6, 34, 28, 1, 0, 0, 0, 34, 31, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, 34, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 3, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 40, 6, 2, -1, 0, 40, 41, 3, 6, 3, 0, 41, 59, 1, 0, 0, 0, 42, 43, 10, 6, 0, 0, 43, 44, 5, 6, 0, 0, 44, 58, 3, 4, 2, 7, 45, 46, 10, 5, 0, 0, 46, 47, 5, 7, 0, 0, 47, 58, 3, 4, 2, 6, 48, 49, 10, 4, 0, 0, 49, 50, 5, 8, 0, 0, 50, 58, 3, 4, 2, 5, 51, 52, 10, 3, 0, 0, 52, 53, 5, 9, 0, 0, 53, 58, 3, 4, 2, 4, 54, 55, 10, 2, 0, 0, 55, 56, 5, 10, 0, 0, 56, 58, 3, 4, 2, 3, 57, 42, 1, 0, 0, 0, 57, 45, 1, 0, 0, 0, 57, 48, 1, 0, 0, 0, 57, 51, 1, 0, 0, 0, 57, 54, 1, 0, 0, 0, 58, 61, 1, 0, 0, 0, 59, 57, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 5, 1, 0, 0, 0, 61, 59, 1, 0, 0, 0, 62, 77, 5, 17, 0, 0, 63, 77, 5, 18, 0, 0, 64, 77, 5, 19, 0, 0, 65, 77, 5, 20, 0, 0, 66, 77, 5, 21, 0, 0, 67, 77, 5, 15, 0, 0, 68, 69, 5, 4, 0, 0, 69, 70, 3, 4, 2, 0, 70, 71, 5, 5, 0, 0, 71, 77, 1, 0, 0, 0, 72, 77, 5, 22, 0, 0, 73, 77, 5, 23, 0, 0, 74, 77, 3, 8, 4, 0, 75, 77, 3, 10, 5, 0, 76, 62, 1, 0, 0, 0, 76, 63, 1, 0, 0, 0, 76, 64, 1, 0, 0, 0, 76, 65, 1, 0, 0, 0, 76, 66, 1, 0, 0, 0, 76, 67, 1, 0, 0, 0, 76, 68, 1, 0, 0, 0, 76, 72, 1, 0, 0, 0, 76, 73, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 76, 75, 1, 0, 0, 0, 77, 7, 1, 0, 0, 0, 78, 79, 5, 17, 0, 0, 79, 80, 5, 11, 0, 0, 80, 81, 5, 17, 0, 0, 81, 9, 1, 0, 0, 0, 82, 83, 5, 17, 0, 0, 83, 84, 5, 11, 0, 0, 84, 85, 5, 17, 0, 0, 85, 86, 5, 12, 0, 0, 86, 87, 7, 0, 0, 0, 87, 88, 5, 13, 0, 0, 88, 11, 1, 0, 0, 0, 6, 26, 34, 36, 57, 59, 76] \ No newline at end of file diff --git a/src/kontrol/solidity/Solidity.tokens b/src/kontrol/solidity/Solidity.tokens index 3a8d82041..a5bc42fd8 100644 --- a/src/kontrol/solidity/Solidity.tokens +++ b/src/kontrol/solidity/Solidity.tokens @@ -10,18 +10,19 @@ T__8=9 T__9=10 T__10=11 T__11=12 -BOOLEAN_LITERAL=13 -INTEGER=14 -ADDRESS=15 -VariableName=16 -LengthAccess=17 -ArrayElement=18 -MappingElement=19 -AddressLiteral=20 -BlockAccess=21 -MsgAccess=22 -RelOp=23 -WS=24 +T__12=13 +BOOLEAN_LITERAL=14 +INTEGER=15 +ADDRESS=16 +VariableName=17 +LengthAccess=18 +ArrayElement=19 +MappingElement=20 +AddressLiteral=21 +BlockAccess=22 +MsgAccess=23 +RelOp=24 +WS=25 '&&'=1 '||'=2 '!'=3 @@ -31,6 +32,7 @@ WS=24 '-'=7 '*'=8 '/'=9 -'.'=10 -'['=11 -']'=12 +'**'=10 +'.'=11 +'['=12 +']'=13 diff --git a/src/kontrol/solidity/SolidityLexer.interp b/src/kontrol/solidity/SolidityLexer.interp index 066d32c00..dd76882fa 100644 --- a/src/kontrol/solidity/SolidityLexer.interp +++ b/src/kontrol/solidity/SolidityLexer.interp @@ -9,6 +9,7 @@ null '-' '*' '/' +'**' '.' '[' ']' @@ -39,6 +40,7 @@ null null null null +null BOOLEAN_LITERAL INTEGER ADDRESS @@ -65,6 +67,7 @@ T__8 T__9 T__10 T__11 +T__12 BOOLEAN_LITERAL INTEGER ADDRESS @@ -86,4 +89,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 24, 182, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 85, 8, 12, 1, 13, 4, 13, 88, 8, 13, 11, 13, 12, 13, 89, 1, 14, 1, 14, 1, 14, 1, 14, 4, 14, 96, 8, 14, 11, 14, 12, 14, 97, 1, 15, 1, 15, 5, 15, 102, 8, 15, 10, 15, 12, 15, 105, 9, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 150, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 174, 8, 22, 1, 23, 4, 23, 177, 8, 23, 11, 23, 12, 23, 178, 1, 23, 1, 23, 0, 0, 24, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 1, 0, 5, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 192, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 1, 49, 1, 0, 0, 0, 3, 52, 1, 0, 0, 0, 5, 55, 1, 0, 0, 0, 7, 57, 1, 0, 0, 0, 9, 59, 1, 0, 0, 0, 11, 61, 1, 0, 0, 0, 13, 63, 1, 0, 0, 0, 15, 65, 1, 0, 0, 0, 17, 67, 1, 0, 0, 0, 19, 69, 1, 0, 0, 0, 21, 71, 1, 0, 0, 0, 23, 73, 1, 0, 0, 0, 25, 84, 1, 0, 0, 0, 27, 87, 1, 0, 0, 0, 29, 91, 1, 0, 0, 0, 31, 99, 1, 0, 0, 0, 33, 106, 1, 0, 0, 0, 35, 115, 1, 0, 0, 0, 37, 120, 1, 0, 0, 0, 39, 125, 1, 0, 0, 0, 41, 127, 1, 0, 0, 0, 43, 151, 1, 0, 0, 0, 45, 173, 1, 0, 0, 0, 47, 176, 1, 0, 0, 0, 49, 50, 5, 38, 0, 0, 50, 51, 5, 38, 0, 0, 51, 2, 1, 0, 0, 0, 52, 53, 5, 124, 0, 0, 53, 54, 5, 124, 0, 0, 54, 4, 1, 0, 0, 0, 55, 56, 5, 33, 0, 0, 56, 6, 1, 0, 0, 0, 57, 58, 5, 40, 0, 0, 58, 8, 1, 0, 0, 0, 59, 60, 5, 41, 0, 0, 60, 10, 1, 0, 0, 0, 61, 62, 5, 43, 0, 0, 62, 12, 1, 0, 0, 0, 63, 64, 5, 45, 0, 0, 64, 14, 1, 0, 0, 0, 65, 66, 5, 42, 0, 0, 66, 16, 1, 0, 0, 0, 67, 68, 5, 47, 0, 0, 68, 18, 1, 0, 0, 0, 69, 70, 5, 46, 0, 0, 70, 20, 1, 0, 0, 0, 71, 72, 5, 91, 0, 0, 72, 22, 1, 0, 0, 0, 73, 74, 5, 93, 0, 0, 74, 24, 1, 0, 0, 0, 75, 76, 5, 116, 0, 0, 76, 77, 5, 114, 0, 0, 77, 78, 5, 117, 0, 0, 78, 85, 5, 101, 0, 0, 79, 80, 5, 102, 0, 0, 80, 81, 5, 97, 0, 0, 81, 82, 5, 108, 0, 0, 82, 83, 5, 115, 0, 0, 83, 85, 5, 101, 0, 0, 84, 75, 1, 0, 0, 0, 84, 79, 1, 0, 0, 0, 85, 26, 1, 0, 0, 0, 86, 88, 7, 0, 0, 0, 87, 86, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 28, 1, 0, 0, 0, 91, 92, 5, 48, 0, 0, 92, 93, 5, 120, 0, 0, 93, 95, 1, 0, 0, 0, 94, 96, 7, 1, 0, 0, 95, 94, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 30, 1, 0, 0, 0, 99, 103, 7, 2, 0, 0, 100, 102, 7, 3, 0, 0, 101, 100, 1, 0, 0, 0, 102, 105, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 103, 104, 1, 0, 0, 0, 104, 32, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 106, 107, 3, 31, 15, 0, 107, 108, 5, 46, 0, 0, 108, 109, 5, 108, 0, 0, 109, 110, 5, 101, 0, 0, 110, 111, 5, 110, 0, 0, 111, 112, 5, 103, 0, 0, 112, 113, 5, 116, 0, 0, 113, 114, 5, 104, 0, 0, 114, 34, 1, 0, 0, 0, 115, 116, 3, 31, 15, 0, 116, 117, 5, 91, 0, 0, 117, 118, 3, 27, 13, 0, 118, 119, 5, 93, 0, 0, 119, 36, 1, 0, 0, 0, 120, 121, 3, 31, 15, 0, 121, 122, 5, 91, 0, 0, 122, 123, 3, 31, 15, 0, 123, 124, 5, 93, 0, 0, 124, 38, 1, 0, 0, 0, 125, 126, 3, 29, 14, 0, 126, 40, 1, 0, 0, 0, 127, 128, 5, 98, 0, 0, 128, 129, 5, 108, 0, 0, 129, 130, 5, 111, 0, 0, 130, 131, 5, 99, 0, 0, 131, 132, 5, 107, 0, 0, 132, 133, 5, 46, 0, 0, 133, 149, 1, 0, 0, 0, 134, 135, 5, 116, 0, 0, 135, 136, 5, 105, 0, 0, 136, 137, 5, 109, 0, 0, 137, 138, 5, 101, 0, 0, 138, 139, 5, 115, 0, 0, 139, 140, 5, 116, 0, 0, 140, 141, 5, 97, 0, 0, 141, 142, 5, 109, 0, 0, 142, 150, 5, 112, 0, 0, 143, 144, 5, 110, 0, 0, 144, 145, 5, 117, 0, 0, 145, 146, 5, 109, 0, 0, 146, 147, 5, 98, 0, 0, 147, 148, 5, 101, 0, 0, 148, 150, 5, 114, 0, 0, 149, 134, 1, 0, 0, 0, 149, 143, 1, 0, 0, 0, 150, 42, 1, 0, 0, 0, 151, 152, 5, 109, 0, 0, 152, 153, 5, 115, 0, 0, 153, 154, 5, 103, 0, 0, 154, 155, 5, 46, 0, 0, 155, 156, 1, 0, 0, 0, 156, 157, 5, 115, 0, 0, 157, 158, 5, 101, 0, 0, 158, 159, 5, 110, 0, 0, 159, 160, 5, 100, 0, 0, 160, 161, 5, 101, 0, 0, 161, 162, 5, 114, 0, 0, 162, 44, 1, 0, 0, 0, 163, 174, 5, 60, 0, 0, 164, 165, 5, 60, 0, 0, 165, 174, 5, 61, 0, 0, 166, 174, 5, 62, 0, 0, 167, 168, 5, 62, 0, 0, 168, 174, 5, 61, 0, 0, 169, 170, 5, 61, 0, 0, 170, 174, 5, 61, 0, 0, 171, 172, 5, 33, 0, 0, 172, 174, 5, 61, 0, 0, 173, 163, 1, 0, 0, 0, 173, 164, 1, 0, 0, 0, 173, 166, 1, 0, 0, 0, 173, 167, 1, 0, 0, 0, 173, 169, 1, 0, 0, 0, 173, 171, 1, 0, 0, 0, 174, 46, 1, 0, 0, 0, 175, 177, 7, 4, 0, 0, 176, 175, 1, 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 178, 179, 1, 0, 0, 0, 179, 180, 1, 0, 0, 0, 180, 181, 6, 23, 0, 0, 181, 48, 1, 0, 0, 0, 8, 0, 84, 89, 97, 103, 149, 173, 178, 1, 6, 0, 0] \ No newline at end of file +[4, 0, 25, 187, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 90, 8, 13, 1, 14, 4, 14, 93, 8, 14, 11, 14, 12, 14, 94, 1, 15, 1, 15, 1, 15, 1, 15, 4, 15, 101, 8, 15, 11, 15, 12, 15, 102, 1, 16, 1, 16, 5, 16, 107, 8, 16, 10, 16, 12, 16, 110, 9, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 155, 8, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 179, 8, 23, 1, 24, 4, 24, 182, 8, 24, 11, 24, 12, 24, 183, 1, 24, 1, 24, 0, 0, 25, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 1, 0, 5, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 197, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 1, 51, 1, 0, 0, 0, 3, 54, 1, 0, 0, 0, 5, 57, 1, 0, 0, 0, 7, 59, 1, 0, 0, 0, 9, 61, 1, 0, 0, 0, 11, 63, 1, 0, 0, 0, 13, 65, 1, 0, 0, 0, 15, 67, 1, 0, 0, 0, 17, 69, 1, 0, 0, 0, 19, 71, 1, 0, 0, 0, 21, 74, 1, 0, 0, 0, 23, 76, 1, 0, 0, 0, 25, 78, 1, 0, 0, 0, 27, 89, 1, 0, 0, 0, 29, 92, 1, 0, 0, 0, 31, 96, 1, 0, 0, 0, 33, 104, 1, 0, 0, 0, 35, 111, 1, 0, 0, 0, 37, 120, 1, 0, 0, 0, 39, 125, 1, 0, 0, 0, 41, 130, 1, 0, 0, 0, 43, 132, 1, 0, 0, 0, 45, 156, 1, 0, 0, 0, 47, 178, 1, 0, 0, 0, 49, 181, 1, 0, 0, 0, 51, 52, 5, 38, 0, 0, 52, 53, 5, 38, 0, 0, 53, 2, 1, 0, 0, 0, 54, 55, 5, 124, 0, 0, 55, 56, 5, 124, 0, 0, 56, 4, 1, 0, 0, 0, 57, 58, 5, 33, 0, 0, 58, 6, 1, 0, 0, 0, 59, 60, 5, 40, 0, 0, 60, 8, 1, 0, 0, 0, 61, 62, 5, 41, 0, 0, 62, 10, 1, 0, 0, 0, 63, 64, 5, 43, 0, 0, 64, 12, 1, 0, 0, 0, 65, 66, 5, 45, 0, 0, 66, 14, 1, 0, 0, 0, 67, 68, 5, 42, 0, 0, 68, 16, 1, 0, 0, 0, 69, 70, 5, 47, 0, 0, 70, 18, 1, 0, 0, 0, 71, 72, 5, 42, 0, 0, 72, 73, 5, 42, 0, 0, 73, 20, 1, 0, 0, 0, 74, 75, 5, 46, 0, 0, 75, 22, 1, 0, 0, 0, 76, 77, 5, 91, 0, 0, 77, 24, 1, 0, 0, 0, 78, 79, 5, 93, 0, 0, 79, 26, 1, 0, 0, 0, 80, 81, 5, 116, 0, 0, 81, 82, 5, 114, 0, 0, 82, 83, 5, 117, 0, 0, 83, 90, 5, 101, 0, 0, 84, 85, 5, 102, 0, 0, 85, 86, 5, 97, 0, 0, 86, 87, 5, 108, 0, 0, 87, 88, 5, 115, 0, 0, 88, 90, 5, 101, 0, 0, 89, 80, 1, 0, 0, 0, 89, 84, 1, 0, 0, 0, 90, 28, 1, 0, 0, 0, 91, 93, 7, 0, 0, 0, 92, 91, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 30, 1, 0, 0, 0, 96, 97, 5, 48, 0, 0, 97, 98, 5, 120, 0, 0, 98, 100, 1, 0, 0, 0, 99, 101, 7, 1, 0, 0, 100, 99, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 100, 1, 0, 0, 0, 102, 103, 1, 0, 0, 0, 103, 32, 1, 0, 0, 0, 104, 108, 7, 2, 0, 0, 105, 107, 7, 3, 0, 0, 106, 105, 1, 0, 0, 0, 107, 110, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 108, 109, 1, 0, 0, 0, 109, 34, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 111, 112, 3, 33, 16, 0, 112, 113, 5, 46, 0, 0, 113, 114, 5, 108, 0, 0, 114, 115, 5, 101, 0, 0, 115, 116, 5, 110, 0, 0, 116, 117, 5, 103, 0, 0, 117, 118, 5, 116, 0, 0, 118, 119, 5, 104, 0, 0, 119, 36, 1, 0, 0, 0, 120, 121, 3, 33, 16, 0, 121, 122, 5, 91, 0, 0, 122, 123, 3, 29, 14, 0, 123, 124, 5, 93, 0, 0, 124, 38, 1, 0, 0, 0, 125, 126, 3, 33, 16, 0, 126, 127, 5, 91, 0, 0, 127, 128, 3, 33, 16, 0, 128, 129, 5, 93, 0, 0, 129, 40, 1, 0, 0, 0, 130, 131, 3, 31, 15, 0, 131, 42, 1, 0, 0, 0, 132, 133, 5, 98, 0, 0, 133, 134, 5, 108, 0, 0, 134, 135, 5, 111, 0, 0, 135, 136, 5, 99, 0, 0, 136, 137, 5, 107, 0, 0, 137, 138, 5, 46, 0, 0, 138, 154, 1, 0, 0, 0, 139, 140, 5, 116, 0, 0, 140, 141, 5, 105, 0, 0, 141, 142, 5, 109, 0, 0, 142, 143, 5, 101, 0, 0, 143, 144, 5, 115, 0, 0, 144, 145, 5, 116, 0, 0, 145, 146, 5, 97, 0, 0, 146, 147, 5, 109, 0, 0, 147, 155, 5, 112, 0, 0, 148, 149, 5, 110, 0, 0, 149, 150, 5, 117, 0, 0, 150, 151, 5, 109, 0, 0, 151, 152, 5, 98, 0, 0, 152, 153, 5, 101, 0, 0, 153, 155, 5, 114, 0, 0, 154, 139, 1, 0, 0, 0, 154, 148, 1, 0, 0, 0, 155, 44, 1, 0, 0, 0, 156, 157, 5, 109, 0, 0, 157, 158, 5, 115, 0, 0, 158, 159, 5, 103, 0, 0, 159, 160, 5, 46, 0, 0, 160, 161, 1, 0, 0, 0, 161, 162, 5, 115, 0, 0, 162, 163, 5, 101, 0, 0, 163, 164, 5, 110, 0, 0, 164, 165, 5, 100, 0, 0, 165, 166, 5, 101, 0, 0, 166, 167, 5, 114, 0, 0, 167, 46, 1, 0, 0, 0, 168, 179, 5, 60, 0, 0, 169, 170, 5, 60, 0, 0, 170, 179, 5, 61, 0, 0, 171, 179, 5, 62, 0, 0, 172, 173, 5, 62, 0, 0, 173, 179, 5, 61, 0, 0, 174, 175, 5, 61, 0, 0, 175, 179, 5, 61, 0, 0, 176, 177, 5, 33, 0, 0, 177, 179, 5, 61, 0, 0, 178, 168, 1, 0, 0, 0, 178, 169, 1, 0, 0, 0, 178, 171, 1, 0, 0, 0, 178, 172, 1, 0, 0, 0, 178, 174, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 179, 48, 1, 0, 0, 0, 180, 182, 7, 4, 0, 0, 181, 180, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 181, 1, 0, 0, 0, 183, 184, 1, 0, 0, 0, 184, 185, 1, 0, 0, 0, 185, 186, 6, 24, 0, 0, 186, 50, 1, 0, 0, 0, 8, 0, 89, 94, 102, 108, 154, 178, 183, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/kontrol/solidity/SolidityLexer.py b/src/kontrol/solidity/SolidityLexer.py index 35909f86d..c6af1dd58 100644 --- a/src/kontrol/solidity/SolidityLexer.py +++ b/src/kontrol/solidity/SolidityLexer.py @@ -1,9 +1,7 @@ # Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.2 -import sys -from io import StringIO - from antlr4 import * - +from io import StringIO +import sys if sys.version_info[1] > 5: from typing import TextIO else: @@ -12,1651 +10,80 @@ def serializedATN(): return [ - 4, - 0, - 24, - 182, - 6, - -1, - 2, - 0, - 7, - 0, - 2, - 1, - 7, - 1, - 2, - 2, - 7, - 2, - 2, - 3, - 7, - 3, - 2, - 4, - 7, - 4, - 2, - 5, - 7, - 5, - 2, - 6, - 7, - 6, - 2, - 7, - 7, - 7, - 2, - 8, - 7, - 8, - 2, - 9, - 7, - 9, - 2, - 10, - 7, - 10, - 2, - 11, - 7, - 11, - 2, - 12, - 7, - 12, - 2, - 13, - 7, - 13, - 2, - 14, - 7, - 14, - 2, - 15, - 7, - 15, - 2, - 16, - 7, - 16, - 2, - 17, - 7, - 17, - 2, - 18, - 7, - 18, - 2, - 19, - 7, - 19, - 2, - 20, - 7, - 20, - 2, - 21, - 7, - 21, - 2, - 22, - 7, - 22, - 2, - 23, - 7, - 23, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 1, - 2, - 1, - 3, - 1, - 3, - 1, - 4, - 1, - 4, - 1, - 5, - 1, - 5, - 1, - 6, - 1, - 6, - 1, - 7, - 1, - 7, - 1, - 8, - 1, - 8, - 1, - 9, - 1, - 9, - 1, - 10, - 1, - 10, - 1, - 11, - 1, - 11, - 1, - 12, - 1, - 12, - 1, - 12, - 1, - 12, - 1, - 12, - 1, - 12, - 1, - 12, - 1, - 12, - 1, - 12, - 3, - 12, - 85, - 8, - 12, - 1, - 13, - 4, - 13, - 88, - 8, - 13, - 11, - 13, - 12, - 13, - 89, - 1, - 14, - 1, - 14, - 1, - 14, - 1, - 14, - 4, - 14, - 96, - 8, - 14, - 11, - 14, - 12, - 14, - 97, - 1, - 15, - 1, - 15, - 5, - 15, - 102, - 8, - 15, - 10, - 15, - 12, - 15, - 105, - 9, - 15, - 1, - 16, - 1, - 16, - 1, - 16, - 1, - 16, - 1, - 16, - 1, - 16, - 1, - 16, - 1, - 16, - 1, - 16, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 17, - 1, - 18, - 1, - 18, - 1, - 18, - 1, - 18, - 1, - 18, - 1, - 19, - 1, - 19, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 1, - 20, - 3, - 20, - 150, - 8, - 20, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 21, - 1, - 22, - 1, - 22, - 1, - 22, - 1, - 22, - 1, - 22, - 1, - 22, - 1, - 22, - 1, - 22, - 1, - 22, - 1, - 22, - 3, - 22, - 174, - 8, - 22, - 1, - 23, - 4, - 23, - 177, - 8, - 23, - 11, - 23, - 12, - 23, - 178, - 1, - 23, - 1, - 23, - 0, - 0, - 24, - 1, - 1, - 3, - 2, - 5, - 3, - 7, - 4, - 9, - 5, - 11, - 6, - 13, - 7, - 15, - 8, - 17, - 9, - 19, - 10, - 21, - 11, - 23, - 12, - 25, - 13, - 27, - 14, - 29, - 15, - 31, - 16, - 33, - 17, - 35, - 18, - 37, - 19, - 39, - 20, - 41, - 21, - 43, - 22, - 45, - 23, - 47, - 24, - 1, - 0, - 5, - 1, - 0, - 48, - 57, - 3, - 0, - 48, - 57, - 65, - 70, - 97, - 102, - 3, - 0, - 65, - 90, - 95, - 95, - 97, - 122, - 4, - 0, - 48, - 57, - 65, - 90, - 95, - 95, - 97, - 122, - 3, - 0, - 9, - 10, - 13, - 13, - 32, - 32, - 192, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - 3, - 1, - 0, - 0, - 0, - 0, - 5, - 1, - 0, - 0, - 0, - 0, - 7, - 1, - 0, - 0, - 0, - 0, - 9, - 1, - 0, - 0, - 0, - 0, - 11, - 1, - 0, - 0, - 0, - 0, - 13, - 1, - 0, - 0, - 0, - 0, - 15, - 1, - 0, - 0, - 0, - 0, - 17, - 1, - 0, - 0, - 0, - 0, - 19, - 1, - 0, - 0, - 0, - 0, - 21, - 1, - 0, - 0, - 0, - 0, - 23, - 1, - 0, - 0, - 0, - 0, - 25, - 1, - 0, - 0, - 0, - 0, - 27, - 1, - 0, - 0, - 0, - 0, - 29, - 1, - 0, - 0, - 0, - 0, - 31, - 1, - 0, - 0, - 0, - 0, - 33, - 1, - 0, - 0, - 0, - 0, - 35, - 1, - 0, - 0, - 0, - 0, - 37, - 1, - 0, - 0, - 0, - 0, - 39, - 1, - 0, - 0, - 0, - 0, - 41, - 1, - 0, - 0, - 0, - 0, - 43, - 1, - 0, - 0, - 0, - 0, - 45, - 1, - 0, - 0, - 0, - 0, - 47, - 1, - 0, - 0, - 0, - 1, - 49, - 1, - 0, - 0, - 0, - 3, - 52, - 1, - 0, - 0, - 0, - 5, - 55, - 1, - 0, - 0, - 0, - 7, - 57, - 1, - 0, - 0, - 0, - 9, - 59, - 1, - 0, - 0, - 0, - 11, - 61, - 1, - 0, - 0, - 0, - 13, - 63, - 1, - 0, - 0, - 0, - 15, - 65, - 1, - 0, - 0, - 0, - 17, - 67, - 1, - 0, - 0, - 0, - 19, - 69, - 1, - 0, - 0, - 0, - 21, - 71, - 1, - 0, - 0, - 0, - 23, - 73, - 1, - 0, - 0, - 0, - 25, - 84, - 1, - 0, - 0, - 0, - 27, - 87, - 1, - 0, - 0, - 0, - 29, - 91, - 1, - 0, - 0, - 0, - 31, - 99, - 1, - 0, - 0, - 0, - 33, - 106, - 1, - 0, - 0, - 0, - 35, - 115, - 1, - 0, - 0, - 0, - 37, - 120, - 1, - 0, - 0, - 0, - 39, - 125, - 1, - 0, - 0, - 0, - 41, - 127, - 1, - 0, - 0, - 0, - 43, - 151, - 1, - 0, - 0, - 0, - 45, - 173, - 1, - 0, - 0, - 0, - 47, - 176, - 1, - 0, - 0, - 0, - 49, - 50, - 5, - 38, - 0, - 0, - 50, - 51, - 5, - 38, - 0, - 0, - 51, - 2, - 1, - 0, - 0, - 0, - 52, - 53, - 5, - 124, - 0, - 0, - 53, - 54, - 5, - 124, - 0, - 0, - 54, - 4, - 1, - 0, - 0, - 0, - 55, - 56, - 5, - 33, - 0, - 0, - 56, - 6, - 1, - 0, - 0, - 0, - 57, - 58, - 5, - 40, - 0, - 0, - 58, - 8, - 1, - 0, - 0, - 0, - 59, - 60, - 5, - 41, - 0, - 0, - 60, - 10, - 1, - 0, - 0, - 0, - 61, - 62, - 5, - 43, - 0, - 0, - 62, - 12, - 1, - 0, - 0, - 0, - 63, - 64, - 5, - 45, - 0, - 0, - 64, - 14, - 1, - 0, - 0, - 0, - 65, - 66, - 5, - 42, - 0, - 0, - 66, - 16, - 1, - 0, - 0, - 0, - 67, - 68, - 5, - 47, - 0, - 0, - 68, - 18, - 1, - 0, - 0, - 0, - 69, - 70, - 5, - 46, - 0, - 0, - 70, - 20, - 1, - 0, - 0, - 0, - 71, - 72, - 5, - 91, - 0, - 0, - 72, - 22, - 1, - 0, - 0, - 0, - 73, - 74, - 5, - 93, - 0, - 0, - 74, - 24, - 1, - 0, - 0, - 0, - 75, - 76, - 5, - 116, - 0, - 0, - 76, - 77, - 5, - 114, - 0, - 0, - 77, - 78, - 5, - 117, - 0, - 0, - 78, - 85, - 5, - 101, - 0, - 0, - 79, - 80, - 5, - 102, - 0, - 0, - 80, - 81, - 5, - 97, - 0, - 0, - 81, - 82, - 5, - 108, - 0, - 0, - 82, - 83, - 5, - 115, - 0, - 0, - 83, - 85, - 5, - 101, - 0, - 0, - 84, - 75, - 1, - 0, - 0, - 0, - 84, - 79, - 1, - 0, - 0, - 0, - 85, - 26, - 1, - 0, - 0, - 0, - 86, - 88, - 7, - 0, - 0, - 0, - 87, - 86, - 1, - 0, - 0, - 0, - 88, - 89, - 1, - 0, - 0, - 0, - 89, - 87, - 1, - 0, - 0, - 0, - 89, - 90, - 1, - 0, - 0, - 0, - 90, - 28, - 1, - 0, - 0, - 0, - 91, - 92, - 5, - 48, - 0, - 0, - 92, - 93, - 5, - 120, - 0, - 0, - 93, - 95, - 1, - 0, - 0, - 0, - 94, - 96, - 7, - 1, - 0, - 0, - 95, - 94, - 1, - 0, - 0, - 0, - 96, - 97, - 1, - 0, - 0, - 0, - 97, - 95, - 1, - 0, - 0, - 0, - 97, - 98, - 1, - 0, - 0, - 0, - 98, - 30, - 1, - 0, - 0, - 0, - 99, - 103, - 7, - 2, - 0, - 0, - 100, - 102, - 7, - 3, - 0, - 0, - 101, - 100, - 1, - 0, - 0, - 0, - 102, - 105, - 1, - 0, - 0, - 0, - 103, - 101, - 1, - 0, - 0, - 0, - 103, - 104, - 1, - 0, - 0, - 0, - 104, - 32, - 1, - 0, - 0, - 0, - 105, - 103, - 1, - 0, - 0, - 0, - 106, - 107, - 3, - 31, - 15, - 0, - 107, - 108, - 5, - 46, - 0, - 0, - 108, - 109, - 5, - 108, - 0, - 0, - 109, - 110, - 5, - 101, - 0, - 0, - 110, - 111, - 5, - 110, - 0, - 0, - 111, - 112, - 5, - 103, - 0, - 0, - 112, - 113, - 5, - 116, - 0, - 0, - 113, - 114, - 5, - 104, - 0, - 0, - 114, - 34, - 1, - 0, - 0, - 0, - 115, - 116, - 3, - 31, - 15, - 0, - 116, - 117, - 5, - 91, - 0, - 0, - 117, - 118, - 3, - 27, - 13, - 0, - 118, - 119, - 5, - 93, - 0, - 0, - 119, - 36, - 1, - 0, - 0, - 0, - 120, - 121, - 3, - 31, - 15, - 0, - 121, - 122, - 5, - 91, - 0, - 0, - 122, - 123, - 3, - 31, - 15, - 0, - 123, - 124, - 5, - 93, - 0, - 0, - 124, - 38, - 1, - 0, - 0, - 0, - 125, - 126, - 3, - 29, - 14, - 0, - 126, - 40, - 1, - 0, - 0, - 0, - 127, - 128, - 5, - 98, - 0, - 0, - 128, - 129, - 5, - 108, - 0, - 0, - 129, - 130, - 5, - 111, - 0, - 0, - 130, - 131, - 5, - 99, - 0, - 0, - 131, - 132, - 5, - 107, - 0, - 0, - 132, - 133, - 5, - 46, - 0, - 0, - 133, - 149, - 1, - 0, - 0, - 0, - 134, - 135, - 5, - 116, - 0, - 0, - 135, - 136, - 5, - 105, - 0, - 0, - 136, - 137, - 5, - 109, - 0, - 0, - 137, - 138, - 5, - 101, - 0, - 0, - 138, - 139, - 5, - 115, - 0, - 0, - 139, - 140, - 5, - 116, - 0, - 0, - 140, - 141, - 5, - 97, - 0, - 0, - 141, - 142, - 5, - 109, - 0, - 0, - 142, - 150, - 5, - 112, - 0, - 0, - 143, - 144, - 5, - 110, - 0, - 0, - 144, - 145, - 5, - 117, - 0, - 0, - 145, - 146, - 5, - 109, - 0, - 0, - 146, - 147, - 5, - 98, - 0, - 0, - 147, - 148, - 5, - 101, - 0, - 0, - 148, - 150, - 5, - 114, - 0, - 0, - 149, - 134, - 1, - 0, - 0, - 0, - 149, - 143, - 1, - 0, - 0, - 0, - 150, - 42, - 1, - 0, - 0, - 0, - 151, - 152, - 5, - 109, - 0, - 0, - 152, - 153, - 5, - 115, - 0, - 0, - 153, - 154, - 5, - 103, - 0, - 0, - 154, - 155, - 5, - 46, - 0, - 0, - 155, - 156, - 1, - 0, - 0, - 0, - 156, - 157, - 5, - 115, - 0, - 0, - 157, - 158, - 5, - 101, - 0, - 0, - 158, - 159, - 5, - 110, - 0, - 0, - 159, - 160, - 5, - 100, - 0, - 0, - 160, - 161, - 5, - 101, - 0, - 0, - 161, - 162, - 5, - 114, - 0, - 0, - 162, - 44, - 1, - 0, - 0, - 0, - 163, - 174, - 5, - 60, - 0, - 0, - 164, - 165, - 5, - 60, - 0, - 0, - 165, - 174, - 5, - 61, - 0, - 0, - 166, - 174, - 5, - 62, - 0, - 0, - 167, - 168, - 5, - 62, - 0, - 0, - 168, - 174, - 5, - 61, - 0, - 0, - 169, - 170, - 5, - 61, - 0, - 0, - 170, - 174, - 5, - 61, - 0, - 0, - 171, - 172, - 5, - 33, - 0, - 0, - 172, - 174, - 5, - 61, - 0, - 0, - 173, - 163, - 1, - 0, - 0, - 0, - 173, - 164, - 1, - 0, - 0, - 0, - 173, - 166, - 1, - 0, - 0, - 0, - 173, - 167, - 1, - 0, - 0, - 0, - 173, - 169, - 1, - 0, - 0, - 0, - 173, - 171, - 1, - 0, - 0, - 0, - 174, - 46, - 1, - 0, - 0, - 0, - 175, - 177, - 7, - 4, - 0, - 0, - 176, - 175, - 1, - 0, - 0, - 0, - 177, - 178, - 1, - 0, - 0, - 0, - 178, - 176, - 1, - 0, - 0, - 0, - 178, - 179, - 1, - 0, - 0, - 0, - 179, - 180, - 1, - 0, - 0, - 0, - 180, - 181, - 6, - 23, - 0, - 0, - 181, - 48, - 1, - 0, - 0, - 0, - 8, - 0, - 84, - 89, - 97, - 103, - 149, - 173, - 178, - 1, - 6, - 0, - 0, + 4,0,25,187,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5, + 2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2, + 13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7, + 19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,1,0,1,0,1,0, + 1,1,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8, + 1,8,1,9,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,13,1,13, + 1,13,1,13,1,13,1,13,1,13,3,13,90,8,13,1,14,4,14,93,8,14,11,14,12, + 14,94,1,15,1,15,1,15,1,15,4,15,101,8,15,11,15,12,15,102,1,16,1,16, + 5,16,107,8,16,10,16,12,16,110,9,16,1,17,1,17,1,17,1,17,1,17,1,17, + 1,17,1,17,1,17,1,18,1,18,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,19, + 1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21, + 1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,3,21,155, + 8,21,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22, + 1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,179,8,23, + 1,24,4,24,182,8,24,11,24,12,24,183,1,24,1,24,0,0,25,1,1,3,2,5,3, + 7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15, + 31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,1,0, + 5,1,0,48,57,3,0,48,57,65,70,97,102,3,0,65,90,95,95,97,122,4,0,48, + 57,65,90,95,95,97,122,3,0,9,10,13,13,32,32,197,0,1,1,0,0,0,0,3,1, + 0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0, + 0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0, + 0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0, + 0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0, + 0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,1,51,1,0,0,0,3,54,1,0, + 0,0,5,57,1,0,0,0,7,59,1,0,0,0,9,61,1,0,0,0,11,63,1,0,0,0,13,65,1, + 0,0,0,15,67,1,0,0,0,17,69,1,0,0,0,19,71,1,0,0,0,21,74,1,0,0,0,23, + 76,1,0,0,0,25,78,1,0,0,0,27,89,1,0,0,0,29,92,1,0,0,0,31,96,1,0,0, + 0,33,104,1,0,0,0,35,111,1,0,0,0,37,120,1,0,0,0,39,125,1,0,0,0,41, + 130,1,0,0,0,43,132,1,0,0,0,45,156,1,0,0,0,47,178,1,0,0,0,49,181, + 1,0,0,0,51,52,5,38,0,0,52,53,5,38,0,0,53,2,1,0,0,0,54,55,5,124,0, + 0,55,56,5,124,0,0,56,4,1,0,0,0,57,58,5,33,0,0,58,6,1,0,0,0,59,60, + 5,40,0,0,60,8,1,0,0,0,61,62,5,41,0,0,62,10,1,0,0,0,63,64,5,43,0, + 0,64,12,1,0,0,0,65,66,5,45,0,0,66,14,1,0,0,0,67,68,5,42,0,0,68,16, + 1,0,0,0,69,70,5,47,0,0,70,18,1,0,0,0,71,72,5,42,0,0,72,73,5,42,0, + 0,73,20,1,0,0,0,74,75,5,46,0,0,75,22,1,0,0,0,76,77,5,91,0,0,77,24, + 1,0,0,0,78,79,5,93,0,0,79,26,1,0,0,0,80,81,5,116,0,0,81,82,5,114, + 0,0,82,83,5,117,0,0,83,90,5,101,0,0,84,85,5,102,0,0,85,86,5,97,0, + 0,86,87,5,108,0,0,87,88,5,115,0,0,88,90,5,101,0,0,89,80,1,0,0,0, + 89,84,1,0,0,0,90,28,1,0,0,0,91,93,7,0,0,0,92,91,1,0,0,0,93,94,1, + 0,0,0,94,92,1,0,0,0,94,95,1,0,0,0,95,30,1,0,0,0,96,97,5,48,0,0,97, + 98,5,120,0,0,98,100,1,0,0,0,99,101,7,1,0,0,100,99,1,0,0,0,101,102, + 1,0,0,0,102,100,1,0,0,0,102,103,1,0,0,0,103,32,1,0,0,0,104,108,7, + 2,0,0,105,107,7,3,0,0,106,105,1,0,0,0,107,110,1,0,0,0,108,106,1, + 0,0,0,108,109,1,0,0,0,109,34,1,0,0,0,110,108,1,0,0,0,111,112,3,33, + 16,0,112,113,5,46,0,0,113,114,5,108,0,0,114,115,5,101,0,0,115,116, + 5,110,0,0,116,117,5,103,0,0,117,118,5,116,0,0,118,119,5,104,0,0, + 119,36,1,0,0,0,120,121,3,33,16,0,121,122,5,91,0,0,122,123,3,29,14, + 0,123,124,5,93,0,0,124,38,1,0,0,0,125,126,3,33,16,0,126,127,5,91, + 0,0,127,128,3,33,16,0,128,129,5,93,0,0,129,40,1,0,0,0,130,131,3, + 31,15,0,131,42,1,0,0,0,132,133,5,98,0,0,133,134,5,108,0,0,134,135, + 5,111,0,0,135,136,5,99,0,0,136,137,5,107,0,0,137,138,5,46,0,0,138, + 154,1,0,0,0,139,140,5,116,0,0,140,141,5,105,0,0,141,142,5,109,0, + 0,142,143,5,101,0,0,143,144,5,115,0,0,144,145,5,116,0,0,145,146, + 5,97,0,0,146,147,5,109,0,0,147,155,5,112,0,0,148,149,5,110,0,0,149, + 150,5,117,0,0,150,151,5,109,0,0,151,152,5,98,0,0,152,153,5,101,0, + 0,153,155,5,114,0,0,154,139,1,0,0,0,154,148,1,0,0,0,155,44,1,0,0, + 0,156,157,5,109,0,0,157,158,5,115,0,0,158,159,5,103,0,0,159,160, + 5,46,0,0,160,161,1,0,0,0,161,162,5,115,0,0,162,163,5,101,0,0,163, + 164,5,110,0,0,164,165,5,100,0,0,165,166,5,101,0,0,166,167,5,114, + 0,0,167,46,1,0,0,0,168,179,5,60,0,0,169,170,5,60,0,0,170,179,5,61, + 0,0,171,179,5,62,0,0,172,173,5,62,0,0,173,179,5,61,0,0,174,175,5, + 61,0,0,175,179,5,61,0,0,176,177,5,33,0,0,177,179,5,61,0,0,178,168, + 1,0,0,0,178,169,1,0,0,0,178,171,1,0,0,0,178,172,1,0,0,0,178,174, + 1,0,0,0,178,176,1,0,0,0,179,48,1,0,0,0,180,182,7,4,0,0,181,180,1, + 0,0,0,182,183,1,0,0,0,183,181,1,0,0,0,183,184,1,0,0,0,184,185,1, + 0,0,0,185,186,6,24,0,0,186,50,1,0,0,0,8,0,89,94,102,108,154,178, + 183,1,6,0,0 ] - class SolidityLexer(Lexer): atn = ATNDeserializer().deserialize(serializedATN()) - decisionsToDFA = [DFA(ds, i) for i, ds in enumerate(atn.decisionToState)] + decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ] T__0 = 1 T__1 = 2 @@ -1670,73 +97,46 @@ class SolidityLexer(Lexer): T__9 = 10 T__10 = 11 T__11 = 12 - BOOLEAN_LITERAL = 13 - INTEGER = 14 - ADDRESS = 15 - VariableName = 16 - LengthAccess = 17 - ArrayElement = 18 - MappingElement = 19 - AddressLiteral = 20 - BlockAccess = 21 - MsgAccess = 22 - RelOp = 23 - WS = 24 - - channelNames = [u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN"] - - modeNames = ["DEFAULT_MODE"] - - literalNames = ["", "'&&'", "'||'", "'!'", "'('", "')'", "'+'", "'-'", "'*'", "'/'", "'.'", "'['", "']'"] - - symbolicNames = [ - "", - "BOOLEAN_LITERAL", - "INTEGER", - "ADDRESS", - "VariableName", - "LengthAccess", - "ArrayElement", - "MappingElement", - "AddressLiteral", - "BlockAccess", - "MsgAccess", - "RelOp", - "WS", - ] - - ruleNames = [ - "T__0", - "T__1", - "T__2", - "T__3", - "T__4", - "T__5", - "T__6", - "T__7", - "T__8", - "T__9", - "T__10", - "T__11", - "BOOLEAN_LITERAL", - "INTEGER", - "ADDRESS", - "VariableName", - "LengthAccess", - "ArrayElement", - "MappingElement", - "AddressLiteral", - "BlockAccess", - "MsgAccess", - "RelOp", - "WS", - ] + T__12 = 13 + BOOLEAN_LITERAL = 14 + INTEGER = 15 + ADDRESS = 16 + VariableName = 17 + LengthAccess = 18 + ArrayElement = 19 + MappingElement = 20 + AddressLiteral = 21 + BlockAccess = 22 + MsgAccess = 23 + RelOp = 24 + WS = 25 + + channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] + + modeNames = [ "DEFAULT_MODE" ] + + literalNames = [ "", + "'&&'", "'||'", "'!'", "'('", "')'", "'+'", "'-'", "'*'", "'/'", + "'**'", "'.'", "'['", "']'" ] + + symbolicNames = [ "", + "BOOLEAN_LITERAL", "INTEGER", "ADDRESS", "VariableName", "LengthAccess", + "ArrayElement", "MappingElement", "AddressLiteral", "BlockAccess", + "MsgAccess", "RelOp", "WS" ] + + ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", + "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "BOOLEAN_LITERAL", + "INTEGER", "ADDRESS", "VariableName", "LengthAccess", + "ArrayElement", "MappingElement", "AddressLiteral", "BlockAccess", + "MsgAccess", "RelOp", "WS" ] grammarFileName = "Solidity.g4" - def __init__(self, input=None, output: TextIO = sys.stdout): + def __init__(self, input=None, output:TextIO = sys.stdout): super().__init__(input, output) self.checkVersion("4.13.2") self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) self._actions = None self._predicates = None + + diff --git a/src/kontrol/solidity/SolidityLexer.tokens b/src/kontrol/solidity/SolidityLexer.tokens index 3a8d82041..a5bc42fd8 100644 --- a/src/kontrol/solidity/SolidityLexer.tokens +++ b/src/kontrol/solidity/SolidityLexer.tokens @@ -10,18 +10,19 @@ T__8=9 T__9=10 T__10=11 T__11=12 -BOOLEAN_LITERAL=13 -INTEGER=14 -ADDRESS=15 -VariableName=16 -LengthAccess=17 -ArrayElement=18 -MappingElement=19 -AddressLiteral=20 -BlockAccess=21 -MsgAccess=22 -RelOp=23 -WS=24 +T__12=13 +BOOLEAN_LITERAL=14 +INTEGER=15 +ADDRESS=16 +VariableName=17 +LengthAccess=18 +ArrayElement=19 +MappingElement=20 +AddressLiteral=21 +BlockAccess=22 +MsgAccess=23 +RelOp=24 +WS=25 '&&'=1 '||'=2 '!'=3 @@ -31,6 +32,7 @@ WS=24 '-'=7 '*'=8 '/'=9 -'.'=10 -'['=11 -']'=12 +'**'=10 +'.'=11 +'['=12 +']'=13 diff --git a/src/kontrol/solidity/SolidityListener.py b/src/kontrol/solidity/SolidityListener.py index 99cd558aa..8494e8ae9 100644 --- a/src/kontrol/solidity/SolidityListener.py +++ b/src/kontrol/solidity/SolidityListener.py @@ -1,214 +1,246 @@ # Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.2 from antlr4 import * - if "." in __name__: from .SolidityParser import SolidityParser else: from SolidityParser import SolidityParser - # This class defines a complete listener for a parse tree produced by SolidityParser. class SolidityListener(ParseTreeListener): # Enter a parse tree produced by SolidityParser#expression. - def enterExpression(self, ctx: SolidityParser.ExpressionContext): + def enterExpression(self, ctx:SolidityParser.ExpressionContext): pass # Exit a parse tree produced by SolidityParser#expression. - def exitExpression(self, ctx: SolidityParser.ExpressionContext): + def exitExpression(self, ctx:SolidityParser.ExpressionContext): pass + # Enter a parse tree produced by SolidityParser#RelationalExpression. - def enterRelationalExpression(self, ctx: SolidityParser.RelationalExpressionContext): + def enterRelationalExpression(self, ctx:SolidityParser.RelationalExpressionContext): pass # Exit a parse tree produced by SolidityParser#RelationalExpression. - def exitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionContext): + def exitRelationalExpression(self, ctx:SolidityParser.RelationalExpressionContext): pass + # Enter a parse tree produced by SolidityParser#AndExpression. - def enterAndExpression(self, ctx: SolidityParser.AndExpressionContext): + def enterAndExpression(self, ctx:SolidityParser.AndExpressionContext): pass # Exit a parse tree produced by SolidityParser#AndExpression. - def exitAndExpression(self, ctx: SolidityParser.AndExpressionContext): + def exitAndExpression(self, ctx:SolidityParser.AndExpressionContext): pass + # Enter a parse tree produced by SolidityParser#BooleanLiteral. - def enterBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext): + def enterBooleanLiteral(self, ctx:SolidityParser.BooleanLiteralContext): pass # Exit a parse tree produced by SolidityParser#BooleanLiteral. - def exitBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext): + def exitBooleanLiteral(self, ctx:SolidityParser.BooleanLiteralContext): pass + # Enter a parse tree produced by SolidityParser#NotExpression. - def enterNotExpression(self, ctx: SolidityParser.NotExpressionContext): + def enterNotExpression(self, ctx:SolidityParser.NotExpressionContext): pass # Exit a parse tree produced by SolidityParser#NotExpression. - def exitNotExpression(self, ctx: SolidityParser.NotExpressionContext): + def exitNotExpression(self, ctx:SolidityParser.NotExpressionContext): pass + # Enter a parse tree produced by SolidityParser#OrExpression. - def enterOrExpression(self, ctx: SolidityParser.OrExpressionContext): + def enterOrExpression(self, ctx:SolidityParser.OrExpressionContext): pass # Exit a parse tree produced by SolidityParser#OrExpression. - def exitOrExpression(self, ctx: SolidityParser.OrExpressionContext): + def exitOrExpression(self, ctx:SolidityParser.OrExpressionContext): pass + # Enter a parse tree produced by SolidityParser#ParenthesizedBooleanExpression. - def enterParenthesizedBooleanExpression(self, ctx: SolidityParser.ParenthesizedBooleanExpressionContext): + def enterParenthesizedBooleanExpression(self, ctx:SolidityParser.ParenthesizedBooleanExpressionContext): pass # Exit a parse tree produced by SolidityParser#ParenthesizedBooleanExpression. - def exitParenthesizedBooleanExpression(self, ctx: SolidityParser.ParenthesizedBooleanExpressionContext): + def exitParenthesizedBooleanExpression(self, ctx:SolidityParser.ParenthesizedBooleanExpressionContext): pass + # Enter a parse tree produced by SolidityParser#SubtractExpression. - def enterSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + def enterSubtractExpression(self, ctx:SolidityParser.SubtractExpressionContext): pass # Exit a parse tree produced by SolidityParser#SubtractExpression. - def exitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + def exitSubtractExpression(self, ctx:SolidityParser.SubtractExpressionContext): pass + # Enter a parse tree produced by SolidityParser#DivideExpression. - def enterDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + def enterDivideExpression(self, ctx:SolidityParser.DivideExpressionContext): pass # Exit a parse tree produced by SolidityParser#DivideExpression. - def exitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + def exitDivideExpression(self, ctx:SolidityParser.DivideExpressionContext): pass + # Enter a parse tree produced by SolidityParser#AddExpression. - def enterAddExpression(self, ctx: SolidityParser.AddExpressionContext): + def enterAddExpression(self, ctx:SolidityParser.AddExpressionContext): pass # Exit a parse tree produced by SolidityParser#AddExpression. - def exitAddExpression(self, ctx: SolidityParser.AddExpressionContext): + def exitAddExpression(self, ctx:SolidityParser.AddExpressionContext): + pass + + + # Enter a parse tree produced by SolidityParser#PowExpression. + def enterPowExpression(self, ctx:SolidityParser.PowExpressionContext): + pass + + # Exit a parse tree produced by SolidityParser#PowExpression. + def exitPowExpression(self, ctx:SolidityParser.PowExpressionContext): pass + # Enter a parse tree produced by SolidityParser#MultiplyExpression. - def enterMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + def enterMultiplyExpression(self, ctx:SolidityParser.MultiplyExpressionContext): pass # Exit a parse tree produced by SolidityParser#MultiplyExpression. - def exitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + def exitMultiplyExpression(self, ctx:SolidityParser.MultiplyExpressionContext): pass + # Enter a parse tree produced by SolidityParser#AtomExpression. - def enterAtomExpression(self, ctx: SolidityParser.AtomExpressionContext): + def enterAtomExpression(self, ctx:SolidityParser.AtomExpressionContext): pass # Exit a parse tree produced by SolidityParser#AtomExpression. - def exitAtomExpression(self, ctx: SolidityParser.AtomExpressionContext): + def exitAtomExpression(self, ctx:SolidityParser.AtomExpressionContext): pass + # Enter a parse tree produced by SolidityParser#Variable. - def enterVariable(self, ctx: SolidityParser.VariableContext): + def enterVariable(self, ctx:SolidityParser.VariableContext): pass # Exit a parse tree produced by SolidityParser#Variable. - def exitVariable(self, ctx: SolidityParser.VariableContext): + def exitVariable(self, ctx:SolidityParser.VariableContext): pass + # Enter a parse tree produced by SolidityParser#LengthAccess. - def enterLengthAccess(self, ctx: SolidityParser.LengthAccessContext): + def enterLengthAccess(self, ctx:SolidityParser.LengthAccessContext): pass # Exit a parse tree produced by SolidityParser#LengthAccess. - def exitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): + def exitLengthAccess(self, ctx:SolidityParser.LengthAccessContext): pass + # Enter a parse tree produced by SolidityParser#ArrayElement. - def enterArrayElement(self, ctx: SolidityParser.ArrayElementContext): + def enterArrayElement(self, ctx:SolidityParser.ArrayElementContext): pass # Exit a parse tree produced by SolidityParser#ArrayElement. - def exitArrayElement(self, ctx: SolidityParser.ArrayElementContext): + def exitArrayElement(self, ctx:SolidityParser.ArrayElementContext): pass + # Enter a parse tree produced by SolidityParser#MappingElement. - def enterMappingElement(self, ctx: SolidityParser.MappingElementContext): + def enterMappingElement(self, ctx:SolidityParser.MappingElementContext): pass # Exit a parse tree produced by SolidityParser#MappingElement. - def exitMappingElement(self, ctx: SolidityParser.MappingElementContext): + def exitMappingElement(self, ctx:SolidityParser.MappingElementContext): pass + # Enter a parse tree produced by SolidityParser#AddressLiteral. - def enterAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): + def enterAddressLiteral(self, ctx:SolidityParser.AddressLiteralContext): pass # Exit a parse tree produced by SolidityParser#AddressLiteral. - def exitAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): + def exitAddressLiteral(self, ctx:SolidityParser.AddressLiteralContext): pass + # Enter a parse tree produced by SolidityParser#IntegerLiteral. - def enterIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext): + def enterIntegerLiteral(self, ctx:SolidityParser.IntegerLiteralContext): pass # Exit a parse tree produced by SolidityParser#IntegerLiteral. - def exitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext): + def exitIntegerLiteral(self, ctx:SolidityParser.IntegerLiteralContext): pass + # Enter a parse tree produced by SolidityParser#ParenthesizedArithmeticExpression. - def enterParenthesizedArithmeticExpression(self, ctx: SolidityParser.ParenthesizedArithmeticExpressionContext): + def enterParenthesizedArithmeticExpression(self, ctx:SolidityParser.ParenthesizedArithmeticExpressionContext): pass # Exit a parse tree produced by SolidityParser#ParenthesizedArithmeticExpression. - def exitParenthesizedArithmeticExpression(self, ctx: SolidityParser.ParenthesizedArithmeticExpressionContext): + def exitParenthesizedArithmeticExpression(self, ctx:SolidityParser.ParenthesizedArithmeticExpressionContext): pass + # Enter a parse tree produced by SolidityParser#BlockAccess. - def enterBlockAccess(self, ctx: SolidityParser.BlockAccessContext): + def enterBlockAccess(self, ctx:SolidityParser.BlockAccessContext): pass # Exit a parse tree produced by SolidityParser#BlockAccess. - def exitBlockAccess(self, ctx: SolidityParser.BlockAccessContext): + def exitBlockAccess(self, ctx:SolidityParser.BlockAccessContext): pass + # Enter a parse tree produced by SolidityParser#MsgAccess. - def enterMsgAccess(self, ctx: SolidityParser.MsgAccessContext): + def enterMsgAccess(self, ctx:SolidityParser.MsgAccessContext): pass # Exit a parse tree produced by SolidityParser#MsgAccess. - def exitMsgAccess(self, ctx: SolidityParser.MsgAccessContext): + def exitMsgAccess(self, ctx:SolidityParser.MsgAccessContext): pass + # Enter a parse tree produced by SolidityParser#ContractVariableAccess. - def enterContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccessContext): + def enterContractVariableAccess(self, ctx:SolidityParser.ContractVariableAccessContext): pass # Exit a parse tree produced by SolidityParser#ContractVariableAccess. - def exitContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccessContext): + def exitContractVariableAccess(self, ctx:SolidityParser.ContractVariableAccessContext): pass + # Enter a parse tree produced by SolidityParser#ContractVariableArrayElement. - def enterContractVariableArrayElement(self, ctx: SolidityParser.ContractVariableArrayElementContext): + def enterContractVariableArrayElement(self, ctx:SolidityParser.ContractVariableArrayElementContext): pass # Exit a parse tree produced by SolidityParser#ContractVariableArrayElement. - def exitContractVariableArrayElement(self, ctx: SolidityParser.ContractVariableArrayElementContext): + def exitContractVariableArrayElement(self, ctx:SolidityParser.ContractVariableArrayElementContext): pass + # Enter a parse tree produced by SolidityParser#contractVariableAccessExpr. - def enterContractVariableAccessExpr(self, ctx: SolidityParser.ContractVariableAccessExprContext): + def enterContractVariableAccessExpr(self, ctx:SolidityParser.ContractVariableAccessExprContext): pass # Exit a parse tree produced by SolidityParser#contractVariableAccessExpr. - def exitContractVariableAccessExpr(self, ctx: SolidityParser.ContractVariableAccessExprContext): + def exitContractVariableAccessExpr(self, ctx:SolidityParser.ContractVariableAccessExprContext): pass + # Enter a parse tree produced by SolidityParser#contractVariableArrayElemExpr. - def enterContractVariableArrayElemExpr(self, ctx: SolidityParser.ContractVariableArrayElemExprContext): + def enterContractVariableArrayElemExpr(self, ctx:SolidityParser.ContractVariableArrayElemExprContext): pass # Exit a parse tree produced by SolidityParser#contractVariableArrayElemExpr. - def exitContractVariableArrayElemExpr(self, ctx: SolidityParser.ContractVariableArrayElemExprContext): + def exitContractVariableArrayElemExpr(self, ctx:SolidityParser.ContractVariableArrayElemExprContext): pass -del SolidityParser + +del SolidityParser \ No newline at end of file diff --git a/src/kontrol/solidity/SolidityParser.py b/src/kontrol/solidity/SolidityParser.py index 57b0a664b..5711f5896 100644 --- a/src/kontrol/solidity/SolidityParser.py +++ b/src/kontrol/solidity/SolidityParser.py @@ -1,863 +1,67 @@ # Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.2 # encoding: utf-8 -import sys -from io import StringIO - from antlr4 import * - +from io import StringIO +import sys if sys.version_info[1] > 5: - from typing import TextIO + from typing import TextIO else: - from typing.io import TextIO - + from typing.io import TextIO def serializedATN(): return [ - 4, - 1, - 24, - 87, - 2, - 0, - 7, - 0, - 2, - 1, - 7, - 1, - 2, - 2, - 7, - 2, - 2, - 3, - 7, - 3, - 2, - 4, - 7, - 4, - 2, - 5, - 7, - 5, - 1, - 0, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 3, - 1, - 27, - 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 5, - 1, - 35, - 8, - 1, - 10, - 1, - 12, - 1, - 38, - 9, - 1, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 1, - 2, - 5, - 2, - 55, - 8, - 2, - 10, - 2, - 12, - 2, - 58, - 9, - 2, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 1, - 3, - 3, - 3, - 74, - 8, - 3, - 1, - 4, - 1, - 4, - 1, - 4, - 1, - 4, - 1, - 5, - 1, - 5, - 1, - 5, - 1, - 5, - 1, - 5, - 1, - 5, - 1, - 5, - 1, - 5, - 0, - 2, - 2, - 4, - 6, - 0, - 2, - 4, - 6, - 8, - 10, - 0, - 1, - 1, - 0, - 14, - 16, - 99, - 0, - 12, - 1, - 0, - 0, - 0, - 2, - 26, - 1, - 0, - 0, - 0, - 4, - 39, - 1, - 0, - 0, - 0, - 6, - 73, - 1, - 0, - 0, - 0, - 8, - 75, - 1, - 0, - 0, - 0, - 10, - 79, - 1, - 0, - 0, - 0, - 12, - 13, - 3, - 2, - 1, - 0, - 13, - 1, - 1, - 0, - 0, - 0, - 14, - 15, - 6, - 1, - -1, - 0, - 15, - 16, - 5, - 3, - 0, - 0, - 16, - 27, - 3, - 2, - 1, - 4, - 17, - 18, - 3, - 4, - 2, - 0, - 18, - 19, - 5, - 23, - 0, - 0, - 19, - 20, - 3, - 4, - 2, - 0, - 20, - 27, - 1, - 0, - 0, - 0, - 21, - 27, - 5, - 13, - 0, - 0, - 22, - 23, - 5, - 4, - 0, - 0, - 23, - 24, - 3, - 2, - 1, - 0, - 24, - 25, - 5, - 5, - 0, - 0, - 25, - 27, - 1, - 0, - 0, - 0, - 26, - 14, - 1, - 0, - 0, - 0, - 26, - 17, - 1, - 0, - 0, - 0, - 26, - 21, - 1, - 0, - 0, - 0, - 26, - 22, - 1, - 0, - 0, - 0, - 27, - 36, - 1, - 0, - 0, - 0, - 28, - 29, - 10, - 6, - 0, - 0, - 29, - 30, - 5, - 1, - 0, - 0, - 30, - 35, - 3, - 2, - 1, - 7, - 31, - 32, - 10, - 5, - 0, - 0, - 32, - 33, - 5, - 2, - 0, - 0, - 33, - 35, - 3, - 2, - 1, - 6, - 34, - 28, - 1, - 0, - 0, - 0, - 34, - 31, - 1, - 0, - 0, - 0, - 35, - 38, - 1, - 0, - 0, - 0, - 36, - 34, - 1, - 0, - 0, - 0, - 36, - 37, - 1, - 0, - 0, - 0, - 37, - 3, - 1, - 0, - 0, - 0, - 38, - 36, - 1, - 0, - 0, - 0, - 39, - 40, - 6, - 2, - -1, - 0, - 40, - 41, - 3, - 6, - 3, - 0, - 41, - 56, - 1, - 0, - 0, - 0, - 42, - 43, - 10, - 5, - 0, - 0, - 43, - 44, - 5, - 6, - 0, - 0, - 44, - 55, - 3, - 4, - 2, - 6, - 45, - 46, - 10, - 4, - 0, - 0, - 46, - 47, - 5, - 7, - 0, - 0, - 47, - 55, - 3, - 4, - 2, - 5, - 48, - 49, - 10, - 3, - 0, - 0, - 49, - 50, - 5, - 8, - 0, - 0, - 50, - 55, - 3, - 4, - 2, - 4, - 51, - 52, - 10, - 2, - 0, - 0, - 52, - 53, - 5, - 9, - 0, - 0, - 53, - 55, - 3, - 4, - 2, - 3, - 54, - 42, - 1, - 0, - 0, - 0, - 54, - 45, - 1, - 0, - 0, - 0, - 54, - 48, - 1, - 0, - 0, - 0, - 54, - 51, - 1, - 0, - 0, - 0, - 55, - 58, - 1, - 0, - 0, - 0, - 56, - 54, - 1, - 0, - 0, - 0, - 56, - 57, - 1, - 0, - 0, - 0, - 57, - 5, - 1, - 0, - 0, - 0, - 58, - 56, - 1, - 0, - 0, - 0, - 59, - 74, - 5, - 16, - 0, - 0, - 60, - 74, - 5, - 17, - 0, - 0, - 61, - 74, - 5, - 18, - 0, - 0, - 62, - 74, - 5, - 19, - 0, - 0, - 63, - 74, - 5, - 20, - 0, - 0, - 64, - 74, - 5, - 14, - 0, - 0, - 65, - 66, - 5, - 4, - 0, - 0, - 66, - 67, - 3, - 4, - 2, - 0, - 67, - 68, - 5, - 5, - 0, - 0, - 68, - 74, - 1, - 0, - 0, - 0, - 69, - 74, - 5, - 21, - 0, - 0, - 70, - 74, - 5, - 22, - 0, - 0, - 71, - 74, - 3, - 8, - 4, - 0, - 72, - 74, - 3, - 10, - 5, - 0, - 73, - 59, - 1, - 0, - 0, - 0, - 73, - 60, - 1, - 0, - 0, - 0, - 73, - 61, - 1, - 0, - 0, - 0, - 73, - 62, - 1, - 0, - 0, - 0, - 73, - 63, - 1, - 0, - 0, - 0, - 73, - 64, - 1, - 0, - 0, - 0, - 73, - 65, - 1, - 0, - 0, - 0, - 73, - 69, - 1, - 0, - 0, - 0, - 73, - 70, - 1, - 0, - 0, - 0, - 73, - 71, - 1, - 0, - 0, - 0, - 73, - 72, - 1, - 0, - 0, - 0, - 74, - 7, - 1, - 0, - 0, - 0, - 75, - 76, - 5, - 16, - 0, - 0, - 76, - 77, - 5, - 10, - 0, - 0, - 77, - 78, - 5, - 16, - 0, - 0, - 78, - 9, - 1, - 0, - 0, - 0, - 79, - 80, - 5, - 16, - 0, - 0, - 80, - 81, - 5, - 10, - 0, - 0, - 81, - 82, - 5, - 16, - 0, - 0, - 82, - 83, - 5, - 11, - 0, - 0, - 83, - 84, - 7, - 0, - 0, - 0, - 84, - 85, - 5, - 12, - 0, - 0, - 85, - 11, - 1, - 0, - 0, - 0, - 6, - 26, - 34, - 36, - 54, - 56, - 73, + 4,1,25,90,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,1,0,1, + 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,27,8,1,1,1, + 1,1,1,1,1,1,1,1,1,1,5,1,35,8,1,10,1,12,1,38,9,1,1,2,1,2,1,2,1,2, + 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,5,2,58,8, + 2,10,2,12,2,61,9,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1, + 3,1,3,1,3,3,3,77,8,3,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5, + 1,5,0,2,2,4,6,0,2,4,6,8,10,0,1,1,0,15,17,103,0,12,1,0,0,0,2,26,1, + 0,0,0,4,39,1,0,0,0,6,76,1,0,0,0,8,78,1,0,0,0,10,82,1,0,0,0,12,13, + 3,2,1,0,13,1,1,0,0,0,14,15,6,1,-1,0,15,16,5,3,0,0,16,27,3,2,1,4, + 17,18,3,4,2,0,18,19,5,24,0,0,19,20,3,4,2,0,20,27,1,0,0,0,21,27,5, + 14,0,0,22,23,5,4,0,0,23,24,3,2,1,0,24,25,5,5,0,0,25,27,1,0,0,0,26, + 14,1,0,0,0,26,17,1,0,0,0,26,21,1,0,0,0,26,22,1,0,0,0,27,36,1,0,0, + 0,28,29,10,6,0,0,29,30,5,1,0,0,30,35,3,2,1,7,31,32,10,5,0,0,32,33, + 5,2,0,0,33,35,3,2,1,6,34,28,1,0,0,0,34,31,1,0,0,0,35,38,1,0,0,0, + 36,34,1,0,0,0,36,37,1,0,0,0,37,3,1,0,0,0,38,36,1,0,0,0,39,40,6,2, + -1,0,40,41,3,6,3,0,41,59,1,0,0,0,42,43,10,6,0,0,43,44,5,6,0,0,44, + 58,3,4,2,7,45,46,10,5,0,0,46,47,5,7,0,0,47,58,3,4,2,6,48,49,10,4, + 0,0,49,50,5,8,0,0,50,58,3,4,2,5,51,52,10,3,0,0,52,53,5,9,0,0,53, + 58,3,4,2,4,54,55,10,2,0,0,55,56,5,10,0,0,56,58,3,4,2,3,57,42,1,0, + 0,0,57,45,1,0,0,0,57,48,1,0,0,0,57,51,1,0,0,0,57,54,1,0,0,0,58,61, + 1,0,0,0,59,57,1,0,0,0,59,60,1,0,0,0,60,5,1,0,0,0,61,59,1,0,0,0,62, + 77,5,17,0,0,63,77,5,18,0,0,64,77,5,19,0,0,65,77,5,20,0,0,66,77,5, + 21,0,0,67,77,5,15,0,0,68,69,5,4,0,0,69,70,3,4,2,0,70,71,5,5,0,0, + 71,77,1,0,0,0,72,77,5,22,0,0,73,77,5,23,0,0,74,77,3,8,4,0,75,77, + 3,10,5,0,76,62,1,0,0,0,76,63,1,0,0,0,76,64,1,0,0,0,76,65,1,0,0,0, + 76,66,1,0,0,0,76,67,1,0,0,0,76,68,1,0,0,0,76,72,1,0,0,0,76,73,1, + 0,0,0,76,74,1,0,0,0,76,75,1,0,0,0,77,7,1,0,0,0,78,79,5,17,0,0,79, + 80,5,11,0,0,80,81,5,17,0,0,81,9,1,0,0,0,82,83,5,17,0,0,83,84,5,11, + 0,0,84,85,5,17,0,0,85,86,5,12,0,0,86,87,7,0,0,0,87,88,5,13,0,0,88, + 11,1,0,0,0,6,26,34,36,57,59,76 ] - -class SolidityParser(Parser): +class SolidityParser ( Parser ): grammarFileName = "Solidity.g4" atn = ATNDeserializer().deserialize(serializedATN()) - decisionsToDFA = [DFA(ds, i) for i, ds in enumerate(atn.decisionToState)] + decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ] sharedContextCache = PredictionContextCache() - literalNames = ["", "'&&'", "'||'", "'!'", "'('", "')'", "'+'", "'-'", "'*'", "'/'", "'.'", "'['", "']'"] - - symbolicNames = [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "BOOLEAN_LITERAL", - "INTEGER", - "ADDRESS", - "VariableName", - "LengthAccess", - "ArrayElement", - "MappingElement", - "AddressLiteral", - "BlockAccess", - "MsgAccess", - "RelOp", - "WS", - ] + literalNames = [ "", "'&&'", "'||'", "'!'", "'('", "')'", "'+'", + "'-'", "'*'", "'/'", "'**'", "'.'", "'['", "']'" ] + + symbolicNames = [ "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "BOOLEAN_LITERAL", "INTEGER", + "ADDRESS", "VariableName", "LengthAccess", "ArrayElement", + "MappingElement", "AddressLiteral", "BlockAccess", + "MsgAccess", "RelOp", "WS" ] RULE_expression = 0 RULE_booleanExpression = 1 @@ -866,74 +70,76 @@ class SolidityParser(Parser): RULE_contractVariableAccessExpr = 4 RULE_contractVariableArrayElemExpr = 5 - ruleNames = [ - "expression", - "booleanExpression", - "arithmeticExpression", - "atom", - "contractVariableAccessExpr", - "contractVariableArrayElemExpr", - ] + ruleNames = [ "expression", "booleanExpression", "arithmeticExpression", + "atom", "contractVariableAccessExpr", "contractVariableArrayElemExpr" ] EOF = Token.EOF - T__0 = 1 - T__1 = 2 - T__2 = 3 - T__3 = 4 - T__4 = 5 - T__5 = 6 - T__6 = 7 - T__7 = 8 - T__8 = 9 - T__9 = 10 - T__10 = 11 - T__11 = 12 - BOOLEAN_LITERAL = 13 - INTEGER = 14 - ADDRESS = 15 - VariableName = 16 - LengthAccess = 17 - ArrayElement = 18 - MappingElement = 19 - AddressLiteral = 20 - BlockAccess = 21 - MsgAccess = 22 - RelOp = 23 - WS = 24 - - def __init__(self, input: TokenStream, output: TextIO = sys.stdout): + T__0=1 + T__1=2 + T__2=3 + T__3=4 + T__4=5 + T__5=6 + T__6=7 + T__7=8 + T__8=9 + T__9=10 + T__10=11 + T__11=12 + T__12=13 + BOOLEAN_LITERAL=14 + INTEGER=15 + ADDRESS=16 + VariableName=17 + LengthAccess=18 + ArrayElement=19 + MappingElement=20 + AddressLiteral=21 + BlockAccess=22 + MsgAccess=23 + RelOp=24 + WS=25 + + def __init__(self, input:TokenStream, output:TextIO = sys.stdout): super().__init__(input, output) self.checkVersion("4.13.2") self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache) self._predicates = None + + + class ExpressionContext(ParserRuleContext): __slots__ = 'parser' - def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser def booleanExpression(self): - return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, 0) + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext,0) + def getRuleIndex(self): return SolidityParser.RULE_expression - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterExpression"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterExpression" ): listener.enterExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitExpression" ): listener.exitExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitExpression" ): return visitor.visitExpression(self) else: return visitor.visitChildren(self) + + + def expression(self): localctx = SolidityParser.ExpressionContext(self, self._ctx, self.state) @@ -950,170 +156,185 @@ def expression(self): self.exitRule() return localctx + class BooleanExpressionContext(ParserRuleContext): __slots__ = 'parser' - def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser + def getRuleIndex(self): return SolidityParser.RULE_booleanExpression - def copyFrom(self, ctx: ParserRuleContext): + + def copyFrom(self, ctx:ParserRuleContext): super().copyFrom(ctx) + class RelationalExpressionContext(BooleanExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext super().__init__(parser) self.copyFrom(ctx) - def arithmeticExpression(self, i: int = None): + def arithmeticExpression(self, i:int=None): if i is None: return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) else: - return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext,i) def RelOp(self): return self.getToken(SolidityParser.RelOp, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterRelationalExpression"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterRelationalExpression" ): listener.enterRelationalExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitRelationalExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitRelationalExpression" ): listener.exitRelationalExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitRelationalExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitRelationalExpression" ): return visitor.visitRelationalExpression(self) else: return visitor.visitChildren(self) + class AndExpressionContext(BooleanExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext super().__init__(parser) self.copyFrom(ctx) - def booleanExpression(self, i: int = None): + def booleanExpression(self, i:int=None): if i is None: return self.getTypedRuleContexts(SolidityParser.BooleanExpressionContext) else: - return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, i) + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext,i) + - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterAndExpression"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterAndExpression" ): listener.enterAndExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitAndExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitAndExpression" ): listener.exitAndExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitAndExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitAndExpression" ): return visitor.visitAndExpression(self) else: return visitor.visitChildren(self) + class BooleanLiteralContext(BooleanExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext super().__init__(parser) self.copyFrom(ctx) def BOOLEAN_LITERAL(self): return self.getToken(SolidityParser.BOOLEAN_LITERAL, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterBooleanLiteral"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterBooleanLiteral" ): listener.enterBooleanLiteral(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitBooleanLiteral"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitBooleanLiteral" ): listener.exitBooleanLiteral(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitBooleanLiteral"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitBooleanLiteral" ): return visitor.visitBooleanLiteral(self) else: return visitor.visitChildren(self) + class NotExpressionContext(BooleanExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext super().__init__(parser) self.copyFrom(ctx) def booleanExpression(self): - return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, 0) + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext,0) + - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterNotExpression"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterNotExpression" ): listener.enterNotExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitNotExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitNotExpression" ): listener.exitNotExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitNotExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitNotExpression" ): return visitor.visitNotExpression(self) else: return visitor.visitChildren(self) + class OrExpressionContext(BooleanExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext super().__init__(parser) self.copyFrom(ctx) - def booleanExpression(self, i: int = None): + def booleanExpression(self, i:int=None): if i is None: return self.getTypedRuleContexts(SolidityParser.BooleanExpressionContext) else: - return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, i) + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext,i) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterOrExpression"): + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterOrExpression" ): listener.enterOrExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitOrExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitOrExpression" ): listener.exitOrExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitOrExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitOrExpression" ): return visitor.visitOrExpression(self) else: return visitor.visitChildren(self) + class ParenthesizedBooleanExpressionContext(BooleanExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.BooleanExpressionContext super().__init__(parser) self.copyFrom(ctx) def booleanExpression(self): - return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext, 0) + return self.getTypedRuleContext(SolidityParser.BooleanExpressionContext,0) + - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterParenthesizedBooleanExpression"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterParenthesizedBooleanExpression" ): listener.enterParenthesizedBooleanExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitParenthesizedBooleanExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitParenthesizedBooleanExpression" ): listener.exitParenthesizedBooleanExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitParenthesizedBooleanExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitParenthesizedBooleanExpression" ): return visitor.visitParenthesizedBooleanExpression(self) else: return visitor.visitChildren(self) - def booleanExpression(self, _p: int = 0): + + + def booleanExpression(self, _p:int=0): _parentctx = self._ctx _parentState = self.state localctx = SolidityParser.BooleanExpressionContext(self, self._ctx, _parentState) @@ -1124,7 +345,7 @@ def booleanExpression(self, _p: int = 0): self.enterOuterAlt(localctx, 1) self.state = 26 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input, 0, self._ctx) + la_ = self._interp.adaptivePredict(self._input,0,self._ctx) if la_ == 1: localctx = SolidityParser.NotExpressionContext(self, localctx) self._ctx = localctx @@ -1168,27 +389,25 @@ def booleanExpression(self, _p: int = 0): self.match(SolidityParser.T__4) pass + self._ctx.stop = self._input.LT(-1) self.state = 36 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input, 2, self._ctx) - while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER: - if _alt == 1: + _alt = self._interp.adaptivePredict(self._input,2,self._ctx) + while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + if _alt==1: if self._parseListeners is not None: self.triggerExitRuleEvent() _prevctx = localctx self.state = 34 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input, 1, self._ctx) + la_ = self._interp.adaptivePredict(self._input,1,self._ctx) if la_ == 1: - localctx = SolidityParser.AndExpressionContext( - self, SolidityParser.BooleanExpressionContext(self, _parentctx, _parentState) - ) + localctx = SolidityParser.AndExpressionContext(self, SolidityParser.BooleanExpressionContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_booleanExpression) self.state = 28 if not self.precpred(self._ctx, 6): from antlr4.error.Errors import FailedPredicateException - raise FailedPredicateException(self, "self.precpred(self._ctx, 6)") self.state = 29 self.match(SolidityParser.T__0) @@ -1197,14 +416,11 @@ def booleanExpression(self, _p: int = 0): pass elif la_ == 2: - localctx = SolidityParser.OrExpressionContext( - self, SolidityParser.BooleanExpressionContext(self, _parentctx, _parentState) - ) + localctx = SolidityParser.OrExpressionContext(self, SolidityParser.BooleanExpressionContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_booleanExpression) self.state = 31 if not self.precpred(self._ctx, 5): from antlr4.error.Errors import FailedPredicateException - raise FailedPredicateException(self, "self.precpred(self._ctx, 5)") self.state = 32 self.match(SolidityParser.T__1) @@ -1212,9 +428,10 @@ def booleanExpression(self, _p: int = 0): self.booleanExpression(6) pass + self.state = 38 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input, 2, self._ctx) + _alt = self._interp.adaptivePredict(self._input,2,self._ctx) except RecognitionException as re: localctx.exception = re @@ -1224,147 +441,190 @@ def booleanExpression(self, _p: int = 0): self.unrollRecursionContexts(_parentctx) return localctx + class ArithmeticExpressionContext(ParserRuleContext): __slots__ = 'parser' - def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser + def getRuleIndex(self): return SolidityParser.RULE_arithmeticExpression - def copyFrom(self, ctx: ParserRuleContext): + + def copyFrom(self, ctx:ParserRuleContext): super().copyFrom(ctx) + class SubtractExpressionContext(ArithmeticExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext super().__init__(parser) self.copyFrom(ctx) - def arithmeticExpression(self, i: int = None): + def arithmeticExpression(self, i:int=None): if i is None: return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) else: - return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext,i) + - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterSubtractExpression"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterSubtractExpression" ): listener.enterSubtractExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitSubtractExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitSubtractExpression" ): listener.exitSubtractExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitSubtractExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitSubtractExpression" ): return visitor.visitSubtractExpression(self) else: return visitor.visitChildren(self) + class DivideExpressionContext(ArithmeticExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext super().__init__(parser) self.copyFrom(ctx) - def arithmeticExpression(self, i: int = None): + def arithmeticExpression(self, i:int=None): if i is None: return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) else: - return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext,i) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterDivideExpression"): + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterDivideExpression" ): listener.enterDivideExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitDivideExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitDivideExpression" ): listener.exitDivideExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitDivideExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitDivideExpression" ): return visitor.visitDivideExpression(self) else: return visitor.visitChildren(self) + class AddExpressionContext(ArithmeticExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext super().__init__(parser) self.copyFrom(ctx) - def arithmeticExpression(self, i: int = None): + def arithmeticExpression(self, i:int=None): if i is None: return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) else: - return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext,i) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterAddExpression"): + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterAddExpression" ): listener.enterAddExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitAddExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitAddExpression" ): listener.exitAddExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitAddExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitAddExpression" ): return visitor.visitAddExpression(self) else: return visitor.visitChildren(self) + + class PowExpressionContext(ArithmeticExpressionContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + super().__init__(parser) + self.copyFrom(ctx) + + def arithmeticExpression(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) + else: + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterPowExpression" ): + listener.enterPowExpression(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitPowExpression" ): + listener.exitPowExpression(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitPowExpression" ): + return visitor.visitPowExpression(self) + else: + return visitor.visitChildren(self) + + class MultiplyExpressionContext(ArithmeticExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext super().__init__(parser) self.copyFrom(ctx) - def arithmeticExpression(self, i: int = None): + def arithmeticExpression(self, i:int=None): if i is None: return self.getTypedRuleContexts(SolidityParser.ArithmeticExpressionContext) else: - return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, i) + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext,i) + - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterMultiplyExpression"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMultiplyExpression" ): listener.enterMultiplyExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitMultiplyExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMultiplyExpression" ): listener.exitMultiplyExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitMultiplyExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitMultiplyExpression" ): return visitor.visitMultiplyExpression(self) else: return visitor.visitChildren(self) + class AtomExpressionContext(ArithmeticExpressionContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.ArithmeticExpressionContext super().__init__(parser) self.copyFrom(ctx) def atom(self): - return self.getTypedRuleContext(SolidityParser.AtomContext, 0) + return self.getTypedRuleContext(SolidityParser.AtomContext,0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterAtomExpression"): + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterAtomExpression" ): listener.enterAtomExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitAtomExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitAtomExpression" ): listener.exitAtomExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitAtomExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitAtomExpression" ): return visitor.visitAtomExpression(self) else: return visitor.visitChildren(self) - def arithmeticExpression(self, _p: int = 0): + + + def arithmeticExpression(self, _p:int=0): _parentctx = self._ctx _parentState = self.state localctx = SolidityParser.ArithmeticExpressionContext(self, self._ctx, _parentState) @@ -1380,84 +640,86 @@ def arithmeticExpression(self, _p: int = 0): self.state = 40 self.atom() self._ctx.stop = self._input.LT(-1) - self.state = 56 + self.state = 59 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input, 4, self._ctx) - while _alt != 2 and _alt != ATN.INVALID_ALT_NUMBER: - if _alt == 1: + _alt = self._interp.adaptivePredict(self._input,4,self._ctx) + while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + if _alt==1: if self._parseListeners is not None: self.triggerExitRuleEvent() _prevctx = localctx - self.state = 54 + self.state = 57 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input, 3, self._ctx) + la_ = self._interp.adaptivePredict(self._input,3,self._ctx) if la_ == 1: - localctx = SolidityParser.AddExpressionContext( - self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) - ) + localctx = SolidityParser.AddExpressionContext(self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) self.state = 42 - if not self.precpred(self._ctx, 5): + if not self.precpred(self._ctx, 6): from antlr4.error.Errors import FailedPredicateException - - raise FailedPredicateException(self, "self.precpred(self._ctx, 5)") + raise FailedPredicateException(self, "self.precpred(self._ctx, 6)") self.state = 43 self.match(SolidityParser.T__5) self.state = 44 - self.arithmeticExpression(6) + self.arithmeticExpression(7) pass elif la_ == 2: - localctx = SolidityParser.SubtractExpressionContext( - self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) - ) + localctx = SolidityParser.SubtractExpressionContext(self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) self.state = 45 - if not self.precpred(self._ctx, 4): + if not self.precpred(self._ctx, 5): from antlr4.error.Errors import FailedPredicateException - - raise FailedPredicateException(self, "self.precpred(self._ctx, 4)") + raise FailedPredicateException(self, "self.precpred(self._ctx, 5)") self.state = 46 self.match(SolidityParser.T__6) self.state = 47 - self.arithmeticExpression(5) + self.arithmeticExpression(6) pass elif la_ == 3: - localctx = SolidityParser.MultiplyExpressionContext( - self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) - ) + localctx = SolidityParser.MultiplyExpressionContext(self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) self.state = 48 - if not self.precpred(self._ctx, 3): + if not self.precpred(self._ctx, 4): from antlr4.error.Errors import FailedPredicateException - - raise FailedPredicateException(self, "self.precpred(self._ctx, 3)") + raise FailedPredicateException(self, "self.precpred(self._ctx, 4)") self.state = 49 self.match(SolidityParser.T__7) self.state = 50 - self.arithmeticExpression(4) + self.arithmeticExpression(5) pass elif la_ == 4: - localctx = SolidityParser.DivideExpressionContext( - self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState) - ) + localctx = SolidityParser.DivideExpressionContext(self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) self.state = 51 - if not self.precpred(self._ctx, 2): + if not self.precpred(self._ctx, 3): from antlr4.error.Errors import FailedPredicateException - - raise FailedPredicateException(self, "self.precpred(self._ctx, 2)") + raise FailedPredicateException(self, "self.precpred(self._ctx, 3)") self.state = 52 self.match(SolidityParser.T__8) self.state = 53 + self.arithmeticExpression(4) + pass + + elif la_ == 5: + localctx = SolidityParser.PowExpressionContext(self, SolidityParser.ArithmeticExpressionContext(self, _parentctx, _parentState)) + self.pushNewRecursionContext(localctx, _startState, self.RULE_arithmeticExpression) + self.state = 54 + if not self.precpred(self._ctx, 2): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 2)") + self.state = 55 + self.match(SolidityParser.T__9) + self.state = 56 self.arithmeticExpression(3) pass - self.state = 58 + + self.state = 61 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input, 4, self._ctx) + _alt = self._interp.adaptivePredict(self._input,4,self._ctx) except RecognitionException as re: localctx.exception = re @@ -1467,361 +729,382 @@ def arithmeticExpression(self, _p: int = 0): self.unrollRecursionContexts(_parentctx) return localctx + class AtomContext(ParserRuleContext): __slots__ = 'parser' - def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser + def getRuleIndex(self): return SolidityParser.RULE_atom - def copyFrom(self, ctx: ParserRuleContext): + + def copyFrom(self, ctx:ParserRuleContext): super().copyFrom(ctx) + + class ParenthesizedArithmeticExpressionContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def arithmeticExpression(self): - return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext, 0) + return self.getTypedRuleContext(SolidityParser.ArithmeticExpressionContext,0) + - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterParenthesizedArithmeticExpression"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterParenthesizedArithmeticExpression" ): listener.enterParenthesizedArithmeticExpression(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitParenthesizedArithmeticExpression"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitParenthesizedArithmeticExpression" ): listener.exitParenthesizedArithmeticExpression(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitParenthesizedArithmeticExpression"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitParenthesizedArithmeticExpression" ): return visitor.visitParenthesizedArithmeticExpression(self) else: return visitor.visitChildren(self) + class LengthAccessContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def LengthAccess(self): return self.getToken(SolidityParser.LengthAccess, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterLengthAccess"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterLengthAccess" ): listener.enterLengthAccess(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitLengthAccess"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitLengthAccess" ): listener.exitLengthAccess(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitLengthAccess"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitLengthAccess" ): return visitor.visitLengthAccess(self) else: return visitor.visitChildren(self) + class ContractVariableAccessContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def contractVariableAccessExpr(self): - return self.getTypedRuleContext(SolidityParser.ContractVariableAccessExprContext, 0) + return self.getTypedRuleContext(SolidityParser.ContractVariableAccessExprContext,0) + - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterContractVariableAccess"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterContractVariableAccess" ): listener.enterContractVariableAccess(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitContractVariableAccess"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitContractVariableAccess" ): listener.exitContractVariableAccess(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitContractVariableAccess"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitContractVariableAccess" ): return visitor.visitContractVariableAccess(self) else: return visitor.visitChildren(self) + class VariableContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def VariableName(self): return self.getToken(SolidityParser.VariableName, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterVariable"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterVariable" ): listener.enterVariable(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitVariable"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitVariable" ): listener.exitVariable(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitVariable"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitVariable" ): return visitor.visitVariable(self) else: return visitor.visitChildren(self) + class MappingElementContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def MappingElement(self): return self.getToken(SolidityParser.MappingElement, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterMappingElement"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMappingElement" ): listener.enterMappingElement(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitMappingElement"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMappingElement" ): listener.exitMappingElement(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitMappingElement"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitMappingElement" ): return visitor.visitMappingElement(self) else: return visitor.visitChildren(self) + class BlockAccessContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def BlockAccess(self): return self.getToken(SolidityParser.BlockAccess, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterBlockAccess"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterBlockAccess" ): listener.enterBlockAccess(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitBlockAccess"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitBlockAccess" ): listener.exitBlockAccess(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitBlockAccess"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitBlockAccess" ): return visitor.visitBlockAccess(self) else: return visitor.visitChildren(self) + class AddressLiteralContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def AddressLiteral(self): return self.getToken(SolidityParser.AddressLiteral, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterAddressLiteral"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterAddressLiteral" ): listener.enterAddressLiteral(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitAddressLiteral"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitAddressLiteral" ): listener.exitAddressLiteral(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitAddressLiteral"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitAddressLiteral" ): return visitor.visitAddressLiteral(self) else: return visitor.visitChildren(self) + class ContractVariableArrayElementContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def contractVariableArrayElemExpr(self): - return self.getTypedRuleContext(SolidityParser.ContractVariableArrayElemExprContext, 0) + return self.getTypedRuleContext(SolidityParser.ContractVariableArrayElemExprContext,0) + - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterContractVariableArrayElement"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterContractVariableArrayElement" ): listener.enterContractVariableArrayElement(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitContractVariableArrayElement"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitContractVariableArrayElement" ): listener.exitContractVariableArrayElement(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitContractVariableArrayElement"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitContractVariableArrayElement" ): return visitor.visitContractVariableArrayElement(self) else: return visitor.visitChildren(self) + class ArrayElementContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def ArrayElement(self): return self.getToken(SolidityParser.ArrayElement, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterArrayElement"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterArrayElement" ): listener.enterArrayElement(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitArrayElement"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitArrayElement" ): listener.exitArrayElement(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitArrayElement"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitArrayElement" ): return visitor.visitArrayElement(self) else: return visitor.visitChildren(self) + class IntegerLiteralContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def INTEGER(self): return self.getToken(SolidityParser.INTEGER, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterIntegerLiteral"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterIntegerLiteral" ): listener.enterIntegerLiteral(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitIntegerLiteral"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitIntegerLiteral" ): listener.exitIntegerLiteral(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitIntegerLiteral"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitIntegerLiteral" ): return visitor.visitIntegerLiteral(self) else: return visitor.visitChildren(self) + class MsgAccessContext(AtomContext): - def __init__(self, parser, ctx: ParserRuleContext): # actually a SolidityParser.AtomContext + def __init__(self, parser, ctx:ParserRuleContext): # actually a SolidityParser.AtomContext super().__init__(parser) self.copyFrom(ctx) def MsgAccess(self): return self.getToken(SolidityParser.MsgAccess, 0) - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterMsgAccess"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMsgAccess" ): listener.enterMsgAccess(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitMsgAccess"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMsgAccess" ): listener.exitMsgAccess(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitMsgAccess"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitMsgAccess" ): return visitor.visitMsgAccess(self) else: return visitor.visitChildren(self) + + def atom(self): localctx = SolidityParser.AtomContext(self, self._ctx, self.state) self.enterRule(localctx, 6, self.RULE_atom) try: - self.state = 73 + self.state = 76 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input, 5, self._ctx) + la_ = self._interp.adaptivePredict(self._input,5,self._ctx) if la_ == 1: localctx = SolidityParser.VariableContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 59 + self.state = 62 self.match(SolidityParser.VariableName) pass elif la_ == 2: localctx = SolidityParser.LengthAccessContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 60 + self.state = 63 self.match(SolidityParser.LengthAccess) pass elif la_ == 3: localctx = SolidityParser.ArrayElementContext(self, localctx) self.enterOuterAlt(localctx, 3) - self.state = 61 + self.state = 64 self.match(SolidityParser.ArrayElement) pass elif la_ == 4: localctx = SolidityParser.MappingElementContext(self, localctx) self.enterOuterAlt(localctx, 4) - self.state = 62 + self.state = 65 self.match(SolidityParser.MappingElement) pass elif la_ == 5: localctx = SolidityParser.AddressLiteralContext(self, localctx) self.enterOuterAlt(localctx, 5) - self.state = 63 + self.state = 66 self.match(SolidityParser.AddressLiteral) pass elif la_ == 6: localctx = SolidityParser.IntegerLiteralContext(self, localctx) self.enterOuterAlt(localctx, 6) - self.state = 64 + self.state = 67 self.match(SolidityParser.INTEGER) pass elif la_ == 7: localctx = SolidityParser.ParenthesizedArithmeticExpressionContext(self, localctx) self.enterOuterAlt(localctx, 7) - self.state = 65 + self.state = 68 self.match(SolidityParser.T__3) - self.state = 66 + self.state = 69 self.arithmeticExpression(0) - self.state = 67 + self.state = 70 self.match(SolidityParser.T__4) pass elif la_ == 8: localctx = SolidityParser.BlockAccessContext(self, localctx) self.enterOuterAlt(localctx, 8) - self.state = 69 + self.state = 72 self.match(SolidityParser.BlockAccess) pass elif la_ == 9: localctx = SolidityParser.MsgAccessContext(self, localctx) self.enterOuterAlt(localctx, 9) - self.state = 70 + self.state = 73 self.match(SolidityParser.MsgAccess) pass elif la_ == 10: localctx = SolidityParser.ContractVariableAccessContext(self, localctx) self.enterOuterAlt(localctx, 10) - self.state = 71 + self.state = 74 self.contractVariableAccessExpr() pass elif la_ == 11: localctx = SolidityParser.ContractVariableArrayElementContext(self, localctx) self.enterOuterAlt(localctx, 11) - self.state = 72 + self.state = 75 self.contractVariableArrayElemExpr() pass + except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -1830,14 +1113,15 @@ def atom(self): self.exitRule() return localctx + class ContractVariableAccessExprContext(ParserRuleContext): __slots__ = 'parser' - def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def VariableName(self, i: int = None): + def VariableName(self, i:int=None): if i is None: return self.getTokens(SolidityParser.VariableName) else: @@ -1846,31 +1130,34 @@ def VariableName(self, i: int = None): def getRuleIndex(self): return SolidityParser.RULE_contractVariableAccessExpr - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterContractVariableAccessExpr"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterContractVariableAccessExpr" ): listener.enterContractVariableAccessExpr(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitContractVariableAccessExpr"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitContractVariableAccessExpr" ): listener.exitContractVariableAccessExpr(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitContractVariableAccessExpr"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitContractVariableAccessExpr" ): return visitor.visitContractVariableAccessExpr(self) else: return visitor.visitChildren(self) + + + def contractVariableAccessExpr(self): localctx = SolidityParser.ContractVariableAccessExprContext(self, self._ctx, self.state) self.enterRule(localctx, 8, self.RULE_contractVariableAccessExpr) try: self.enterOuterAlt(localctx, 1) - self.state = 75 + self.state = 78 self.match(SolidityParser.VariableName) - self.state = 76 - self.match(SolidityParser.T__9) - self.state = 77 + self.state = 79 + self.match(SolidityParser.T__10) + self.state = 80 self.match(SolidityParser.VariableName) except RecognitionException as re: localctx.exception = re @@ -1880,14 +1167,15 @@ def contractVariableAccessExpr(self): self.exitRule() return localctx + class ContractVariableArrayElemExprContext(ParserRuleContext): __slots__ = 'parser' - def __init__(self, parser, parent: ParserRuleContext = None, invokingState: int = -1): + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def VariableName(self, i: int = None): + def VariableName(self, i:int=None): if i is None: return self.getTokens(SolidityParser.VariableName) else: @@ -1902,44 +1190,47 @@ def ADDRESS(self): def getRuleIndex(self): return SolidityParser.RULE_contractVariableArrayElemExpr - def enterRule(self, listener: ParseTreeListener): - if hasattr(listener, "enterContractVariableArrayElemExpr"): + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterContractVariableArrayElemExpr" ): listener.enterContractVariableArrayElemExpr(self) - def exitRule(self, listener: ParseTreeListener): - if hasattr(listener, "exitContractVariableArrayElemExpr"): + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitContractVariableArrayElemExpr" ): listener.exitContractVariableArrayElemExpr(self) - def accept(self, visitor: ParseTreeVisitor): - if hasattr(visitor, "visitContractVariableArrayElemExpr"): + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitContractVariableArrayElemExpr" ): return visitor.visitContractVariableArrayElemExpr(self) else: return visitor.visitChildren(self) + + + def contractVariableArrayElemExpr(self): localctx = SolidityParser.ContractVariableArrayElemExprContext(self, self._ctx, self.state) self.enterRule(localctx, 10, self.RULE_contractVariableArrayElemExpr) - self._la = 0 # Token type + self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 79 - self.match(SolidityParser.VariableName) - self.state = 80 - self.match(SolidityParser.T__9) - self.state = 81 - self.match(SolidityParser.VariableName) self.state = 82 - self.match(SolidityParser.T__10) + self.match(SolidityParser.VariableName) self.state = 83 + self.match(SolidityParser.T__10) + self.state = 84 + self.match(SolidityParser.VariableName) + self.state = 85 + self.match(SolidityParser.T__11) + self.state = 86 _la = self._input.LA(1) - if not ((((_la) & ~0x3F) == 0 and ((1 << _la) & 114688) != 0)): + if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 229376) != 0)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 84 - self.match(SolidityParser.T__11) + self.state = 87 + self.match(SolidityParser.T__12) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -1948,7 +1239,9 @@ def contractVariableArrayElemExpr(self): self.exitRule() return localctx - def sempred(self, localctx: RuleContext, ruleIndex: int, predIndex: int): + + + def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int): if self._predicates == None: self._predicates = dict() self._predicates[1] = self.booleanExpression_sempred @@ -1959,22 +1252,36 @@ def sempred(self, localctx: RuleContext, ruleIndex: int, predIndex: int): else: return pred(localctx, predIndex) - def booleanExpression_sempred(self, localctx: BooleanExpressionContext, predIndex: int): - if predIndex == 0: - return self.precpred(self._ctx, 6) + def booleanExpression_sempred(self, localctx:BooleanExpressionContext, predIndex:int): + if predIndex == 0: + return self.precpred(self._ctx, 6) + + + if predIndex == 1: + return self.precpred(self._ctx, 5) + + + def arithmeticExpression_sempred(self, localctx:ArithmeticExpressionContext, predIndex:int): + if predIndex == 2: + return self.precpred(self._ctx, 6) + + + if predIndex == 3: + return self.precpred(self._ctx, 5) + + + if predIndex == 4: + return self.precpred(self._ctx, 4) + + + if predIndex == 5: + return self.precpred(self._ctx, 3) + - if predIndex == 1: - return self.precpred(self._ctx, 5) + if predIndex == 6: + return self.precpred(self._ctx, 2) + - def arithmeticExpression_sempred(self, localctx: ArithmeticExpressionContext, predIndex: int): - if predIndex == 2: - return self.precpred(self._ctx, 5) - if predIndex == 3: - return self.precpred(self._ctx, 4) - if predIndex == 4: - return self.precpred(self._ctx, 3) - if predIndex == 5: - return self.precpred(self._ctx, 2) diff --git a/src/kontrol/solidity/SolidityVisitor.py b/src/kontrol/solidity/SolidityVisitor.py index ce951efcd..9e4050a0d 100644 --- a/src/kontrol/solidity/SolidityVisitor.py +++ b/src/kontrol/solidity/SolidityVisitor.py @@ -1,6 +1,5 @@ # Generated from src/kontrol/solidity/Solidity.g4 by ANTLR 4.13.2 from antlr4 import * - if "." in __name__: from .SolidityParser import SolidityParser else: @@ -8,108 +7,137 @@ # This class defines a complete generic visitor for a parse tree produced by SolidityParser. - class SolidityVisitor(ParseTreeVisitor): # Visit a parse tree produced by SolidityParser#expression. - def visitExpression(self, ctx: SolidityParser.ExpressionContext): + def visitExpression(self, ctx:SolidityParser.ExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#RelationalExpression. - def visitRelationalExpression(self, ctx: SolidityParser.RelationalExpressionContext): + def visitRelationalExpression(self, ctx:SolidityParser.RelationalExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#AndExpression. - def visitAndExpression(self, ctx: SolidityParser.AndExpressionContext): + def visitAndExpression(self, ctx:SolidityParser.AndExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#BooleanLiteral. - def visitBooleanLiteral(self, ctx: SolidityParser.BooleanLiteralContext): + def visitBooleanLiteral(self, ctx:SolidityParser.BooleanLiteralContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#NotExpression. - def visitNotExpression(self, ctx: SolidityParser.NotExpressionContext): + def visitNotExpression(self, ctx:SolidityParser.NotExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#OrExpression. - def visitOrExpression(self, ctx: SolidityParser.OrExpressionContext): + def visitOrExpression(self, ctx:SolidityParser.OrExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#ParenthesizedBooleanExpression. - def visitParenthesizedBooleanExpression(self, ctx: SolidityParser.ParenthesizedBooleanExpressionContext): + def visitParenthesizedBooleanExpression(self, ctx:SolidityParser.ParenthesizedBooleanExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#SubtractExpression. - def visitSubtractExpression(self, ctx: SolidityParser.SubtractExpressionContext): + def visitSubtractExpression(self, ctx:SolidityParser.SubtractExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#DivideExpression. - def visitDivideExpression(self, ctx: SolidityParser.DivideExpressionContext): + def visitDivideExpression(self, ctx:SolidityParser.DivideExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#AddExpression. - def visitAddExpression(self, ctx: SolidityParser.AddExpressionContext): + def visitAddExpression(self, ctx:SolidityParser.AddExpressionContext): return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#PowExpression. + def visitPowExpression(self, ctx:SolidityParser.PowExpressionContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by SolidityParser#MultiplyExpression. - def visitMultiplyExpression(self, ctx: SolidityParser.MultiplyExpressionContext): + def visitMultiplyExpression(self, ctx:SolidityParser.MultiplyExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#AtomExpression. - def visitAtomExpression(self, ctx: SolidityParser.AtomExpressionContext): + def visitAtomExpression(self, ctx:SolidityParser.AtomExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#Variable. - def visitVariable(self, ctx: SolidityParser.VariableContext): + def visitVariable(self, ctx:SolidityParser.VariableContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#LengthAccess. - def visitLengthAccess(self, ctx: SolidityParser.LengthAccessContext): + def visitLengthAccess(self, ctx:SolidityParser.LengthAccessContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#ArrayElement. - def visitArrayElement(self, ctx: SolidityParser.ArrayElementContext): + def visitArrayElement(self, ctx:SolidityParser.ArrayElementContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#MappingElement. - def visitMappingElement(self, ctx: SolidityParser.MappingElementContext): + def visitMappingElement(self, ctx:SolidityParser.MappingElementContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#AddressLiteral. - def visitAddressLiteral(self, ctx: SolidityParser.AddressLiteralContext): + def visitAddressLiteral(self, ctx:SolidityParser.AddressLiteralContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#IntegerLiteral. - def visitIntegerLiteral(self, ctx: SolidityParser.IntegerLiteralContext): + def visitIntegerLiteral(self, ctx:SolidityParser.IntegerLiteralContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#ParenthesizedArithmeticExpression. - def visitParenthesizedArithmeticExpression(self, ctx: SolidityParser.ParenthesizedArithmeticExpressionContext): + def visitParenthesizedArithmeticExpression(self, ctx:SolidityParser.ParenthesizedArithmeticExpressionContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#BlockAccess. - def visitBlockAccess(self, ctx: SolidityParser.BlockAccessContext): + def visitBlockAccess(self, ctx:SolidityParser.BlockAccessContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#MsgAccess. - def visitMsgAccess(self, ctx: SolidityParser.MsgAccessContext): + def visitMsgAccess(self, ctx:SolidityParser.MsgAccessContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#ContractVariableAccess. - def visitContractVariableAccess(self, ctx: SolidityParser.ContractVariableAccessContext): + def visitContractVariableAccess(self, ctx:SolidityParser.ContractVariableAccessContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#ContractVariableArrayElement. - def visitContractVariableArrayElement(self, ctx: SolidityParser.ContractVariableArrayElementContext): + def visitContractVariableArrayElement(self, ctx:SolidityParser.ContractVariableArrayElementContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#contractVariableAccessExpr. - def visitContractVariableAccessExpr(self, ctx: SolidityParser.ContractVariableAccessExprContext): + def visitContractVariableAccessExpr(self, ctx:SolidityParser.ContractVariableAccessExprContext): return self.visitChildren(ctx) + # Visit a parse tree produced by SolidityParser#contractVariableArrayElemExpr. - def visitContractVariableArrayElemExpr(self, ctx: SolidityParser.ContractVariableArrayElemExprContext): + def visitContractVariableArrayElemExpr(self, ctx:SolidityParser.ContractVariableArrayElemExprContext): return self.visitChildren(ctx) -del SolidityParser + +del SolidityParser \ No newline at end of file From f0c310b90fb62f10495d373b9f6b85c040f7907d Mon Sep 17 00:00:00 2001 From: palinatolmach Date: Fri, 9 Aug 2024 17:56:35 +0800 Subject: [PATCH 15/15] `poetry lock` update --- poetry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 0ebff8ce7..6bcf1c66c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1414,4 +1414,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "deaf5e5c753ac249dfc1fed3bd939dcbd4a13a48df5c76d00074537a0f5f55c3" +content-hash = "fea5e92ca0f1bcc96b144959da4537fe5ce6cf002b38f5174d8971f1110cba39"