|
|
|
|
|
|
Re: Rule written for DSL in xtext, It is not working as expected [message #1300670 is a reply to message #1300639] |
Thu, 17 April 2014 18:54 |
|
hi, this is still not complete . stringRule is missing.
and the info if you use terminals grammar or not.
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 (asuming
TestLabelBase returns ResultExpressionRhs:
'VL:' path=STRING;)
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
e.g:
NUMBER: INT? ('.' INT);
MY_STRING: STRING | (ID+);
stuff like 'this one has been deactivated'
is a bad idea (dont use blanks in strings)
--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
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 16:42 |
Ricardo \\\"CaWal\\\" Cacheta Waldemarin Messages: 29 Registered: January 2013 |
Junior Member |
|
|
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 0.04047 seconds