0

I need C++ code generation that's why I'm using ANTLR3. I would like parse: Identifier ( TOKEN_A ( LEX_A | LEX_B | ANYTHING ) TOK_B ) I implement it like that:

enum_default_value_coma
:
EQUAL
(   valI0=SIGNED_INTEGER    { m_oCurrentEnumValue.AddDefaultValue( static_cast< Int64 >( atoll( $valI0.text.c_str() ) ) ); }
|   valU0=UNSIGNED_INTEGER  { m_oCurrentEnumValue.AddDefaultValue( static_cast< UInt64 >( atoll( $valU0.text.c_str() ) ) ); }
|   valS0=XXXXXX            { m_oCurrentEnumValue.AddDefaultValue( $valS0.text ); }
)?
COMA { m_oCurrentEnum.AddValue( m_oCurrentEnumValue ); }
;

I don't know how can I detect the "anything else", XXXXXX. Have we a "Else" pattern?

Thanks

chkone
  • 3
  • 1
  • 3
  • Hello,I know how to can "anything" with "." on ANTL but my question is about the "else pattern": – chkone Jun 12 '15 at 22:38
  • What I tried: enum_member : ID { m_oCurrentEnumValue.SetName( $ID.text ); } ( EQUAL ( SIGNED_INTEGER_VALUE { m_oCurrentEnumValue.AddDefaultValue( static_cast< Int64 >( atoi( $SIGNED_INTEGER_VALUE.text.c_str() ) ) ); } | UNSIGNED_INTEGER_VALUE { m_oCurrentEnumValue.AddDefaultValue( static_cast< UInt64 >( atoi( $UNSIGNED_INTEGER_VALUE.text.c_str() ) ) ); } | SOMETHING { m_oCurrentEnumValue.AddDefaultValue( $SOMETHING.text ); } ) )? { m_oCurrentEnum.AddValue( m_oCurrentEnumValue ); } ;* But SOMETHING contain more prior lexer exemple. – chkone Jun 14 '15 at 22:58
  • To fix that I do a more complexe parser to describe strictly my "SOMETHING". – chkone Jun 14 '15 at 22:58

0 Answers0