Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Newbie Grammar Question - Quoted Attribute List
Newbie Grammar Question - Quoted Attribute List [message #1703433] Fri, 31 July 2015 14:15 Go to next message
Andrew Myers is currently offline Andrew MyersFriend
Messages: 14
Registered: October 2010
Junior Member
Hello,

I'm a complete newbie when it comes to Xtext and I have been trying to write my first grammar.

A valid input should look like:

param1="value1" param2="value2"


However I'm struggling to get it to work with the quotes around the values.

The grammar below works:

grammar com.abmyers.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.abmyers.com/mydsl/MyDsl"

Model:
	attributes+=AttributePair*;
	
AttributePair:
	name=ID '=' val=STRING;



But I wanted to capture the actual content of the string, without the quote marks and this is what I'm struggling with.

An example of what I've tried to do, but is failing is:

grammar com.abmyers.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.abmyers.com/mydsl/MyDsl"

Model:
	attributes+=AttributePair*;
	
AttributePair:
	name=ID '=' value=AttributeValue;
	
AttributeValue:
	QUOTE VAL QUOTE
;	

terminal QUOTE:
	('"' | "'") 	
;

terminal VAL:
	('a'..'z'|'0'..'1')*
;



If anyone could point me in the right direction I'd be extremely grateful.
Re: Newbie Grammar Question - Quoted Attribute List [message #1703435 is a reply to message #1703433] Fri, 31 July 2015 14:22 Go to previous message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

The SRING value converter already removes the quotes for you, so what you want is the default behavior. When you look into the parsed model you should see that you get the values without quotes.
Previous Topic:language inheritance and Xbase
Next Topic:problem in the autocomplete method, Xtext bug?
Goto Forum:
  


Current Time: Tue Mar 19 10:40:05 GMT 2024

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

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

Back to the top