evalis 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evalis-0.1.1/LICENSE +8 -0
- evalis-0.1.1/MANIFEST.in +11 -0
- evalis-0.1.1/PKG-INFO +157 -0
- evalis-0.1.1/README.md +124 -0
- evalis-0.1.1/pyproject.toml +55 -0
- evalis-0.1.1/setup.cfg +4 -0
- evalis-0.1.1/src/evalis/__gen__/EvalisLexer.py +135 -0
- evalis-0.1.1/src/evalis/__gen__/EvalisListener.py +192 -0
- evalis-0.1.1/src/evalis/__gen__/EvalisParser.py +1213 -0
- evalis-0.1.1/src/evalis/__gen__/EvalisVisitor.py +113 -0
- evalis-0.1.1/src/evalis/__gen__/grammar.py +31 -0
- evalis-0.1.1/src/evalis/__init__.py +14 -0
- evalis-0.1.1/src/evalis/antlr4_adapter.py +38 -0
- evalis-0.1.1/src/evalis/ast.py +137 -0
- evalis-0.1.1/src/evalis/constants.py +10 -0
- evalis-0.1.1/src/evalis/error.py +34 -0
- evalis-0.1.1/src/evalis/eval.py +112 -0
- evalis-0.1.1/src/evalis/evalis.py +34 -0
- evalis-0.1.1/src/evalis/types.py +53 -0
- evalis-0.1.1/src/evalis.egg-info/PKG-INFO +157 -0
- evalis-0.1.1/src/evalis.egg-info/SOURCES.txt +22 -0
- evalis-0.1.1/src/evalis.egg-info/dependency_links.txt +1 -0
- evalis-0.1.1/src/evalis.egg-info/requires.txt +10 -0
- evalis-0.1.1/src/evalis.egg-info/top_level.txt +1 -0
evalis-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright 2025 Paul Slaughter
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
+
|
evalis-0.1.1/MANIFEST.in
ADDED
evalis-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: evalis
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A polyglot, safe, user-friendly expression evaluator.
|
|
5
|
+
Author-email: Paul Slaughter <paul@souldzin.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/GojiYoji/evalis
|
|
8
|
+
Project-URL: Repository, https://github.com/GojiYoji/evalis
|
|
9
|
+
Project-URL: Issues, https://github.com/GojiYoji/evalis/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/GojiYoji/evalis/tree/main/python
|
|
11
|
+
Keywords: expression,evaluator,parser,antlr,safe-eval
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: antlr4-python3-runtime==4.13.2
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: antlr4-tools==0.2.2; extra == "dev"
|
|
26
|
+
Requires-Dist: black==25.1.0; extra == "dev"
|
|
27
|
+
Requires-Dist: build==1.3.0; extra == "dev"
|
|
28
|
+
Requires-Dist: flake8==7.2.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pyright==1.1.400; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest==8.4.1; extra == "dev"
|
|
31
|
+
Requires-Dist: pyyaml==6.0.2; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# Evalis
|
|
35
|
+
|
|
36
|
+
A secure, user-friendly expression evaluator for Python.
|
|
37
|
+
|
|
38
|
+
> **Early Release**: This is an early release with core functionality. More features are in active development. Check the [main project](https://github.com/GojiYoji/evalis) for roadmap and updates.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install evalis
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from evalis import evaluate_expression
|
|
50
|
+
|
|
51
|
+
context = {"a": {"b": 5}}
|
|
52
|
+
value = evaluate_expression("a.b + 2", context)
|
|
53
|
+
|
|
54
|
+
print(value) # 7
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
- **Safe evaluation** - No `eval()`. No access to global namespace.
|
|
60
|
+
- **Simple syntax** - Familiar expressions with property access, operators, and comprehensions.
|
|
61
|
+
- **Type-safe** - Full type hints included for static type checking.
|
|
62
|
+
|
|
63
|
+
## Supported Operations
|
|
64
|
+
|
|
65
|
+
- **Arithmetic**: `+`, `-`, `*`, `/`
|
|
66
|
+
- **Comparison**: `==`, `!=`, `<`, `<=`, `>`, `>=`
|
|
67
|
+
- **Logical**: `and`, `or`, `not`
|
|
68
|
+
- **Property access**: `obj.property`, `obj['key']`
|
|
69
|
+
- **Array access**: `arr[0]`
|
|
70
|
+
- **List comprehensions**: `[x * 2 for x in numbers]`
|
|
71
|
+
- **Membership**: `x in collection`
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### `evaluate_expression(expression, context, options)`
|
|
76
|
+
|
|
77
|
+
Evaluates an expression string with the given context.
|
|
78
|
+
|
|
79
|
+
**Parameters:**
|
|
80
|
+
- `expression` (str): The expression to evaluate
|
|
81
|
+
- `context` (dict): Variable context for the expression
|
|
82
|
+
- `options` (EvaluatorOptions, optional): Evaluation options
|
|
83
|
+
|
|
84
|
+
**Returns:** The evaluated result
|
|
85
|
+
|
|
86
|
+
**Example:**
|
|
87
|
+
```python
|
|
88
|
+
from evalis import evaluate_expression
|
|
89
|
+
|
|
90
|
+
result = evaluate_expression("x * 2", {"x": 21})
|
|
91
|
+
# result = 42
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### `parse_ast(expression)`
|
|
95
|
+
|
|
96
|
+
Parses an expression into an AST without evaluating it.
|
|
97
|
+
|
|
98
|
+
**Parameters:**
|
|
99
|
+
- `expression` (str): The expression to parse
|
|
100
|
+
|
|
101
|
+
**Returns:** An AST node representing the expression
|
|
102
|
+
|
|
103
|
+
**Example:**
|
|
104
|
+
```python
|
|
105
|
+
from evalis import parse_ast
|
|
106
|
+
|
|
107
|
+
ast = parse_ast("a + b")
|
|
108
|
+
# Returns: BinaryOpNode(op=BinaryOpType.ADD, left=..., right=...)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### `evaluate_ast(node, context, options)`
|
|
112
|
+
|
|
113
|
+
Evaluates a pre-parsed AST node.
|
|
114
|
+
|
|
115
|
+
**Parameters:**
|
|
116
|
+
- `node` (EvalisNode): The AST node to evaluate
|
|
117
|
+
- `context` (dict): Variable context for evaluation
|
|
118
|
+
- `options` (EvaluatorOptions, optional): Evaluation options
|
|
119
|
+
|
|
120
|
+
**Returns:** The evaluated result
|
|
121
|
+
|
|
122
|
+
**Example:**
|
|
123
|
+
```python
|
|
124
|
+
from evalis import parse_ast, evaluate_ast
|
|
125
|
+
|
|
126
|
+
ast = parse_ast("x + 1")
|
|
127
|
+
result = evaluate_ast(ast, {"x": 5})
|
|
128
|
+
# result = 6
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### `EvaluatorOptions`
|
|
132
|
+
|
|
133
|
+
Configuration options for evaluation.
|
|
134
|
+
|
|
135
|
+
**Fields:**
|
|
136
|
+
- `should_null_on_bad_access` (bool, default=False): Return `None` instead of raising errors on invalid property access
|
|
137
|
+
|
|
138
|
+
**Example:**
|
|
139
|
+
```python
|
|
140
|
+
from evalis import evaluate_expression, EvaluatorOptions
|
|
141
|
+
|
|
142
|
+
options = EvaluatorOptions(should_null_on_bad_access=True)
|
|
143
|
+
result = evaluate_expression("foo.missing", {}, options)
|
|
144
|
+
# result = None (instead of raising an error)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## More Information
|
|
148
|
+
|
|
149
|
+
This is the Python implementation of Evalis. For more details about the project:
|
|
150
|
+
|
|
151
|
+
- [Main Project](https://github.com/GojiYoji/evalis)
|
|
152
|
+
- [Architecture](https://github.com/GojiYoji/evalis/blob/main/docs/architecture.md)
|
|
153
|
+
- [TypeScript Implementation](https://github.com/GojiYoji/evalis/tree/main/typescript)
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT
|
evalis-0.1.1/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Evalis
|
|
2
|
+
|
|
3
|
+
A secure, user-friendly expression evaluator for Python.
|
|
4
|
+
|
|
5
|
+
> **Early Release**: This is an early release with core functionality. More features are in active development. Check the [main project](https://github.com/GojiYoji/evalis) for roadmap and updates.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install evalis
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from evalis import evaluate_expression
|
|
17
|
+
|
|
18
|
+
context = {"a": {"b": 5}}
|
|
19
|
+
value = evaluate_expression("a.b + 2", context)
|
|
20
|
+
|
|
21
|
+
print(value) # 7
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- **Safe evaluation** - No `eval()`. No access to global namespace.
|
|
27
|
+
- **Simple syntax** - Familiar expressions with property access, operators, and comprehensions.
|
|
28
|
+
- **Type-safe** - Full type hints included for static type checking.
|
|
29
|
+
|
|
30
|
+
## Supported Operations
|
|
31
|
+
|
|
32
|
+
- **Arithmetic**: `+`, `-`, `*`, `/`
|
|
33
|
+
- **Comparison**: `==`, `!=`, `<`, `<=`, `>`, `>=`
|
|
34
|
+
- **Logical**: `and`, `or`, `not`
|
|
35
|
+
- **Property access**: `obj.property`, `obj['key']`
|
|
36
|
+
- **Array access**: `arr[0]`
|
|
37
|
+
- **List comprehensions**: `[x * 2 for x in numbers]`
|
|
38
|
+
- **Membership**: `x in collection`
|
|
39
|
+
|
|
40
|
+
## API Reference
|
|
41
|
+
|
|
42
|
+
### `evaluate_expression(expression, context, options)`
|
|
43
|
+
|
|
44
|
+
Evaluates an expression string with the given context.
|
|
45
|
+
|
|
46
|
+
**Parameters:**
|
|
47
|
+
- `expression` (str): The expression to evaluate
|
|
48
|
+
- `context` (dict): Variable context for the expression
|
|
49
|
+
- `options` (EvaluatorOptions, optional): Evaluation options
|
|
50
|
+
|
|
51
|
+
**Returns:** The evaluated result
|
|
52
|
+
|
|
53
|
+
**Example:**
|
|
54
|
+
```python
|
|
55
|
+
from evalis import evaluate_expression
|
|
56
|
+
|
|
57
|
+
result = evaluate_expression("x * 2", {"x": 21})
|
|
58
|
+
# result = 42
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### `parse_ast(expression)`
|
|
62
|
+
|
|
63
|
+
Parses an expression into an AST without evaluating it.
|
|
64
|
+
|
|
65
|
+
**Parameters:**
|
|
66
|
+
- `expression` (str): The expression to parse
|
|
67
|
+
|
|
68
|
+
**Returns:** An AST node representing the expression
|
|
69
|
+
|
|
70
|
+
**Example:**
|
|
71
|
+
```python
|
|
72
|
+
from evalis import parse_ast
|
|
73
|
+
|
|
74
|
+
ast = parse_ast("a + b")
|
|
75
|
+
# Returns: BinaryOpNode(op=BinaryOpType.ADD, left=..., right=...)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `evaluate_ast(node, context, options)`
|
|
79
|
+
|
|
80
|
+
Evaluates a pre-parsed AST node.
|
|
81
|
+
|
|
82
|
+
**Parameters:**
|
|
83
|
+
- `node` (EvalisNode): The AST node to evaluate
|
|
84
|
+
- `context` (dict): Variable context for evaluation
|
|
85
|
+
- `options` (EvaluatorOptions, optional): Evaluation options
|
|
86
|
+
|
|
87
|
+
**Returns:** The evaluated result
|
|
88
|
+
|
|
89
|
+
**Example:**
|
|
90
|
+
```python
|
|
91
|
+
from evalis import parse_ast, evaluate_ast
|
|
92
|
+
|
|
93
|
+
ast = parse_ast("x + 1")
|
|
94
|
+
result = evaluate_ast(ast, {"x": 5})
|
|
95
|
+
# result = 6
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### `EvaluatorOptions`
|
|
99
|
+
|
|
100
|
+
Configuration options for evaluation.
|
|
101
|
+
|
|
102
|
+
**Fields:**
|
|
103
|
+
- `should_null_on_bad_access` (bool, default=False): Return `None` instead of raising errors on invalid property access
|
|
104
|
+
|
|
105
|
+
**Example:**
|
|
106
|
+
```python
|
|
107
|
+
from evalis import evaluate_expression, EvaluatorOptions
|
|
108
|
+
|
|
109
|
+
options = EvaluatorOptions(should_null_on_bad_access=True)
|
|
110
|
+
result = evaluate_expression("foo.missing", {}, options)
|
|
111
|
+
# result = None (instead of raising an error)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## More Information
|
|
115
|
+
|
|
116
|
+
This is the Python implementation of Evalis. For more details about the project:
|
|
117
|
+
|
|
118
|
+
- [Main Project](https://github.com/GojiYoji/evalis)
|
|
119
|
+
- [Architecture](https://github.com/GojiYoji/evalis/blob/main/docs/architecture.md)
|
|
120
|
+
- [TypeScript Implementation](https://github.com/GojiYoji/evalis/tree/main/typescript)
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "evalis"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "A polyglot, safe, user-friendly expression evaluator."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Paul Slaughter", email = "paul@souldzin.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["expression", "evaluator", "parser", "antlr", "safe-eval"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Software Development :: Libraries",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"antlr4-python3-runtime==4.13.2"
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/GojiYoji/evalis"
|
|
32
|
+
Repository = "https://github.com/GojiYoji/evalis"
|
|
33
|
+
Issues = "https://github.com/GojiYoji/evalis/issues"
|
|
34
|
+
Documentation = "https://github.com/GojiYoji/evalis/tree/main/python"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = [
|
|
38
|
+
"antlr4-tools==0.2.2",
|
|
39
|
+
"black==25.1.0",
|
|
40
|
+
"build==1.3.0",
|
|
41
|
+
"flake8==7.2.0",
|
|
42
|
+
"pyright==1.1.400",
|
|
43
|
+
"pytest==8.4.1",
|
|
44
|
+
"pyyaml==6.0.2"
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[tool.pyright]
|
|
48
|
+
include = ["src"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.dynamic]
|
|
51
|
+
version = { attr = "evalis.constants.__version__" }
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.packages.find]
|
|
54
|
+
where = ["src"]
|
|
55
|
+
|
evalis-0.1.1/setup.cfg
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Generated from /home/runner/work/evalis/evalis/grammar/Evalis.g4 by ANTLR 4.13.2
|
|
2
|
+
from antlr4 import *
|
|
3
|
+
from io import StringIO
|
|
4
|
+
import sys
|
|
5
|
+
if sys.version_info[1] > 5:
|
|
6
|
+
from typing import TextIO
|
|
7
|
+
else:
|
|
8
|
+
from typing.io import TextIO
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def serializedATN():
|
|
12
|
+
return [
|
|
13
|
+
4,0,28,166,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,
|
|
14
|
+
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,
|
|
15
|
+
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,
|
|
16
|
+
19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,
|
|
17
|
+
26,7,26,2,27,7,27,1,0,1,0,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,
|
|
18
|
+
4,1,5,1,5,1,6,1,6,1,6,1,7,1,7,1,8,1,8,1,8,1,9,1,9,1,9,1,10,1,10,
|
|
19
|
+
1,10,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,14,1,14,
|
|
20
|
+
1,15,1,15,1,16,1,16,1,17,1,17,1,17,1,17,1,18,1,18,1,19,1,19,1,20,
|
|
21
|
+
1,20,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,
|
|
22
|
+
1,22,1,22,1,23,1,23,5,23,128,8,23,10,23,12,23,131,9,23,1,24,4,24,
|
|
23
|
+
134,8,24,11,24,12,24,135,1,25,4,25,139,8,25,11,25,12,25,140,1,25,
|
|
24
|
+
1,25,4,25,145,8,25,11,25,12,25,146,1,26,1,26,1,26,1,26,5,26,153,
|
|
25
|
+
8,26,10,26,12,26,156,9,26,1,26,1,26,1,27,4,27,161,8,27,11,27,12,
|
|
26
|
+
27,162,1,27,1,27,0,0,28,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,
|
|
27
|
+
19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,
|
|
28
|
+
41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,1,0,5,3,0,65,90,
|
|
29
|
+
95,95,97,122,4,0,48,57,65,90,95,95,97,122,1,0,48,57,2,0,34,34,92,
|
|
30
|
+
92,3,0,9,10,13,13,32,32,172,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,
|
|
31
|
+
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,
|
|
32
|
+
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,
|
|
33
|
+
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,
|
|
34
|
+
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,
|
|
35
|
+
47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,1,
|
|
36
|
+
57,1,0,0,0,3,61,1,0,0,0,5,63,1,0,0,0,7,65,1,0,0,0,9,67,1,0,0,0,11,
|
|
37
|
+
69,1,0,0,0,13,71,1,0,0,0,15,74,1,0,0,0,17,76,1,0,0,0,19,79,1,0,0,
|
|
38
|
+
0,21,82,1,0,0,0,23,85,1,0,0,0,25,88,1,0,0,0,27,92,1,0,0,0,29,95,
|
|
39
|
+
1,0,0,0,31,97,1,0,0,0,33,99,1,0,0,0,35,101,1,0,0,0,37,105,1,0,0,
|
|
40
|
+
0,39,107,1,0,0,0,41,109,1,0,0,0,43,114,1,0,0,0,45,119,1,0,0,0,47,
|
|
41
|
+
125,1,0,0,0,49,133,1,0,0,0,51,138,1,0,0,0,53,148,1,0,0,0,55,160,
|
|
42
|
+
1,0,0,0,57,58,5,110,0,0,58,59,5,111,0,0,59,60,5,116,0,0,60,2,1,0,
|
|
43
|
+
0,0,61,62,5,42,0,0,62,4,1,0,0,0,63,64,5,47,0,0,64,6,1,0,0,0,65,66,
|
|
44
|
+
5,43,0,0,66,8,1,0,0,0,67,68,5,45,0,0,68,10,1,0,0,0,69,70,5,60,0,
|
|
45
|
+
0,70,12,1,0,0,0,71,72,5,60,0,0,72,73,5,61,0,0,73,14,1,0,0,0,74,75,
|
|
46
|
+
5,62,0,0,75,16,1,0,0,0,76,77,5,62,0,0,77,78,5,61,0,0,78,18,1,0,0,
|
|
47
|
+
0,79,80,5,61,0,0,80,81,5,61,0,0,81,20,1,0,0,0,82,83,5,33,0,0,83,
|
|
48
|
+
84,5,61,0,0,84,22,1,0,0,0,85,86,5,105,0,0,86,87,5,110,0,0,87,24,
|
|
49
|
+
1,0,0,0,88,89,5,97,0,0,89,90,5,110,0,0,90,91,5,100,0,0,91,26,1,0,
|
|
50
|
+
0,0,92,93,5,111,0,0,93,94,5,114,0,0,94,28,1,0,0,0,95,96,5,40,0,0,
|
|
51
|
+
96,30,1,0,0,0,97,98,5,41,0,0,98,32,1,0,0,0,99,100,5,91,0,0,100,34,
|
|
52
|
+
1,0,0,0,101,102,5,102,0,0,102,103,5,111,0,0,103,104,5,114,0,0,104,
|
|
53
|
+
36,1,0,0,0,105,106,5,93,0,0,106,38,1,0,0,0,107,108,5,46,0,0,108,
|
|
54
|
+
40,1,0,0,0,109,110,5,110,0,0,110,111,5,117,0,0,111,112,5,108,0,0,
|
|
55
|
+
112,113,5,108,0,0,113,42,1,0,0,0,114,115,5,116,0,0,115,116,5,114,
|
|
56
|
+
0,0,116,117,5,117,0,0,117,118,5,101,0,0,118,44,1,0,0,0,119,120,5,
|
|
57
|
+
102,0,0,120,121,5,97,0,0,121,122,5,108,0,0,122,123,5,115,0,0,123,
|
|
58
|
+
124,5,101,0,0,124,46,1,0,0,0,125,129,7,0,0,0,126,128,7,1,0,0,127,
|
|
59
|
+
126,1,0,0,0,128,131,1,0,0,0,129,127,1,0,0,0,129,130,1,0,0,0,130,
|
|
60
|
+
48,1,0,0,0,131,129,1,0,0,0,132,134,7,2,0,0,133,132,1,0,0,0,134,135,
|
|
61
|
+
1,0,0,0,135,133,1,0,0,0,135,136,1,0,0,0,136,50,1,0,0,0,137,139,7,
|
|
62
|
+
2,0,0,138,137,1,0,0,0,139,140,1,0,0,0,140,138,1,0,0,0,140,141,1,
|
|
63
|
+
0,0,0,141,142,1,0,0,0,142,144,5,46,0,0,143,145,7,2,0,0,144,143,1,
|
|
64
|
+
0,0,0,145,146,1,0,0,0,146,144,1,0,0,0,146,147,1,0,0,0,147,52,1,0,
|
|
65
|
+
0,0,148,154,5,34,0,0,149,153,8,3,0,0,150,151,5,92,0,0,151,153,9,
|
|
66
|
+
0,0,0,152,149,1,0,0,0,152,150,1,0,0,0,153,156,1,0,0,0,154,152,1,
|
|
67
|
+
0,0,0,154,155,1,0,0,0,155,157,1,0,0,0,156,154,1,0,0,0,157,158,5,
|
|
68
|
+
34,0,0,158,54,1,0,0,0,159,161,7,4,0,0,160,159,1,0,0,0,161,162,1,
|
|
69
|
+
0,0,0,162,160,1,0,0,0,162,163,1,0,0,0,163,164,1,0,0,0,164,165,6,
|
|
70
|
+
27,0,0,165,56,1,0,0,0,8,0,129,135,140,146,152,154,162,1,6,0,0
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
class EvalisLexer(Lexer):
|
|
74
|
+
|
|
75
|
+
atn = ATNDeserializer().deserialize(serializedATN())
|
|
76
|
+
|
|
77
|
+
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
|
|
78
|
+
|
|
79
|
+
T__0 = 1
|
|
80
|
+
T__1 = 2
|
|
81
|
+
T__2 = 3
|
|
82
|
+
T__3 = 4
|
|
83
|
+
T__4 = 5
|
|
84
|
+
T__5 = 6
|
|
85
|
+
T__6 = 7
|
|
86
|
+
T__7 = 8
|
|
87
|
+
T__8 = 9
|
|
88
|
+
T__9 = 10
|
|
89
|
+
T__10 = 11
|
|
90
|
+
T__11 = 12
|
|
91
|
+
T__12 = 13
|
|
92
|
+
T__13 = 14
|
|
93
|
+
T__14 = 15
|
|
94
|
+
T__15 = 16
|
|
95
|
+
T__16 = 17
|
|
96
|
+
T__17 = 18
|
|
97
|
+
T__18 = 19
|
|
98
|
+
T__19 = 20
|
|
99
|
+
T__20 = 21
|
|
100
|
+
T__21 = 22
|
|
101
|
+
T__22 = 23
|
|
102
|
+
IDENTIFIER = 24
|
|
103
|
+
INT = 25
|
|
104
|
+
FLOAT = 26
|
|
105
|
+
STRING = 27
|
|
106
|
+
WS = 28
|
|
107
|
+
|
|
108
|
+
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
|
|
109
|
+
|
|
110
|
+
modeNames = [ "DEFAULT_MODE" ]
|
|
111
|
+
|
|
112
|
+
literalNames = [ "<INVALID>",
|
|
113
|
+
"'not'", "'*'", "'/'", "'+'", "'-'", "'<'", "'<='", "'>'", "'>='",
|
|
114
|
+
"'=='", "'!='", "'in'", "'and'", "'or'", "'('", "')'", "'['",
|
|
115
|
+
"'for'", "']'", "'.'", "'null'", "'true'", "'false'" ]
|
|
116
|
+
|
|
117
|
+
symbolicNames = [ "<INVALID>",
|
|
118
|
+
"IDENTIFIER", "INT", "FLOAT", "STRING", "WS" ]
|
|
119
|
+
|
|
120
|
+
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6",
|
|
121
|
+
"T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__13",
|
|
122
|
+
"T__14", "T__15", "T__16", "T__17", "T__18", "T__19",
|
|
123
|
+
"T__20", "T__21", "T__22", "IDENTIFIER", "INT", "FLOAT",
|
|
124
|
+
"STRING", "WS" ]
|
|
125
|
+
|
|
126
|
+
grammarFileName = "Evalis.g4"
|
|
127
|
+
|
|
128
|
+
def __init__(self, input=None, output:TextIO = sys.stdout):
|
|
129
|
+
super().__init__(input, output)
|
|
130
|
+
self.checkVersion("4.13.2")
|
|
131
|
+
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
|
|
132
|
+
self._actions = None
|
|
133
|
+
self._predicates = None
|
|
134
|
+
|
|
135
|
+
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Generated from /home/runner/work/evalis/evalis/grammar/Evalis.g4 by ANTLR 4.13.2
|
|
2
|
+
from antlr4 import *
|
|
3
|
+
if "." in __name__:
|
|
4
|
+
from .EvalisParser import EvalisParser
|
|
5
|
+
else:
|
|
6
|
+
from EvalisParser import EvalisParser
|
|
7
|
+
|
|
8
|
+
# This class defines a complete listener for a parse tree produced by EvalisParser.
|
|
9
|
+
class EvalisListener(ParseTreeListener):
|
|
10
|
+
|
|
11
|
+
# Enter a parse tree produced by EvalisParser#parse.
|
|
12
|
+
def enterParse(self, ctx:EvalisParser.ParseContext):
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
# Exit a parse tree produced by EvalisParser#parse.
|
|
16
|
+
def exitParse(self, ctx:EvalisParser.ParseContext):
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Enter a parse tree produced by EvalisParser#AndExpr.
|
|
21
|
+
def enterAndExpr(self, ctx:EvalisParser.AndExprContext):
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
# Exit a parse tree produced by EvalisParser#AndExpr.
|
|
25
|
+
def exitAndExpr(self, ctx:EvalisParser.AndExprContext):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Enter a parse tree produced by EvalisParser#MulDivExpr.
|
|
30
|
+
def enterMulDivExpr(self, ctx:EvalisParser.MulDivExprContext):
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
# Exit a parse tree produced by EvalisParser#MulDivExpr.
|
|
34
|
+
def exitMulDivExpr(self, ctx:EvalisParser.MulDivExprContext):
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# Enter a parse tree produced by EvalisParser#EqualityExpr.
|
|
39
|
+
def enterEqualityExpr(self, ctx:EvalisParser.EqualityExprContext):
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
# Exit a parse tree produced by EvalisParser#EqualityExpr.
|
|
43
|
+
def exitEqualityExpr(self, ctx:EvalisParser.EqualityExprContext):
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# Enter a parse tree produced by EvalisParser#NotExpr.
|
|
48
|
+
def enterNotExpr(self, ctx:EvalisParser.NotExprContext):
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
# Exit a parse tree produced by EvalisParser#NotExpr.
|
|
52
|
+
def exitNotExpr(self, ctx:EvalisParser.NotExprContext):
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# Enter a parse tree produced by EvalisParser#RelationalExpr.
|
|
57
|
+
def enterRelationalExpr(self, ctx:EvalisParser.RelationalExprContext):
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
# Exit a parse tree produced by EvalisParser#RelationalExpr.
|
|
61
|
+
def exitRelationalExpr(self, ctx:EvalisParser.RelationalExprContext):
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# Enter a parse tree produced by EvalisParser#InExpr.
|
|
66
|
+
def enterInExpr(self, ctx:EvalisParser.InExprContext):
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
# Exit a parse tree produced by EvalisParser#InExpr.
|
|
70
|
+
def exitInExpr(self, ctx:EvalisParser.InExprContext):
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# Enter a parse tree produced by EvalisParser#AtomExpr.
|
|
75
|
+
def enterAtomExpr(self, ctx:EvalisParser.AtomExprContext):
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
# Exit a parse tree produced by EvalisParser#AtomExpr.
|
|
79
|
+
def exitAtomExpr(self, ctx:EvalisParser.AtomExprContext):
|
|
80
|
+
pass
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# Enter a parse tree produced by EvalisParser#AddSubExpr.
|
|
84
|
+
def enterAddSubExpr(self, ctx:EvalisParser.AddSubExprContext):
|
|
85
|
+
pass
|
|
86
|
+
|
|
87
|
+
# Exit a parse tree produced by EvalisParser#AddSubExpr.
|
|
88
|
+
def exitAddSubExpr(self, ctx:EvalisParser.AddSubExprContext):
|
|
89
|
+
pass
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# Enter a parse tree produced by EvalisParser#OrExpr.
|
|
93
|
+
def enterOrExpr(self, ctx:EvalisParser.OrExprContext):
|
|
94
|
+
pass
|
|
95
|
+
|
|
96
|
+
# Exit a parse tree produced by EvalisParser#OrExpr.
|
|
97
|
+
def exitOrExpr(self, ctx:EvalisParser.OrExprContext):
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
# Enter a parse tree produced by EvalisParser#LiteralAtom.
|
|
102
|
+
def enterLiteralAtom(self, ctx:EvalisParser.LiteralAtomContext):
|
|
103
|
+
pass
|
|
104
|
+
|
|
105
|
+
# Exit a parse tree produced by EvalisParser#LiteralAtom.
|
|
106
|
+
def exitLiteralAtom(self, ctx:EvalisParser.LiteralAtomContext):
|
|
107
|
+
pass
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# Enter a parse tree produced by EvalisParser#IdentifierAtom.
|
|
111
|
+
def enterIdentifierAtom(self, ctx:EvalisParser.IdentifierAtomContext):
|
|
112
|
+
pass
|
|
113
|
+
|
|
114
|
+
# Exit a parse tree produced by EvalisParser#IdentifierAtom.
|
|
115
|
+
def exitIdentifierAtom(self, ctx:EvalisParser.IdentifierAtomContext):
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# Enter a parse tree produced by EvalisParser#ParenAtom.
|
|
120
|
+
def enterParenAtom(self, ctx:EvalisParser.ParenAtomContext):
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
# Exit a parse tree produced by EvalisParser#ParenAtom.
|
|
124
|
+
def exitParenAtom(self, ctx:EvalisParser.ParenAtomContext):
|
|
125
|
+
pass
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# Enter a parse tree produced by EvalisParser#ListComprehension.
|
|
129
|
+
def enterListComprehension(self, ctx:EvalisParser.ListComprehensionContext):
|
|
130
|
+
pass
|
|
131
|
+
|
|
132
|
+
# Exit a parse tree produced by EvalisParser#ListComprehension.
|
|
133
|
+
def exitListComprehension(self, ctx:EvalisParser.ListComprehensionContext):
|
|
134
|
+
pass
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
# Enter a parse tree produced by EvalisParser#accessSuffix.
|
|
138
|
+
def enterAccessSuffix(self, ctx:EvalisParser.AccessSuffixContext):
|
|
139
|
+
pass
|
|
140
|
+
|
|
141
|
+
# Exit a parse tree produced by EvalisParser#accessSuffix.
|
|
142
|
+
def exitAccessSuffix(self, ctx:EvalisParser.AccessSuffixContext):
|
|
143
|
+
pass
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# Enter a parse tree produced by EvalisParser#literal.
|
|
147
|
+
def enterLiteral(self, ctx:EvalisParser.LiteralContext):
|
|
148
|
+
pass
|
|
149
|
+
|
|
150
|
+
# Exit a parse tree produced by EvalisParser#literal.
|
|
151
|
+
def exitLiteral(self, ctx:EvalisParser.LiteralContext):
|
|
152
|
+
pass
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
# Enter a parse tree produced by EvalisParser#number.
|
|
156
|
+
def enterNumber(self, ctx:EvalisParser.NumberContext):
|
|
157
|
+
pass
|
|
158
|
+
|
|
159
|
+
# Exit a parse tree produced by EvalisParser#number.
|
|
160
|
+
def exitNumber(self, ctx:EvalisParser.NumberContext):
|
|
161
|
+
pass
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# Enter a parse tree produced by EvalisParser#boolean.
|
|
165
|
+
def enterBoolean(self, ctx:EvalisParser.BooleanContext):
|
|
166
|
+
pass
|
|
167
|
+
|
|
168
|
+
# Exit a parse tree produced by EvalisParser#boolean.
|
|
169
|
+
def exitBoolean(self, ctx:EvalisParser.BooleanContext):
|
|
170
|
+
pass
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
# Enter a parse tree produced by EvalisParser#identifier.
|
|
174
|
+
def enterIdentifier(self, ctx:EvalisParser.IdentifierContext):
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
# Exit a parse tree produced by EvalisParser#identifier.
|
|
178
|
+
def exitIdentifier(self, ctx:EvalisParser.IdentifierContext):
|
|
179
|
+
pass
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
# Enter a parse tree produced by EvalisParser#stringLiteral.
|
|
183
|
+
def enterStringLiteral(self, ctx:EvalisParser.StringLiteralContext):
|
|
184
|
+
pass
|
|
185
|
+
|
|
186
|
+
# Exit a parse tree produced by EvalisParser#stringLiteral.
|
|
187
|
+
def exitStringLiteral(self, ctx:EvalisParser.StringLiteralContext):
|
|
188
|
+
pass
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
del EvalisParser
|