define a terminal that is a subset of ID in xtext -


i to create terminal can matched id, not fully. while id

terminal id         : '^'?('a'..'z'|'a'..'z'|'_') ('a'..'z'|'a'..'z'|'_'|'0'..'9')*; 

the terminal define is

terminal type: (('a'..'z'|'a'..'z')?('a'..'z'|'a'..'z'|'_'|'0'..'9')*)? 

because type can match id getting rule_id errors, can in case?

______edit__________  domainmodel :     (elements+=xtype)*;  terminal type: ('a'..'z'|'a'..'z')('a'..'z'|'a'..'z'|'0'..'9'|'_')*;  myid:      type | id ;  xtype:     datatype | entity;  datatype:     'datatype' name=myid;  entity:     'entity' name=myid ('extends' supertype=[entity])? '{'         (features+=feature)*     '}';  feature:     (many?='many')? name=myid ':' type=[xtype]; 

model (base on blog example)

datatype string  entity blog {     title: string     title2: string     many posts: post     many posts: post }  entity hasauthor {     author: string }  entity post extends hasauthor {     title: string     content: string     many comments: comment }  entity comment extends hasauthor {     content: string } 

you can introduce datatype rule

myid: id | type; 

and value converter myid , use @ places used id

or forget type , check restricted range inside validator

domainmodel :     (elements+=xtype)*;  terminal type: ('a'..'z'|'a'..'z')('a'..'z'|'a'..'z'|'0'..'9'|'_')*;  myid:      type | id ;  xtype:     datatype | entity;  datatype:     'datatype' name=myid;  entity:     'entity' name=myid ('extends' supertype=[entity|myid])? '{'         (features+=feature)*     '}';  feature:     (many?='many')? name=myid ':' type=[xtype|myid]; 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -