Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problems parsing ruby on rails files with xtext(Problems parsing ' '* and equals symbol.)
Problems parsing ruby on rails files with xtext [message #1743033] Fri, 09 September 2016 17:46 Go to next message
Jair Garcia is currently offline Jair GarciaFriend
Messages: 4
Registered: September 2016
Junior Member
Hi
I'm parsing Ruby on rails models with xtext.

I'm having problems parsing the las 3 lines of this sample (when there is no space between foreign_key and equals symbol (=).

belongs_to :school,:foreign_key => "model_id"
belongs_to "school", :foreign_key =>:model_id
belongs_to "school", :foreign_key =>"model_id"
belongs_to :school,:foreign_key=> "model_id"
belongs_to "school", :foreign_key=>:model_id
belongs_to "school", :foreign_key =>"school_id"


The xtext file is:


Main:
belongs_to+=BelongsTo*
;

BelongsTo returns BelongsTo:
'belongs_to' RWS+ name=(RUBY_SYMBOL|RUBY_STRING) (RWS*','RWS* ('foreign_key:'|':foreign_key'RWS*'=>')RWS*foreign_key=(RUBY_SYMBOL|RUBY_STRING))? (RWS*'\r'? '\n')
;

terminal RUBY_STRING: '"' -> '"'|"'"->"'";
terminal RUBY_METHOD_NAME: ('a'..'z'|'_') ('a'..'z'|'_'|'0'..'9')*'='?;
terminal RUBY_SYMBOL:':'RUBY_METHOD_NAME;
terminal RWS:(' '|'\t');


Thanks in advance, for any idea
  • Attachment: MyDsl.xtext
    (Size: 0.54KB, Downloaded 48 times)
  • Attachment: samples.mydsl
    (Size: 0.27KB, Downloaded 45 times)
Re: Problems parsing ruby on rails files with xtext [message #1743042 is a reply to message #1743033] Fri, 09 September 2016 20:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13884
Registered: July 2009
Senior Member
you may try something like

Main:
  belongs_to+=BelongsTo*
;

BelongsTo returns BelongsTo:
  'belongs_to' RWS+ name=(RUBY_SYMBOL|RUBY_STRING) (RWS*','RWS* ('foreign_key:'|':foreign_key'RWS* ('=''>') )RWS*foreign_key=(RUBY_SYMBOL|RUBY_STRING))? (RWS*'\r'? '\n')
;

RUBY_METHOD_NAME: RUBY_METHOD_NAME_PREFIX ;
RUBY_SYMBOL:':'RUBY_METHOD_NAME;

terminal RUBY_STRING: '"' -> '"'|"'"->"'";
terminal RUBY_METHOD_NAME_PREFIX: ('a'..'z'|'_') ('a'..'z'|'_'|'0'..'9')*;
terminal RWS:(' '|'\t');


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problems parsing ruby on rails files with xtext [message #1743043 is a reply to message #1743042] Fri, 09 September 2016 20:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13884
Registered: July 2009
Senior Member
or

Main:
belongs_to+=BelongsTo*
;

BelongsTo returns BelongsTo:
'belongs_to' RWS+ name=(RUBY_SYMBOL|RUBY_STRING) (RWS*','RWS* ('foreign_key:'|':foreign_key'RWS*'=''>')RWS*foreign_key=(RUBY_SYMBOL|RUBY_STRING))? (RWS*'\r'? '\n')
;

terminal RUBY_STRING: '"' -> '"'|"'"->"'";
terminal RUBY_METHOD_NAME: ('a'..'z'|'_') ('a'..'z'|'_'|'0'..'9')*;
RUBY_SYMBOL:':'RUBY_METHOD_NAME '='?;
terminal RWS:(' '|'\t');


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problems parsing ruby on rails files with xtext [message #1743053 is a reply to message #1743043] Sat, 10 September 2016 02:47 Go to previous message
Jair Garcia is currently offline Jair GarciaFriend
Messages: 4
Registered: September 2016
Junior Member
It works well

I had a misconception about terminals/rules use.

Thanks a lot
Previous Topic:Help with grammar
Next Topic:Parsing of language fragments
Goto Forum:
  


Current Time: Fri Apr 16 17:29:10 GMT 2021

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

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

Back to the top