Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Parsing double quotes
Parsing double quotes [message #1131217] Thu, 10 October 2013 09:59 Go to next message
Davide G is currently offline Davide GFriend
Messages: 36
Registered: October 2013
Member
Hi, i'm writing a simple xtext project to parse xml file. I wrote a simple rule to parse the xml files header:

Model:
	greetings+=Header*;
	
Greeting:
	'Hello' name=ID '!';

Header:
	'<' '?' '"' name=ID '"'  '?' '>'		
;



but it doesn't work. When i write a simple tag as

<?"hi"?>

i get this error:

mismatched input '"hi"' expecting '"'. Now, if i replace the double quotes with brackets:

Model:
	greetings+=Header*;
	
Greeting:
	'Hello' name=ID '!';

Header:
	'<' '?' '(' name=ID ')'  '?' '>'		
;



it works! So the question is: how can i correctly parse double qoutes?

Thanks
Re: Parsing double quotes [message #1131364 is a reply to message #1131217] Thu, 10 October 2013 13:00 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
If you are using the standard terminals, there is already a STRING token
that parses it for you.

Header:
'<' '?' name = STRING '?' '>'

- henrik

On 2013-10-10 11:59, Davide G wrote:
> Hi, i'm writing a simple xtext project to parse xml file. I wrote a
> simple rule to parse the xml files header:
>
>
> Model:
> greetings+=Header*;
>
> Greeting:
> 'Hello' name=ID '!';
>
> Header:
> '<' '?' '"' name=ID '"' '?' '>'
> ;
>
>
>
> but it doesn't work. When i write a simple tag as
>
> <?"hi"?>
>
> i get this error:
>
> mismatched input '"hi"' expecting '"'. Now, if i replace the double
> quotes with brackets:
>
>
> Model:
> greetings+=Header*;
>
> Greeting:
> 'Hello' name=ID '!';
>
> Header:
> '<' '?' '(' name=ID ')' '?' '>'
> ;
>
>
>
> it works! So the question is: how can i correctly parse double qoutes?
>
> Thanks
Previous Topic:How to trigger the Xtext indexer programmatically
Next Topic:Invalid character constant after succesful workflow-run
Goto Forum:
  


Current Time: Sat Apr 20 04:00:05 GMT 2024

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

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

Back to the top