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

Allow empty arrays/funcs

parent b9b68609
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,8 @@
//MACROS
_separated_list{sub, sep}: sub (sep sub)*
separated_list{sub, sep}: _separated_list{sub, sep}
_separated_maybe_empty_list{sub, sep}: _separated_list{sub, sep}?
separated_maybe_empty_list{sub, sep}: _separated_list{sub, sep}?
plist{content}: content*
// HEADER
......@@ -86,7 +88,7 @@ COMPARISON_OPERATOR: "<" | ">" | "!="
definition: ID "=" rvalue ";"
// ARRAYS
array: "{" _separated_list{generated_rvalue, ","} "}"
array: "{" _separated_maybe_empty_list{generated_rvalue, ","} "}"
// RANGE
range: "[" expression ":" expression [":" expression] "]"
......@@ -104,7 +106,7 @@ unary_minus: "-" value
?value: function | var_or_param | INT | FLOAT | ("(" expression ")")
// FUNCTIONS
function: ID "(" separated_list{generated_rvalue, ","} ")"
function: ID "(" separated_maybe_empty_list{generated_rvalue, ","} ")"
// VAR OR PARAM LINK
var_or_param: separated_list{var_or_param_leaf, "."}
......
......@@ -53,7 +53,8 @@ def _lark_to_gboml(tree: Tree, filename: Optional[str] = None) -> GBOMLGraph:
as_list = {
"objectives_block", "constraints_block", "variables_block",
"parameters_block", "global_block", "plist", "node_redefs",
"hyperedge_redefs", "separated_list", "array"
"hyperedge_redefs", "separated_list", "separated_maybe_empty_list",
"array"
}
#
......
// Working example where x = -4
#TIMEHORIZON T = 1;
#NODE H
#PARAMETERS
a = {};
b = len({});
c = myfunc();
#VARIABLES
internal : x;
#CONSTRAINTS
x <= -4;
#OBJECTIVES
max : x;
\ No newline at end of file
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