[Newbie] Problem with grammar [message #892861] |
Sat, 30 June 2012 13:16  |
Eclipse User |
|
|
|
Hello,
I'm trrying to specify a grammar to support the Byteman rules language.
I'm starting with a subset of the language, as described here:
Each 'rule' has the following form:
- zero or more comment lines which must start with '#' (whatever the other chars)
- a rule name defined after the 'RULE' keyword. The rule name can be anything but must at least contain a non-space char.
- a 'ENDRULE' line to indicate the end of the rule definition.
eg:
# a comment
# another comment
RULE bar
ENDRULE
Here's the .xtext I have for now (excluding the usual headers 'grammar ... with ... generate ...' )
ByteManRule:
COMMENT*
'RULE' name=RULE_NAME LINE_BREAK
'ENDRULE' LINE_BREAK*
;
terminal CHAR: ('a'..'z'|'A'..'Z');
terminal RULE_NAME:
(CHAR|INT) (CHAR|INT|' '|'\t')*
;
terminal LINE_BREAK: ('\r'? '\n');
terminal COMMENT: '#' -> LINE_BREAK;
When I generate the XText artifacts, I get the following errors:
...
error(208): ...InternalBytemanDsl.g:174:1: The following token definitions can never be matched because prior tokens match the same input: RULE_INT
2839 [main] INFO or.validation.JavaValidatorFragment - generating Java-based EValidator API
error(208): ...InternalBytemanDsl.g:349:1: The following token definitions can never be matched because prior tokens match the same input: RULE_INT
...
And in the Eclipse runtime, using the XText Editor, I get an error marker at the 'RULE...' line:
"Missing 'RULE' at 'RULE bar'"
(Strangely, I have a marker in the editor, but nothing in the project explorer nor in the Problems view)
Can you help me ?
Thanks
Best regards,
Xavier
|
|
|
Re: [Newbie] Problem with grammar [message #892862 is a reply to message #892861] |
Sat, 30 June 2012 14:00   |
Eclipse User |
|
|
|
Xavier,
I think you need to show more of your grammar. It seems likely that
your RULE_INT accepts the same characters as RULE_NAME. I.e., "1" can
be both an int and a name, which is a problem.
On 30/06/2012 7:16 PM, Xavier Coulon wrote:
> Hello,
>
> I'm trrying to specify a grammar to support the Byteman rules language.
> I'm starting with a subset of the language, as described here:
>
> Each 'rule' has the following form:
> - zero or more comment lines which must start with '#' (whatever the
> other chars) - a rule name defined after the 'RULE' keyword. The rule
> name can be anything but must at least contain a non-space char. - a
> 'ENDRULE' line to indicate the end of the rule definition.
>
> eg:
>
> # a comment
> # another comment
> RULE bar
> ENDRULE
>
>
> Here's the .xtext I have for now (excluding the usual headers 'grammar
> ... with ... generate ...' )
>
>
> ByteManRule:
> COMMENT*
> 'RULE' name=RULE_NAME LINE_BREAK
> 'ENDRULE' LINE_BREAK*
> ;
>
> terminal CHAR: ('a'..'z'|'A'..'Z');
>
> terminal RULE_NAME:
> (CHAR|INT) (CHAR|INT|' '|'\t')*
> ;
>
> terminal LINE_BREAK: ('\r'? '\n');
>
> terminal COMMENT: '#' -> LINE_BREAK;
>
> When I generate the XText artifacts, I get the following errors:
>
> ..
> error(208): ...InternalBytemanDsl.g:174:1: The following token
> definitions can never be matched because prior tokens match the same
> input: RULE_INT
> 2839 [main] INFO or.validation.JavaValidatorFragment - generating
> Java-based EValidator API
> error(208): ...InternalBytemanDsl.g:349:1: The following token
> definitions can never be matched because prior tokens match the same
> input: RULE_INT
> ..
>
>
> And in the Eclipse runtime, using the XText Editor, I get an error
> marker at the 'RULE...' line: "Missing 'RULE' at 'RULE bar'"
> (Strangely, I have a marker in the editor, but nothing in the project
> explorer nor in the Problems view)
>
> Can you help me ?
> Thanks
> Best regards,
> Xavier
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05110 seconds