Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to GemsPy are documented here.
## [Unreleased]

### Added
- **Power operator `^` in the expression language** - right-associative, binding
tighter than unary minus and than `*` `/`, so `-2^2` is `-(2^2)`. Operands
must be literals or parameters, except in `extra-outputs` where a variable may
be raised to a power. The Python API gains `**` on `ExpressionNode`.

- **Taxonomy conformance checked when a study is loaded** - `load_study` reads
the optional `input/taxonomy.yml` and calls
`validate_libraries_against_taxonomy` on every library declaring a `taxonomy`
Expand Down
43 changes: 40 additions & 3 deletions grammar/Expr.g4
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fullexpr: expr EOF;
expr
: atom # unsignedAtom
| portFieldExpr # portField
| <assoc=right> expr '^' expr # power
| '-' expr # negation
| '(' expr ')' # expression
| expr op=('/' | '*') expr # muldiv
Expand Down Expand Up @@ -53,20 +54,56 @@ shift: TIME shift_expr?;
// A shift expression can only be extended to the right by a
// "right_expr" which cannot start with a + or -,
// unlike shift_expr itself.
//
// Unlike "expr", which is one left-recursive rule where precedence falls out
// of the order of the alternatives, this sub-grammar is a hand-written cascade:
// precedence is encoded in which rule each operand recurses into. An operator
// therefore has to be given its precedence twice, once in "expr" and once here,
// and the two must agree — "x[t-2^2]" is expected to shift by the value of the
// expression "-2^2". Adding an operator to "expr" alone gives it nothing inside
// a shift.
//
// TODO: the grammar is still a little weird, because we
// allow more things in the "expr" parts of those
// shift expressions than on their left-most part
// (port fields, nested time shifts and so on).
shift_expr
: shift_expr op=('*' | '/') right_expr # shiftMuldiv
| shift_expr op=('+' | '-') right_expr # shiftAddsub
| op=('+' | '-') atom # signedAtom
| op=('+' | '-') '(' expr ')' # signedExpression
| op=('+' | '-') shift_operand # signedOperand
;

right_expr
: right_expr op=('/' | '*') right_expr # rightMuldiv
| '(' expr ')' # rightExpression
| shift_operand # rightOperand
;

// The two highest precedence tiers of the shift sub-grammar, mirroring the
// "power" and atom levels of "expr". They are named after their level, not
// after '^': every operand of a shift goes through them, whether or not a
// power is involved.
//
// They must stay separate from "right_expr" for two reasons, both of them
// restating here what "expr" gets for free from its alternative order:
// - the leading sign of "shift_expr" needs a power-capable operand, so that
// '^' binds tighter than the sign and "t - 2^2" shifts by -4, matching
// "-2^2" = "-(2^2)". That operand must NOT also swallow '*' and '/', or
// "t - 2*3" becomes ambiguous and reassociates to "-(2*3)" instead of
// "(-2)*3";
// - "right_expr" is the muldiv tier, so on the right of '^' it would be
// entered at precedence 0 and greedily swallow '*' and '/': "t - 2^2*3"
// would mean "2^(2*3)" instead of "(2^2)*3".
//
// The one deliberate divergence from "expr" is that the exponent is unsigned
// here, so "t + 2^-1" is a parse error: a fractional time shift is
// meaningless, while negative exponents remain available in "expr".
shift_operand
: shift_primary '^' shift_operand # rightPower
| shift_primary # rightPrimary
;

shift_primary
: '(' expr ')' # rightExpression
| atom # rightAtom
;

Expand Down
4 changes: 2 additions & 2 deletions grammar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use for defining constraints, objective, etc.

[ANTLR](https://www.antlr.org) needs to be used to generate the associated
parser code, which must be written to [andromede.expression.parsing.antlr](/src/andromede/expression/parsing/antlr)
parser code, which must be written to [gems_craft.expression.parsing.antlr](/src/gems_craft/expression/parsing/antlr)
package. **No other files are expected to be present in that package**.

To achieve this you may use the provided `generate-parser.sh` script after having installed
antlr4-tools (`pip install -r requirements-dev.txt` in root directory).
antlr4-tools (`uv sync --group dev` in root directory).

You may also, for example, use the ANTLR4 PyCharm plugin.

Expand Down
2 changes: 1 addition & 1 deletion grammar/generate-parser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

script_file=$(readlink -f -- "$0")
script_dir=$(dirname -- "${script_file}")
antlr4 -Dlanguage=Python3 -Werror -no-listener -visitor -o ${script_dir}/../src/gems/expression/parsing/antlr Expr.g4
antlr4 -Dlanguage=Python3 -Werror -no-listener -visitor -o ${script_dir}/../src/gems_craft/expression/parsing/antlr Expr.g4
1 change: 1 addition & 0 deletions src/gems_craft/expression/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
MultiplicationNode,
NegationNode,
ParameterNode,
PowerNode,
RoundNode,
VariableNode,
literal,
Expand Down
21 changes: 21 additions & 0 deletions src/gems_craft/expression/degree.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@
MultiplicationNode,
NegationNode,
ParameterNode,
PowerNode,
ScenarioOperatorNode,
VariableNode,
)
from .visitor import ExpressionVisitor, T, visit


