Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Parser wants spaces
Parser wants spaces [message #1857917] Mon, 06 March 2023 17:22 Go to next message
Frank Behr is currently offline Frank BehrFriend
Messages: 5
Registered: March 2023
Junior Member
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 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14723
Registered: July 2009
Senior Member
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: .;



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Parser wants spaces [message #1857924 is a reply to message #1857920] Tue, 07 March 2023 05:25 Go to previous message
Frank Behr is currently offline Frank BehrFriend
Messages: 5
Registered: March 2023
Junior Member
Ok. I understand. Now it works. Thank you! :-)
Previous Topic:Xtext 2.30.0 is out
Next Topic:How to replace DefaultFoldingRegionProvider
Goto Forum:
  


Current Time: Sat Oct 12 16:27:35 GMT 2024

Powered by FUDForum. Page generated in 0.03401 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top