Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328156 - MWE2 does not allow to specify int properties
Summary: MWE2 does not allow to specify int properties
Status: RESOLVED FIXED
Alias: None
Product: EMFT
Classification: Modeling
Component: MWE (show other bugs)
Version: 1.0.1   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-19 12:48 EDT by Philipp Salvisberg CLA
Modified: 2020-10-19 09:06 EDT (History)
4 users (show)

See Also:
sebastian.zarnekow: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Salvisberg CLA 2010-10-19 12:48:01 EDT
Build Identifier: I20100608-0911

cannot define a var of type int nor pass an int value as parameter. E.g the following does not work:


a) causing error in editor "no viable alternative at input '1'"
var k=1
...
fragment = parser.antlr.ex.rt.AntlrGeneratorFragment {
    options = auto-inject {
    }
}

b) causing runtime error "argument type mismatch"
var k="1"
...
fragment = parser.antlr.ex.rt.AntlrGeneratorFragment {
    options = auto-inject {
    }
}

c) causing error in editor "no viable alternative at input '1'"
fragment = parser.antlr.ex.rt.AntlrGeneratorFragment {
    options = {k=1}
}


d) causing error in editor "no viable alternative at input '1'"
fragment = parser.antlr.ex.rt.AntlrGeneratorFragment {
    options = {k=1;}
}

Reproducible: Always
Comment 1 Sven Efftinge CLA 2010-10-20 02:30:32 EDT
As a workaround you should subclass the org.eclipse.xtext.generator.parser.antlr.AntlrOptions and add a method setKAsString(String s) and do the conversion in Java.

You can instantiate the subtype like this:

 options = MyWorkaroundAntlrOptions {kAsString="1"}
Comment 2 Philipp Salvisberg CLA 2010-10-20 04:13:59 EDT
(In reply to comment #1)
> As a workaround you should subclass the
> org.eclipse.xtext.generator.parser.antlr.AntlrOptions and add a method
> setKAsString(String s) and do the conversion in Java.

Thanks, works! - I've created a subclass named AntLrOptionsWithKAsString and used the following variant in MWE successfully:

...
var kAsString = "7"
...
fragment = parser.antlr.ex.rt.AntlrGeneratorFragment {
	options = AntLrOptionsWithKAsString auto-inject {
	}
}
...

I've changed importance to P4 since a workaround is available now.
Comment 3 Armando Blancas CLA 2011-08-29 13:03:40 EDT
Any chance that this might be fixed in the next service release?  It'd be great to use this DSL the way you intended. Having to use the workaround is a step back from XML. I'm sold on the idea of using DSLs to write DSLs; that's why it's disappointing to see this bug as a minor with no plan to fix it.
Comment 4 Christian Dietrich CLA 2020-10-19 09:06:54 EDT
we support int now (some 2.11.x version)