Problems parsing ruby on rails files with xtext [message #1743033] |
Fri, 09 September 2016 17:46 |
Jair Garcia 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 66 times) -
Attachment: samples.mydsl
(Size: 0.27KB, Downloaded 64 times)
|
|
|
Re: Problems parsing ruby on rails files with xtext [message #1743042 is a reply to message #1743033] |
Fri, 09 September 2016 20:06 |
|
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');
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 |
|
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');
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.03850 seconds