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
Eclipse UserFriend
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
Eclipse UserFriend
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: .;

Re: Parser wants spaces [message #1857924 is a reply to message #1857920] Tue, 07 March 2023 05:25 Go to previous message
Eclipse UserFriend
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: Tue Feb 18 11:05:13 GMT 2025

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

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

Back to the top