PageRenderTime 5ms CodeModel.GetById 15ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/parser.y

https://github.com/gitpan/Rinchi-CPlusPlus-Preprocessor
Happy | 1307 lines | 1065 code | 242 blank | 0 comment | 0 complexity | 9b5128bd8f4c613fe76d4762a5600cac MD5 | raw file
   1%{
   2/*
   3 * UUID: db754b9f-f2fd-11dc-b899-00502c05c241
   4 * Author: Brian M. Ames, bames@apk.net
   5 * Copyright: Copyright (C) 2008 by Brian M. Ames
   6 */
   7
   8#include <stdio.h>
   9#include "parser_routines.h"
  10#include "tree.h"
  11#include "lexer.h"
  12#define YYDEBUG 1
  13#define YYERROR_VERBOSE 1
  14//define YYSTYPE int
  15char *getCurrentFilename();
  16void yyerror(char const *s);
  17int yypp_lex (void);
  18
  19%}
  20
  21%no-lines
  22%name-prefix="yypp_"
  23%locations
  24
  25%union {
  26  float fval;
  27  char *sval;
  28  unsigned int uval;
  29  int ival;
  30  long lval;
  31}
  32
  33%token ECS_NULL
  34%token ASC_SOH
  35%token ASC_STX
  36%token ASC_ETX
  37%token ASC_EOT
  38%token ASC_ENQ
  39%token ASC_ACK
  40%token ECS_ALERT
  41%token ECS_BACKSPACE
  42%token BCS_WHTSP_TAB
  43%token BCS_WHTSP_NEWLINE
  44%token BCS_WHTSP_VERTICAL_TAB
  45%token BCS_WHTSP_FORMFEED
  46%token ECS_CARRIAGE_RETURN
  47%token ASC_SHIFT_OUT
  48%token ASC_SHIFT_IN
  49%token ASC_DLE
  50%token ASC_DC1
  51%token ASC_DC2
  52%token ASC_DC3
  53%token ASC_DC4
  54%token ASC_NAK
  55%token ASC_SYN
  56%token ASC_ETB
  57%token ASC_CAN
  58%token ASC_EM
  59%token ASC_SUB
  60%token ASC_ESC
  61%token ASC_IS4
  62%token ASC_IS3
  63%token ASC_IS2
  64%token ASC_IS1
  65%token BCS_WHTSP_SPACE
  66%token BCS_PUNCT_EXCLAMATION
  67%token BCS_PUNCT_QUOTE
  68%token BCS_PUNCT_HASH
  69%token ASC_DOLLAR_SIGN
  70%token BCS_PUNCT_PERCENT
  71%token BCS_PUNCT_AMPERSAND
  72%token BCS_PUNCT_APOSTROPHE
  73%token BCS_PUNCT_OPEN_PARENTHESIS
  74%token BCS_PUNCT_CLOSE_PARENTHESIS
  75%token BCS_PUNCT_ASTERISK
  76%token BCS_PUNCT_PLUS
  77%token BCS_PUNCT_COMMA
  78%token BCS_PUNCT_MINUS
  79%token BCS_PUNCT_PERIOD
  80%token BCS_PUNCT_SLASH
  81%token BCS_DIGIT_0
  82%token BCS_DIGIT_1
  83%token BCS_DIGIT_2
  84%token BCS_DIGIT_3
  85%token BCS_DIGIT_4
  86%token BCS_DIGIT_5
  87%token BCS_DIGIT_6
  88%token BCS_DIGIT_7
  89%token BCS_DIGIT_8
  90%token BCS_DIGIT_9
  91%token BCS_PUNCT_COLON
  92%token BCS_PUNCT_SEMICOLON
  93%token BCS_PUNCT_LESS_THAN
  94%token BCS_PUNCT_EQUAL
  95%token BCS_PUNCT_GREATER_THAN
  96%token BCS_PUNCT_QUESTION
  97%token ASC_AT_SIGN
  98%token BCS_UPPER_A
  99%token BCS_UPPER_B
 100%token BCS_UPPER_C
 101%token BCS_UPPER_D
 102%token BCS_UPPER_E
 103%token BCS_UPPER_F
 104%token BCS_UPPER_G
 105%token BCS_UPPER_H
 106%token BCS_UPPER_I
 107%token BCS_UPPER_J
 108%token BCS_UPPER_K
 109%token BCS_UPPER_L
 110%token BCS_UPPER_M
 111%token BCS_UPPER_N
 112%token BCS_UPPER_O
 113%token BCS_UPPER_P
 114%token BCS_UPPER_Q
 115%token BCS_UPPER_R
 116%token BCS_UPPER_S
 117%token BCS_UPPER_T
 118%token BCS_UPPER_U
 119%token BCS_UPPER_V
 120%token BCS_UPPER_W
 121%token BCS_UPPER_X
 122%token BCS_UPPER_Y
 123%token BCS_UPPER_Z
 124%token BCS_PUNCT_OPEN_BRACKET
 125%token BCS_PUNCT_BACKSLASH
 126%token BCS_PUNCT_CLOSE_BRACKET
 127%token BCS_PUNCT_CARET
 128%token BCS_PUNCT_UNDERSCORE
 129%token BCS_LOWER_A
 130%token BCS_LOWER_B
 131%token BCS_LOWER_C
 132%token BCS_LOWER_D
 133%token BCS_LOWER_E
 134%token BCS_LOWER_F
 135%token BCS_LOWER_G
 136%token BCS_LOWER_H
 137%token BCS_LOWER_I
 138%token BCS_LOWER_J
 139%token BCS_LOWER_K
 140%token BCS_LOWER_L
 141%token BCS_LOWER_M
 142%token BCS_LOWER_N
 143%token BCS_LOWER_O
 144%token BCS_LOWER_P
 145%token BCS_LOWER_Q
 146%token BCS_LOWER_R
 147%token BCS_LOWER_S
 148%token BCS_LOWER_T
 149%token BCS_LOWER_U
 150%token BCS_LOWER_V
 151%token BCS_LOWER_W
 152%token BCS_LOWER_X
 153%token BCS_LOWER_Y
 154%token BCS_LOWER_Z
 155%token BCS_PUNCT_OPEN_BRACE
 156%token BCS_PUNCT_VERTICAL_BAR
 157%token BCS_PUNCT_CLOSE_BRACE
 158%token BCS_PUNCT_TILDE
 159%token ASC_DEL
 160
 161%token ALT_PUNCT_OPEN_BRACE
 162%token ALT_PUNCT_CLOSE_BRACE
 163%token ALT_PUNCT_OPEN_BRACKET
 164%token ALT_PUNCT_CLOSE_BRACKET
 165%token ALT_PUNCT_HASH
 166
 167%token KWD_ASM
 168%token KWD_AUTO
 169%token KWD_BOOL
 170%token KWD_BREAK
 171%token KWD_CASE
 172%token KWD_CATCH
 173%token KWD_CHAR
 174%token KWD_CLASS
 175%token KWD_CONST
 176%token KWD_CONST_CAST
 177%token KWD_CONTINUE
 178%token KWD_DEFAULT
 179%token KWD_DEFINED
 180%token KWD_DELETE
 181%token KWD_DO
 182%token KWD_DOUBLE
 183%token KWD_DYNAMIC_CAST
 184%token KWD_ELSE
 185%token KWD_ENUM
 186%token KWD_EXPLICIT
 187%token KWD_EXPORT
 188%token KWD_EXTERN
 189%token KWD_FALSE
 190%token KWD_FLOAT
 191%token KWD_FOR
 192%token KWD_FRIEND
 193%token KWD_GOTO
 194%token KWD_IF
 195%token KWD_INLINE
 196%token KWD_INT
 197%token KWD_LONG
 198%token KWD_MUTABLE
 199%token KWD_NAMESPACE
 200%token KWD_NEW
 201%token KWD_OPERATOR
 202%token KWD_PRIVATE
 203%token KWD_PROTECTED
 204%token KWD_PUBLIC
 205%token KWD_REGISTER
 206%token KWD_REINTERPRET_CAST
 207%token KWD_RETURN
 208%token KWD_SHORT
 209%token KWD_SIGNED
 210%token KWD_SIZEOF
 211%token KWD_STATIC
 212%token KWD_STATIC_CAST
 213%token KWD_STRUCT
 214%token KWD_SWITCH
 215%token KWD_TEMPLATE
 216%token KWD_THIS
 217%token KWD_THROW
 218%token KWD_TRUE
 219%token KWD_TRY
 220%token KWD_TYPEDEF
 221%token KWD_TYPENAME
 222%token KWD_TYPEID
 223%token KWD_UNION
 224%token KWD_UNSIGNED
 225%token KWD_USING
 226%token KWD_VIRTUAL
 227%token KWD_VOID
 228%token KWD_VOLATILE
 229%token KWD_WCHAR_T
 230%token KWD_WHILE
 231
 232%token PPD_NULL
 233%token PPD_DEFINE
 234%token PPD_ELIF
 235%token PPD_ELSE
 236%token PPD_ENDIF
 237%token PPD_ERROR
 238%token PPD_IF
 239%token PPD_IFDEF
 240%token PPD_IFNDEF
 241%token PPD_INCLUDE
 242%token PPD_LINE
 243%token PPD_PRAGMA
 244%token PPD_UNDEF
 245
 246%token OP_LOGICAL_NOT
 247%token OP_NE
 248%token OP_STRINGIZE
 249%token OP_TOKEN_SPLICE
 250%token OP_MODULO
 251%token ALT_OP_TOKEN_SPLICE
 252%token OP_ASSIGN_MODULO
 253%token OP_BIT_AND
 254%token OP_ADDRESS
 255%token OP_LOGICAL_AND
 256%token OP_ASSIGN_BIT_AND
 257%token OP_DEREFERENCE
 258%token OP_MULTIPLY
 259%token OP_ASSIGN_MULTIPLY
 260%token OP_PLUS
 261%token OP_INCREMENT
 262%token OP_ASSIGN_PLUS
 263%token OP_MINUS
 264%token OP_DECREMENT
 265%token OP_ASSIGN_MINUS
 266%token OP_POINTER_MEMBER
 267%token OP_POINTER_POINTER_TO_MEMBER
 268%token OP_OBJECT_MEMBER
 269%token OP_OBJECT_POINTER_TO_MEMBER
 270%token OP_DIVIDE
 271%token OP_ASSIGN_DIVIDE
 272%token OP_ELSE
 273%token OP_SCOPE_REF
 274%token OP_LT
 275%token OP_SHIFT_LEFT
 276%token OP_ASSIGN_SHIFT_LEFT
 277%token OP_LE
 278%token OP_ASSIGN
 279%token OP_EQ
 280%token OP_GT
 281%token OP_GE
 282%token OP_SHIFT_RIGHT
 283%token OP_ASSIGN_SHIFT_RIGHT
 284%token OP_CONDITIONAL
 285%token OP_BIT_PLUS
 286%token OP_ASSIGN_BIT_PLUS
 287%token OP_BIT_OR
 288%token OP_ASSIGN_BIT_OR
 289%token OP_LOGICAL_OR
 290%token OP_BIT_NOT
 291
 292%token OP_ALT_LOGICAL_AND
 293%token OP_ALT_ASSIGN_BIT_AND
 294%token OP_ALT_BIT_AND
 295%token OP_ALT_BIT_OR
 296%token OP_ALT_BIT_NOT
 297%token OP_ALT_LOGICAL_NOT
 298%token OP_ALT_NE
 299%token OP_ALT_LOGICAL_OR
 300%token OP_ALT_ASSIGN_BIT_OR
 301%token OP_ALT_BIT_PLUS
 302%token OP_ALT_ASSIGN_BIT_PLUS
 303
 304%token INV_ALT_LOGICAL_AND
 305%token INV_ALT_ASSIGN_BIT_AND
 306%token INV_ALT_BIT_AND
 307%token INV_ALT_BIT_OR
 308%token INV_ALT_BIT_NOT
 309%token INV_ALT_LOGICAL_NOT
 310%token INV_ALT_NE
 311%token INV_ALT_LOGICAL_OR
 312%token INV_ALT_ASSIGN_BIT_OR
 313%token INV_ALT_BIT_PLUS
 314%token INV_ALT_ASSIGN_BIT_PLUS
 315
 316%token INV_MFI_LOGICAL_AND
 317%token INV_MFI_ASSIGN_BIT_AND
 318%token INV_MFI_BIT_AND
 319%token INV_MFI_BIT_OR
 320%token INV_MFI_BIT_NOT
 321%token INV_MFI_LOGICAL_NOT
 322%token INV_MFI_NE
 323%token INV_MFI_LOGICAL_OR
 324%token INV_MFI_ASSIGN_BIT_OR
 325%token INV_MFI_BIT_PLUS
 326%token INV_MFI_ASSIGN_BIT_PLUS
 327
 328%token DECL_REFERENCE
 329%token DECL_POINTER
 330%token DECL_VAR_ARGS
 331
 332%token SYSTEM_HEADER_STRING
 333%token HEADER_STRING
 334%token IDENTIFIER
 335%token NON_REPLACEABLE_IDENTIFIER
 336%token MACRO_FUNCTION_IDENTIFIER
 337%token MACRO_OBJECT_IDENTIFIER
 338%token REPLACED_IDENTIFIER
 339%token PP_NUMBER
 340%token CHARACTER_LITERAL
 341%token L_CHARACTER_LITERAL
 342%token STRING_LITERAL
 343%token L_STRING_LITERAL
 344%token <lval> INTEGER_LITERAL
 345%token <lval> OCTAL_LITERAL
 346%token <lval> DECIMAL_LITERAL
 347%token <lval> HEXADECIMAL_LITERAL
 348%token FLOATING_LITERAL
 349
 350%token <sval> UNIVERSAL_CHARACTER_NAME
 351%token <sval> USE_ON_CODE
 352
 353%token PUNC_INITIALIZE
 354%token PUNC_SYNONYM
 355%token DONT_CARE
 356
 357%token <sval> RESERVED_WORD
 358%token <sval> ACCESS_SPECIFIER
 359%token <ival> BOOLEAN_LITERAL
 360%token <sval> CV_QUALIFIER
 361%token <sval> INTRINSIC_TYPE
 362%token <sval> FUNCTION_SPECIFIER
 363%token <sval> STORAGE_CLASS_SPECIFIER
 364
 365
 366%token <sval> USER_TOKEN
 367%token <sval> SYMBOL
 368%token <sval> COMMENT
 369%token <sval> BLOCK_COMMENT
 370%token END_OF_STATEMENT
 371%token BLOCK_OPEN
 372%token BLOCK_CLOSE
 373%token LIST_OPEN
 374%token LIST_SEPARATOR
 375%token LIST_CLOSE
 376
 377%type <lval> pp_constant_expression
 378%type <lval> pp_expression
 379%type <lval> pp_conditional_expression
 380%type <lval> pp_logical_or_expression
 381%type <lval> pp_logical_and_expression
 382%type <lval> pp_inclusive_or_expression
 383%type <lval> pp_exclusive_or_expression
 384%type <lval> pp_and_expression
 385%type <lval> pp_equality_expression
 386%type <lval> pp_relational_expression
 387%type <lval> pp_shift_expression
 388%type <lval> pp_additive_expression
 389%type <lval> pp_multiplicative_expression
 390%type <lval> pp_unary_expression
 391%type <lval> pp_primary_expression
 392%type <lval> pp_boolean_literal
 393%type <lval> pp_integer_literal
 394%type <lval> pp_octal_literal
 395%type <lval> pp_decimal_literal
 396%type <lval> pp_hexadecimal_literal
 397
 398%%
 399
 400preprocessing_file: { handle_file_begin(preprocessing_file_index); } group_part_seq_opt {handle_file_end(preprocessing_file_index); } 
 401  ;
 402
 403group_part_seq_opt: /* empty */
 404  | group_part_seq
 405  ;
 406
 407group_part_seq: group_part
 408  | group_part_seq group_part
 409  ;
 410
 411group_part: { /* handle_token(group_part_index); */ } preprocessing_token_seq_opt new_line 
 412  | if_section
 413  | control_line
 414  ;
 415
 416if_section: if_group elif_group_seq_opt else_group_opt endif_line 
 417  ;
 418
 419if_open: PPD_IF pp_constant_expression { handle_if_open(PPD_IF_INDEX, $2); } 
 420  |  PPD_IF string_literal { handle_if_open(PPD_IF_INDEX, 0); }
 421  ;
 422
 423ifdef_open: PPD_IFDEF 
 424  ;
 425
 426ifndef_open: PPD_IFNDEF 
 427  ;
 428
 429ifdef_identifier: IDENTIFIER { handle_ifdef_open(PPD_IFDEF_INDEX); } 
 430  ;
 431
 432ifndef_identifier: IDENTIFIER { handle_ifndef_open(PPD_IFNDEF_INDEX); } 
 433  ;
 434
 435if_group: if_open new_line group_part_seq_opt
 436  | ifdef_open ifdef_identifier new_line group_part_seq_opt
 437  | ifndef_open ifndef_identifier new_line group_part_seq_opt
 438  | ifdef_open invalid_ifdef_identifier new_line group_part_seq_opt
 439  | ifndef_open invalid_ifndef_identifier new_line group_part_seq_opt
 440  ;
 441
 442elif_group_seq_opt: /* empty */
 443  | elif_group_seq
 444  ;
 445
 446elif_group_seq: elif_group
 447  | elif_group_seq elif_group
 448  ;
 449
 450elif_group_open: PPD_ELIF pp_constant_expression { handle_elif_open(PPD_ELIF_INDEX, $2); } 
 451  ;
 452
 453elif_group: elif_group_open new_line group_part_seq_opt { handle_elif_close(PPD_ELIF_INDEX); }
 454  ;
 455
 456else_group_opt: /* empty */
 457  | else_group
 458  ;
 459
 460else_open: PPD_ELSE { handle_else_open(PPD_ELSE_INDEX); }
 461  ;
 462
 463else_group: else_open new_line group_part_seq_opt
 464  ;
 465
 466endif_open: PPD_ENDIF { handle_endif(PPD_ENDIF_INDEX); }
 467  ;
 468
 469endif_line: endif_open new_line
 470  ;
 471
 472control_line: PPD_INCLUDE preprocessing_token_seq new_line { handle_include(PPD_INCLUDE_INDEX); };
 473  | PPD_DEFINE mo_identifier replacement_list new_line { handle_macro_close (object_macro_index); }
 474  | PPD_DEFINE mf_identifier mf_args replacement_list new_line  { handle_macro_close (function_macro_index); }
 475  | PPD_UNDEF mu_identifier new_line
 476  | PPD_LINE { handle_token_open (PPD_LINE_INDEX); } preprocessing_token_seq new_line { handle_token_close (PPD_LINE_INDEX); }
 477  | PPD_ERROR { handle_token_open (PPD_ERROR_INDEX); } preprocessing_token_seq_opt new_line { handle_token_close (PPD_ERROR_INDEX); }
 478  | PPD_PRAGMA { handle_token_open (PPD_PRAGMA_INDEX); } preprocessing_token_seq_opt new_line { handle_token_close (PPD_PRAGMA_INDEX); }
 479  | PPD_NULL new_line
 480  ;
 481
 482mf_args: BCS_PUNCT_OPEN_PARENTHESIS clean_identifier_list_opt BCS_PUNCT_CLOSE_PARENTHESIS
 483  ;
 484
 485replacement_list: { handle_replacement_open (replacement_list_index); } preprocessing_token_seq_opt { handle_replacement_close (replacement_list_index); }
 486  ;
 487
 488preprocessing_token_seq_opt: /* empty */
 489  | preprocessing_token_seq
 490  ;
 491
 492preprocessing_token_seq: preprocessing_token
 493  | preprocessing_token_seq preprocessing_token
 494  ;
 495
 496preprocessing_token: header_name
 497  | identifier
 498  | pp_number
 499  | character_literal
 500  | string_literal
 501  | preprocessing_op_or_punc
 502  | BCS_PUNCT_BACKSLASH { handle_token(BCS_PUNCT_BACKSLASH_INDEX); }
 503  ;
 504
 505header_name: SYSTEM_HEADER_STRING { handle_header_name(SYSTEM_HEADER_STRING_INDEX); }
 506  | HEADER_STRING { handle_header_name(HEADER_STRING_INDEX); }
 507  ;
 508
 509clean_identifier_list_opt: /* empty */
 510  | clean_identifier_list
 511  ;
 512
 513clean_identifier_list: identifier
 514  | clean_identifier_list BCS_PUNCT_COMMA identifier
 515  ;
 516
 517identifier: IDENTIFIER   { handle_identifier(IDENTIFIER_INDEX); }
 518  | NON_REPLACEABLE_IDENTIFIER { handle_nonrepl_identifier(IDENTIFIER_INDEX); }
 519  | REPLACED_IDENTIFIER { handle_identifier(REPLACED_IDENTIFIER_INDEX); }
 520  | key_word
 521  ;
 522
 523pp_identifier: IDENTIFIER
 524  | NON_REPLACEABLE_IDENTIFIER
 525  ;
 526
 527pp_replaced_identifier_seq_opt: /* empty */
 528  | pp_replaced_identifier_seq
 529  ;
 530
 531pp_replaced_identifier_seq: pp_replaced_identifier
 532  | pp_replaced_identifier_seq pp_replaced_identifier
 533  ;
 534
 535pp_replaced_identifier: REPLACED_IDENTIFIER
 536  ;
 537
 538key_word: kwd_asm
 539  | kwd_auto
 540  | kwd_bool
 541  | kwd_break
 542  | kwd_case
 543  | kwd_catch
 544  | kwd_char
 545  | kwd_class
 546  | kwd_const
 547  | kwd_const_cast
 548  | kwd_continue
 549  | kwd_default
 550  | kwd_do
 551  | kwd_double
 552  | kwd_dynamic_cast
 553  | kwd_else
 554  | kwd_enum
 555  | kwd_explicit
 556  | kwd_export
 557  | kwd_extern
 558  | kwd_float
 559  | kwd_for
 560  | kwd_friend
 561  | kwd_goto
 562  | kwd_if
 563  | kwd_inline
 564  | kwd_int
 565  | kwd_long
 566  | kwd_mutable
 567  | kwd_namespace
 568  | kwd_operator
 569  | kwd_private
 570  | kwd_protected
 571  | kwd_public
 572  | kwd_register
 573  | kwd_reinterpret_cast
 574  | kwd_return
 575  | kwd_short
 576  | kwd_signed
 577  | kwd_static
 578  | kwd_static_cast
 579  | kwd_struct
 580  | kwd_switch
 581  | kwd_template
 582  | kwd_this
 583  | kwd_throw
 584  | kwd_try
 585  | kwd_typedef
 586  | kwd_typename
 587  | kwd_typeid
 588  | kwd_union
 589  | kwd_unsigned
 590  | kwd_using
 591  | kwd_virtual
 592  | kwd_void
 593  | kwd_volatile
 594  | kwd_wchar_t
 595  | kwd_while
 596  ;
 597
 598pp_number: PP_NUMBER { handle_pp_number(); }
 599  | integer_literal
 600  | floating_literal
 601  ;
 602
 603integer_literal: INTEGER_LITERAL { handle_string_token(INTEGER_LITERAL_INDEX); }
 604  | octal_literal
 605  | decimal_literal
 606  | hexadecimal_literal
 607  ;
 608
 609octal_literal: OCTAL_LITERAL { handle_string_token(OCTAL_LITERAL_INDEX); }
 610  ;
 611
 612decimal_literal: DECIMAL_LITERAL { handle_string_token(DECIMAL_LITERAL_INDEX); }
 613  ;
 614
 615hexadecimal_literal: HEXADECIMAL_LITERAL { handle_string_token(HEXADECIMAL_LITERAL_INDEX); }
 616  ;
 617
 618pp_integer_literal: INTEGER_LITERAL { $$ = $1; }
 619  | pp_octal_literal { $$ = $1; }
 620  | pp_decimal_literal { $$ = $1; }
 621  | pp_hexadecimal_literal { $$ = $1; }
 622  ;
 623
 624pp_octal_literal: OCTAL_LITERAL { $$ = $1; }
 625  ;
 626
 627pp_decimal_literal: DECIMAL_LITERAL { $$ = $1; }
 628  ;
 629
 630pp_hexadecimal_literal: HEXADECIMAL_LITERAL { $$ = $1; }
 631  ;
 632
 633character_literal: CHARACTER_LITERAL { handle_string_token(CHARACTER_LITERAL_INDEX); }
 634  | L_CHARACTER_LITERAL { handle_string_token(L_CHARACTER_LITERAL_INDEX); }
 635  ;
 636
 637string_literal: STRING_LITERAL { handle_string_token(STRING_LITERAL_INDEX); }
 638  | L_STRING_LITERAL { handle_string_token(L_STRING_LITERAL_INDEX); }
 639  ;
 640
 641floating_literal: FLOATING_LITERAL { handle_string_token(FLOATING_LITERAL_INDEX); }
 642  ;
 643
 644pp_boolean_literal: KWD_FALSE { $$ = 0; }
 645  | KWD_TRUE { $$ = 1; }
 646  | BOOLEAN_LITERAL { $$ = $1; }
 647  ;
 648
 649preprocessing_op_or_punc: bcs_exclamation
 650  | bcs_hash
 651  | op_stringize
 652  | bcs_percent
 653  | bcs_ampersand
 654  | bcs_open_parenthesis
 655  | bcs_close_parenthesis
 656  | bcs_asterisk
 657  | bcs_plus
 658  | bcs_comma
 659  | bcs_minus
 660  | bcs_period
 661  | bcs_slash
 662  | bcs_colon
 663  | bcs_semicolon
 664  | bcs_less_than
 665  | bcs_equal
 666  | bcs_greater_than
 667  | bcs_question
 668  | bcs_open_bracket
 669  | bcs_caret
 670  | bcs_close_bracket
 671  | bcs_open_brace
 672  | bcs_vertical_bar
 673  | bcs_close_brace
 674  | bcs_tilde
 675  | ne
 676  | token_splice
 677  | assign_modulo
 678  | truth_and
 679  | assign_bit_and
 680  | assign_multiply
 681  | increment
 682  | assign_plus
 683  | decrement
 684  | assign_minus
 685  | pointer_member
 686  | pointer_ptm
 687  | object_ptm
 688  | assign_divide
 689  | scope_ref
 690  | shift_left
 691  | assign_shift_left
 692  | le
 693  | eq
 694  | ge
 695  | shift_right
 696  | assign_shift_right
 697  | assign_bit_xor
 698  | assign_bit_or
 699  | truth_or
 700  | var_args
 701  | kwd_new
 702  | kwd_delete
 703  | alt_bit_and
 704  | alt_bit_or
 705  | alt_bit_not
 706  | alt_truth_not
 707  | alt_bit_xor
 708  | kwd_sizeof
 709  ;
 710
 711pp_constant_expression: pp_expression {$$ = $1;}
 712  ;
 713
 714pp_expression: pp_conditional_expression {$$ = $1;}
 715  | pp_expression pp_comma_op pp_conditional_expression {$$ = $3;}
 716  ;
 717
 718pp_conditional_expression: pp_logical_or_expression {$$ = $1;}
 719  | pp_logical_or_expression pp_conditional_operator pp_expression pp_conditional_separator pp_conditional_expression {$$ = ($1) ? $3 : $5;}
 720  ;
 721
 722pp_logical_or_expression: pp_logical_and_expression {$$ = $1;}
 723  | pp_logical_or_expression pp_truth_or pp_logical_and_expression {$$ = $1 || $3;}
 724  ;
 725
 726pp_logical_and_expression: pp_inclusive_or_expression {$$ = $1;}
 727  | pp_logical_and_expression pp_truth_and pp_inclusive_or_expression {$$ = $1 && $3;}
 728  ;
 729
 730pp_inclusive_or_expression: pp_exclusive_or_expression {$$ = $1;}
 731  | pp_inclusive_or_expression pp_bit_or pp_exclusive_or_expression  {$$ = $1 | $3;}
 732  ;
 733
 734pp_exclusive_or_expression: pp_and_expression {$$ = $1;}
 735  | pp_exclusive_or_expression pp_bit_xor pp_and_expression {$$ = $1 ^ $3;}
 736  ;
 737
 738pp_and_expression: pp_equality_expression {$$ = $1;}
 739  | pp_and_expression pp_bit_and pp_equality_expression {$$ = $1 & $3;}
 740  ;
 741
 742pp_equality_expression: pp_relational_expression {$$ = $1;}
 743  | pp_equality_expression pp_eq pp_relational_expression {$$ = ($1 == $3);}
 744  | pp_equality_expression pp_ne pp_relational_expression {$$ = ($1 != $3);}
 745  ;
 746
 747pp_relational_expression: pp_shift_expression {$$ = $1;}
 748  | pp_relational_expression pp_lt pp_shift_expression {$$ = ($1 < $3);}
 749  | pp_relational_expression pp_gt pp_shift_expression {$$ = ($1 > $3);}
 750  | pp_relational_expression pp_le pp_shift_expression {$$ = ($1 <= $3);}
 751  | pp_relational_expression pp_ge pp_shift_expression {$$ = ($1 >= $3);}
 752  ;
 753
 754pp_shift_expression: pp_additive_expression {$$ = $1;}
 755  | pp_shift_expression pp_shift_left pp_additive_expression {$$ = ($1 << $3);}
 756  | pp_shift_expression pp_shift_right pp_additive_expression {$$ = ($1 >> $3);}
 757  ;
 758
 759pp_additive_expression: pp_multiplicative_expression {$$ = $1;}
 760  | pp_additive_expression pp_plus pp_multiplicative_expression {$$ = ($1 + $3);}
 761  | pp_additive_expression pp_minus pp_multiplicative_expression {$$ = ($1 - $3);}
 762  ;
 763
 764pp_multiplicative_expression: pp_unary_expression {$$ = $1;}
 765  | pp_multiplicative_expression pp_multiply pp_unary_expression {$$ = ($1 * $3);}
 766  | pp_multiplicative_expression pp_divide pp_unary_expression {$$ = ($1 / $3);}
 767  | pp_multiplicative_expression pp_modulo pp_unary_expression {$$ = ($1 % $3);}
 768  ;
 769
 770pp_unary_expression: pp_replaced_identifier_seq_opt pp_primary_expression {$$ = $2;}
 771  | pp_unary_plus pp_unary_expression {$$ = $2;}
 772  | pp_unary_minus pp_unary_expression {$$ = -$2;}
 773  | pp_truth_not pp_unary_expression {$$ = !$2;}
 774  | pp_bit_not pp_unary_expression {$$ = ~$2;}
 775  ;
 776
 777pp_primary_expression: pp_boolean_literal {$$ = $1;}
 778  | pp_integer_literal {$$ = $1;}
 779  | BCS_PUNCT_OPEN_PARENTHESIS pp_expression BCS_PUNCT_CLOSE_PARENTHESIS {$$ = $2;}
 780  | pp_identifier {$$ = 0;}
 781  ;
 782
 783kwd_asm:               KWD_ASM              { handle_token(KWD_ASM_INDEX); }
 784  ;
 785
 786kwd_auto:              KWD_AUTO             { handle_token(KWD_AUTO_INDEX); }
 787  ;
 788
 789kwd_bool:              KWD_BOOL             { handle_token(KWD_BOOL_INDEX); }
 790  ;
 791
 792kwd_break:             KWD_BREAK            { handle_token(KWD_BREAK_INDEX); }
 793  ;
 794
 795kwd_case:              KWD_CASE             { handle_token(KWD_CASE_INDEX); }
 796  ;
 797
 798kwd_catch:             KWD_CATCH            { handle_token(KWD_CATCH_INDEX); }
 799  ;
 800
 801kwd_char:              KWD_CHAR             { handle_token(KWD_CHAR_INDEX); }
 802  ;
 803
 804kwd_class:             KWD_CLASS            { handle_token(KWD_CLASS_INDEX); }
 805  ;
 806
 807kwd_const:             KWD_CONST            { handle_token(KWD_CONST_INDEX); }
 808  ;
 809
 810kwd_const_cast:        KWD_CONST_CAST       { handle_token(KWD_CONST_CAST_INDEX); }
 811  ;
 812
 813kwd_continue:          KWD_CONTINUE         { handle_token(KWD_CONTINUE_INDEX); }
 814  ;
 815
 816kwd_default:           KWD_DEFAULT          { handle_token(KWD_DEFAULT_INDEX); }
 817  ;
 818
 819kwd_delete:            KWD_DELETE           { handle_token(KWD_DELETE_INDEX); }
 820  ;
 821
 822kwd_do:                KWD_DO               { handle_token(KWD_DO_INDEX); }
 823  ;
 824
 825kwd_double:            KWD_DOUBLE           { handle_token(KWD_DOUBLE_INDEX); }
 826  ;
 827
 828kwd_dynamic_cast:      KWD_DYNAMIC_CAST     { handle_token(KWD_DYNAMIC_CAST_INDEX); }
 829  ;
 830
 831kwd_else:              KWD_ELSE             { handle_token(KWD_ELSE_INDEX); }
 832  ;
 833
 834kwd_enum:              KWD_ENUM             { handle_token(KWD_ENUM_INDEX); }
 835  ;
 836
 837kwd_explicit:          KWD_EXPLICIT         { handle_token(KWD_EXPLICIT_INDEX); }
 838  ;
 839
 840kwd_export:            KWD_EXPORT           { handle_token(KWD_EXPORT_INDEX); }
 841  ;
 842
 843kwd_extern:            KWD_EXTERN           { handle_token(KWD_EXTERN_INDEX); }
 844  ;
 845
 846kwd_float:             KWD_FLOAT            { handle_token(KWD_FLOAT_INDEX); }
 847  ;
 848
 849kwd_for:               KWD_FOR              { handle_token(KWD_FOR_INDEX); }
 850  ;
 851
 852kwd_friend:            KWD_FRIEND           { handle_token(KWD_FRIEND_INDEX); }
 853  ;
 854
 855kwd_goto:              KWD_GOTO             { handle_token(KWD_GOTO_INDEX); }
 856  ;
 857
 858kwd_if:                KWD_IF               { handle_token(KWD_IF_INDEX); }
 859  ;
 860
 861kwd_inline:            KWD_INLINE           { handle_token(KWD_INLINE_INDEX); }
 862  ;
 863
 864kwd_int:               KWD_INT              { handle_token(KWD_INT_INDEX); }
 865  ;
 866
 867kwd_long:              KWD_LONG             { handle_token(KWD_LONG_INDEX); }
 868  ;
 869
 870kwd_mutable:           KWD_MUTABLE          { handle_token(KWD_MUTABLE_INDEX); }
 871  ;
 872
 873kwd_namespace:         KWD_NAMESPACE        { handle_token(KWD_NAMESPACE_INDEX); }
 874  ;
 875
 876kwd_new:               KWD_NEW              { handle_token(KWD_NEW_INDEX); }
 877  ;
 878
 879kwd_operator:          KWD_OPERATOR         { handle_token(KWD_OPERATOR_INDEX); }
 880  ;
 881
 882kwd_private:           KWD_PRIVATE          { handle_token(KWD_PRIVATE_INDEX); }
 883  ;
 884
 885kwd_protected:         KWD_PROTECTED        { handle_token(KWD_PROTECTED_INDEX); }
 886  ;
 887
 888kwd_public:            KWD_PUBLIC           { handle_token(KWD_PUBLIC_INDEX); }
 889  ;
 890
 891kwd_register:          KWD_REGISTER         { handle_token(KWD_REGISTER_INDEX); }
 892  ;
 893
 894kwd_reinterpret_cast:  KWD_REINTERPRET_CAST { handle_token(KWD_REINTERPRET_CAST_INDEX); }
 895  ;
 896
 897kwd_return:            KWD_RETURN           { handle_token(KWD_RETURN_INDEX); }
 898  ;
 899
 900kwd_short:             KWD_SHORT            { handle_token(KWD_SHORT_INDEX); }
 901  ;
 902
 903kwd_signed:            KWD_SIGNED           { handle_token(KWD_SIGNED_INDEX); }
 904  ;
 905
 906kwd_sizeof:            KWD_SIZEOF           { handle_token(KWD_SIZEOF_INDEX); }
 907  ;
 908
 909kwd_static:            KWD_STATIC           { handle_token(KWD_STATIC_INDEX); }
 910  ;
 911
 912kwd_static_cast:       KWD_STATIC_CAST      { handle_token(KWD_STATIC_CAST_INDEX); }
 913  ;
 914
 915kwd_struct:            KWD_STRUCT           { handle_token(KWD_STRUCT_INDEX); }
 916  ;
 917
 918kwd_switch:            KWD_SWITCH           { handle_token(KWD_SWITCH_INDEX); }
 919  ;
 920
 921kwd_template:          KWD_TEMPLATE         { handle_token(KWD_TEMPLATE_INDEX); }
 922  ;
 923
 924kwd_this:              KWD_THIS             { handle_token(KWD_THIS_INDEX); }
 925  ;
 926
 927kwd_throw:             KWD_THROW            { handle_token(KWD_THROW_INDEX); }
 928  ;
 929
 930kwd_try:               KWD_TRY              { handle_token(KWD_TRY_INDEX); }
 931  ;
 932
 933kwd_typedef:           KWD_TYPEDEF          { handle_token(KWD_TYPEDEF_INDEX); }
 934  ;
 935
 936kwd_typename:          KWD_TYPENAME         { handle_token(KWD_TYPENAME_INDEX); }
 937  ;
 938
 939kwd_typeid:            KWD_TYPEID           { handle_token(KWD_TYPEID_INDEX); }
 940  ;
 941
 942kwd_union:             KWD_UNION            { handle_token(KWD_UNION_INDEX); }
 943  ;
 944
 945kwd_unsigned:          KWD_UNSIGNED         { handle_token(KWD_UNSIGNED_INDEX); }
 946  ;
 947
 948kwd_using:             KWD_USING            { handle_token(KWD_USING_INDEX); }
 949  ;
 950
 951kwd_virtual:           KWD_VIRTUAL          { handle_token(KWD_VIRTUAL_INDEX); }
 952  ;
 953
 954kwd_void:              KWD_VOID             { handle_token(KWD_VOID_INDEX); }
 955  ;
 956
 957kwd_volatile:          KWD_VOLATILE         { handle_token(KWD_VOLATILE_INDEX); }
 958  ;
 959
 960kwd_wchar_t:           KWD_WCHAR_T          { handle_token(KWD_WCHAR_T_INDEX); }
 961  ;
 962
 963kwd_while:             KWD_WHILE            { handle_token(KWD_WHILE_INDEX); }
 964  ;
 965
 966new_line: BCS_WHTSP_NEWLINE
 967  ;
 968
 969bcs_hash: BCS_PUNCT_HASH { handle_token(BCS_PUNCT_HASH_INDEX); }
 970  | ALT_PUNCT_HASH { handle_token(ALT_PUNCT_HASH_INDEX); }
 971  ;
 972
 973op_stringize: OP_STRINGIZE { handle_token(OP_STRINGIZE_INDEX); }
 974  ;
 975
 976token_splice: OP_TOKEN_SPLICE { handle_token(OP_TOKEN_SPLICE_INDEX); }
 977  | ALT_OP_TOKEN_SPLICE { handle_token(ALT_OP_TOKEN_SPLICE_INDEX); }
 978  ;
 979
 980mf_identifier: MACRO_FUNCTION_IDENTIFIER { handle_macro_open(function_macro_index /*MACRO_FUNCTION_IDENTIFIER_INDEX*/); }
 981  | INV_MFI_LOGICAL_AND  { handle_invalid_macro_id(OP_ALT_LOGICAL_AND_INDEX); }
 982  | INV_MFI_ASSIGN_BIT_AND  { handle_invalid_macro_id(OP_ALT_ASSIGN_BIT_AND_INDEX); }
 983  | INV_MFI_BIT_AND  { handle_invalid_macro_id(OP_ALT_BIT_AND_INDEX); }
 984  | INV_MFI_BIT_OR  { handle_invalid_macro_id(OP_ALT_BIT_OR_INDEX); }
 985  | INV_MFI_BIT_NOT  { handle_invalid_macro_id(OP_ALT_BIT_NOT_INDEX); }
 986  | INV_MFI_LOGICAL_NOT  { handle_invalid_macro_id(OP_ALT_LOGICAL_NOT_INDEX); }
 987  | INV_MFI_NE  { handle_invalid_macro_id(OP_ALT_NE_INDEX); }
 988  | INV_MFI_LOGICAL_OR  { handle_invalid_macro_id(OP_ALT_LOGICAL_OR_INDEX); }
 989  | INV_MFI_ASSIGN_BIT_OR  { handle_invalid_macro_id(OP_ALT_ASSIGN_BIT_OR_INDEX); }
 990  | INV_MFI_BIT_PLUS  { handle_invalid_macro_id(OP_ALT_BIT_PLUS_INDEX); }
 991  | INV_MFI_ASSIGN_BIT_PLUS  { handle_invalid_macro_id(OP_ALT_ASSIGN_BIT_PLUS_INDEX); }
 992  ;
 993
 994mo_identifier: MACRO_OBJECT_IDENTIFIER { handle_macro_open(object_macro_index/*MACRO_OBJECT_IDENTIFIER_INDEX*/); }
 995  | invalid_macro_identifier
 996  ;
 997
 998mu_identifier: IDENTIFIER { handle_macro_undef(PPD_UNDEF_INDEX); }
 999  | invalid_macro_identifier { pop(); }
