Rule written for DSL in xtext, It is not working as expected [message #1300171] |
Thu, 17 April 2014 07:31  |
Eclipse User |
|
|
|
I am trying -->> VL:'this is test dsl in xtext' IS ABC
TestLabelBase returns ResultExpressionRhs: 'VL:' path=stringRule;
The Rule I tried was: TestLabel returns ResultExpressionRhs: TestLabelBase ('IS' modifier=alphabateModifier)?;
alphabateModifier: (abc?='ABC' | def?='DEF' | ghi?='GHI');
It would recognize the 'IS' but not the 'ABC'.
|
|
|
|
|
|
|
|
|
|
Re: Rule written for DSL in xtext, It is not working as expected [message #1311169 is a reply to message #1300670] |
Wed, 23 April 2014 12:42   |
Eclipse User |
|
|
|
Christian Dietrich wrote on Thu, 17 April 2014 14:54...
then you have way to many terminals,
including critical ones like string unquoted.
it contains a ' ' (blank)
(...)
xtext works with lexer and parser,
the lexing is eager.
generating the grammar (...) gives a lot of ambiguity warnings
is this a existing language or a new one?
maybe you should start with an easier grammar
reusing the terminals defined in the terminal grammar
(...)
stuff like 'this one has been deactivated'
is a bad idea (dont use blanks in strings)
Is possible to write a grammar that permits spaces in strings?
I have this problem: I need to write a grammar to load a OBO Flat File Format as an Ecore model. The OBOFFF has stanzas that are formatted as tag-value pairs that can be (or not) followed by modifiers (strings between brackets) and inline comments (string after an exclamation mark).
<tag>: <value> ['{'<modifier1>=<value1> ',' [<modifier2> '=' <value2>,...]'}'] ['!'<comment>]
The <value> part of the pair can be an ID (a unquoted string without whitespaces), a URI, a quoted string (whitespaces and escape characters allowed) or a unquoted string that should end at the end of the line or before the trailing modifiers/comment. Additionally, some values should use a combination of those strings, like:
subsetdef: GO_SLIM "GO SLIM"
I'd thought that I could write a rule to match it as
SubSetDefPair returns SubSetDefPair:
tag='subsetdef:' WS_CHAR* subsetName=ID WS_CHAR description=QUOTED_STRING
;
terminal WS_CHAR :
' ' | '\t'
;
terminal ID : '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
terminal QUOTED_STRING :
// A String that starts and ends with double quotation marks
'"' ( '\ \' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\') | !('\\'|'"') )* '"'
;
terminal UNBOUNDED_STRING:
// a string that should end at the ending of the line or before a comment
('a'..'z'|'A'..'Z'|'_'|'0'..'9')
(('a'..'z'|'A'..'Z'|'_'|'0'..'9' | WS_CHAR)*
('a'..'z'|'A'..'Z'|'_'|'0'..'9'))?
;
[/code]
But it's not working.
I expected to match something like
but it returns the following error:
Multiple markers at this line
- mismatched character '"' expecting set null
- mismatched character '<EOF>' expecting '"'
Does anyone have an idea of how I can address this issue?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 1.60722 seconds