Skip to content
Snippets Groups Projects
Commit 8150a68f authored by Derval Guillaume's avatar Derval Guillaume
Browse files

Expressions

parent 034c1b1d
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,8 @@ __all__ = [
"StdConstraint", "SOSConstraint", "Objective", "VariableDefinition", "Node",
"HyperEdge", "NodeDefinition", "NodeImport", "HyperEdgeDefinition", "HyperEdgeImport",
"ExpressionOp", "GBOMLGraph", "ImplicitLoop", "RValue", "RValueWithGen", "GeneratedRValue",
"Range", "MultiLoop", "DictEntry", "Dictionary", "NodeGenerator", "HyperEdgeGenerator"
"Range", "MultiLoop", "DictEntry", "Dictionary", "NodeGenerator", "HyperEdgeGenerator",
"DefinitionType"
]
from gboml.ast.arrays import *
......
......@@ -18,9 +18,14 @@ class VarType(Enum):
binary = "binary"
class DefinitionType(Enum):
constant = "="
expression = "<-"
@dataclass
class Definition(GBOMLObject):
name: str
type: DefinitionType
value: RValue
tags: list[str] = field(default_factory=list)
......
......@@ -91,7 +91,8 @@ bool_expression_comparison: expression (COMPARISON_OPERATOR | CTR_OPERATOR) expr
COMPARISON_OPERATOR: "<" | ">" | "!="
// DEFINITIONS
definition: ID "=" rvalue tags ";"
definition: ID DEF_TYPE rvalue tags ";"
DEF_TYPE: "=" | "<-"
// ARRAYS
array_or_dict: "{" separated_maybe_empty_list{_array_or_dict_entry, ","} "}"
......
......@@ -114,6 +114,7 @@ def _lark_to_gboml(tree: Tree, filename: Optional[str] = None) -> GBOMLGraph:
def COMPARISON_OPERATOR(self, token): return Operator(token.value)
def STRING(self, token): return token.value[1:-1].replace('\\"', '"')
def VTYPE(self, token): return VarType(token.value)
def DEF_TYPE(self, token): return DefinitionType(token.value)
NodesAndHyperEdges = namedtuple("NodesAndHyperEdges", ["nodes", "hyperedges"])
......
......@@ -5,7 +5,7 @@
b = 2.2;
c = 2e2;
d = -1;
e = 2e-2;
e <- 2e-2;
f = [0:2];
g = [0:10:2];
#NODE nodeI = import nodeA from "hello.gboml";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment