Parser wants spaces [message #1857917] |
Mon, 06 March 2023 17:22  |
Eclipse User |
|
|
|
Hello everyone.
Most likely I'm making a rookie mistake. Maybe you can help me. I have the following example for a really small grammar.
SWSyntax:
MultirowSyntaxitem = MultiSyntax;
MultiSyntax:
Syntaxitem (Syntaxitem)*;
Syntaxitem:
ALPHACHARACTERSET;
terminal ALPHACHARACTERSET: "a" | "x";
Why does the generated parser accept in the editor
a a a a x a x a x
but not
aaaaaxxxa ?
Errortext is : mismatched input 'aa' expecting RULE_ALPHACHARACTERSET
Why does he always want spaces? The whole thing should match like regular expression [a-z].
Thanks very much.
|
|
|
Re: Parser wants spaces [message #1857920 is a reply to message #1857917] |
Mon, 06 March 2023 19:02   |
Eclipse User |
|
|
|
i assume you inherit from the terminals grammar. that one has an ID rule that matches aaaaaxxxa
=>
grammar org.xtext.example.mydsl1.MyDsl hidden(WS, ML_COMMENT, SL_COMMENT)
generate myDsl "http://www.xtext.org/example/mydsl1/MyDsl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
SWSyntax:
MultirowSyntaxitem = MultiSyntax;
MultiSyntax:
Syntaxitem (Syntaxitem)*;
Syntaxitem:
ALPHACHARACTERSET;
terminal ALPHACHARACTERSET: "a" | "x";
//terminal ID: '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
terminal INT returns ecore::EInt: ('0'..'9')+;
terminal STRING:
'"' ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|'"') )* '"' |
"'" ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|"'") )* "'"
;
terminal ML_COMMENT : '/*' -> '*/';
terminal SL_COMMENT : '//' !('\n'|'\r')* ('\r'? '\n')?;
terminal WS : (' '|'\t'|'\r'|'\n')+;
terminal ANY_OTHER: .;
|
|
|
|
Powered by
FUDForum. Page generated in 0.04412 seconds