Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328156

Summary: MWE2 does not allow to specify int properties
Product: [Modeling] EMFT Reporter: Philipp Salvisberg <philipp.salvisberg>
Component: MWEAssignee: Project Inbox <emft-mwe-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: abm221617, christian.dietrich.opensource, sebastian.zarnekow, sven.efftinge
Version: 1.0.1Flags: sebastian.zarnekow: juno+
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

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)