Commit 3f990c4a by alokp@chromium.org

Added lexer rules for operators.

Review URL: https://codereview.appspot.com/5966072 git-svn-id: https://angleproject.googlecode.com/svn/trunk@1014 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 3b130253
......@@ -21,14 +21,27 @@ struct Token
CONST_INT,
CONST_FLOAT,
OP_LEFT_SHIFT,
OP_RIGHT_SHIFT,
OP_LESS_EQUAL,
OP_GREATER_EQUAL,
OP_EQUAL,
OP_NOT_EQUAL,
OP_AND_AND,
OP_OR_OR
OP_INC,
OP_DEC,
OP_LEFT,
OP_RIGHT,
OP_LE,
OP_GE,
OP_EQ,
OP_NE,
OP_AND,
OP_XOR,
OP_OR,
OP_ADD_ASSIGN,
OP_SUB_ASSIGN,
OP_MUL_ASSIGN,
OP_DIV_ASSIGN,
OP_MOD_ASSIGN,
OP_LEFT_ASSIGN,
OP_RIGHT_ASSIGN,
OP_AND_ASSIGN,
OP_XOR_ASSIGN,
OP_OR_ASSIGN
};
struct Location
{
......
......@@ -77,6 +77,28 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".")
return pp::Token::CONST_FLOAT;
}
"++" { return pp::Token::OP_INC; }
"--" { return pp::Token::OP_DEC; }
"<<" { return pp::Token::OP_LEFT; }
">>" { return pp::Token::OP_RIGHT; }
"<=" { return pp::Token::OP_LE; }
">=" { return pp::Token::OP_GE; }
"==" { return pp::Token::OP_EQ; }
"!=" { return pp::Token::OP_NE; }
"&&" { return pp::Token::OP_AND; }
"^^" { return pp::Token::OP_XOR; }
"||" { return pp::Token::OP_OR; }
"+=" { return pp::Token::OP_ADD_ASSIGN; }
"-=" { return pp::Token::OP_SUB_ASSIGN; }
"*=" { return pp::Token::OP_MUL_ASSIGN; }
"/=" { return pp::Token::OP_DIV_ASSIGN; }
"%=" { return pp::Token::OP_MOD_ASSIGN; }
"<<=" { return pp::Token::OP_LEFT_ASSIGN; }
">>=" { return pp::Token::OP_RIGHT_ASSIGN; }
"&=" { return pp::Token::OP_AND_ASSIGN; }
"^=" { return pp::Token::OP_XOR_ASSIGN; }
"|=" { return pp::Token::OP_OR_ASSIGN; }
{PUNCTUATOR} { return yytext[0]; }
[ \t\v\f]+ { /* Ignore whitespace */ }
......
#line 16 "compiler/preprocessor/new/pp.l"
#line 16 "./src/compiler/preprocessor/new/pp.l"
//
// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
......@@ -9,7 +9,7 @@
#line 13 "compiler/preprocessor/new/pp_lex.cpp"
#line 13 "./src/compiler/preprocessor/new/pp_lex.cpp"
#define YY_INT_ALIGNED short int
......@@ -371,8 +371,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 8
#define YY_END_OF_BUFFER 9
#define YY_NUM_RULES 29
#define YY_END_OF_BUFFER 30
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
......@@ -380,11 +380,15 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[29] =
static yyconst flex_int16_t yy_accept[62] =
{ 0,
0, 0, 9, 8, 6, 7, 5, 1, 5, 3,
3, 2, 6, 4, 4, 3, 0, 0, 0, 3,
2, 0, 0, 4, 3, 0, 4, 0
0, 0, 30, 29, 27, 28, 26, 1, 26, 26,
26, 26, 26, 26, 26, 26, 3, 3, 26, 26,
26, 2, 26, 26, 27, 12, 20, 13, 23, 18,
5, 16, 6, 17, 4, 19, 4, 3, 0, 0,
0, 3, 7, 9, 11, 10, 8, 2, 24, 14,
25, 15, 0, 0, 4, 3, 21, 22, 0, 4,
0
} ;
static yyconst flex_int32_t yy_ec[256] =
......@@ -392,17 +396,17 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
2, 2, 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, 4,
4, 4, 6, 4, 6, 7, 4, 8, 9, 9,
9, 9, 9, 9, 9, 10, 10, 4, 4, 4,
4, 4, 4, 1, 11, 11, 11, 11, 12, 11,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 14, 13, 13,
4, 1, 4, 4, 13, 1, 11, 11, 11, 11,
12, 11, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 14,
13, 13, 4, 4, 4, 4, 1, 1, 1, 1,
1, 2, 4, 1, 5, 1, 6, 7, 1, 8,
8, 9, 10, 8, 11, 12, 13, 14, 15, 15,
15, 15, 15, 15, 15, 16, 16, 8, 8, 17,
18, 19, 8, 1, 20, 20, 20, 20, 21, 20,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 23, 22, 22,
8, 1, 8, 24, 22, 1, 20, 20, 20, 20,
21, 20, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
22, 22, 8, 25, 8, 8, 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,
......@@ -419,54 +423,76 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst flex_int32_t yy_meta[15] =
static yyconst flex_int32_t yy_meta[26] =
{ 0,
1, 1, 1, 1, 1, 2, 3, 4, 4, 4,
5, 6, 7, 7
1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
2, 3, 1, 4, 4, 4, 1, 1, 1, 5,
6, 7, 7, 1, 1
} ;
static yyconst flex_int16_t yy_base[35] =
static yyconst flex_int16_t yy_base[68] =
{ 0,
0, 0, 50, 51, 47, 51, 51, 51, 0, 8,
12, 0, 46, 35, 0, 32, 17, 38, 0, 16,
0, 32, 25, 0, 0, 21, 0, 51, 17, 26,
29, 35, 36, 41
0, 0, 99, 100, 96, 100, 79, 100, 78, 19,
100, 77, 17, 18, 16, 76, 26, 22, 27, 74,
32, 0, 15, 28, 84, 100, 100, 100, 100, 100,
100, 100, 100, 100, 62, 100, 55, 37, 40, 46,
0, 40, 30, 100, 100, 100, 10, 0, 100, 100,
100, 100, 48, 48, 51, 0, 100, 100, 54, 57,
100, 71, 74, 78, 83, 84, 89
} ;
static yyconst flex_int16_t yy_def[35] =
static yyconst flex_int16_t yy_def[68] =
{ 0,
28, 1, 28, 28, 28, 28, 28, 28, 29, 28,
30, 31, 28, 29, 14, 10, 16, 32, 33, 30,
31, 34, 32, 23, 33, 34, 26, 0, 28, 28,
28, 28, 28, 28
61, 1, 61, 61, 61, 61, 61, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 62, 61, 61,
61, 63, 61, 61, 61, 61, 61, 61, 61, 61,
61, 61, 61, 61, 64, 61, 64, 17, 38, 65,
66, 62, 61, 61, 61, 61, 61, 63, 61, 61,
61, 61, 67, 61, 61, 66, 61, 61, 61, 61,
0, 61, 61, 61, 61, 61, 61
} ;
static yyconst flex_int16_t yy_nxt[66] =
static yyconst flex_int16_t yy_nxt[126] =
{ 0,
4, 5, 6, 7, 8, 7, 9, 10, 11, 11,
12, 12, 12, 12, 15, 16, 16, 17, 15, 18,
14, 19, 15, 18, 17, 17, 28, 18, 20, 20,
28, 20, 21, 21, 21, 21, 24, 26, 24, 25,
25, 25, 27, 23, 27, 28, 22, 13, 13, 28,
3, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 18, 19, 20, 21, 22,
22, 22, 22, 23, 24, 28, 31, 58, 33, 35,
35, 35, 49, 37, 32, 34, 29, 37, 50, 38,
38, 39, 40, 43, 44, 51, 40, 57, 41, 46,
47, 37, 52, 39, 39, 54, 54, 59, 59, 61,
40, 55, 55, 55, 55, 55, 55, 60, 60, 60,
60, 60, 60, 42, 42, 53, 42, 48, 48, 48,
48, 35, 53, 35, 55, 25, 55, 56, 56, 56,
60, 45, 60, 36, 30, 27, 26, 25, 61, 3,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
61, 61, 61, 61, 61
} ;
static yyconst flex_int16_t yy_chk[66] =
static yyconst flex_int16_t yy_chk[126] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 10, 10, 10, 10, 11, 10,
29, 10, 20, 11, 17, 17, 26, 20, 30, 30,
23, 30, 31, 31, 31, 31, 32, 22, 32, 33,
33, 33, 34, 18, 34, 16, 14, 13, 5, 3,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 10, 13, 47, 14, 15,
15, 15, 23, 18, 13, 14, 10, 17, 23, 17,
17, 17, 18, 19, 19, 24, 17, 43, 17, 21,
21, 42, 24, 39, 39, 40, 40, 53, 53, 38,
42, 54, 54, 54, 55, 55, 55, 59, 59, 59,
60, 60, 60, 62, 62, 37, 62, 63, 63, 63,
63, 64, 35, 64, 65, 25, 65, 66, 66, 66,
67, 20, 67, 16, 12, 9, 7, 5, 3, 61,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
61, 61, 61, 61, 61
} ;
/* Table of booleans, true if rule could match eol. */
static yyconst flex_int32_t yy_rule_can_match_eol[9] =
static yyconst flex_int32_t yy_rule_can_match_eol[30] =
{ 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, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, };
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
......@@ -787,13 +813,13 @@ yy_match:
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 >= 29 )
if ( yy_current_state >= 62 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 28 );
while ( yy_current_state != 61 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
......@@ -854,14 +880,98 @@ YY_RULE_SETUP
YY_BREAK
case 5:
YY_RULE_SETUP
{ return yytext[0]; }
{ return pp::Token::OP_INC; }
YY_BREAK
case 6:
YY_RULE_SETUP
{ /* Ignore whitespace */ }
{ return pp::Token::OP_DEC; }
YY_BREAK
case 7:
/* rule 7 can match eol */
YY_RULE_SETUP
{ return pp::Token::OP_LEFT; }
YY_BREAK
case 8:
YY_RULE_SETUP
{ return pp::Token::OP_RIGHT; }
YY_BREAK
case 9:
YY_RULE_SETUP
{ return pp::Token::OP_LE; }
YY_BREAK
case 10:
YY_RULE_SETUP
{ return pp::Token::OP_GE; }
YY_BREAK
case 11:
YY_RULE_SETUP
{ return pp::Token::OP_EQ; }
YY_BREAK
case 12:
YY_RULE_SETUP
{ return pp::Token::OP_NE; }
YY_BREAK
case 13:
YY_RULE_SETUP
{ return pp::Token::OP_AND; }
YY_BREAK
case 14:
YY_RULE_SETUP
{ return pp::Token::OP_XOR; }
YY_BREAK
case 15:
YY_RULE_SETUP
{ return pp::Token::OP_OR; }
YY_BREAK
case 16:
YY_RULE_SETUP
{ return pp::Token::OP_ADD_ASSIGN; }
YY_BREAK
case 17:
YY_RULE_SETUP
{ return pp::Token::OP_SUB_ASSIGN; }
YY_BREAK
case 18:
YY_RULE_SETUP
{ return pp::Token::OP_MUL_ASSIGN; }
YY_BREAK
case 19:
YY_RULE_SETUP
{ return pp::Token::OP_DIV_ASSIGN; }
YY_BREAK
case 20:
YY_RULE_SETUP
{ return pp::Token::OP_MOD_ASSIGN; }
YY_BREAK
case 21:
YY_RULE_SETUP
{ return pp::Token::OP_LEFT_ASSIGN; }
YY_BREAK
case 22:
YY_RULE_SETUP
{ return pp::Token::OP_RIGHT_ASSIGN; }
YY_BREAK
case 23:
YY_RULE_SETUP
{ return pp::Token::OP_AND_ASSIGN; }
YY_BREAK
case 24:
YY_RULE_SETUP
{ return pp::Token::OP_XOR_ASSIGN; }
YY_BREAK
case 25:
YY_RULE_SETUP
{ return pp::Token::OP_OR_ASSIGN; }
YY_BREAK
case 26:
YY_RULE_SETUP
{ return yytext[0]; }
YY_BREAK
case 27:
YY_RULE_SETUP
{ /* Ignore whitespace */ }
YY_BREAK
case 28:
/* rule 28 can match eol */
YY_RULE_SETUP
{
++yylineno; yycolumn = 0;
......@@ -871,7 +981,7 @@ YY_RULE_SETUP
case YY_STATE_EOF(INITIAL):
{ yyterminate(); }
YY_BREAK
case 8:
case 29:
YY_RULE_SETUP
ECHO;
YY_BREAK
......@@ -1167,7 +1277,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
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 >= 29 )
if ( yy_current_state >= 62 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
......@@ -1196,11 +1306,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
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 >= 29 )
if ( yy_current_state >= 62 )
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 == 28);
yy_is_jam = (yy_current_state == 61);
return yy_is_jam ? 0 : yy_current_state;
}
......
/* A Bison parser, made by GNU Bison 2.3. */
/* A Bison parser, made by GNU Bison 2.4.2. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
......@@ -29,7 +27,7 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
......@@ -47,7 +45,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.3"
#define YYBISON_VERSION "2.4.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
......@@ -55,69 +53,24 @@
/* Pure parsers. */
#define YYPURE 1
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Using locations. */
#define YYLSP_NEEDED 1
/* Substitute the variable and function names. */
#define yyparse ppparse
#define yylex pplex
#define yyerror pperror
#define yylval pplval
#define yychar ppchar
#define yydebug ppdebug
#define yynerrs ppnerrs
#define yylloc pplloc
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
HASH = 258,
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_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
#define yyparse ppparse
#define yylex pplex
#define yyerror pperror
#define yylval pplval
#define yychar ppchar
#define yydebug ppdebug
#define yynerrs ppnerrs
#define yylloc pplloc
/* Copy the first part of user declarations. */
......@@ -140,6 +93,7 @@
#define YYDEBUG 1
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
......@@ -158,21 +112,53 @@
# define YYTOKEN_TABLE 0
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
HASH = 258,
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
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
int ival;
std::string* sval;
pp::Token* tval;
pp::TokenVector* tlist;
}
/* Line 187 of yacc.c. */
YYSTYPE;
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
......@@ -201,8 +187,6 @@ static void pushConditionalBlock(pp::Context* context, bool condition);
static void popConditionalBlock(pp::Context* context);
/* Line 216 of yacc.c. */
#ifdef short
# undef short
......@@ -252,7 +236,7 @@ typedef short int yytype_int16;
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
# if YYENABLE_NLS
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
......@@ -277,14 +261,14 @@ typedef short int yytype_int16;
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
YYID (int i)
YYID (int yyi)
#else
static int
YYID (i)
int i;
YYID (yyi)
int yyi;
#endif
{
return i;
return yyi;
}
#endif
......@@ -366,9 +350,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
yytype_int16 yyss;
YYSTYPE yyvs;
YYLTYPE yyls;
yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc;
YYLTYPE yyls_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
......@@ -403,12 +387,12 @@ union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack) \
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack, Stack, yysize); \
Stack = &yyptr->Stack; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
......@@ -712,9 +696,18 @@ static const yytype_uint8 yystos[] =
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
Once GCC version 2 has supplanted version 1, this can go. However,
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
discussed. */
#define YYFAIL goto yyerrlab
#if defined YYFAIL
/* This is here to suppress warnings from the GCC cpp's
-Wunused-macros. Normally we don't worry about that warning, but
some users do, and we want to make it easy for users to remove
YYFAIL uses, which will produce warnings from Bison 2.5. */
#endif
#define YYRECOVERING() (!!yyerrstatus)
......@@ -771,7 +764,7 @@ while (YYID (0))
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# if YYLTYPE_IS_TRIVIAL
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
......@@ -890,17 +883,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, context)
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
yy_stack_print (bottom, top)
yytype_int16 *bottom;
yytype_int16 *top;
yy_stack_print (yybottom, yytop)
yytype_int16 *yybottom;
yytype_int16 *yytop;
#endif
{
YYFPRINTF (stderr, "Stack now");
for (; bottom <= top; ++bottom)
YYFPRINTF (stderr, " %d", *bottom);
for (; yybottom <= yytop; yybottom++)
{
int yybot = *yybottom;
YYFPRINTF (stderr, " %d", yybot);
}
YYFPRINTF (stderr, "\n");
}
......@@ -936,11 +932,11 @@ yy_reduce_print (yyvsp, yylsp, yyrule, context)
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
fprintf (stderr, " $%d = ", yyi + 1);
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
, &(yylsp[(yyi + 1) - (yynrhs)]) , context);
fprintf (stderr, "\n");
YYFPRINTF (stderr, "\n");
}
}
......@@ -1224,10 +1220,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, context)
break;
}
}
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
......@@ -1246,10 +1240,9 @@ int yyparse ();
/*----------.
| yyparse. |
`----------*/
/*-------------------------.
| yyparse or yypush_parse. |
`-------------------------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
......@@ -1273,88 +1266,97 @@ yyparse (context)
#endif
#endif
{
/* The look-ahead symbol. */
/* The lookahead symbol. */
int yychar;
/* The semantic value of the look-ahead symbol. */
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
/* Number of syntax errors so far. */
int yynerrs;
/* Location data for the look-ahead symbol. */
/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
int yystate;
int yyn;
int yyresult;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* Look-ahead token as an internal (translated) token number. */
int yytoken = 0;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
/* Number of syntax errors so far. */
int yynerrs;
/* Three stacks and their tools:
`yyss': related to states,
`yyvs': related to semantic values,
`yyls': related to locations.
int yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
Refer to the stacks thru separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The stacks and their tools:
`yyss': related to states.
`yyvs': related to semantic values.
`yyls': related to locations.
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss = yyssa;
yytype_int16 *yyssp;
Refer to the stacks thru separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs = yyvsa;
YYSTYPE *yyvsp;
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The location stack. */
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls = yylsa;
YYLTYPE *yylsp;
/* The locations where the error started and ended. */
YYLTYPE yyerror_range[2];
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
/* The location stack. */
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls;
YYLTYPE *yylsp;
/* The locations where the error started and ended. */
YYLTYPE yyerror_range[2];
YYSIZE_T yystacksize = YYINITDEPTH;
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
YYLTYPE yyloc;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;
yyls = yylsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
#if YYLTYPE_IS_TRIVIAL
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = 0;
yylloc.first_column = yylloc.last_column = 1;
#endif
goto yysetstate;
......@@ -1393,6 +1395,7 @@ YYLTYPE yylloc;
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
......@@ -1414,9 +1417,9 @@ YYLTYPE yylloc;
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss);
YYSTACK_RELOCATE (yyvs);
YYSTACK_RELOCATE (yyls);
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
......@@ -1437,6 +1440,9 @@ YYLTYPE yylloc;
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
......@@ -1445,16 +1451,16 @@ YYLTYPE yylloc;
yybackup:
/* Do appropriate processing given the current state. Read a
look-ahead token if we need one and don't already have one. */
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to look-ahead token. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
/* Not known => get a look-ahead token if don't already have one. */
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
......@@ -1486,20 +1492,16 @@ yybackup:
goto yyreduce;
}
if (yyn == YYFINAL)
YYACCEPT;
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the look-ahead token. */
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
/* Discard the shifted token. */
yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
......@@ -1546,78 +1548,78 @@ yyreduce:
pp::TokenVector* out = context->output();
out->insert(out->end(), (yyvsp[(1) - (2)].tlist)->begin(), (yyvsp[(1) - (2)].tlist)->end());
delete (yyvsp[(1) - (2)].tlist);
;}
}
break;
case 9:
{
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[(1) - (6)]).first_line, pp::Macro::kTypeFunc, (yyvsp[(1) - (6)].sval), (yyvsp[(3) - (6)].tlist), (yyvsp[(5) - (6)].tlist));
;}
}
break;
case 11:
{
context->undefineMacro((yyvsp[(2) - (3)].sval));
;}
}
break;
case 12:
{
pushConditionalBlock(context, (yyvsp[(2) - (3)].tlist) ? true : false);
;}
}
break;
case 13:
{
pushConditionalBlock(context, context->isMacroDefined((yyvsp[(2) - (3)].sval)));
;}
}
break;
case 14:
{
pushConditionalBlock(context, !context->isMacroDefined((yyvsp[(2) - (3)].sval)));
;}
}
break;
case 15:
{
;}
}
break;
case 16:
{
;}
}
break;
case 17:
{
popConditionalBlock(context);
;}
}
break;
case 23:
{ (yyval.tlist) = NULL; ;}
{ (yyval.tlist) = NULL; }
break;
case 25:
{ (yyval.tlist) = NULL; ;}
{ (yyval.tlist) = NULL; }
break;
case 26:
......@@ -1625,7 +1627,7 @@ yyreduce:
{
(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:
......@@ -1633,7 +1635,7 @@ yyreduce:
{
(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:
......@@ -1641,7 +1643,7 @@ yyreduce:
{
(yyval.tlist) = new pp::TokenVector;
(yyval.tlist)->push_back((yyvsp[(1) - (1)].tval));
;}
}
break;
case 29:
......@@ -1649,7 +1651,7 @@ yyreduce:
{
(yyval.tlist) = (yyvsp[(1) - (2)].tlist);
(yyval.tlist)->push_back((yyvsp[(2) - (2)].tval));
;}
}
break;
case 30:
......@@ -1657,7 +1659,7 @@ yyreduce:
{
(yyval.tlist) = new pp::TokenVector;
(yyval.tlist)->push_back((yyvsp[(1) - (1)].tval));
;}
}
break;
case 31:
......@@ -1665,171 +1667,170 @@ yyreduce:
{
(yyval.tlist) = (yyvsp[(1) - (2)].tlist);
(yyval.tlist)->push_back((yyvsp[(2) - (2)].tval));
;}
}
break;
case 32:
{
;}
}
break;
case 33:
{
;}
}
break;
case 35:
{
(yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, (yyvsp[(1) - (1)].ival), NULL);
;}
}
break;
case 36:
{
(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, FLOAT_CONSTANT, (yyvsp[(1) - (1)].sval));
;}
}
break;
case 38:
{
(yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, IDENTIFIER, (yyvsp[(1) - (1)].sval));
;}
}
break;
case 39:
{ (yyval.ival) = '['; ;}
{ (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) = ','; ;}
{ (yyval.ival) = ','; }
break;
case 62:
{ (yyval.ival) = '?'; ;}
{ (yyval.ival) = '?'; }
break;
/* Line 1267 of yacc.c. */
default: break;
}
......@@ -1906,7 +1907,7 @@ yyerrlab:
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse look-ahead token after an
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
......@@ -1923,7 +1924,7 @@ yyerrlab:
}
}
/* Else will try to reuse look-ahead token after shifting the error
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
......@@ -1981,14 +1982,11 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
if (yyn == YYFINAL)
YYACCEPT;
*++yyvsp = yylval;
yyerror_range[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
the look-ahead. YYLOC is available though. */
the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc;
......@@ -2013,7 +2011,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
#ifndef yyoverflow
#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
......@@ -2024,7 +2022,7 @@ yyexhaustedlab:
#endif
yyreturn:
if (yychar != YYEOF && yychar != YYEMPTY)
if (yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, &yylloc, context);
/* Do not reclaim the symbols of the rule which action triggered
......
/* A Bison parser, made by GNU Bison 2.3. */
/* A Bison parser, made by GNU Bison 2.4.2. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
......@@ -29,10 +27,11 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
......@@ -60,45 +59,25 @@
IDENTIFIER = 276
};
#endif
/* Tokens. */
#define HASH 258
#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
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
int ival;
std::string* sval;
pp::Token* tval;
pp::TokenVector* tlist;
}
/* Line 1489 of yacc.c. */
YYSTYPE;
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
......@@ -117,3 +96,4 @@ typedef struct YYLTYPE
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment