Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » need to accept backslashes in the language
need to accept backslashes in the language [message #872000] Tue, 15 May 2012 09:20 Go to next message
Tim Student is currently offline Tim StudentFriend
Messages: 12
Registered: May 2012
Junior Member
Hi guys,

first, here comes my little excerpt of code:
Input hidden():	'input' (WS '-s' WS VARIABLE)? WS value+=STRING+


This will support things like
input 		 "String0" "String1" "String2"

input -s $var 	 "String0" "String1" "String2"


In my given language, we support things like:
input 		 "String0" \
		 "String1" \
		 "String2"

input -s $var 	 "String0" \
		 "String1" \
		 "String2"

to make the code better readable. The backslash sign is the marker, to tell my compiler, to continue reading in the next line (physically it escapes the <newline> character for my private parser).
How can I support this to be recognized by my Xtext grammar? I tried to define a Terminal Rule and try to hide that within the rule like this:
terminal BS   : '\\';

Input hidden(BS):	'input' (WS '-s' WS VARIABLE)? WS value+=STRING+

but it does not work....
Does anybody have an Idea?
Re: need to accept backslashes in the language [message #872009 is a reply to message #872000] Tue, 15 May 2012 09:43 Go to previous messageGo to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
HI,

try with a unicode:
Input hidden(): 'input' (WS '-s' WS VARIABLE)? WS value+=STRING ('\u005C' EOL value+=STRING)*


-Phil
Re: need to accept backslashes in the language [message #872128 is a reply to message #872009] Tue, 15 May 2012 14:06 Go to previous message
Tim Student is currently offline Tim StudentFriend
Messages: 12
Registered: May 2012
Junior Member
Thanks, that fixed it!
/tim
Previous Topic:Referencing external resources
Next Topic:Xtext generator grammar from Ecore model
Goto Forum:
  


Current Time: Wed Apr 24 23:50:09 GMT 2024

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

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

Back to the top