1000  ;
1001
1002invalid_ifdef_identifier: invalid_macro_identifier
1003  ;
1004
1005invalid_ifndef_identifier: invalid_macro_identifier
1006  ;
1007
1008invalid_macro_identifier: INV_ALT_LOGICAL_AND  { handle_invalid_macro_id(OP_ALT_LOGICAL_AND_INDEX); }
1009  | INV_ALT_ASSIGN_BIT_AND  { handle_invalid_macro_id(OP_ALT_ASSIGN_BIT_AND_INDEX); }
1010  | INV_ALT_BIT_AND  { handle_invalid_macro_id(OP_ALT_BIT_AND_INDEX); }
1011  | INV_ALT_BIT_OR  { handle_invalid_macro_id(OP_ALT_BIT_OR_INDEX); }
1012  | INV_ALT_BIT_NOT  { handle_invalid_macro_id(OP_ALT_BIT_NOT_INDEX); }
1013  | INV_ALT_LOGICAL_NOT  { handle_invalid_macro_id(OP_ALT_LOGICAL_NOT_INDEX); }
1014  | INV_ALT_NE  { handle_invalid_macro_id(OP_ALT_NE_INDEX); }
1015  | INV_ALT_LOGICAL_OR  { handle_invalid_macro_id(OP_ALT_LOGICAL_OR_INDEX); }
1016  | INV_ALT_ASSIGN_BIT_OR  { handle_invalid_macro_id(OP_ALT_ASSIGN_BIT_OR_INDEX); }
1017  | INV_ALT_BIT_PLUS  { handle_invalid_macro_id(OP_ALT_BIT_PLUS_INDEX); }
1018  | INV_ALT_ASSIGN_BIT_PLUS  { handle_invalid_macro_id(OP_ALT_ASSIGN_BIT_PLUS_INDEX); }
1019  ;
1020
1021bcs_exclamation: BCS_PUNCT_EXCLAMATION { handle_token(OP_LOGICAL_NOT_INDEX); }
1022  ;
1023
1024alt_truth_not: OP_ALT_LOGICAL_NOT { handle_token(OP_ALT_LOGICAL_NOT_INDEX); }
1025  ;
1026
1027pp_truth_not: BCS_PUNCT_EXCLAMATION
1028  | OP_ALT_LOGICAL_NOT
1029  ;
1030
1031ne: OP_NE { handle_token(OP_NE_INDEX); }
1032  | OP_ALT_NE { handle_token(OP_ALT_NE_INDEX); }
1033  ;
1034
1035pp_ne: OP_NE
1036  | OP_ALT_NE
1037  ;
1038
1039bcs_percent: modulo
1040  ;
1041
1042modulo: BCS_PUNCT_PERCENT { handle_token(OP_MODULO_INDEX); }
1043  ;
1044
1045pp_modulo: BCS_PUNCT_PERCENT
1046  ;
1047
1048assign_modulo: OP_ASSIGN_MODULO  { handle_token(OP_ASSIGN_MODULO_INDEX); }
1049  ;
1050
1051bcs_ampersand: BCS_PUNCT_AMPERSAND { handle_token(BCS_PUNCT_AMPERSAND_INDEX); }
1052  ;
1053
1054alt_bit_and:  OP_ALT_BIT_AND { handle_token(OP_ALT_BIT_AND_INDEX); }
1055  ;
1056
1057pp_bit_and: BCS_PUNCT_AMPERSAND
1058  |  OP_ALT_BIT_AND
1059  ;
1060
1061truth_and: OP_LOGICAL_AND { handle_token(OP_LOGICAL_AND_INDEX); }
1062  |  OP_ALT_LOGICAL_AND { handle_token(OP_ALT_LOGICAL_AND_INDEX); }
1063  ;
1064
1065pp_truth_and: OP_LOGICAL_AND
1066  |  OP_ALT_LOGICAL_AND
1067  ;
1068
1069assign_bit_and: OP_ASSIGN_BIT_AND { handle_token(OP_ASSIGN_BIT_AND_INDEX); }
1070  |  OP_ALT_ASSIGN_BIT_AND { handle_token(OP_ALT_ASSIGN_BIT_AND_INDEX); }
1071  ;
1072
1073bcs_open_parenthesis: BCS_PUNCT_OPEN_PARENTHESIS { handle_token_open(BCS_PUNCT_OPEN_PARENTHESIS_INDEX); }
1074  ;
1075
1076bcs_close_parenthesis: BCS_PUNCT_CLOSE_PARENTHESIS { handle_token_close(BCS_PUNCT_CLOSE_PARENTHESIS_INDEX); }
1077  ;
1078
1079bcs_asterisk: BCS_PUNCT_ASTERISK { handle_token(BCS_PUNCT_ASTERISK_INDEX); }
1080  ;
1081
1082pp_multiply: BCS_PUNCT_ASTERISK
1083  ;
1084
1085assign_multiply: OP_ASSIGN_MULTIPLY  { handle_token(OP_ASSIGN_MULTIPLY_INDEX); }
1086  ;
1087
1088bcs_plus: BCS_PUNCT_PLUS { handle_token(BCS_PUNCT_PLUS_INDEX); }
1089  ;
1090
1091pp_plus: BCS_PUNCT_PLUS
1092  ;
1093
1094pp_unary_plus: BCS_PUNCT_PLUS
1095  ;
1096
1097increment: OP_INCREMENT { handle_token(OP_INCREMENT_INDEX); }
1098  ;
1099
1100assign_plus: OP_ASSIGN_PLUS { handle_token(OP_ASSIGN_PLUS_INDEX); }
1101  ;
1102
1103bcs_comma: BCS_PUNCT_COMMA { handle_token(BCS_PUNCT_COMMA_INDEX); }
1104  ;
1105
1106pp_comma_op: BCS_PUNCT_COMMA
1107  ;
1108
1109bcs_minus: BCS_PUNCT_MINUS { handle_token(BCS_PUNCT_MINUS_INDEX); }
1110  ;
1111
1112pp_minus: BCS_PUNCT_MINUS
1113  ;
1114
1115pp_unary_minus: BCS_PUNCT_MINUS
1116  ;
1117
1118decrement: OP_DECREMENT { handle_token(OP_DECREMENT_INDEX); }
1119  ;
1120
1121assign_minus: OP_ASSIGN_MINUS { handle_token(OP_ASSIGN_MINUS_INDEX); }
1122  ;
1123
1124pointer_member: OP_POINTER_MEMBER { handle_token(OP_POINTER_MEMBER_INDEX); }
1125  ;
1126
1127pointer_ptm: OP_POINTER_POINTER_TO_MEMBER { handle_token(OP_POINTER_POINTER_TO_MEMBER_INDEX); }
1128  ;
1129
1130bcs_period: BCS_PUNCT_PERIOD { handle_token(BCS_PUNCT_PERIOD_INDEX); }
1131  ;
1132
1133var_args: DECL_VAR_ARGS { handle_token(DECL_VAR_ARGS_INDEX); }
1134  ;
1135
1136object_ptm: OP_OBJECT_POINTER_TO_MEMBER  { handle_token(OP_OBJECT_POINTER_TO_MEMBER_INDEX); }
1137  ;
1138
1139bcs_slash: divide
1140  ;
1141
1142divide: BCS_PUNCT_SLASH { handle_token(OP_DIVIDE_INDEX); }
1143  ;
1144
1145pp_divide: BCS_PUNCT_SLASH
1146  ;
1147
1148assign_divide: OP_ASSIGN_DIVIDE { handle_token(OP_ASSIGN_DIVIDE_INDEX); }
1149  ;
1150
1151bcs_colon: BCS_PUNCT_COLON { handle_token(BCS_PUNCT_COLON_INDEX); }
1152  ;
1153
1154pp_conditional_separator: BCS_PUNCT_COLON
1155  ;
1156
1157scope_ref: OP_SCOPE_REF                 { handle_token(OP_SCOPE_REF_INDEX); }
1158  ;
1159
1160bcs_semicolon: BCS_PUNCT_SEMICOLON { handle_token(BCS_PUNCT_SEMICOLON_INDEX); }
1161  ;
1162
1163bcs_less_than: BCS_PUNCT_LESS_THAN { handle_token(BCS_PUNCT_LESS_THAN_INDEX); }
1164  ;
1165
1166pp_lt: BCS_PUNCT_LESS_THAN
1167  ;
1168
1169shift_left: OP_SHIFT_LEFT  { handle_token(OP_SHIFT_LEFT_INDEX); }
1170  ;
1171
1172pp_shift_left: OP_SHIFT_LEFT
1173  ;
1174
1175assign_shift_left: OP_ASSIGN_SHIFT_LEFT  { handle_token(OP_ASSIGN_SHIFT_LEFT_INDEX); }
1176  ;
1177
1178le: OP_LE { handle_token(OP_LE_INDEX); }
1179  ;
1180
1181pp_le: OP_LE
1182  ;
1183
1184bcs_equal: BCS_PUNCT_EQUAL { handle_token(BCS_PUNCT_EQUAL_INDEX); }
1185  ;
1186
1187eq: OP_EQ { handle_token(OP_EQ_INDEX); }
1188  ;
1189
1190pp_eq: OP_EQ
1191  ;
1192
1193bcs_greater_than: BCS_PUNCT_GREATER_THAN { handle_token(BCS_PUNCT_GREATER_THAN_INDEX); }
1194  ;
1195
1196pp_gt: BCS_PUNCT_GREATER_THAN
1197  ;
1198
1199ge: OP_GE { handle_token(OP_GE_INDEX); }
1200  ;
1201
1202pp_ge: OP_GE
1203  ;
1204
1205shift_right: OP_SHIFT_RIGHT { handle_token(OP_SHIFT_RIGHT_INDEX); }
1206  ;
1207
1208pp_shift_right: OP_SHIFT_RIGHT { handle_token(OP_SHIFT_RIGHT_INDEX); }
1209  ;
1210
1211assign_shift_right: OP_ASSIGN_SHIFT_RIGHT { handle_token(OP_ASSIGN_SHIFT_RIGHT_INDEX); }
1212  ;
1213
1214bcs_question: conditional_operator           
1215
1216conditional_operator: OP_CONDITIONAL  { handle_token(OP_CONDITIONAL_INDEX); }
1217  ;
1218
1219pp_conditional_operator: OP_CONDITIONAL
1220  ;
1221
1222bcs_open_bracket: BCS_PUNCT_OPEN_BRACKET { handle_token_open(BCS_PUNCT_OPEN_BRACKET_INDEX); }
1223  | ALT_PUNCT_OPEN_BRACKET { handle_token_open(ALT_PUNCT_OPEN_BRACKET_INDEX); }
1224  ;
1225
1226bcs_close_bracket: BCS_PUNCT_CLOSE_BRACKET { handle_token_close(BCS_PUNCT_CLOSE_BRACKET_INDEX); }
1227  | ALT_PUNCT_CLOSE_BRACKET { handle_token_close(ALT_PUNCT_CLOSE_BRACKET_INDEX); }
1228  ;
1229
1230bcs_caret: BCS_PUNCT_CARET  { handle_token(OP_BIT_PLUS_INDEX); }
1231  ;
1232
1233alt_bit_xor: OP_ALT_BIT_PLUS  { handle_token(OP_ALT_BIT_PLUS_INDEX); }
1234  ;
1235
1236pp_bit_xor: BCS_PUNCT_CARET
1237  | OP_ALT_BIT_PLUS
1238  ;
1239
1240assign_bit_xor: OP_ASSIGN_BIT_PLUS  { handle_token(OP_ASSIGN_BIT_PLUS_INDEX); }
1241  |  OP_ALT_ASSIGN_BIT_PLUS  { handle_token(OP_ALT_ASSIGN_BIT_PLUS_INDEX); }
1242  ;
1243
1244bcs_open_brace: BCS_PUNCT_OPEN_BRACE { handle_token_open(BCS_PUNCT_OPEN_BRACE_INDEX); }
1245  | ALT_PUNCT_OPEN_BRACE { handle_token_open(ALT_PUNCT_OPEN_BRACE_INDEX); }
1246  ;
1247
1248bcs_close_brace: BCS_PUNCT_CLOSE_BRACE { handle_token_close(BCS_PUNCT_CLOSE_BRACE_INDEX); }
1249  | ALT_PUNCT_CLOSE_BRACE { handle_token_close(ALT_PUNCT_CLOSE_BRACE_INDEX); }
1250  ;
1251
1252bcs_vertical_bar: BCS_PUNCT_VERTICAL_BAR { handle_token(OP_BIT_OR_INDEX); }
1253  ;
1254
1255alt_bit_or: OP_ALT_BIT_OR { handle_token(OP_BIT_OR_INDEX); }
1256  ;
1257
1258pp_bit_or: BCS_PUNCT_VERTICAL_BAR
1259  | OP_ALT_BIT_OR
1260  ;
1261
1262assign_bit_or: OP_ASSIGN_BIT_OR { handle_token(OP_ASSIGN_BIT_OR_INDEX); }
1263  |  OP_ALT_ASSIGN_BIT_OR { handle_token(OP_ALT_ASSIGN_BIT_OR_INDEX); }
1264  ;
1265
1266truth_or: OP_LOGICAL_OR { handle_token(OP_LOGICAL_OR_INDEX); }
1267  |  OP_ALT_LOGICAL_OR { handle_token(OP_ALT_LOGICAL_OR_INDEX); }
1268  ;
1269
1270pp_truth_or: OP_LOGICAL_OR
1271  |  OP_ALT_LOGICAL_OR
1272  ;
1273
1274bcs_tilde: BCS_PUNCT_TILDE { handle_token(OP_BIT_NOT_INDEX); }
1275  ;
1276
1277alt_bit_not: OP_ALT_BIT_NOT { handle_token(OP_ALT_BIT_NOT_INDEX); }
1278  ;
1279
1280pp_bit_not: BCS_PUNCT_TILDE
1281  | OP_ALT_BIT_NOT
1282  ;
1283
1284%%
1285
1286/*
1287 *
1288 */
1289const char *get_yytname(int token) {
1290  return yytname[yytranslate[token]];
1291}
1292
1293/*
1294 *
1295 */
1296void yyerror(char const *s) {
1297  extern int error_count;
1298  extern int yychar;
1299  fprintf(stderr, "%s\n", s);
1300    if (yychar > 126) {
1301      fprintf(stderr, "File %s; line %d: yychar = %s(%d)\n",getCurrentFilename(), getCurrentLineNumber(), get_yytname(yychar), yychar);
1302    } else {
1303      fprintf(stderr, "File %s; line %d: yychar = %c\n",getCurrentFilename(),getCurrentLineNumber(), yychar);
1304    }
1305  error_count++;
1306}
1307