Skip to main content



      Home
Home » Modeling » TMF (Xtext) » warning: "using multiple alternatives: 1, 2 ..." in syntax for constant values
warning: "using multiple alternatives: 1, 2 ..." in syntax for constant values [message #757374] Thu, 17 November 2011 23:06 Go to next message
Eclipse UserFriend
I got warnings below for the syntax I developed to express contanst values.

warning:
--------
3297 [main] INFO clipse.emf.mwe.utils.GenModelHelper - Registered GenModel 'http://www.wincornixdorf.com/protopas/api/Dsl' from 'platform:/resource/com.wincornixdorf.protopas.api/src-gen/com/wincornixdorf/protopas/api/Dsl.genmodel'
warning(200): ../com.wincornixdorf.protopas.api/src-gen/com/wincornixdorf/protopas/api/parser/antlr/internal/InternalDsl.g:1900:2: Decision can match input such as "{RULE_STRING..RULE_INT, RULE_HEX}" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input


syntax:
-------
ConstantValue:
('+'|'-')? INT | STRING | HEX | '('INT ')' | '('HEX ')'
;

Constant:
(constant ?= 'constant')? type = [DataType | QualifiedName] name = ID '=' value= ConstantValue
;


I try to have a model and then generate C++ and Java code from it. Here below are an example.

Dsl model:
------------------------------------------------------------------
constant CCCINFW_RC_ERROR -1
constant CCCINFW_EVT_INFO_AVAILABLE 38
constant CCCINFW_CUINFO_VSTACKER (32)
constant CCCINFW_POSNULL (0x0000)
constant CCCINFW_POSINIT (0xFFFF)
constant PCSTEP_PIN_KEY_PRESS "PCSTEP_PIN_KEY_PRESS"
constant ACTIVESTEP_RC_FKTN_UNKNOWN (-1)


C++:
----------------------------------------------------------------
#define CCCINFW_RC_ERROR -1
#define CCCINFW_EVT_INFO_AVAILABLE 38
#define CCCINFW_CUINFO_VSTACKER (32)
#define CCCINFW_POSNULL (0x0000)
#define CCCINFW_POSINIT (0xFFFF)
#define PCSTEP_PIN_KEY_PRESS "PCSTEP_PIN_KEY_PRESS"
#define ACTIVESTEP_RC_FKTN_UNKNOWN (-1)

Java:
----------------------------------------------------------------
public static final int CCCINFW_RC_ERROR = -1;
public static final int CCCINFW_EVT_INFO_AVAILABLE 38;
public static final int CCCINFW_CUINFO_VSTACKER (32);
public static final int CCCINFW_POSNULL (0x0000)
public static final int CCCINFW_POSINIT (0xFFFF)
public static final String PCSTEP_PIN_KEY_PRESS "PCSTEP_PIN_KEY_PRESS"
public static final int ACTIVESTEP_RC_FKTN_UNKNOWN (-1)


The syntax file is attached for your reference.



Please advice the proper syntax to express the constants above, thanks a lot!


~ Peter lin
  • Attachment: Dsl.xtext
    (Size: 3.64KB, Downloaded 132 times)
Re: warning: "using multiple alternatives: 1, 2 ..." in syntax for constant values [message #757411 is a reply to message #757374] Fri, 18 November 2011 05:54 Go to previous messageGo to next message
Eclipse UserFriend
Your problem doesn't reside in the ConstantValue rule but in the Parameter rule: it can optionally match both a ConstantValue (which can be an INT) or an INT. ANTLR chooses to disable the 2nd one, meaning you can't specify a value for the 'order' attribute in the Parameter rule. http://www.antlr.org/works/index.html is a great tool for getting insight on these things.
Re: warning: "using multiple alternatives: 1, 2 ..." in syntax for constant values [message #757686 is a reply to message #757411] Mon, 21 November 2011 04:13 Go to previous message
Eclipse UserFriend
thanks, got it.
Previous Topic:Understanding cross reference
Next Topic:Generate Annotation with several parameters
Goto Forum:
  


Current Time: Sun Jul 06 20:47:56 EDT 2025

Powered by FUDForum. Page generated in 0.03485 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top