From 16efbbaeeef255bb28294838cd94087918f12ebc Mon Sep 17 00:00:00 2001 From: "alokp@chromium.org" Date: Tue, 13 Sep 2011 04:10:41 +0000 Subject: [PATCH] Complete implementation for handling #define directive. Review URL: http://codereview.appspot.com/4963062 git-svn-id: https://angleproject.googlecode.com/svn/trunk@752 736b8ea6-26fd-11df-bfd4-992fa37f6226 --- src/compiler/preprocessor/new/Context.cpp | 52 ++- src/compiler/preprocessor/new/Context.h | 10 +- src/compiler/preprocessor/new/Macro.cpp | 8 +- src/compiler/preprocessor/new/Macro.h | 13 +- src/compiler/preprocessor/new/Token.cpp | 3 - src/compiler/preprocessor/new/pp.l | 35 +- src/compiler/preprocessor/new/pp.y | 85 ++-- src/compiler/preprocessor/new/pp_lex.cpp | 402 ++++++++--------- src/compiler/preprocessor/new/pp_tab.cpp | 515 +++++++++++----------- src/compiler/preprocessor/new/pp_tab.h | 75 ++-- 10 files changed, 608 insertions(+), 590 deletions(-) diff --git a/src/compiler/preprocessor/new/Context.cpp b/src/compiler/preprocessor/new/Context.cpp index 4cb8476f9..259cc43ea 100644 --- a/src/compiler/preprocessor/new/Context.cpp +++ b/src/compiler/preprocessor/new/Context.cpp @@ -13,6 +13,21 @@ #include "stl_utils.h" #include "token_type.h" +static bool isMacroNameReserved(const std::string* name) +{ + ASSERT(name); + + // Names prefixed with "GL_" are reserved. + if (name->substr(0, 3) == "GL_") + return true; + + // Names containing two consecutive underscores are reserved. + if (name->find("__") != std::string::npos) + return true; + + return false; +} + namespace pp { @@ -58,18 +73,29 @@ bool Context::process(int count, bool Context::defineMacro(pp::Token::Location location, pp::Macro::Type type, - std::string* identifier, - pp::Macro::ParameterVector* parameters, + std::string* name, + pp::TokenVector* parameters, pp::TokenVector* replacements) { - // TODO(alokp): Check for reserved macro names and duplicate macros. - mMacros[*identifier] = new Macro(type, identifier, parameters, replacements); + std::auto_ptr macro(new Macro(type, name, parameters, replacements)); + if (isMacroNameReserved(name)) + { + // TODO(alokp): Report error. + return false; + } + if (isMacroDefined(name)) + { + // TODO(alokp): Report error. + return false; + } + + mMacros[*name] = macro.release(); return true; } -bool Context::undefineMacro(const std::string* identifier) +bool Context::undefineMacro(const std::string* name) { - MacroSet::iterator iter = mMacros.find(*identifier); + MacroSet::iterator iter = mMacros.find(*name); if (iter == mMacros.end()) { // TODO(alokp): Report error. @@ -79,9 +105,9 @@ bool Context::undefineMacro(const std::string* identifier) return true; } -bool Context::isMacroDefined(const std::string* identifier) +bool Context::isMacroDefined(const std::string* name) { - return mMacros.find(*identifier) != mMacros.end(); + return mMacros.find(*name) != mMacros.end(); } // Reset to initialized state. @@ -96,17 +122,17 @@ void Context::reset() mOutput = NULL; } -void Context::defineBuiltInMacro(const std::string& identifier, int value) +void Context::defineBuiltInMacro(const std::string& name, int value) { std::ostringstream stream; stream << value; Token* token = new Token(0, INT_CONSTANT, new std::string(stream.str())); TokenVector* replacements = new pp::TokenVector(1, token); - mMacros[identifier] = new Macro(Macro::kTypeObj, - new std::string(identifier), - NULL, - replacements); + mMacros[name] = new Macro(Macro::kTypeObj, + new std::string(name), + NULL, + replacements); } } // namespace pp diff --git a/src/compiler/preprocessor/new/Context.h b/src/compiler/preprocessor/new/Context.h index 799e3f9ce..a81274719 100644 --- a/src/compiler/preprocessor/new/Context.h +++ b/src/compiler/preprocessor/new/Context.h @@ -33,11 +33,11 @@ class Context bool defineMacro(pp::Token::Location location, pp::Macro::Type type, - std::string* identifier, - pp::Macro::ParameterVector* parameters, + std::string* name, + pp::TokenVector* parameters, pp::TokenVector* replacements); - bool undefineMacro(const std::string* identifier); - bool isMacroDefined(const std::string* identifier); + bool undefineMacro(const std::string* name); + bool isMacroDefined(const std::string* name); private: DISALLOW_COPY_AND_ASSIGN(Context); @@ -46,7 +46,7 @@ class Context void reset(); bool initLexer(); void destroyLexer(); - void defineBuiltInMacro(const std::string& identifier, int value); + void defineBuiltInMacro(const std::string& name, int value); bool parse(); void* mLexer; // Lexer handle. diff --git a/src/compiler/preprocessor/new/Macro.cpp b/src/compiler/preprocessor/new/Macro.cpp index b8ff745af..fccca966d 100644 --- a/src/compiler/preprocessor/new/Macro.cpp +++ b/src/compiler/preprocessor/new/Macro.cpp @@ -14,11 +14,11 @@ namespace pp { Macro::Macro(Type type, - std::string* identifier, - ParameterVector* parameters, + std::string* name, + TokenVector* parameters, TokenVector* replacements) : mType(type), - mIdentifier(identifier), + mName(name), mParameters(parameters), mReplacements(replacements) { @@ -26,7 +26,7 @@ Macro::Macro(Type type, Macro::~Macro() { - delete mIdentifier; + delete mName; if (mParameters) { diff --git a/src/compiler/preprocessor/new/Macro.h b/src/compiler/preprocessor/new/Macro.h index 71dad06ac..e24330660 100644 --- a/src/compiler/preprocessor/new/Macro.h +++ b/src/compiler/preprocessor/new/Macro.h @@ -24,26 +24,25 @@ class Macro kTypeObj, kTypeFunc }; - typedef std::vector ParameterVector; // Takes ownership of pointer parameters. Macro(Type type, - std::string* identifier, - ParameterVector* parameters, + std::string* name, + TokenVector* parameters, TokenVector* replacements); ~Macro(); Type type() const { return mType; } - const std::string* identifier() const { return mIdentifier; } - const ParameterVector* parameters() const { return mParameters; } + const std::string* identifier() const { return mName; } + const TokenVector* parameters() const { return mParameters; } const TokenVector* replacements() const { return mReplacements; } private: DISALLOW_COPY_AND_ASSIGN(Macro); Type mType; - std::string* mIdentifier; - ParameterVector* mParameters; + std::string* mName; + TokenVector* mParameters; TokenVector* mReplacements; }; diff --git a/src/compiler/preprocessor/new/Token.cpp b/src/compiler/preprocessor/new/Token.cpp index cedd9abe2..a2e759c69 100644 --- a/src/compiler/preprocessor/new/Token.cpp +++ b/src/compiler/preprocessor/new/Token.cpp @@ -40,9 +40,6 @@ std::ostream& operator<<(std::ostream& out, const Token& token) { switch (token.type()) { - case SPACE: - out << " "; - break; case INT_CONSTANT: case FLOAT_CONSTANT: case IDENTIFIER: diff --git a/src/compiler/preprocessor/new/pp.l b/src/compiler/preprocessor/new/pp.l index 3669ef8c1..627ca04b2 100644 --- a/src/compiler/preprocessor/new/pp.l +++ b/src/compiler/preprocessor/new/pp.l @@ -36,6 +36,8 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh. #define YY_INPUT(buf, result, maxSize) \ result = yyextra->readInput(buf, maxSize); + +static std::string* extractMacroName(const char* str, int len); %} %option noyywrap nounput never-interactive @@ -61,9 +63,15 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".") {HASH} { return HASH; } -{HASH}define { return HASH_DEFINE_OBJ; } -{HASH}define{HSPACE}+/{IDENTIFIER}"(" { return HASH_DEFINE_FUNC; } -{HASH}undef { return HASH_UNDEF; } +{HASH}define{HSPACE}+{IDENTIFIER}/[ \t\n] { + yylval->sval = extractMacroName(yytext, yyleng); + return HASH_DEFINE_OBJ; +} +{HASH}define{HSPACE}+{IDENTIFIER}/"(" { + yylval->sval = extractMacroName(yytext, yyleng); + return HASH_DEFINE_FUNC; +} +{HASH}undef{HSPACE}+ { return HASH_UNDEF; } {HASH}if { return HASH_IF; } {HASH}ifdef { return HASH_IFDEF; } @@ -96,7 +104,7 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".") {PUNCTUATOR} { return yytext[0]; } -{HSPACE}+ { return SPACE; } +[ \t\v\f]+ { /* Ignore whitespace */ } \n { ++yylineno; yycolumn = 0; @@ -107,6 +115,25 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".") %% +std::string* extractMacroName(const char* str, int len) +{ + // The input string is of the form {HASH}define{HSPACE}+{IDENTIFIER} + // We just need to find the last HSPACE. + ASSERT(str && (len > 8)); // strlen("#define ") == 8; + + std::string* name = NULL; + for (int i = len - 1; i >= 0; --i) + { + if ((str[i] == ' ') || (str[i] == '\t')) + { + name = new std::string(str + i + 1, len - i - 1); + break; + } + } + ASSERT(name); + return name; +} + namespace pp { int Context::readInput(char* buf, int maxSize) diff --git a/src/compiler/preprocessor/new/pp.y b/src/compiler/preprocessor/new/pp.y index 9a6973907..55193abfc 100644 --- a/src/compiler/preprocessor/new/pp.y +++ b/src/compiler/preprocessor/new/pp.y @@ -36,7 +36,6 @@ WHICH GENERATES THE GLSL ES PARSER. %union { int ival; std::string* sval; - std::vector* slist; pp::Token* tval; pp::TokenVector* tlist; } @@ -51,15 +50,14 @@ static void pushConditionalBlock(pp::Context* context, bool condition); static void popConditionalBlock(pp::Context* context); %} -%token HASH HASH_DEFINE_OBJ HASH_DEFINE_FUNC HASH_UNDEF +%token HASH HASH_UNDEF %token HASH_IF HASH_IFDEF HASH_IFNDEF HASH_ELSE HASH_ELIF HASH_ENDIF DEFINED %token HASH_ERROR HASH_PRAGMA HASH_EXTENSION HASH_VERSION HASH_LINE -%token SPACE +%token HASH_DEFINE_OBJ HASH_DEFINE_FUNC %token INT_CONSTANT FLOAT_CONSTANT IDENTIFIER %type operator -%type parameter_list %type conditional_token token -%type text_line replacement_token_list conditional_token_list token_list +%type parameter_list replacement_list conditional_list token_list %% input @@ -68,32 +66,32 @@ input ; line - : text_line { + : text_line + | control_line +; + +text_line + : '\n' + | token_list '\n' { // TODO(alokp): Expand macros. pp::TokenVector* out = context->output(); out->insert(out->end(), $1->begin(), $1->end()); delete $1; } - | control_line -; - -text_line - : '\n' { $$ = NULL; } - | token_list '\n' { $$ = $1; } ; control_line : HASH '\n' - | HASH_DEFINE_OBJ IDENTIFIER replacement_token_list '\n' { - context->defineMacro(@2.first_line, pp::Macro::kTypeObj, $2, NULL, $3); + | HASH_DEFINE_OBJ replacement_list '\n' { + context->defineMacro(@1.first_line, pp::Macro::kTypeObj, $1, NULL, $2); } - | HASH_DEFINE_FUNC IDENTIFIER '(' parameter_list ')' replacement_token_list '\n' { - context->defineMacro(@2.first_line, pp::Macro::kTypeFunc, $2, $4, $6); + | HASH_DEFINE_FUNC '(' parameter_list ')' replacement_list '\n' { + context->defineMacro(@1.first_line, pp::Macro::kTypeFunc, $1, $3, $5); } | HASH_UNDEF IDENTIFIER '\n' { context->undefineMacro($2); } - | HASH_IF conditional_token_list '\n' { + | HASH_IF conditional_list '\n' { pushConditionalBlock(context, $2 ? true : false); } | HASH_IFDEF IDENTIFIER '\n' { @@ -102,7 +100,7 @@ control_line | HASH_IFNDEF IDENTIFIER '\n' { pushConditionalBlock(context, !context->isMacroDefined($2)); } - | HASH_ELIF conditional_token_list '\n' { + | HASH_ELIF conditional_list '\n' { } | HASH_ELSE '\n' { } @@ -116,39 +114,29 @@ control_line | HASH_LINE '\n' ; -replacement_token_list - : /* empty */ { $$ = NULL } +replacement_list + : /* empty */ { $$ = NULL; } | token_list -; - -conditional_token_list - : conditional_token { - $$ = new pp::TokenVector; - $$->push_back($1); - } - | conditional_token_list conditional_token { - $$ = $1; - $$->push_back($2); - } -; - -conditional_token - : DEFINED IDENTIFIER { - } - | DEFINED '(' IDENTIFIER ')' { - } - | token -; parameter_list : /* empty */ { $$ = NULL; } | IDENTIFIER { - $$ = new std::vector(); - $$->push_back($1); + $$ = new pp::TokenVector; + $$->push_back(new pp::Token(@1.first_line, IDENTIFIER, $1)); } | parameter_list ',' IDENTIFIER { $$ = $1; - $$->push_back($3); + $$->push_back(new pp::Token(@3.first_line, IDENTIFIER, $3)); + } + +conditional_list + : conditional_token { + $$ = new pp::TokenVector; + $$->push_back($1); + } + | conditional_list conditional_token { + $$ = $1; + $$->push_back($2); } ; @@ -163,13 +151,18 @@ token_list } ; +conditional_token + : DEFINED IDENTIFIER { + } + | DEFINED '(' IDENTIFIER ')' { + } + | token +; + token : operator { $$ = new pp::Token(@1.first_line, $1, NULL); } - | SPACE { - $$ = new pp::Token(@1.first_line, SPACE, NULL); - } | INT_CONSTANT { $$ = new pp::Token(@1.first_line, INT_CONSTANT, $1); } diff --git a/src/compiler/preprocessor/new/pp_lex.cpp b/src/compiler/preprocessor/new/pp_lex.cpp index d410e3e2b..7084831a1 100644 --- a/src/compiler/preprocessor/new/pp_lex.cpp +++ b/src/compiler/preprocessor/new/pp_lex.cpp @@ -380,48 +380,38 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_acclist[57] = +static yyconst flex_int16_t yy_accept[105] = { 0, - 24, 23, 21, 23, 22, 23, 20, 23, 20, 23, - 18, 23, 18, 23, 17, 23, 17, 23, 21, 23, - 1, 23, 21, 19, 19, 18, 18, 17, 17, 21, - 1, 1, 19, 18, 17, 5, 19, 17, 17, 9, - 8, 16, 17, 10, 12, 6, 4, 11, 17, 2, - 7, 13,16387, 15, 8195, 14 - } ; + 0, 0, 24, 23, 21, 22, 20, 20, 18, 18, + 17, 17, 21, 1, 21, 19, 19, 18, 0, 0, + 0, 18, 17, 17, 21, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 19, 18, 17, 0, + 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, + 19, 17, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 17, 0, 9, 8, 0, 0, + 0, 0, 0, 16, 0, 0, 0, 17, 0, 10, + 12, 0, 6, 0, 0, 0, 0, 11, 0, 0, + 7, 13, 4, 0, 0, 0, 15, 0, 0, 2, -static yyconst flex_int16_t yy_accept[104] = - { 0, - 1, 1, 1, 2, 3, 5, 7, 9, 11, 13, - 15, 17, 19, 21, 23, 24, 25, 26, 27, 27, - 27, 27, 28, 29, 30, 31, 32, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 33, 34, 35, 36, - 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, - 37, 38, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 40, 40, 41, 42, 42, - 42, 42, 42, 42, 43, 43, 43, 43, 44, 44, - 45, 46, 46, 47, 47, 47, 48, 48, 50, 51, - 51, 52, 53, 53, 54, 54, 55, 55, 55, 56, - - 56, 57, 57 + 3, 0, 14, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 1, 5, 1, 4, 4, 1, 6, - 4, 4, 7, 4, 7, 8, 4, 9, 10, 10, - 10, 10, 10, 10, 10, 11, 11, 4, 4, 4, - 4, 4, 4, 1, 12, 12, 12, 12, 13, 12, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 15, 14, 14, - 4, 1, 4, 4, 14, 1, 16, 12, 12, 17, + 1, 2, 5, 1, 6, 1, 5, 5, 1, 7, + 5, 5, 8, 5, 8, 9, 5, 10, 11, 11, + 11, 11, 11, 11, 11, 12, 12, 5, 5, 5, + 5, 5, 5, 1, 13, 13, 13, 13, 14, 13, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 16, 15, 15, + 5, 1, 5, 5, 15, 1, 17, 13, 13, 18, - 18, 19, 20, 14, 21, 14, 14, 22, 23, 24, - 25, 26, 14, 27, 28, 29, 30, 31, 14, 32, - 14, 14, 4, 4, 4, 4, 1, 1, 1, 1, + 19, 20, 21, 15, 22, 15, 15, 23, 24, 25, + 26, 27, 15, 28, 29, 30, 31, 32, 15, 33, + 15, 15, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -438,119 +428,112 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[33] = +static yyconst flex_int32_t yy_meta[34] = { 0, - 1, 2, 1, 1, 1, 3, 1, 1, 4, 4, - 4, 5, 6, 7, 7, 5, 5, 6, 5, 7, + 1, 2, 3, 1, 1, 1, 3, 1, 1, 4, + 4, 4, 5, 6, 7, 7, 5, 5, 6, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7 + 7, 7, 7 } ; -static yyconst flex_int16_t yy_base[109] = +static yyconst flex_int16_t yy_base[111] = { 0, - 0, 17, 171, 172, 168, 172, 172, 3, 27, 52, - 0, 151, 27, 69, 166, 26, 28, 1, 21, 40, - 0, 0, 0, 148, 50, 0, 0, 148, 42, 146, - 143, 136, 138, 143, 47, 66, 69, 0, 139, 140, - 60, 141, 130, 127, 65, 131, 138, 136, 125, 74, - 83, 127, 129, 130, 130, 126, 121, 127, 126, 126, - 124, 121, 122, 111, 120, 113, 172, 172, 117, 108, - 110, 114, 114, 172, 108, 111, 108, 103, 101, 172, - 172, 85, 172, 79, 81, 172, 71, 0, 71, 51, - 172, 172, 44, 65, 28, 172, 42, 19, 172, 9, + 0, 18, 184, 185, 11, 185, 185, 21, 28, 53, + 0, 164, 39, 71, 12, 32, 34, 1, 39, 44, + 0, 0, 0, 162, 64, 0, 0, 162, 46, 160, + 157, 150, 152, 157, 70, 47, 65, 0, 153, 154, + 62, 155, 144, 141, 67, 145, 152, 150, 139, 76, + 85, 141, 143, 144, 144, 140, 135, 141, 140, 140, + 138, 135, 136, 125, 134, 127, 185, 185, 131, 122, + 124, 128, 128, 185, 122, 125, 122, 125, 123, 185, + 185, 112, 185, 120, 113, 127, 97, 0, 107, 86, + 185, 185, 105, 76, 81, 34, 185, 97, 10, 185, - 172, 172, 100, 104, 108, 111, 116, 121 + 185, 103, 185, 185, 110, 114, 118, 121, 126, 132 } ; -static yyconst flex_int16_t yy_def[109] = +static yyconst flex_int16_t yy_def[111] = { 0, - 103, 103, 102, 102, 102, 102, 102, 102, 102, 102, - 104, 104, 102, 102, 102, 105, 105, 9, 18, 102, - 106, 10, 104, 104, 102, 14, 14, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 106, 104, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - 102, 104, 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 104, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 104, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 104, 102, 102, - 102, 102, 102, 107, 102, 102, 108, 102, 102, 108, + 105, 105, 104, 104, 104, 104, 104, 104, 104, 104, + 106, 106, 104, 104, 104, 107, 107, 9, 18, 104, + 108, 10, 106, 106, 104, 14, 14, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 108, 106, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 106, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 106, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 106, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 106, 104, 104, + 104, 104, 104, 104, 109, 104, 104, 110, 104, 104, - 102, 0, 102, 102, 102, 102, 102, 102 + 104, 110, 104, 0, 104, 104, 104, 104, 104, 104 } ; -static yyconst flex_int16_t yy_nxt[205] = +static yyconst flex_int16_t yy_nxt[219] = { 0, - 4, 5, 6, 7, 4, 7, 7, 8, 9, 10, - 10, 16, 16, 16, 99, 102, 12, 4, 13, 6, - 7, 14, 7, 7, 8, 9, 10, 10, 25, 19, - 19, 26, 102, 12, 17, 18, 18, 19, 35, 20, - 35, 21, 101, 35, 20, 35, 36, 99, 37, 37, - 37, 25, 98, 50, 26, 51, 51, 51, 21, 17, - 22, 22, 22, 41, 20, 42, 94, 96, 43, 20, - 27, 95, 94, 44, 37, 37, 37, 37, 37, 37, - 54, 59, 51, 51, 51, 28, 29, 55, 60, 30, - 31, 51, 51, 51, 32, 93, 92, 91, 33, 34, + 4, 5, 6, 5, 7, 4, 7, 7, 8, 9, + 10, 10, 15, 15, 15, 15, 104, 12, 4, 13, + 6, 5, 7, 14, 7, 7, 8, 9, 10, 10, + 16, 16, 16, 104, 103, 12, 17, 18, 18, 19, + 25, 20, 15, 21, 26, 35, 20, 35, 19, 19, + 35, 36, 35, 37, 37, 37, 37, 37, 37, 99, + 21, 17, 22, 22, 22, 25, 20, 15, 41, 26, + 42, 20, 27, 43, 37, 37, 37, 50, 44, 51, + 51, 51, 95, 54, 59, 51, 51, 51, 28, 29, + 55, 60, 30, 31, 51, 51, 51, 32, 100, 100, + 97, 33, 34, 101, 100, 100, 93, 96, 95, 101, 11, 11, 11, 11, 11, 11, 11, 23, 23, 23, - 23, 16, 90, 16, 38, 38, 38, 97, 89, 88, - 97, 97, 97, 100, 100, 100, 100, 100, 87, 86, - 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, - 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, - 65, 64, 63, 62, 61, 58, 57, 56, 53, 52, - 49, 48, 47, 46, 45, 40, 39, 15, 24, 15, - 102, 3, 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 23, 16, 94, 16, 38, 38, 38, 98, 93, 92, + 98, 98, 98, 102, 102, 102, 102, 102, 102, 91, + 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, + 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, + 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, + 58, 57, 56, 53, 52, 49, 48, 47, 46, 45, + 40, 39, 24, 104, 3, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, - 102, 102, 102, 102 + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104 } ; -static yyconst flex_int16_t yy_chk[205] = +static yyconst flex_int16_t yy_chk[219] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 8, 8, 8, 100, 18, 1, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 13, 19, - 19, 13, 18, 2, 9, 9, 9, 9, 16, 9, - 17, 9, 98, 16, 9, 17, 20, 97, 20, 20, - 20, 25, 95, 35, 25, 35, 35, 35, 9, 10, - 10, 10, 10, 29, 10, 29, 94, 93, 29, 10, - 14, 90, 89, 29, 36, 36, 36, 37, 37, 37, - 41, 45, 50, 50, 50, 14, 14, 41, 45, 14, - 14, 51, 51, 51, 14, 87, 85, 84, 14, 14, + 1, 1, 5, 15, 5, 15, 18, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 8, 8, 8, 18, 99, 2, 9, 9, 9, 9, + 13, 9, 13, 9, 13, 16, 9, 17, 19, 19, + 16, 20, 17, 20, 20, 20, 36, 36, 36, 96, + 9, 10, 10, 10, 10, 25, 10, 25, 29, 25, + 29, 10, 14, 29, 37, 37, 37, 35, 29, 35, + 35, 35, 95, 41, 45, 50, 50, 50, 14, 14, + 41, 45, 14, 14, 51, 51, 51, 14, 98, 98, - 103, 103, 103, 103, 103, 103, 103, 104, 104, 104, - 104, 105, 82, 105, 106, 106, 106, 107, 79, 78, - 107, 107, 107, 108, 108, 108, 108, 108, 77, 76, - 75, 73, 72, 71, 70, 69, 66, 65, 64, 63, - 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, - 52, 49, 48, 47, 46, 44, 43, 42, 40, 39, - 34, 33, 32, 31, 30, 28, 24, 15, 12, 5, - 3, 102, 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 94, 14, 14, 98, 102, 102, 93, 90, 89, 102, + 105, 105, 105, 105, 105, 105, 105, 106, 106, 106, + 106, 107, 87, 107, 108, 108, 108, 109, 86, 85, + 109, 109, 109, 110, 110, 110, 110, 110, 110, 84, + 82, 79, 78, 77, 76, 75, 73, 72, 71, 70, + 69, 66, 65, 64, 63, 62, 61, 60, 59, 58, + 57, 56, 55, 54, 53, 52, 49, 48, 47, 46, + 44, 43, 42, 40, 39, 34, 33, 32, 31, 30, + 28, 24, 12, 3, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, - 102, 102, 102, 102 + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104 } ; /* Table of booleans, true if rule could match eol. */ static yyconst flex_int32_t yy_rule_can_match_eol[24] = { 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, }; -#define YY_TRAILING_MASK 0x2000 -#define YY_TRAILING_HEAD_MASK 0x4000 -#define REJECT \ -{ \ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ -yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ -yyg->yy_lp = yyg->yy_full_lp; /* restore orig. accepting pos. */ \ -yyg->yy_state_ptr = yyg->yy_full_state; /* restore orig. state */ \ -yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \ -++yyg->yy_lp; \ -goto find_rule; \ -} - +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET @@ -581,6 +564,8 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh. #define YY_INPUT(buf, result, maxSize) \ result = yyextra->readInput(buf, maxSize); + +static std::string* extractMacroName(const char* str, int len); #define INITIAL 0 @@ -614,17 +599,6 @@ struct yyguts_t int yylineno_r; int yy_flex_debug_r; - yy_state_type *yy_state_buf; - yy_state_type *yy_state_ptr; - char *yy_full_match; - int yy_lp; - - /* These are only needed for trailing context rules, - * but there's no conditional variable for that yet. */ - int yy_looking_for_trail_begin; - int yy_full_lp; - int *yy_full_state; - char *yytext_r; int yy_more_flag; int yy_more_len; @@ -841,12 +815,6 @@ YY_DECL YY_USER_INIT; #endif - /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! yyg->yy_state_buf ) - yyg->yy_state_buf = (yy_state_type *)ppalloc(YY_STATE_BUF_SIZE ,yyscanner); - if ( ! yyg->yy_state_buf ) - YY_FATAL_ERROR( "out of dynamic memory in pplex()" ); - if ( ! yyg->yy_start ) yyg->yy_start = 1; /* first start state */ @@ -879,64 +847,30 @@ YY_DECL yy_current_state = yyg->yy_start; yy_current_state += YY_AT_BOL(); - - yyg->yy_state_ptr = yyg->yy_state_buf; - *yyg->yy_state_ptr++ = yy_current_state; - yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 103 ) + if ( yy_current_state >= 105 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *yyg->yy_state_ptr++ = yy_current_state; ++yy_cp; } - while ( yy_current_state != 102 ); + while ( yy_current_state != 104 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; yy_find_action: - yy_current_state = *--yyg->yy_state_ptr; - yyg->yy_lp = yy_accept[yy_current_state]; -find_rule: /* we branch to this label when backing up */ - for ( ; ; ) /* until we find what rule we matched */ - { - if ( yyg->yy_lp && yyg->yy_lp < yy_accept[yy_current_state + 1] ) - { - yy_act = yy_acclist[yyg->yy_lp]; - if ( yy_act & YY_TRAILING_HEAD_MASK || - yyg->yy_looking_for_trail_begin ) - { - if ( yy_act == yyg->yy_looking_for_trail_begin ) - { - yyg->yy_looking_for_trail_begin = 0; - yy_act &= ~YY_TRAILING_HEAD_MASK; - break; - } - } - else if ( yy_act & YY_TRAILING_MASK ) - { - yyg->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; - yyg->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; - } - else - { - yyg->yy_full_match = yy_cp; - yyg->yy_full_state = yyg->yy_state_ptr; - yyg->yy_full_lp = yyg->yy_lp; - break; - } - ++yyg->yy_lp; - goto find_rule; - } - --yy_cp; - yy_current_state = *--yyg->yy_state_ptr; - yyg->yy_lp = yy_accept[yy_current_state]; - } + yy_act = yy_accept[yy_current_state]; YY_DO_BEFORE_ACTION; @@ -956,17 +890,37 @@ do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + case 1: YY_RULE_SETUP { return HASH; } YY_BREAK case 2: +/* rule 2 can match eol */ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -{ return HASH_DEFINE_OBJ; } +{ + yylval->sval = extractMacroName(yytext, yyleng); + return HASH_DEFINE_OBJ; +} YY_BREAK case 3: +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -{ return HASH_DEFINE_FUNC; } +{ + yylval->sval = extractMacroName(yytext, yyleng); + return HASH_DEFINE_FUNC; +} YY_BREAK case 4: YY_RULE_SETUP @@ -1047,7 +1001,7 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -{ return SPACE; } +{ /* Ignore whitespace */ } YY_BREAK case 22: /* rule 22 can match eol */ @@ -1128,7 +1082,8 @@ ECHO; else { - yy_cp = yyg->yy_c_buf_p; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; } } @@ -1254,8 +1209,37 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + pprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; } @@ -1316,20 +1300,21 @@ static int yy_get_next_buffer (yyscan_t yyscanner) yy_current_state = yyg->yy_start; yy_current_state += YY_AT_BOL(); - yyg->yy_state_ptr = yyg->yy_state_buf; - *yyg->yy_state_ptr++ = yy_current_state; - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 103 ) + if ( yy_current_state >= 105 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *yyg->yy_state_ptr++ = yy_current_state; } return yy_current_state; @@ -1344,18 +1329,22 @@ static int yy_get_next_buffer (yyscan_t yyscanner) { register int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + register char *yy_cp = yyg->yy_c_buf_p; register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 103 ) + if ( yy_current_state >= 105 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 102); - if ( ! yy_is_jam ) - *yyg->yy_state_ptr++ = yy_current_state; + yy_is_jam = (yy_current_state == 104); return yy_is_jam ? 0 : yy_current_state; } @@ -2120,11 +2109,6 @@ static int yy_init_globals (yyscan_t yyscanner) yyg->yy_start_stack_depth = 0; yyg->yy_start_stack = NULL; - yyg->yy_state_buf = 0; - yyg->yy_state_ptr = 0; - yyg->yy_full_match = 0; - yyg->yy_lp = 0; - /* Defined in main.c */ #ifdef YY_STDINIT yyin = stdin; @@ -2160,9 +2144,6 @@ int pplex_destroy (yyscan_t yyscanner) ppfree(yyg->yy_start_stack ,yyscanner ); yyg->yy_start_stack = NULL; - ppfree ( yyg->yy_state_buf , yyscanner); - yyg->yy_state_buf = NULL; - /* Reset the globals. This is important in a non-reentrant scanner so the next time * pplex() is called, initialization will occur. */ yy_init_globals( yyscanner); @@ -2221,6 +2202,25 @@ void ppfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" +std::string* extractMacroName(const char* str, int len) +{ + // The input string is of the form {HASH}define{HSPACE}+{IDENTIFIER} + // We just need to find the last HSPACE. + ASSERT(str && (len > 8)); // strlen("#define ") == 8; + + std::string* name = NULL; + for (int i = len - 1; i >= 0; --i) + { + if ((str[i] == ' ') || (str[i] == '\t')) + { + name = new std::string(str + i + 1, len - i - 1); + break; + } + } + ASSERT(name); + return name; +} + namespace pp { int Context::readInput(char* buf, int maxSize) diff --git a/src/compiler/preprocessor/new/pp_tab.cpp b/src/compiler/preprocessor/new/pp_tab.cpp index 86c882df8..ee0f4ef2d 100644 --- a/src/compiler/preprocessor/new/pp_tab.cpp +++ b/src/compiler/preprocessor/new/pp_tab.cpp @@ -75,48 +75,46 @@ know about them. */ enum yytokentype { HASH = 258, - HASH_DEFINE_OBJ = 259, - HASH_DEFINE_FUNC = 260, - HASH_UNDEF = 261, - HASH_IF = 262, - HASH_IFDEF = 263, - HASH_IFNDEF = 264, - HASH_ELSE = 265, - HASH_ELIF = 266, - HASH_ENDIF = 267, - DEFINED = 268, - HASH_ERROR = 269, - HASH_PRAGMA = 270, - HASH_EXTENSION = 271, - HASH_VERSION = 272, - HASH_LINE = 273, - SPACE = 274, - INT_CONSTANT = 275, - FLOAT_CONSTANT = 276, - IDENTIFIER = 277 + HASH_UNDEF = 259, + HASH_IF = 260, + HASH_IFDEF = 261, + HASH_IFNDEF = 262, + HASH_ELSE = 263, + HASH_ELIF = 264, + HASH_ENDIF = 265, + DEFINED = 266, + HASH_ERROR = 267, + HASH_PRAGMA = 268, + HASH_EXTENSION = 269, + HASH_VERSION = 270, + HASH_LINE = 271, + HASH_DEFINE_OBJ = 272, + HASH_DEFINE_FUNC = 273, + INT_CONSTANT = 274, + FLOAT_CONSTANT = 275, + IDENTIFIER = 276 }; #endif /* Tokens. */ #define HASH 258 -#define HASH_DEFINE_OBJ 259 -#define HASH_DEFINE_FUNC 260 -#define HASH_UNDEF 261 -#define HASH_IF 262 -#define HASH_IFDEF 263 -#define HASH_IFNDEF 264 -#define HASH_ELSE 265 -#define HASH_ELIF 266 -#define HASH_ENDIF 267 -#define DEFINED 268 -#define HASH_ERROR 269 -#define HASH_PRAGMA 270 -#define HASH_EXTENSION 271 -#define HASH_VERSION 272 -#define HASH_LINE 273 -#define SPACE 274 -#define INT_CONSTANT 275 -#define FLOAT_CONSTANT 276 -#define IDENTIFIER 277 +#define HASH_UNDEF 259 +#define HASH_IF 260 +#define HASH_IFDEF 261 +#define HASH_IFNDEF 262 +#define HASH_ELSE 263 +#define HASH_ELIF 264 +#define HASH_ENDIF 265 +#define DEFINED 266 +#define HASH_ERROR 267 +#define HASH_PRAGMA 268 +#define HASH_EXTENSION 269 +#define HASH_VERSION 270 +#define HASH_LINE 271 +#define HASH_DEFINE_OBJ 272 +#define HASH_DEFINE_FUNC 273 +#define INT_CONSTANT 274 +#define FLOAT_CONSTANT 275 +#define IDENTIFIER 276 @@ -162,7 +160,6 @@ typedef union YYSTYPE { int ival; std::string* sval; - std::vector* slist; pp::Token* tval; pp::TokenVector* tlist; } @@ -418,20 +415,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 244 +#define YYLAST 247 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 48 +#define YYNTOKENS 47 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 12 /* YYNRULES -- Number of rules. */ -#define YYNRULES 63 +#define YYNRULES 62 /* YYNRULES -- Number of states. */ -#define YYNSTATES 94 +#define YYNSTATES 91 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 277 +#define YYMAXUTOK 276 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -440,18 +437,18 @@ union yyalloc static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 23, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 22, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 44, 2, 2, 2, 38, 41, 2, - 24, 25, 37, 34, 26, 35, 33, 36, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 45, 46, - 29, 43, 30, 47, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 43, 2, 2, 2, 37, 40, 2, + 23, 24, 36, 33, 25, 34, 32, 35, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 44, 45, + 28, 42, 29, 46, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 27, 2, 28, 39, 2, 2, 2, 2, 2, + 2, 26, 2, 27, 38, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 31, 40, 32, 42, 2, 2, 2, + 2, 2, 2, 30, 39, 31, 41, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -466,7 +463,7 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22 + 15, 16, 17, 18, 19, 20, 21 }; #if YYDEBUG @@ -475,46 +472,45 @@ static const yytype_uint8 yytranslate[] = static const yytype_uint8 yyprhs[] = { 0, 0, 3, 4, 7, 9, 11, 13, 16, 19, - 24, 32, 36, 40, 44, 48, 52, 55, 58, 61, - 64, 67, 70, 73, 74, 76, 78, 81, 84, 89, - 91, 92, 94, 98, 100, 103, 105, 107, 109, 111, - 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, - 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, - 153, 155, 157, 159 + 23, 30, 34, 38, 42, 46, 50, 53, 56, 59, + 62, 65, 68, 71, 72, 74, 75, 77, 81, 83, + 86, 88, 91, 94, 99, 101, 103, 105, 107, 109, + 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, + 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, + 151, 153, 155 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 49, 0, -1, -1, 49, 50, -1, 51, -1, 52, - -1, 23, -1, 57, 23, -1, 3, 23, -1, 4, - 22, 53, 23, -1, 5, 22, 24, 56, 25, 53, - 23, -1, 6, 22, 23, -1, 7, 54, 23, -1, - 8, 22, 23, -1, 9, 22, 23, -1, 11, 54, - 23, -1, 10, 23, -1, 12, 23, -1, 14, 23, - -1, 15, 23, -1, 16, 23, -1, 17, 23, -1, - 18, 23, -1, -1, 57, -1, 55, -1, 54, 55, - -1, 13, 22, -1, 13, 24, 22, 25, -1, 58, - -1, -1, 22, -1, 56, 26, 22, -1, 58, -1, - 57, 58, -1, 59, -1, 19, -1, 20, -1, 21, - -1, 22, -1, 27, -1, 28, -1, 29, -1, 30, - -1, 24, -1, 25, -1, 31, -1, 32, -1, 33, - -1, 34, -1, 35, -1, 36, -1, 37, -1, 38, - -1, 39, -1, 40, -1, 41, -1, 42, -1, 43, - -1, 44, -1, 45, -1, 46, -1, 26, -1, 47, - -1 + 48, 0, -1, -1, 48, 49, -1, 50, -1, 51, + -1, 22, -1, 55, 22, -1, 3, 22, -1, 17, + 52, 22, -1, 18, 23, 53, 24, 52, 22, -1, + 4, 21, 22, -1, 5, 54, 22, -1, 6, 21, + 22, -1, 7, 21, 22, -1, 9, 54, 22, -1, + 8, 22, -1, 10, 22, -1, 12, 22, -1, 13, + 22, -1, 14, 22, -1, 15, 22, -1, 16, 22, + -1, -1, 55, -1, -1, 21, -1, 53, 25, 21, + -1, 56, -1, 54, 56, -1, 57, -1, 55, 57, + -1, 11, 21, -1, 11, 23, 21, 24, -1, 57, + -1, 58, -1, 19, -1, 20, -1, 21, -1, 26, + -1, 27, -1, 28, -1, 29, -1, 23, -1, 24, + -1, 30, -1, 31, -1, 32, -1, 33, -1, 34, + -1, 35, -1, 36, -1, 37, -1, 38, -1, 39, + -1, 40, -1, 41, -1, 42, -1, 43, -1, 44, + -1, 45, -1, 25, -1, 46, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 65, 65, 67, 71, 77, 81, 82, 86, 87, - 90, 93, 96, 99, 102, 105, 107, 109, 112, 113, - 114, 115, 116, 120, 121, 125, 129, 136, 138, 140, - 144, 145, 149, 156, 160, 167, 170, 173, 176, 179, - 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, - 205, 206, 207, 208 + 0, 63, 63, 65, 69, 70, 74, 75, 84, 85, + 88, 91, 94, 97, 100, 103, 105, 107, 110, 111, + 112, 113, 114, 118, 119, 122, 123, 127, 133, 137, + 144, 148, 155, 157, 159, 163, 166, 169, 172, 178, + 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201 }; #endif @@ -523,16 +519,16 @@ static const yytype_uint8 yyrline[] = First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "HASH", "HASH_DEFINE_OBJ", - "HASH_DEFINE_FUNC", "HASH_UNDEF", "HASH_IF", "HASH_IFDEF", "HASH_IFNDEF", - "HASH_ELSE", "HASH_ELIF", "HASH_ENDIF", "DEFINED", "HASH_ERROR", - "HASH_PRAGMA", "HASH_EXTENSION", "HASH_VERSION", "HASH_LINE", "SPACE", - "INT_CONSTANT", "FLOAT_CONSTANT", "IDENTIFIER", "'\\n'", "'('", "')'", - "','", "'['", "']'", "'<'", "'>'", "'{'", "'}'", "'.'", "'+'", "'-'", - "'/'", "'*'", "'%'", "'^'", "'|'", "'&'", "'~'", "'='", "'!'", "':'", - "';'", "'?'", "$accept", "input", "line", "text_line", "control_line", - "replacement_token_list", "conditional_token_list", "conditional_token", - "parameter_list", "token_list", "token", "operator", 0 + "$end", "error", "$undefined", "HASH", "HASH_UNDEF", "HASH_IF", + "HASH_IFDEF", "HASH_IFNDEF", "HASH_ELSE", "HASH_ELIF", "HASH_ENDIF", + "DEFINED", "HASH_ERROR", "HASH_PRAGMA", "HASH_EXTENSION", "HASH_VERSION", + "HASH_LINE", "HASH_DEFINE_OBJ", "HASH_DEFINE_FUNC", "INT_CONSTANT", + "FLOAT_CONSTANT", "IDENTIFIER", "'\\n'", "'('", "')'", "','", "'['", + "']'", "'<'", "'>'", "'{'", "'}'", "'.'", "'+'", "'-'", "'/'", "'*'", + "'%'", "'^'", "'|'", "'&'", "'~'", "'='", "'!'", "':'", "';'", "'?'", + "$accept", "input", "line", "text_line", "control_line", + "replacement_list", "parameter_list", "conditional_list", "token_list", + "conditional_token", "token", "operator", 0 }; #endif @@ -543,34 +539,34 @@ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 10, 40, 41, 44, 91, 93, 60, - 62, 123, 125, 46, 43, 45, 47, 42, 37, 94, - 124, 38, 126, 61, 33, 58, 59, 63 + 275, 276, 10, 40, 41, 44, 91, 93, 60, 62, + 123, 125, 46, 43, 45, 47, 42, 37, 94, 124, + 38, 126, 61, 33, 58, 59, 63 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 48, 49, 49, 50, 50, 51, 51, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 53, 53, 54, 54, 55, 55, 55, - 56, 56, 56, 57, 57, 58, 58, 58, 58, 58, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59 + 0, 47, 48, 48, 49, 49, 50, 50, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 52, 52, 53, 53, 53, 54, 54, + 55, 55, 56, 56, 56, 57, 57, 57, 57, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 0, 2, 1, 1, 1, 2, 2, 4, - 7, 3, 3, 3, 3, 3, 2, 2, 2, 2, - 2, 2, 2, 0, 1, 1, 2, 2, 4, 1, - 0, 1, 3, 1, 2, 1, 1, 1, 1, 1, + 0, 2, 0, 2, 1, 1, 1, 2, 2, 3, + 6, 3, 3, 3, 3, 3, 2, 2, 2, 2, + 2, 2, 2, 0, 1, 0, 1, 3, 1, 2, + 1, 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1 + 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -579,46 +575,46 @@ static const yytype_uint8 yyr2[] = static const yytype_uint8 yydefact[] = { 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 36, 37, - 38, 39, 6, 44, 45, 62, 40, 41, 42, 43, + 0, 0, 0, 0, 0, 0, 23, 0, 36, 37, + 38, 6, 43, 44, 61, 39, 40, 41, 42, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 63, 3, 4, 5, - 0, 33, 35, 8, 23, 0, 0, 0, 0, 25, - 29, 0, 0, 16, 0, 17, 18, 19, 20, 21, - 22, 7, 34, 0, 24, 30, 11, 27, 0, 12, - 26, 13, 14, 15, 9, 31, 0, 0, 23, 0, - 28, 0, 32, 10 + 56, 57, 58, 59, 60, 62, 3, 4, 5, 0, + 30, 35, 8, 0, 0, 0, 28, 34, 0, 0, + 16, 0, 17, 18, 19, 20, 21, 22, 0, 24, + 25, 7, 31, 11, 32, 0, 12, 29, 13, 14, + 15, 9, 26, 0, 0, 23, 0, 33, 0, 27, + 10 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 1, 47, 48, 49, 73, 58, 59, 86, 74, - 60, 52 + -1, 1, 46, 47, 48, 68, 83, 55, 69, 56, + 57, 51 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -29 +#define YYPACT_NINF -55 static const yytype_int16 yypact[] = { - -29, 1, -29, -9, 29, 33, 35, 139, 36, 37, - 38, 139, 39, 40, 41, 42, 43, 44, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - 168, -29, -29, -29, 197, 45, 47, 30, 69, -29, - -29, 48, 49, -29, 104, -29, -29, -29, -29, -29, - -29, -29, -29, 51, 197, 46, -29, -29, 53, -29, - -29, -29, -29, -29, -29, -29, -23, 52, 197, 54, - -29, 55, -29, -29 + -55, 73, -55, -17, -18, 145, -10, -9, -16, 145, + -8, 22, 23, 24, 25, 27, 201, 28, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, 173, + -55, -55, -55, 30, -19, -3, -55, -55, 31, 32, + -55, 109, -55, -55, -55, -55, -55, -55, 33, 201, + 29, -55, -55, -55, -55, 35, -55, -55, -55, -55, + -55, -55, -55, -15, -11, 201, 36, -55, 37, -55, + -55 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -29, -29, -29, -29, -29, -28, 68, -8, -29, 79, - -1, -29 + -55, -55, -55, -55, -55, -27, -55, 51, 60, -54, + -1, -55 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -628,76 +624,76 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 51, 2, 88, 89, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 53, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 72, - 80, 54, 77, 51, 78, 55, 80, 56, 61, 62, - 91, 63, 65, 66, 67, 68, 69, 70, 85, 75, - 76, 81, 82, 72, 84, 87, 92, 90, 93, 64, - 50, 0, 57, 0, 0, 0, 0, 51, 18, 19, - 20, 21, 79, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 57, 0, 0, - 0, 0, 0, 18, 19, 20, 21, 83, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 57, 0, 0, 0, 0, 0, 18, 19, - 20, 21, 0, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 18, 19, 20, - 21, 71, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 18, 19, 20, 21, - 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 50, 77, 74, 53, 75, 52, 60, 77, 54, 85, + 86, 58, 59, 87, 62, 50, 18, 19, 20, 76, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46 + 42, 43, 44, 45, 63, 64, 65, 66, 72, 67, + 82, 70, 73, 78, 79, 81, 84, 89, 88, 90, + 61, 49, 0, 0, 0, 0, 0, 0, 72, 0, + 0, 0, 0, 2, 0, 0, 3, 4, 5, 6, + 7, 8, 9, 10, 50, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 54, 0, 0, 0, 0, 0, 0, 0, 18, 19, + 20, 80, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 54, 0, 0, 0, + 0, 0, 0, 0, 18, 19, 20, 0, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 18, 19, 20, 71, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 18, 19, 20, 0, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45 }; static const yytype_int8 yycheck[] = { - 1, 0, 25, 26, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 23, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 50, - 58, 22, 22, 54, 24, 22, 64, 22, 22, 22, - 88, 23, 23, 23, 23, 23, 23, 23, 22, 24, - 23, 23, 23, 74, 23, 22, 22, 25, 23, 11, - 1, -1, 13, -1, -1, -1, -1, 88, 19, 20, + 1, 55, 21, 21, 23, 22, 22, 61, 11, 24, + 25, 21, 21, 24, 22, 16, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 22, 22, 22, 22, 49, 22, + 21, 23, 22, 22, 22, 22, 21, 21, 85, 22, + 9, 1, -1, -1, -1, -1, -1, -1, 69, -1, + -1, -1, -1, 0, -1, -1, 3, 4, 5, 6, + 7, 8, 9, 10, 85, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 11, -1, -1, -1, -1, -1, -1, -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 13, -1, -1, - -1, -1, -1, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 13, -1, -1, -1, -1, -1, 19, 20, - 21, 22, -1, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 19, 20, 21, 22, - -1, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47 + 41, 42, 43, 44, 45, 46, 11, -1, -1, -1, + -1, -1, -1, -1, 19, 20, 21, -1, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 19, 20, 21, -1, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 49, 0, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, + 0, 48, 0, 3, 4, 5, 6, 7, 8, 9, + 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 50, 51, 52, - 57, 58, 59, 23, 22, 22, 22, 13, 54, 55, - 58, 22, 22, 23, 54, 23, 23, 23, 23, 23, - 23, 23, 58, 53, 57, 24, 23, 22, 24, 23, - 55, 23, 23, 23, 23, 22, 56, 22, 25, 26, - 25, 53, 22, 23 + 41, 42, 43, 44, 45, 46, 49, 50, 51, 55, + 57, 58, 22, 21, 11, 54, 56, 57, 21, 21, + 22, 54, 22, 22, 22, 22, 22, 22, 52, 55, + 23, 22, 57, 22, 21, 23, 22, 56, 22, 22, + 22, 22, 21, 53, 21, 24, 25, 24, 52, 21, + 22 }; #define yyerrok (yyerrstatus = 0) @@ -1539,37 +1535,27 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 4: + case 7: { // TODO(alokp): Expand macros. pp::TokenVector* out = context->output(); - out->insert(out->end(), (yyvsp[(1) - (1)].tlist)->begin(), (yyvsp[(1) - (1)].tlist)->end()); - delete (yyvsp[(1) - (1)].tlist); + out->insert(out->end(), (yyvsp[(1) - (2)].tlist)->begin(), (yyvsp[(1) - (2)].tlist)->end()); + delete (yyvsp[(1) - (2)].tlist); ;} break; - case 6: - - { (yyval.tlist) = NULL; ;} - break; - - case 7: - - { (yyval.tlist) = (yyvsp[(1) - (2)].tlist); ;} - break; - case 9: { - context->defineMacro((yylsp[(2) - (4)]).first_line, pp::Macro::kTypeObj, (yyvsp[(2) - (4)].sval), NULL, (yyvsp[(3) - (4)].tlist)); + context->defineMacro((yylsp[(1) - (3)]).first_line, pp::Macro::kTypeObj, (yyvsp[(1) - (3)].sval), NULL, (yyvsp[(2) - (3)].tlist)); ;} break; case 10: { - context->defineMacro((yylsp[(2) - (7)]).first_line, pp::Macro::kTypeFunc, (yyvsp[(2) - (7)].sval), (yyvsp[(4) - (7)].slist), (yyvsp[(6) - (7)].tlist)); + context->defineMacro((yylsp[(1) - (6)]).first_line, pp::Macro::kTypeFunc, (yyvsp[(1) - (6)].sval), (yyvsp[(3) - (6)].tlist), (yyvsp[(5) - (6)].tlist)); ;} break; @@ -1622,67 +1608,39 @@ yyreduce: case 23: - { (yyval.tlist) = NULL ;} + { (yyval.tlist) = NULL; ;} break; case 25: - { - (yyval.tlist) = new pp::TokenVector; - (yyval.tlist)->push_back((yyvsp[(1) - (1)].tval)); - ;} + { (yyval.tlist) = NULL; ;} break; case 26: { - (yyval.tlist) = (yyvsp[(1) - (2)].tlist); - (yyval.tlist)->push_back((yyvsp[(2) - (2)].tval)); + (yyval.tlist) = new pp::TokenVector; + (yyval.tlist)->push_back(new pp::Token((yylsp[(1) - (1)]).first_line, IDENTIFIER, (yyvsp[(1) - (1)].sval))); ;} break; case 27: { + (yyval.tlist) = (yyvsp[(1) - (3)].tlist); + (yyval.tlist)->push_back(new pp::Token((yylsp[(3) - (3)]).first_line, IDENTIFIER, (yyvsp[(3) - (3)].sval))); ;} break; case 28: - { - ;} - break; - - case 30: - - { (yyval.slist) = NULL; ;} - break; - - case 31: - - { - (yyval.slist) = new std::vector(); - (yyval.slist)->push_back((yyvsp[(1) - (1)].sval)); - ;} - break; - - case 32: - - { - (yyval.slist) = (yyvsp[(1) - (3)].slist); - (yyval.slist)->push_back((yyvsp[(3) - (3)].sval)); - ;} - break; - - case 33: - { (yyval.tlist) = new pp::TokenVector; (yyval.tlist)->push_back((yyvsp[(1) - (1)].tval)); ;} break; - case 34: + case 29: { (yyval.tlist) = (yyvsp[(1) - (2)].tlist); @@ -1690,6 +1648,34 @@ yyreduce: ;} break; + case 30: + + { + (yyval.tlist) = new pp::TokenVector; + (yyval.tlist)->push_back((yyvsp[(1) - (1)].tval)); + ;} + break; + + case 31: + + { + (yyval.tlist) = (yyvsp[(1) - (2)].tlist); + (yyval.tlist)->push_back((yyvsp[(2) - (2)].tval)); + ;} + break; + + case 32: + + { + ;} + break; + + case 33: + + { + ;} + break; + case 35: { @@ -1700,147 +1686,140 @@ yyreduce: case 36: { - (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, SPACE, NULL); + (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, INT_CONSTANT, (yyvsp[(1) - (1)].sval)); ;} break; case 37: { - (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, INT_CONSTANT, (yyvsp[(1) - (1)].sval)); + (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, FLOAT_CONSTANT, (yyvsp[(1) - (1)].sval)); ;} break; case 38: { - (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, FLOAT_CONSTANT, (yyvsp[(1) - (1)].sval)); + (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, IDENTIFIER, (yyvsp[(1) - (1)].sval)); ;} break; case 39: - { - (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, IDENTIFIER, (yyvsp[(1) - (1)].sval)); - ;} + { (yyval.ival) = '['; ;} break; case 40: - { (yyval.ival) = '['; ;} + { (yyval.ival) = ']'; ;} break; case 41: - { (yyval.ival) = ']'; ;} + { (yyval.ival) = '<'; ;} break; case 42: - { (yyval.ival) = '<'; ;} + { (yyval.ival) = '>'; ;} break; case 43: - { (yyval.ival) = '>'; ;} + { (yyval.ival) = '('; ;} break; case 44: - { (yyval.ival) = '('; ;} + { (yyval.ival) = ')'; ;} break; case 45: - { (yyval.ival) = ')'; ;} + { (yyval.ival) = '{'; ;} break; case 46: - { (yyval.ival) = '{'; ;} + { (yyval.ival) = '}'; ;} break; case 47: - { (yyval.ival) = '}'; ;} + { (yyval.ival) = '.'; ;} break; case 48: - { (yyval.ival) = '.'; ;} + { (yyval.ival) = '+'; ;} break; case 49: - { (yyval.ival) = '+'; ;} + { (yyval.ival) = '-'; ;} break; case 50: - { (yyval.ival) = '-'; ;} + { (yyval.ival) = '/'; ;} break; case 51: - { (yyval.ival) = '/'; ;} + { (yyval.ival) = '*'; ;} break; case 52: - { (yyval.ival) = '*'; ;} + { (yyval.ival) = '%'; ;} break; case 53: - { (yyval.ival) = '%'; ;} + { (yyval.ival) = '^'; ;} break; case 54: - { (yyval.ival) = '^'; ;} + { (yyval.ival) = '|'; ;} break; case 55: - { (yyval.ival) = '|'; ;} + { (yyval.ival) = '&'; ;} break; case 56: - { (yyval.ival) = '&'; ;} + { (yyval.ival) = '~'; ;} break; case 57: - { (yyval.ival) = '~'; ;} + { (yyval.ival) = '='; ;} break; case 58: - { (yyval.ival) = '='; ;} + { (yyval.ival) = '!'; ;} break; case 59: - { (yyval.ival) = '!'; ;} + { (yyval.ival) = ':'; ;} break; case 60: - { (yyval.ival) = ':'; ;} + { (yyval.ival) = ';'; ;} break; case 61: - { (yyval.ival) = ';'; ;} - break; - - case 62: - { (yyval.ival) = ','; ;} break; - case 63: + case 62: { (yyval.ival) = '?'; ;} break; diff --git a/src/compiler/preprocessor/new/pp_tab.h b/src/compiler/preprocessor/new/pp_tab.h index 34f6237c9..9e534197e 100644 --- a/src/compiler/preprocessor/new/pp_tab.h +++ b/src/compiler/preprocessor/new/pp_tab.h @@ -40,48 +40,46 @@ know about them. */ enum yytokentype { HASH = 258, - HASH_DEFINE_OBJ = 259, - HASH_DEFINE_FUNC = 260, - HASH_UNDEF = 261, - HASH_IF = 262, - HASH_IFDEF = 263, - HASH_IFNDEF = 264, - HASH_ELSE = 265, - HASH_ELIF = 266, - HASH_ENDIF = 267, - DEFINED = 268, - HASH_ERROR = 269, - HASH_PRAGMA = 270, - HASH_EXTENSION = 271, - HASH_VERSION = 272, - HASH_LINE = 273, - SPACE = 274, - INT_CONSTANT = 275, - FLOAT_CONSTANT = 276, - IDENTIFIER = 277 + HASH_UNDEF = 259, + HASH_IF = 260, + HASH_IFDEF = 261, + HASH_IFNDEF = 262, + HASH_ELSE = 263, + HASH_ELIF = 264, + HASH_ENDIF = 265, + DEFINED = 266, + HASH_ERROR = 267, + HASH_PRAGMA = 268, + HASH_EXTENSION = 269, + HASH_VERSION = 270, + HASH_LINE = 271, + HASH_DEFINE_OBJ = 272, + HASH_DEFINE_FUNC = 273, + INT_CONSTANT = 274, + FLOAT_CONSTANT = 275, + IDENTIFIER = 276 }; #endif /* Tokens. */ #define HASH 258 -#define HASH_DEFINE_OBJ 259 -#define HASH_DEFINE_FUNC 260 -#define HASH_UNDEF 261 -#define HASH_IF 262 -#define HASH_IFDEF 263 -#define HASH_IFNDEF 264 -#define HASH_ELSE 265 -#define HASH_ELIF 266 -#define HASH_ENDIF 267 -#define DEFINED 268 -#define HASH_ERROR 269 -#define HASH_PRAGMA 270 -#define HASH_EXTENSION 271 -#define HASH_VERSION 272 -#define HASH_LINE 273 -#define SPACE 274 -#define INT_CONSTANT 275 -#define FLOAT_CONSTANT 276 -#define IDENTIFIER 277 +#define HASH_UNDEF 259 +#define HASH_IF 260 +#define HASH_IFDEF 261 +#define HASH_IFNDEF 262 +#define HASH_ELSE 263 +#define HASH_ELIF 264 +#define HASH_ENDIF 265 +#define DEFINED 266 +#define HASH_ERROR 267 +#define HASH_PRAGMA 268 +#define HASH_EXTENSION 269 +#define HASH_VERSION 270 +#define HASH_LINE 271 +#define HASH_DEFINE_OBJ 272 +#define HASH_DEFINE_FUNC 273 +#define INT_CONSTANT 274 +#define FLOAT_CONSTANT 275 +#define IDENTIFIER 276 @@ -92,7 +90,6 @@ typedef union YYSTYPE { int ival; std::string* sval; - std::vector* slist; pp::Token* tval; pp::TokenVector* tlist; }