diff --git a/src/lalr/ParserSymbol.hpp b/src/lalr/ParserSymbol.hpp index 5666bf1..a99b717 100644 --- a/src/lalr/ParserSymbol.hpp +++ b/src/lalr/ParserSymbol.hpp @@ -13,10 +13,10 @@ class ParserSymbol { public: int index; ///< The index of this symbol. + SymbolType type; ///< The type of this symbol. const char* identifier; ///< The identifier of this symbol. const char* lexeme; ///< The lexeme of this symbol or null if this symbol is non-terminal. const char* label; ///< The human-readable label for this symbol. - SymbolType type; ///< The type of this symbol. }; } diff --git a/src/lalr/lalrc/lalrc.cpp b/src/lalr/lalrc/lalrc.cpp index 8d8e5b3..0a75c51 100644 --- a/src/lalr/lalrc/lalrc.cpp +++ b/src/lalr/lalrc/lalrc.cpp @@ -296,15 +296,15 @@ void generate_cxx_parser_state_machine( const ParserStateMachine* state_machine const ParserSymbol* symbols_end = symbols + state_machine->symbols_size; for ( const ParserSymbol* symbol = symbols; symbol != symbols_end; ++symbol ) { - write( " {%d, \"%s\", \"%s\", \"%s\", (SymbolType) %d},\n", - symbol->index, - symbol->identifier, + write( " {%d, (SymbolType) %d, \"%s\", \"%s\", \"%s\"},\n", + symbol->index, + symbol->type, + symbol->identifier, sanitize(symbol->lexeme).c_str(), - sanitize(symbol->label).c_str(), - symbol->type + sanitize(symbol->label).c_str() ); } - write( " {-1, nullptr, nullptr, nullptr, (SymbolType) 0}\n" ); + write( " {-1, (SymbolType) 0, nullptr, nullptr, nullptr}\n" ); write( "};\n" ); write( "\n" );