Dynamic type of variable in grammar [message #1441152] |
Thu, 09 October 2014 10:25 |
|
Hey,
I'm trying to implement a grammar for this:
type java.lang.String default "Something";
type java.lang.Long default 0;
type java.lang.Boolean default true;
The JvmType reference is working fine, but I'm a little unsure on how to proceed with the default values. Content assist should propose to me the values allowed for the current type only of course, and validation must make sure that no unsupported types are written there by hand...
What I have so far (incomplete I know, just to test):
TypeRefDecl:
'type' type=JvmTypeRef ('default' (defInt=INT|defStr=STRING|defId=ID))? ';'
;
That basically allows me to write there a lot of different default values. Still this grammar "feels" somehow wrong. Also, how could I distinguish which one to read in my code now...?
Am I on the right track, or is there some method of doing this that I'm not aware of?
Cheers,
Markus
|
|
|
|
|
|
|
|
|
Re: Dynamic type of variable in grammar [message #1441851 is a reply to message #1441840] |
Fri, 10 October 2014 09:14 |
|
Hey,
Thanks. I have tried implementing XBase for that, but found that (you're right) that's a little overkill. For that handfull of java.lang.* types i'll just really manually verify literal types For that I partially copied the concept around XLiteral and use that now.
Cheers,
Markus
|
|
|
Powered by
FUDForum. Page generated in 0.03255 seconds