Whitespace-Aware Languages with unindented Single line comment [message #1748565] |
Thu, 24 November 2016 08:04  |
Eclipse User |
|
|
|
Hello Folks,
I am currently working on a Whitespace-Aware Language (YAML-Style).
Now i would like to allow comments to have any indentation without it triggering the BLOCK_END synthetic. How would i do this properly?
e.g. in the homeautomation example i want my Grammar to accept following:
Device Window can be open, closed
Device Heater can be on, off, error
Rule 'Save energy' when Window.open then
//fire(Heater.off)
fire(Heater.off)
Which with the untouched example project results in having the second fire(Heater.off) highlighted with the error missing RULE_BEGIN at 'fire'
Thanks for the input.
regards,
Stefan
|
|
|
|
|
|
|
|
|
|
Re: Whitespace-Aware Languages with unindented Single line comment [message #1748959 is a reply to message #1748949] |
Wed, 30 November 2016 08:52   |
Eclipse User |
|
|
|
Hi Uli,
Thanks for your response. The repetition of Expressions or Variable declarations are not the problem here.
The then part of the rule 'Rule' consists of a XBlockExpression:
Rule:
'Rule' description=STRING
'when' deviceState=[State|QualifiedName]
'then' thenPart=XBlockExpression;
Which is a block filled with zero or many XExpressionOrVariableDeclaration:
XBlockExpression returns xbase::XExpression:
{xbase::XBlockExpression}
BEGIN
(expressions+=XExpressionOrVarDeclaration ';'?)*
END;
This makes this .rules file valid under the grammar:
Device Window can be open, closed
Device Heater can be on, off, error
Rule 'Save energy' when Window.open then
var someDeclaration = "Anystring";
fire(Heater.off)
// Some Comment
main(["mainArgs..."]);
But this is not because of the aforementioned problem considering block statements and comments:
Device Window can be open, closed
Device Heater can be on, off, error
Rule 'Save energy' when Window.open then
var someDeclaration = "Anystring";
fire(Heater.off)
// Some Comment
main(["mainArgs..."]);
What i would like is to have comments similar to most WS aware languages such as e.g. phyton whereas this is a syntactically valid program:
x = 1
if x == 1:
print("x is 1.")
# syntactically correct comment line
print("some other output")
Regards,
Stefan
edit: i fixed some typos.
[Updated on: Wed, 30 November 2016 08:53] by Moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04113 seconds