def _is_non_negative_integer(value: float) -> bool:
return value >= 0 and float(value).is_integer()


class ExpressionDegreeVisitor(ExpressionVisitor[int | float]):
"""
Computes degree of expression with respect to variables.
Expand All @@ -72,6 +77,22 @@ def division(self, node: DivisionNode) -> int | float:
raise ValueError("Degree computation not implemented for divisions.")
return visit(node.left, self)

def power(self, node: PowerNode) -> int | float:
# A variable exponent is never polynomial, and a variable base only
# stays polynomial for a non-negative integer exponent.
if visit(node.right, self) != 0:
return math.inf
base_degree = visit(node.left, self)
if base_degree == 0:
return 0
if isinstance(node.right, LiteralNode) and _is_non_negative_integer(
node.right.value
):
exponent = int(node.right.value)
# inf * 0 is nan, whereas anything to the power 0 is the constant 1.
return 0 if exponent == 0 else base_degree * exponent
return math.inf

def comparison(self, node: ComparisonNode) -> int | float:
return max(visit(node.left, self), visit(node.right, self))

Expand Down
6 changes: 6 additions & 0 deletions src/gems_craft/expression/equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
MinNode,
PortFieldAggregatorNode,
PortFieldNode,
PowerNode,
ReducedCostNode,
RoundNode,
ScenarioOperatorNode,
Expand Down Expand Up @@ -77,6 +78,8 @@ def visit(self, left: ExpressionNode, right: ExpressionNode) -> bool:
right, MultiplicationNode
):
return self.multiplication(left, right)
if isinstance(left, PowerNode) and isinstance(right, PowerNode):
return self.power(left, right)
if isinstance(left, ComparisonNode) and isinstance(right, ComparisonNode):
return self.comparison(left, right)
if isinstance(left, VariableNode) and isinstance(right, VariableNode):
Expand Down Expand Up @@ -151,6 +154,9 @@ def multiplication(
def division(self, left: DivisionNode, right: DivisionNode) -> bool:
return self._visit_operands(left, right)

def power(self, left: PowerNode, right: PowerNode) -> bool:
return self._visit_operands(left, right)

def comparison(self, left: ComparisonNode, right: ComparisonNode) -> bool:
return left.comparator == right.comparator and self._visit_operands(left, right)

Expand Down
17 changes: 17 additions & 0 deletions src/gems_craft/expression/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ def __truediv__(self, rhs: Any) -> "ExpressionNode":
def __rtruediv__(self, lhs: Any) -> "ExpressionNode":
return _apply_if_node(lhs, lambda x: DivisionNode(x, self))

def __pow__(self, rhs: Any) -> "ExpressionNode":
return _apply_if_node(rhs, lambda x: PowerNode(self, x))

def __rpow__(self, lhs: Any) -> "ExpressionNode":
return _apply_if_node(lhs, lambda x: PowerNode(x, self))

def __le__(self, rhs: Any) -> "ExpressionNode":
return _apply_if_node(
rhs, lambda x: ComparisonNode(self, x, Comparator.LESS_THAN)
Expand Down Expand Up @@ -285,6 +291,17 @@ class DivisionNode(BinaryOperatorNode):
pass


@dataclass(frozen=True, eq=False)
class PowerNode(BinaryOperatorNode):
"""Raises ``left`` to the power ``right``, as written ``left ^ right``.

