Open b1conrad opened 7 years ago
available as of krl-parser@0.19.0
Now semicolons can terminate the last expression in functions. ~They can't terminate items in an action block.~
Available, as of pico-engine 0.12.x
semi-colons can now be used to follow any action, either in a block or by itself.
More details/help here: https://github.com/Picolab/node-pico-engine/blob/master/CHANGELOG.md#0120---may-25-2017
(EDIT: not a problem anymore) Not sure exactly what's going on, but in a defaction the parser is only allowing me to have a semicolon on the first declaration. Any subsequent declarations containing semi-colons cause a parsing ambiguity error. Example code:
deleteChild = defaction(pico_name){
ent_children = children().children
filtered_children = ent_children.collect(function(child){
(child{"name"} == pico_name) => "to_delete" | "dont_delete"
})
child_to_delete = filtered_children{"to_delete"}.head()
every {
engine:removePico(child_to_delete.id)
send_directive("Deleting child", {"message": "Deleting pico with the given name: "+pico_name})
}
returns
{
"status": true,
"updated_children": filtered_children.dont_delete,
"child": child_to_delete.id
}
}```
Only "ent_children = children().children" can have a semi-colon
Also, functions now require semicolons after declarations. This is inconsistent with preludes and defactions.
I noted the special case for functions here.
Labelling as blocked until we agree to forbid standalone expressions in functions, which seems to make the grammar ambiguous unless semicolons are used. @windley?
Can you give me some clear examples?
farskipper's tests can come up with counterexamples for bad grammars, such as the current grammar modified to not require (semicolon) separators in functions. As for 'standalone expressions' I think we can do without, I mean the second line in the function:
function(a){
b = function(c){a + c};
b(0);
b(1)
}
But this isn't valid. A function is a decl block followed by an expression. This has two expressions.
That answers that, then. Thanks.
Also, can we get rid of them in postludes, I wonder...