``^`` binds tighter than unary minus, so ``-2^2`` is ``-(2^2)``, and it is
right-associative, so ``2^3^2`` is ``2^(3^2)``.
"""

pass


@dataclass(frozen=True, eq=False)
class MaxNode(ExpressionNode):
operands: List[ExpressionNode]
Expand Down
4 changes: 4 additions & 0 deletions src/gems_craft/expression/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
ParameterNode,
PortFieldAggregatorNode,
PortFieldNode,
PowerNode,
ReducedCostNode,
RoundNode,
ScenarioOperatorNode,
Expand Down Expand Up @@ -96,6 +97,9 @@ def multiplication(self, node: MultiplicationNode) -> IndexingStructure:
def division(self, node: DivisionNode) -> IndexingStructure:
return self._combine([node.left, node.right])

def power(self, node: PowerNode) -> IndexingStructure:
return self._combine([node.left, node.right])

def comparison(self, node: ComparisonNode) -> IndexingStructure:
return self._combine([node.left, node.right])

Expand Down
6 changes: 5 additions & 1 deletion src/gems_craft/expression/parsing/antlr/Expr.interp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
token literal names:
null
'.'
'^'
'-'
'('
')'
Expand Down Expand Up @@ -34,6 +35,7 @@ null
null
null
null
null
NUMBER
TIME
IDENTIFIER
Expand All @@ -49,7 +51,9 @@ atom
shift
shift_expr
right_expr
shift_operand
shift_primary


atn:
[4, 1, 18, 151, 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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 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, 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, 3, 2, 55, 8, 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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 82, 8, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 93, 8, 2, 10, 2, 12, 2, 96, 9, 2, 1, 3, 1, 3, 1, 3, 5, 3, 101, 8, 3, 10, 3, 12, 3, 104, 9, 3, 1, 4, 1, 4, 3, 4, 108, 8, 4, 1, 5, 1, 5, 3, 5, 112, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 122, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 5, 6, 130, 8, 6, 10, 6, 12, 6, 133, 9, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 141, 8, 7, 1, 7, 1, 7, 1, 7, 5, 7, 146, 8, 7, 10, 7, 12, 7, 149, 9, 7, 1, 7, 0, 3, 4, 12, 14, 8, 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 1, 0, 5, 6, 2, 0, 2, 2, 7, 7, 165, 0, 16, 1, 0, 0, 0, 2, 20, 1, 0, 0, 0, 4, 81, 1, 0, 0, 0, 6, 97, 1, 0, 0, 0, 8, 107, 1, 0, 0, 0, 10, 109, 1, 0, 0, 0, 12, 121, 1, 0, 0, 0, 14, 140, 1, 0, 0, 0, 16, 17, 5, 16, 0, 0, 17, 18, 5, 1, 0, 0, 18, 19, 5, 16, 0, 0, 19, 1, 1, 0, 0, 0, 20, 21, 3, 4, 2, 0, 21, 22, 5, 0, 0, 1, 22, 3, 1, 0, 0, 0, 23, 24, 6, 2, -1, 0, 24, 82, 3, 8, 4, 0, 25, 82, 3, 0, 0, 0, 26, 27, 5, 2, 0, 0, 27, 82, 3, 4, 2, 13, 28, 29, 5, 3, 0, 0, 29, 30, 3, 4, 2, 0, 30, 31, 5, 4, 0, 0, 31, 82, 1, 0, 0, 0, 32, 33, 5, 8, 0, 0, 33, 34, 5, 3, 0, 0, 34, 35, 3, 4, 2, 0, 35, 36, 5, 4, 0, 0, 36, 82, 1, 0, 0, 0, 37, 38, 5, 9, 0, 0, 38, 39, 5, 3, 0, 0, 39, 40, 3, 0, 0, 0, 40, 41, 5, 4, 0, 0, 41, 82, 1, 0, 0, 0, 42, 43, 5, 8, 0, 0, 43, 44, 5, 3, 0, 0, 44, 45, 3, 10, 5, 0, 45, 46, 5, 10, 0, 0, 46, 47, 3, 10, 5, 0, 47, 48, 5, 11, 0, 0, 48, 49, 3, 4, 2, 0, 49, 50, 5, 4, 0, 0, 50, 82, 1, 0, 0, 0, 51, 52, 5, 16, 0, 0, 52, 54, 5, 3, 0, 0, 53, 55, 3, 6, 3, 0, 54, 53, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 82, 5, 4, 0, 0, 57, 58, 5, 16, 0, 0, 58, 59, 5, 12, 0, 0, 59, 60, 3, 10, 5, 0, 60, 61, 5, 13, 0, 0, 61, 82, 1, 0, 0, 0, 62, 63, 5, 16, 0, 0, 63, 64, 5, 12, 0, 0, 64, 65, 3, 4, 2, 0, 65, 66, 5, 13, 0, 0, 66, 82, 1, 0, 0, 0, 67, 68, 5, 3, 0, 0, 68, 69, 3, 4, 2, 0, 69, 70, 5, 4, 0, 0, 70, 71, 5, 12, 0, 0, 71, 72, 3, 10, 5, 0, 72, 73, 5, 13, 0, 0, 73, 82, 1, 0, 0, 0, 74, 75, 5, 3, 0, 0, 75, 76, 3, 4, 2, 0, 76, 77, 5, 4, 0, 0, 77, 78, 5, 12, 0, 0, 78, 79, 3, 4, 2, 0, 79, 80, 5, 13, 0, 0, 80, 82, 1, 0, 0, 0, 81, 23, 1, 0, 0, 0, 81, 25, 1, 0, 0, 0, 81, 26, 1, 0, 0, 0, 81, 28, 1, 0, 0, 0, 81, 32, 1, 0, 0, 0, 81, 37, 1, 0, 0, 0, 81, 42, 1, 0, 0, 0, 81, 51, 1, 0, 0, 0, 81, 57, 1, 0, 0, 0, 81, 62, 1, 0, 0, 0, 81, 67, 1, 0, 0, 0, 81, 74, 1, 0, 0, 0, 82, 94, 1, 0, 0, 0, 83, 84, 10, 11, 0, 0, 84, 85, 7, 0, 0, 0, 85, 93, 3, 4, 2, 12, 86, 87, 10, 10, 0, 0, 87, 88, 7, 1, 0, 0, 88, 93, 3, 4, 2, 11, 89, 90, 10, 9, 0, 0, 90, 91, 5, 17, 0, 0, 91, 93, 3, 4, 2, 10, 92, 83, 1, 0, 0, 0, 92, 86, 1, 0, 0, 0, 92, 89, 1, 0, 0, 0, 93, 96, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 5, 1, 0, 0, 0, 96, 94, 1, 0, 0, 0, 97, 102, 3, 4, 2, 0, 98, 99, 5, 11, 0, 0, 99, 101, 3, 4, 2, 0, 100, 98, 1, 0, 0, 0, 101, 104, 1, 0, 0, 0, 102, 100, 1, 0, 0, 0, 102, 103, 1, 0, 0, 0, 103, 7, 1, 0, 0, 0, 104, 102, 1, 0, 0, 0, 105, 108, 5, 14, 0, 0, 106, 108, 5, 16, 0, 0, 107, 105, 1, 0, 0, 0, 107, 106, 1, 0, 0, 0, 108, 9, 1, 0, 0, 0, 109, 111, 5, 15, 0, 0, 110, 112, 3, 12, 6, 0, 111, 110, 1, 0, 0, 0, 111, 112, 1, 0, 0, 0, 112, 11, 1, 0, 0, 0, 113, 114, 6, 6, -1, 0, 114, 115, 7, 1, 0, 0, 115, 122, 3, 8, 4, 0, 116, 117, 7, 1, 0, 0, 117, 118, 5, 3, 0, 0, 118, 119, 3, 4, 2, 0, 119, 120, 5, 4, 0, 0, 120, 122, 1, 0, 0, 0, 121, 113, 1, 0, 0, 0, 121, 116, 1, 0, 0, 0, 122, 131, 1, 0, 0, 0, 123, 124, 10, 4, 0, 0, 124, 125, 7, 0, 0, 0, 125, 130, 3, 14, 7, 0, 126, 127, 10, 3, 0, 0, 127, 128, 7, 1, 0, 0, 128, 130, 3, 14, 7, 0, 129, 123, 1, 0, 0, 0, 129, 126, 1, 0, 0, 0, 130, 133, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 13, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 134, 135, 6, 7, -1, 0, 135, 136, 5, 3, 0, 0, 136, 137, 3, 4, 2, 0, 137, 138, 5, 4, 0, 0, 138, 141, 1, 0, 0, 0, 139, 141, 3, 8, 4, 0, 140, 134, 1, 0, 0, 0, 140, 139, 1, 0, 0, 0, 141, 147, 1, 0, 0, 0, 142, 143, 10, 3, 0, 0, 143, 144, 7, 0, 0, 0, 144, 146, 3, 14, 7, 4, 145, 142, 1, 0, 0, 0, 146, 149, 1, 0, 0, 0, 147, 145, 1, 0, 0, 0, 147, 148, 1, 0, 0, 0, 148, 15, 1, 0, 0, 0, 149, 147, 1, 0, 0, 0, 12, 54, 81, 92, 94, 102, 107, 111, 121, 129, 131, 140, 147]
[4, 1, 19, 161, 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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 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, 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, 3, 2, 59, 8, 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, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 86, 8, 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, 100, 8, 2, 10, 2, 12, 2, 103, 9, 2, 1, 3, 1, 3, 1, 3, 5, 3, 108, 8, 3, 10, 3, 12, 3, 111, 9, 3, 1, 4, 1, 4, 3, 4, 115, 8, 4, 1, 5, 1, 5, 3, 5, 119, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 5, 6, 131, 8, 6, 10, 6, 12, 6, 134, 9, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 5, 7, 142, 8, 7, 10, 7, 12, 7, 145, 9, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 152, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 159, 8, 9, 1, 9, 0, 3, 4, 12, 14, 10, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 0, 2, 1, 0, 6, 7, 2, 0, 3, 3, 8, 8, 174, 0, 20, 1, 0, 0, 0, 2, 24, 1, 0, 0, 0, 4, 85, 1, 0, 0, 0, 6, 104, 1, 0, 0, 0, 8, 114, 1, 0, 0, 0, 10, 116, 1, 0, 0, 0, 12, 120, 1, 0, 0, 0, 14, 135, 1, 0, 0, 0, 16, 151, 1, 0, 0, 0, 18, 158, 1, 0, 0, 0, 20, 21, 5, 17, 0, 0, 21, 22, 5, 1, 0, 0, 22, 23, 5, 17, 0, 0, 23, 1, 1, 0, 0, 0, 24, 25, 3, 4, 2, 0, 25, 26, 5, 0, 0, 1, 26, 3, 1, 0, 0, 0, 27, 28, 6, 2, -1, 0, 28, 86, 3, 8, 4, 0, 29, 86, 3, 0, 0, 0, 30, 31, 5, 3, 0, 0, 31, 86, 3, 4, 2, 13, 32, 33, 5, 4, 0, 0, 33, 34, 3, 4, 2, 0, 34, 35, 5, 5, 0, 0, 35, 86, 1, 0, 0, 0, 36, 37, 5, 9, 0, 0, 37, 38, 5, 4, 0, 0, 38, 39, 3, 4, 2, 0, 39, 40, 5, 5, 0, 0, 40, 86, 1, 0, 0, 0, 41, 42, 5, 10, 0, 0, 42, 43, 5, 4, 0, 0, 43, 44, 3, 0, 0, 0, 44, 45, 5, 5, 0, 0, 45, 86, 1, 0, 0, 0, 46, 47, 5, 9, 0, 0, 47, 48, 5, 4, 0, 0, 48, 49, 3, 10, 5, 0, 49, 50, 5, 11, 0, 0, 50, 51, 3, 10, 5, 0, 51, 52, 5, 12, 0, 0, 52, 53, 3, 4, 2, 0, 53, 54, 5, 5, 0, 0, 54, 86, 1, 0, 0, 0, 55, 56, 5, 17, 0, 0, 56, 58, 5, 4, 0, 0, 57, 59, 3, 6, 3, 0, 58, 57, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 86, 5, 5, 0, 0, 61, 62, 5, 17, 0, 0, 62, 63, 5, 13, 0, 0, 63, 64, 3, 10, 5, 0, 64, 65, 5, 14, 0, 0, 65, 86, 1, 0, 0, 0, 66, 67, 5, 17, 0, 0, 67, 68, 5, 13, 0, 0, 68, 69, 3, 4, 2, 0, 69, 70, 5, 14, 0, 0, 70, 86, 1, 0, 0, 0, 71, 72, 5, 4, 0, 0, 72, 73, 3, 4, 2, 0, 73, 74, 5, 5, 0, 0, 74, 75, 5, 13, 0, 0, 75, 76, 3, 10, 5, 0, 76, 77, 5, 14, 0, 0, 77, 86, 1, 0, 0, 0, 78, 79, 5, 4, 0, 0, 79, 80, 3, 4, 2, 0, 80, 81, 5, 5, 0, 0, 81, 82, 5, 13, 0, 0, 82, 83, 3, 4, 2, 0, 83, 84, 5, 14, 0, 0, 84, 86, 1, 0, 0, 0, 85, 27, 1, 0, 0, 0, 85, 29, 1, 0, 0, 0, 85, 30, 1, 0, 0, 0, 85, 32, 1, 0, 0, 0, 85, 36, 1, 0, 0, 0, 85, 41, 1, 0, 0, 0, 85, 46, 1, 0, 0, 0, 85, 55, 1, 0, 0, 0, 85, 61, 1, 0, 0, 0, 85, 66, 1, 0, 0, 0, 85, 71, 1, 0, 0, 0, 85, 78, 1, 0, 0, 0, 86, 101, 1, 0, 0, 0, 87, 88, 10, 14, 0, 0, 88, 89, 5, 2, 0, 0, 89, 100, 3, 4, 2, 14, 90, 91, 10, 11, 0, 0, 91, 92, 7, 0, 0, 0, 92, 100, 3, 4, 2, 12, 93, 94, 10, 10, 0, 0, 94, 95, 7, 1, 0, 0, 95, 100, 3, 4, 2, 11, 96, 97, 10, 9, 0, 0, 97, 98, 5, 18, 0, 0, 98, 100, 3, 4, 2, 10, 99, 87, 1, 0, 0, 0, 99, 90, 1, 0, 0, 0, 99, 93, 1, 0, 0, 0, 99, 96, 1, 0, 0, 0, 100, 103, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 5, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 104, 109, 3, 4, 2, 0, 105, 106, 5, 12, 0, 0, 106, 108, 3, 4, 2, 0, 107, 105, 1, 0, 0, 0, 108, 111, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 109, 110, 1, 0, 0, 0, 110, 7, 1, 0, 0, 0, 111, 109, 1, 0, 0, 0, 112, 115, 5, 15, 0, 0, 113, 115, 5, 17, 0, 0, 114, 112, 1, 0, 0, 0, 114, 113, 1, 0, 0, 0, 115, 9, 1, 0, 0, 0, 116, 118, 5, 16, 0, 0, 117, 119, 3, 12, 6, 0, 118, 117, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 11, 1, 0, 0, 0, 120, 121, 6, 6, -1, 0, 121, 122, 7, 1, 0, 0, 122, 123, 3, 16, 8, 0, 123, 132, 1, 0, 0, 0, 124, 125, 10, 3, 0, 0, 125, 126, 7, 0, 0, 0, 126, 131, 3, 14, 7, 0, 127, 128, 10, 2, 0, 0, 128, 129, 7, 1, 0, 0, 129, 131, 3, 14, 7, 0, 130, 124, 1, 0, 0, 0, 130, 127, 1, 0, 0, 0, 131, 134, 1, 0, 0, 0, 132, 130, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 13, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 135, 136, 6, 7, -1, 0, 136, 137, 3, 16, 8, 0, 137, 143, 1, 0, 0, 0, 138, 139, 10, 2, 0, 0, 139, 140, 7, 0, 0, 0, 140, 142, 3, 14, 7, 3, 141, 138, 1, 0, 0, 0, 142, 145, 1, 0, 0, 0, 143, 141, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 15, 1, 0, 0, 0, 145, 143, 1, 0, 0, 0, 146, 147, 3, 18, 9, 0, 147, 148, 5, 2, 0, 0, 148, 149, 3, 16, 8, 0, 149, 152, 1, 0, 0, 0, 150, 152, 3, 18, 9, 0, 151, 146, 1, 0, 0, 0, 151, 150, 1, 0, 0, 0, 152, 17, 1, 0, 0, 0, 153, 154, 5, 4, 0, 0, 154, 155, 3, 4, 2, 0, 155, 156, 5, 5, 0, 0, 156, 159, 1, 0, 0, 0, 157, 159, 3, 8, 4, 0, 158, 153, 1, 0, 0, 0, 158, 157, 1, 0, 0, 0, 159, 19, 1, 0, 0, 0, 12, 58, 85, 99, 101, 109, 114, 118, 130, 132, 143, 151, 158]
38 changes: 20 additions & 18 deletions src/gems_craft/expression/parsing/antlr/Expr.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@ T__9=10
T__10=11
T__11=12
T__12=13
NUMBER=14
TIME=15
IDENTIFIER=16
COMPARISON=17
WS=18
T__13=14
NUMBER=15
TIME=16
IDENTIFIER=17
COMPARISON=18
WS=19
'.'=1
'-'=2
'('=3
')'=4
'/'=5
'*'=6
'+'=7
'sum'=8
'sum_connections'=9
'..'=10
','=11
'['=12
']'=13
't'=15
'^'=2
'-'=3
'('=4
')'=5
'/'=6
'*'=7
'+'=8
'sum'=9
'sum_connections'=10
'..'=11
','=12
'['=13
']'=14
't'=16
Loading
Loading