diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0af9db8bcc23..56a24ce765e2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,7 +26,7 @@ macro(generic_bison name) set(bison_source "${name}_y.tab.cpp") set_source_files_properties(${bison_source} PROPERTIES - COMPILE_FLAGS "-Dyyalloc=${name}_yyalloc -Dyysymbol_kind_t=${name}_yysymbol_kind_t") + COMPILE_FLAGS "-Dyyalloc=${name}_yyalloc -Dyysymbol_kind_t=${name}_yysymbol_kind_t -Dyytokentype=${name}_yytokentype") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${bison_source}") message(FATAL_ERROR "Generated file ${bison_source} found in source tree. If you previously built with `make`, run `make clean` and try again") endif() diff --git a/src/ansi-c/parser.y b/src/ansi-c/parser.y index 5335593b46d2..0fbeefd41959 100644 --- a/src/ansi-c/parser.y +++ b/src/ansi-c/parser.y @@ -24,6 +24,12 @@ extern char *yyansi_ctext; #include "literals/convert_integer_literal.h" +/* To avoid LTO -Wodr clashes */ +#define YYTOKENTYPE 1 +#define YYEMPTY -2 +#define YYEOF 0 /* "end of file" */ +#define YYerror 256 /* error */ +#define YYUNDEF 257 /* "invalid token" */ #include "ansi_c_y.tab.h" #include @@ -50,223 +56,223 @@ extern char *yyansi_ctext; /*** ANSI-C keywords ***/ -%token TOK_AUTO "auto" -%token TOK_BOOL "bool" -%token TOK_COMPLEX "complex" -%token TOK_BREAK "break" -%token TOK_CASE "case" -%token TOK_CHAR "char" -%token TOK_CONST "const" -%token TOK_CONTINUE "continue" -%token TOK_DEFAULT "default" -%token TOK_DO "do" -%token TOK_DOUBLE "double" -%token TOK_ELSE "else" -%token TOK_ENUM "enum" -%token TOK_EXTERN "extern" -%token TOK_FLOAT "float" -%token TOK_FOR "for" -%token TOK_GOTO "goto" -%token TOK_IF "if" -%token TOK_INLINE "inline" -%token TOK_INT "int" -%token TOK_LONG "long" -%token TOK_REGISTER "register" -%token TOK_RESTRICT "restrict" -%token TOK_RETURN "return" -%token TOK_SHORT "short" -%token TOK_SIGNED "signed" -%token TOK_SIZEOF "sizeof" -%token TOK_STATIC "static" -%token TOK_STRUCT "struct" -%token TOK_SWITCH "switch" -%token TOK_TYPEDEF "typedef" -%token TOK_UNION "union" -%token TOK_UNSIGNED "unsigned" -%token TOK_VOID "void" -%token TOK_VOLATILE "volatile" -%token TOK_WCHAR_T "wchar_t" -%token TOK_WHILE "while" +%token ATOK_AUTO "auto" +%token ATOK_BOOL "bool" +%token ATOK_COMPLEX "complex" +%token ATOK_BREAK "break" +%token ATOK_CASE "case" +%token ATOK_CHAR "char" +%token ATOK_CONST "const" +%token ATOK_CONTINUE "continue" +%token ATOK_DEFAULT "default" +%token ATOK_DO "do" +%token ATOK_DOUBLE "double" +%token ATOK_ELSE "else" +%token ATOK_ENUM "enum" +%token ATOK_EXTERN "extern" +%token ATOK_FLOAT "float" +%token ATOK_FOR "for" +%token ATOK_GOTO "goto" +%token ATOK_IF "if" +%token ATOK_INLINE "inline" +%token ATOK_INT "int" +%token ATOK_LONG "long" +%token ATOK_REGISTER "register" +%token ATOK_RESTRICT "restrict" +%token ATOK_RETURN "return" +%token ATOK_SHORT "short" +%token ATOK_SIGNED "signed" +%token ATOK_SIZEOF "sizeof" +%token ATOK_STATIC "static" +%token ATOK_STRUCT "struct" +%token ATOK_SWITCH "switch" +%token ATOK_TYPEDEF "typedef" +%token ATOK_UNION "union" +%token ATOK_UNSIGNED "unsigned" +%token ATOK_VOID "void" +%token ATOK_VOLATILE "volatile" +%token ATOK_WCHAR_T "wchar_t" +%token ATOK_WHILE "while" /*** multi-character operators ***/ -%token TOK_ARROW "->" -%token TOK_INCR "++" -%token TOK_DECR "--" -%token TOK_SHIFTLEFT "<<" -%token TOK_SHIFTRIGHT ">>" -%token TOK_LE "<=" -%token TOK_GE ">=" -%token TOK_EQ "==" -%token TOK_NE "!=" -%token TOK_ANDAND "&&" -%token TOK_OROR "||" -%token TOK_ELLIPSIS "..." +%token ATOK_ARROW "->" +%token ATOK_INCR "++" +%token ATOK_DECR "--" +%token ATOK_SHIFTLEFT "<<" +%token ATOK_SHIFTRIGHT ">>" +%token ATOK_LE "<=" +%token ATOK_GE ">=" +%token ATOK_EQ "==" +%token ATOK_NE "!=" +%token ATOK_ANDAND "&&" +%token ATOK_OROR "||" +%token ATOK_ELLIPSIS "..." /*** modifying assignment operators ***/ -%token TOK_MULTASSIGN "*=" -%token TOK_DIVASSIGN "/=" -%token TOK_MODASSIGN "%=" -%token TOK_PLUSASSIGN "+=" -%token TOK_MINUSASSIGN "-=" -%token TOK_SHLASSIGN "<<=" -%token TOK_SHRASSIGN ">>=" -%token TOK_ANDASSIGN "&=" -%token TOK_XORASSIGN "^=" -%token TOK_ORASSIGN "|=" +%token ATOK_MULTASSIGN "*=" +%token ATOK_DIVASSIGN "/=" +%token ATOK_MODASSIGN "%=" +%token ATOK_PLUSASSIGN "+=" +%token ATOK_MINUSASSIGN "-=" +%token ATOK_SHLASSIGN "<<=" +%token ATOK_SHRASSIGN ">>=" +%token ATOK_ANDASSIGN "&=" +%token ATOK_XORASSIGN "^=" +%token ATOK_ORASSIGN "|=" /*** scanner parsed tokens (these have a value!) ***/ -%token TOK_GCC_IDENTIFIER -%token TOK_MSC_IDENTIFIER -%token TOK_TYPEDEFNAME -%token TOK_INTEGER -%token TOK_FLOATING -%token TOK_CHARACTER -%token TOK_STRING -%token TOK_ASM_STRING +%token ATOK_GCC_IDENTIFIER +%token ATOK_MSC_IDENTIFIER +%token ATOK_TYPEDEFNAME +%token ATOK_INTEGER +%token ATOK_FLOATING +%token ATOK_CHARACTER +%token ATOK_STRING +%token ATOK_ASM_STRING /*** extensions ***/ -%token TOK_INT8 "__int8" -%token TOK_INT16 "__int16" -%token TOK_INT32 "__int32" -%token TOK_INT64 "__int64" -%token TOK_PTR32 "__ptr32" -%token TOK_PTR64 "__ptr64" -%token TOK_TYPEOF "typeof" -%token TOK_GCC_AUTO_TYPE "__auto_type" -%token TOK_GCC_FLOAT16 "_Float16" -%token TOK_GCC_FLOAT32 "_Float32" -%token TOK_GCC_FLOAT32X "_Float32x" -%token TOK_GCC_FLOAT80 "__float80" -%token TOK_GCC_FLOAT64 "_Float64" -%token TOK_GCC_FLOAT64X "_Float64x" -%token TOK_GCC_FLOAT128 "_Float128" -%token TOK_GCC_FLOAT128X "_Float128x" -%token TOK_GCC_INT128 "__int128" -%token TOK_GCC_DECIMAL32 "_Decimal32" -%token TOK_GCC_DECIMAL64 "_Decimal64" -%token TOK_GCC_DECIMAL128 "_Decimal128" -%token TOK_GCC_ASM "__asm__" -%token TOK_GCC_ASM_PAREN "__asm__ (with parentheses)" -%token TOK_GCC_ATTRIBUTE "__attribute__" -%token TOK_GCC_ATTRIBUTE_ALIGNED "aligned" -%token TOK_GCC_ATTRIBUTE_TRANSPARENT_UNION "transparent_union" -%token TOK_GCC_ATTRIBUTE_PACKED "packed" -%token TOK_GCC_ATTRIBUTE_VECTOR_SIZE "vector_size" -%token TOK_GCC_ATTRIBUTE_MODE "mode" -%token TOK_GCC_ATTRIBUTE_GNU_INLINE "__gnu_inline__" -%token TOK_GCC_ATTRIBUTE_WEAK "weak" -%token TOK_GCC_ATTRIBUTE_ALIAS "alias" -%token TOK_GCC_ATTRIBUTE_SECTION "section" -%token TOK_GCC_ATTRIBUTE_NORETURN "noreturn" -%token TOK_GCC_ATTRIBUTE_CONSTRUCTOR "constructor" -%token TOK_GCC_ATTRIBUTE_DESTRUCTOR "destructor" -%token TOK_GCC_ATTRIBUTE_FALLTHROUGH "fallthrough" -%token TOK_GCC_ATTRIBUTE_USED "used" -%token TOK_GCC_LABEL "__label__" -%token TOK_MSC_ASM "__asm" -%token TOK_MSC_BASED "__based" -%token TOK_CW_VAR_ARG_TYPEOF "_var_arg_typeof" -%token TOK_BUILTIN_VA_ARG "__builtin_va_arg" -%token TOK_GCC_BUILTIN_TYPES_COMPATIBLE_P "__builtin_types_compatible_p" -%token TOK_CLANG_BUILTIN_CONVERTVECTOR "__builtin_convertvector" -%token TOK_OFFSETOF "__offsetof" -%token TOK_ALIGNOF "__alignof__" -%token TOK_MSC_TRY "__try" -%token TOK_MSC_FINALLY "__finally" -%token TOK_MSC_EXCEPT "__except" -%token TOK_MSC_LEAVE "__leave" -%token TOK_MSC_DECLSPEC "__declspec" -%token TOK_MSC_FORCEINLINE "__forceinline" -%token TOK_INTERFACE "__interface" -%token TOK_CDECL "__cdecl" -%token TOK_STDCALL "__stdcall" -%token TOK_FASTCALL "__fastcall" -%token TOK_CLRCALL "__clrcall" -%token TOK_FORALL "forall" -%token TOK_EXISTS "exists" -%token TOK_ACSL_FORALL "\\forall" -%token TOK_ACSL_EXISTS "\\exists" -%token TOK_ACSL_LAMBDA "\\lambda" -%token TOK_ACSL_LET "\\let" -%token TOK_ARRAY_OF "array_of" -%token TOK_CPROVER_BITVECTOR "__CPROVER_bitvector" -%token TOK_CPROVER_FLOATBV "__CPROVER_floatbv" -%token TOK_CPROVER_FIXEDBV "__CPROVER_fixedbv" -%token TOK_CPROVER_ATOMIC "__CPROVER_atomic" -%token TOK_CPROVER_BOOL "__CPROVER_bool" -%token TOK_CPROVER_THROW "__CPROVER_throw" -%token TOK_CPROVER_CATCH "__CPROVER_catch" -%token TOK_CPROVER_TRY "__CPROVER_try" -%token TOK_CPROVER_FINALLY "__CPROVER_finally" -%token TOK_CPROVER_ID "__CPROVER_ID" -%token TOK_CPROVER_LOOP_INVARIANT "__CPROVER_loop_invariant" -%token TOK_CPROVER_DECREASES "__CPROVER_decreases" -%token TOK_CPROVER_REQUIRES "__CPROVER_requires" -%token TOK_CPROVER_ENSURES "__CPROVER_ensures" -%token TOK_CPROVER_ASSIGNS "__CPROVER_assigns" -%token TOK_CPROVER_FREES "__CPROVER_frees" -%token TOK_IMPLIES "==>" -%token TOK_EQUIVALENT "<==>" -%token TOK_XORXOR "^^" -%token TOK_TRUE "TRUE" -%token TOK_FALSE "FALSE" -%token TOK_REAL "__real__" -%token TOK_IMAG "__imag__" -%token TOK_ALIGNAS "_Alignas" -%token TOK_ATOMIC_TYPE_QUALIFIER "_Atomic" -%token TOK_ATOMIC_TYPE_SPECIFIER "_Atomic()" -%token TOK_GENERIC "_Generic" -%token TOK_IMAGINARY "_Imaginary" -%token TOK_NORETURN "_Noreturn" -%token TOK_STATIC_ASSERT "_Static_assert" -%token TOK_THREAD_LOCAL "_Thread_local" -%token TOK_NULLPTR "nullptr" -%token TOK_CONSTEXPR "constexpr" +%token ATOK_INT8 "__int8" +%token ATOK_INT16 "__int16" +%token ATOK_INT32 "__int32" +%token ATOK_INT64 "__int64" +%token ATOK_PTR32 "__ptr32" +%token ATOK_PTR64 "__ptr64" +%token ATOK_TYPEOF "typeof" +%token ATOK_GCC_AUTO_TYPE "__auto_type" +%token ATOK_GCC_FLOAT16 "_Float16" +%token ATOK_GCC_FLOAT32 "_Float32" +%token ATOK_GCC_FLOAT32X "_Float32x" +%token ATOK_GCC_FLOAT80 "__float80" +%token ATOK_GCC_FLOAT64 "_Float64" +%token ATOK_GCC_FLOAT64X "_Float64x" +%token ATOK_GCC_FLOAT128 "_Float128" +%token ATOK_GCC_FLOAT128X "_Float128x" +%token ATOK_GCC_INT128 "__int128" +%token ATOK_GCC_DECIMAL32 "_Decimal32" +%token ATOK_GCC_DECIMAL64 "_Decimal64" +%token ATOK_GCC_DECIMAL128 "_Decimal128" +%token ATOK_GCC_ASM "__asm__" +%token ATOK_GCC_ASM_PAREN "__asm__ (with parentheses)" +%token ATOK_GCC_ATTRIBUTE "__attribute__" +%token ATOK_GCC_ATTRIBUTE_ALIGNED "aligned" +%token ATOK_GCC_ATTRIBUTE_TRANSPARENT_UNION "transparent_union" +%token ATOK_GCC_ATTRIBUTE_PACKED "packed" +%token ATOK_GCC_ATTRIBUTE_VECTOR_SIZE "vector_size" +%token ATOK_GCC_ATTRIBUTE_MODE "mode" +%token ATOK_GCC_ATTRIBUTE_GNU_INLINE "__gnu_inline__" +%token ATOK_GCC_ATTRIBUTE_WEAK "weak" +%token ATOK_GCC_ATTRIBUTE_ALIAS "alias" +%token ATOK_GCC_ATTRIBUTE_SECTION "section" +%token ATOK_GCC_ATTRIBUTE_NORETURN "noreturn" +%token ATOK_GCC_ATTRIBUTE_CONSTRUCTOR "constructor" +%token ATOK_GCC_ATTRIBUTE_DESTRUCTOR "destructor" +%token ATOK_GCC_ATTRIBUTE_FALLTHROUGH "fallthrough" +%token ATOK_GCC_ATTRIBUTE_USED "used" +%token ATOK_GCC_LABEL "__label__" +%token ATOK_MSC_ASM "__asm" +%token ATOK_MSC_BASED "__based" +%token ATOK_CW_VAR_ARG_TYPEOF "_var_arg_typeof" +%token ATOK_BUILTIN_VA_ARG "__builtin_va_arg" +%token ATOK_GCC_BUILTIN_TYPES_COMPATIBLE_P "__builtin_types_compatible_p" +%token ATOK_CLANG_BUILTIN_CONVERTVECTOR "__builtin_convertvector" +%token ATOK_OFFSETOF "__offsetof" +%token ATOK_ALIGNOF "__alignof__" +%token ATOK_MSC_TRY "__try" +%token ATOK_MSC_FINALLY "__finally" +%token ATOK_MSC_EXCEPT "__except" +%token ATOK_MSC_LEAVE "__leave" +%token ATOK_MSC_DECLSPEC "__declspec" +%token ATOK_MSC_FORCEINLINE "__forceinline" +%token ATOK_INTERFACE "__interface" +%token ATOK_CDECL "__cdecl" +%token ATOK_STDCALL "__stdcall" +%token ATOK_FASTCALL "__fastcall" +%token ATOK_CLRCALL "__clrcall" +%token ATOK_FORALL "forall" +%token ATOK_EXISTS "exists" +%token ATOK_ACSL_FORALL "\\forall" +%token ATOK_ACSL_EXISTS "\\exists" +%token ATOK_ACSL_LAMBDA "\\lambda" +%token ATOK_ACSL_LET "\\let" +%token ATOK_ARRAY_OF "array_of" +%token ATOK_CPROVER_BITVECTOR "__CPROVER_bitvector" +%token ATOK_CPROVER_FLOATBV "__CPROVER_floatbv" +%token ATOK_CPROVER_FIXEDBV "__CPROVER_fixedbv" +%token ATOK_CPROVER_ATOMIC "__CPROVER_atomic" +%token ATOK_CPROVER_BOOL "__CPROVER_bool" +%token ATOK_CPROVER_THROW "__CPROVER_throw" +%token ATOK_CPROVER_CATCH "__CPROVER_catch" +%token ATOK_CPROVER_TRY "__CPROVER_try" +%token ATOK_CPROVER_FINALLY "__CPROVER_finally" +%token ATOK_CPROVER_ID "__CPROVER_ID" +%token ATOK_CPROVER_LOOP_INVARIANT "__CPROVER_loop_invariant" +%token ATOK_CPROVER_DECREASES "__CPROVER_decreases" +%token ATOK_CPROVER_REQUIRES "__CPROVER_requires" +%token ATOK_CPROVER_ENSURES "__CPROVER_ensures" +%token ATOK_CPROVER_ASSIGNS "__CPROVER_assigns" +%token ATOK_CPROVER_FREES "__CPROVER_frees" +%token ATOK_IMPLIES "==>" +%token ATOK_EQUIVALENT "<==>" +%token ATOK_XORXOR "^^" +%token ATOK_TRUE "TRUE" +%token ATOK_FALSE "FALSE" +%token ATOK_REAL "__real__" +%token ATOK_IMAG "__imag__" +%token ATOK_ALIGNAS "_Alignas" +%token ATOK_ATOMIC_TYPE_QUALIFIER "_Atomic" +%token ATOK_ATOMIC_TYPE_SPECIFIER "_Atomic()" +%token ATOK_GENERIC "_Generic" +%token ATOK_IMAGINARY "_Imaginary" +%token ATOK_NORETURN "_Noreturn" +%token ATOK_STATIC_ASSERT "_Static_assert" +%token ATOK_THREAD_LOCAL "_Thread_local" +%token ATOK_NULLPTR "nullptr" +%token ATOK_CONSTEXPR "constexpr" /*** special scanner reports ***/ -%token TOK_SCANNER_ERROR /* used by scanner to report errors */ -%token TOK_SCANNER_EOF /* used by scanner to report end of import */ +%token ATOK_SCANNER_ERROR /* used by scanner to report errors */ +%token ATOK_SCANNER_EOF /* used by scanner to report end of import */ /*** these exist only for the benefit of the C++ frontend */ -%token TOK_CATCH "catch" -%token TOK_CHAR16_T "char16_t" -%token TOK_CHAR32_T "char32_t" -%token TOK_CLASS "class" -%token TOK_DELETE "delete" -%token TOK_DECLTYPE "decltype" -%token TOK_EXPLICIT "explicit" -%token TOK_FRIEND "friend" -%token TOK_MUTABLE "mutable" -%token TOK_NAMESPACE "namespace" -%token TOK_NEW "new" -%token TOK_NOEXCEPT "noexcept" -%token TOK_OPERATOR "operator" -%token TOK_PRIVATE "private" -%token TOK_PROTECTED "protected" -%token TOK_PUBLIC "public" -%token TOK_TEMPLATE "template" -%token TOK_THIS "this" -%token TOK_THROW "throw" -%token TOK_TYPEID "typeid" -%token TOK_TYPENAME "typename" -%token TOK_TRY "try" -%token TOK_USING "using" -%token TOK_VIRTUAL "virtual" -%token TOK_SCOPE "::" -%token TOK_DOTPM ".*" -%token TOK_ARROWPM "->*" -%token TOK_UNARY_TYPE_PREDICATE -%token TOK_BINARY_TYPE_PREDICATE -%token TOK_MSC_UUIDOF "__uuidof" -%token TOK_MSC_IF_EXISTS "__if_exists" -%token TOK_MSC_IF_NOT_EXISTS "__if_not_exists" -%token TOK_UNDERLYING_TYPE "__underlying_type" +%token ATOK_CATCH "catch" +%token ATOK_CHAR16_T "char16_t" +%token ATOK_CHAR32_T "char32_t" +%token ATOK_CLASS "class" +%token ATOK_DELETE "delete" +%token ATOK_DECLTYPE "decltype" +%token ATOK_EXPLICIT "explicit" +%token ATOK_FRIEND "friend" +%token ATOK_MUTABLE "mutable" +%token ATOK_NAMESPACE "namespace" +%token ATOK_NEW "new" +%token ATOK_NOEXCEPT "noexcept" +%token ATOK_OPERATOR "operator" +%token ATOK_PRIVATE "private" +%token ATOK_PROTECTED "protected" +%token ATOK_PUBLIC "public" +%token ATOK_TEMPLATE "template" +%token ATOK_THIS "this" +%token ATOK_THROW "throw" +%token ATOK_TYPEID "typeid" +%token ATOK_TYPENAME "typename" +%token ATOK_TRY "try" +%token ATOK_USING "using" +%token ATOK_VIRTUAL "virtual" +%token ATOK_SCOPE "::" +%token ATOK_DOTPM ".*" +%token ATOK_ARROWPM "->*" +%token ATOK_UNARY_TYPE_PREDICATE +%token ATOK_BINARY_TYPE_PREDICATE +%token ATOK_MSC_UUIDOF "__uuidof" +%token ATOK_MSC_IF_EXISTS "__if_exists" +%token ATOK_MSC_IF_NOT_EXISTS "__if_not_exists" +%token ATOK_UNDERLYING_TYPE "__underlying_type" /*** priority, associativity, etc. definitions **************************/ @@ -294,9 +300,9 @@ grammar: /*** Token with values **************************************************/ identifier: - TOK_GCC_IDENTIFIER - | TOK_MSC_IDENTIFIER - | TOK_CPROVER_ID TOK_STRING + ATOK_GCC_IDENTIFIER + | ATOK_MSC_IDENTIFIER + | ATOK_CPROVER_ID ATOK_STRING { // construct an identifier from a string that would otherwise not be a // valid identifier in C @@ -311,23 +317,23 @@ identifier: ; typedef_name: - TOK_TYPEDEFNAME + ATOK_TYPEDEFNAME ; integer: - TOK_INTEGER + ATOK_INTEGER ; floating: - TOK_FLOATING + ATOK_FLOATING ; character: - TOK_CHARACTER + ATOK_CHARACTER ; string: - TOK_STRING + ATOK_STRING ; /*** Constants **********************************************************/ @@ -355,7 +361,7 @@ primary_expression: ; generic_selection: - TOK_GENERIC '(' assignment_expression ',' generic_assoc_list ')' + ATOK_GENERIC '(' assignment_expression ',' generic_assoc_list ')' { $$=$1; set($$, ID_generic_selection); @@ -383,7 +389,7 @@ generic_association: parser_stack($$).set(ID_type_arg, parser_stack($1)); parser_stack($$).set(ID_value, parser_stack($3)); } - | TOK_DEFAULT ':' assignment_expression + | ATOK_DEFAULT ':' assignment_expression { $$=$2; parser_stack($$).id(ID_generic_association); @@ -393,14 +399,14 @@ generic_association: ; gcc_builtin_expressions: - TOK_BUILTIN_VA_ARG '(' assignment_expression ',' type_name ')' + ATOK_BUILTIN_VA_ARG '(' assignment_expression ',' type_name ')' { $$=$1; parser_stack($$).id(ID_gcc_builtin_va_arg); mto($$, $3); parser_stack($$).type().swap(parser_stack($5)); } - | TOK_GCC_BUILTIN_TYPES_COMPATIBLE_P '(' + | ATOK_GCC_BUILTIN_TYPES_COMPATIBLE_P '(' type_name ',' type_name ')' { $$=$1; @@ -414,7 +420,7 @@ gcc_builtin_expressions: ; clang_builtin_expressions: - TOK_CLANG_BUILTIN_CONVERTVECTOR '(' assignment_expression ',' type_name ')' + ATOK_CLANG_BUILTIN_CONVERTVECTOR '(' assignment_expression ',' type_name ')' { $$=$1; parser_stack($$).id(ID_clang_builtin_convertvector); @@ -424,7 +430,7 @@ clang_builtin_expressions: ; cw_builtin_expressions: - TOK_CW_VAR_ARG_TYPEOF '(' type_name ')' + ATOK_CW_VAR_ARG_TYPEOF '(' type_name ')' { $$=$1; parser_stack($$).id(ID_cw_va_arg_typeof); @@ -433,7 +439,7 @@ cw_builtin_expressions: ; offsetof: - TOK_OFFSETOF '(' type_name ',' offsetof_member_designator ')' + ATOK_OFFSETOF '(' type_name ',' offsetof_member_designator ')' { $$=$1; parser_stack($$).id(ID_builtin_offsetof); @@ -465,7 +471,7 @@ offsetof_member_designator: mto($2, $3); mto($$, $2); } - | offsetof_member_designator TOK_ARROW member_name + | offsetof_member_designator ATOK_ARROW member_name { $$=$1; set($2, ID_index); @@ -478,7 +484,7 @@ offsetof_member_designator: ; quantifier_expression: - TOK_FORALL compound_scope '{' declaration comma_expression '}' + ATOK_FORALL compound_scope '{' declaration comma_expression '}' { $$=$1; set($$, ID_forall); @@ -486,7 +492,7 @@ quantifier_expression: mto($$, $5); PARSER.pop_scope(); } - | TOK_EXISTS compound_scope '{' declaration comma_expression '}' + | ATOK_EXISTS compound_scope '{' declaration comma_expression '}' { $$=$1; set($$, ID_exists); @@ -497,7 +503,7 @@ quantifier_expression: ; cprover_contract_loop_invariant: - TOK_CPROVER_LOOP_INVARIANT '(' ACSL_binding_expression ')' + ATOK_CPROVER_LOOP_INVARIANT '(' ACSL_binding_expression ')' { $$=$3; } ; @@ -524,7 +530,7 @@ ACSL_binding_expression_list: cprover_contract_decreases_opt: /* nothing */ { init($$); parser_stack($$).make_nil(); } - | TOK_CPROVER_DECREASES '(' ACSL_binding_expression_list ')' + | ATOK_CPROVER_DECREASES '(' ACSL_binding_expression_list ')' { $$=$3; } ; @@ -567,19 +573,19 @@ postfix_expression: mto($$, $1); parser_stack($$).set(ID_component_name, parser_stack($3).get(ID_C_base_name)); } - | postfix_expression TOK_ARROW member_name + | postfix_expression ATOK_ARROW member_name { $$=$2; set($$, ID_ptrmember); mto($$, $1); parser_stack($$).set(ID_component_name, parser_stack($3).get(ID_C_base_name)); } - | postfix_expression TOK_INCR + | postfix_expression ATOK_INCR { $$=$2; set($$, ID_side_effect); parser_stack($$).set(ID_statement, ID_postincrement); mto($$, $1); } - | postfix_expression TOK_DECR + | postfix_expression ATOK_DECR { $$=$2; set($$, ID_side_effect); parser_stack($$).set(ID_statement, ID_postdecrement); @@ -629,13 +635,13 @@ argument_expression_list: unary_expression: postfix_expression - | TOK_INCR unary_expression + | ATOK_INCR unary_expression { $$=$1; set($$, ID_side_effect); parser_stack($$).set(ID_statement, ID_preincrement); mto($$, $2); } - | TOK_DECR unary_expression + | ATOK_DECR unary_expression { $$=$1; set($$, ID_side_effect); parser_stack($$).set(ID_statement, ID_predecrement); @@ -646,7 +652,7 @@ unary_expression: set($$, ID_address_of); mto($$, $2); } - | TOK_ANDAND gcc_local_label + | ATOK_ANDAND gcc_local_label { // this takes the address of a label (a gcc extension) $$=$1; irep_idt identifier=PARSER.lookup_label(parser_stack($2).get(ID_C_base_name)); @@ -682,23 +688,23 @@ unary_expression: set($$, ID_not); mto($$, $2); } - | TOK_SIZEOF unary_expression + | ATOK_SIZEOF unary_expression { $$=$1; set($$, ID_sizeof); mto($$, $2); } - | TOK_SIZEOF '(' type_name ')' + | ATOK_SIZEOF '(' type_name ')' { $$=$1; set($$, ID_sizeof); parser_stack($$).add(ID_type_arg).swap(parser_stack($3)); } - | TOK_ALIGNOF unary_expression + | ATOK_ALIGNOF unary_expression { // note no parentheses for expressions, just like sizeof $$=$1; set($$, ID_alignof); mto($$, $2); } - | TOK_ALIGNOF '(' type_name ')' + | ATOK_ALIGNOF '(' type_name ')' { $$=$1; parser_stack($$).id(ID_alignof); @@ -715,12 +721,12 @@ cast_expression: mto($$, $4); parser_stack($$).type().swap(parser_stack($2)); } - | TOK_REAL cast_expression + | ATOK_REAL cast_expression { $$=$1; set($$, ID_complex_real); mto($$, $2); } - | TOK_IMAG cast_expression + | ATOK_IMAG cast_expression { $$=$1; set($$, ID_complex_imag); mto($$, $2); @@ -747,9 +753,9 @@ additive_expression: shift_expression: additive_expression - | shift_expression TOK_SHIFTLEFT additive_expression + | shift_expression ATOK_SHIFTLEFT additive_expression { binary($$, $1, $2, ID_shl, $3); } - | shift_expression TOK_SHIFTRIGHT additive_expression + | shift_expression ATOK_SHIFTRIGHT additive_expression { binary($$, $1, $2, ID_shr, $3); } ; @@ -759,17 +765,17 @@ relational_expression: { binary($$, $1, $2, ID_lt, $3); } | relational_expression '>' shift_expression { binary($$, $1, $2, ID_gt, $3); } - | relational_expression TOK_LE shift_expression + | relational_expression ATOK_LE shift_expression { binary($$, $1, $2, ID_le, $3); } - | relational_expression TOK_GE shift_expression + | relational_expression ATOK_GE shift_expression { binary($$, $1, $2, ID_ge, $3); } ; equality_expression: relational_expression - | equality_expression TOK_EQ relational_expression + | equality_expression ATOK_EQ relational_expression { binary($$, $1, $2, ID_equal, $3); } - | equality_expression TOK_NE relational_expression + | equality_expression ATOK_NE relational_expression { binary($$, $1, $2, ID_notequal, $3); } ; @@ -793,19 +799,19 @@ inclusive_or_expression: logical_and_expression: inclusive_or_expression - | logical_and_expression TOK_ANDAND inclusive_or_expression + | logical_and_expression ATOK_ANDAND inclusive_or_expression { binary($$, $1, $2, ID_and, $3); } ; logical_xor_expression: logical_and_expression - | logical_xor_expression TOK_XORXOR logical_and_expression + | logical_xor_expression ATOK_XORXOR logical_and_expression { binary($$, $1, $2, ID_xor, $3); } ; logical_or_expression: logical_xor_expression - | logical_or_expression TOK_OROR logical_xor_expression + | logical_or_expression ATOK_OROR logical_xor_expression { binary($$, $1, $2, ID_or, $3); } ; @@ -814,7 +820,7 @@ logical_or_expression: and binds weaker than 'OR', and stronger than bi-implication. */ logical_implication_expression: logical_or_expression - | logical_or_expression TOK_IMPLIES logical_implication_expression + | logical_or_expression ATOK_IMPLIES logical_implication_expression { binary($$, $1, $2, ID_implies, $3); } ; @@ -823,14 +829,14 @@ logical_implication_expression: and binds weaker than '==>', and stronger than quantifiers. */ logical_equivalence_expression: logical_implication_expression - | logical_equivalence_expression TOK_EQUIVALENT logical_implication_expression + | logical_equivalence_expression ATOK_EQUIVALENT logical_implication_expression { binary($$, $1, $2, ID_equal, $3); } ; /* Non-standard, defined by ACSL. Lowest precedence of all operators. */ ACSL_binding_expression: conditional_expression - | TOK_ACSL_FORALL compound_scope declaration ACSL_binding_expression + | ATOK_ACSL_FORALL compound_scope declaration ACSL_binding_expression { $$=$1; set($$, ID_forall); @@ -838,7 +844,7 @@ ACSL_binding_expression: mto($$, $4); PARSER.pop_scope(); } - | TOK_ACSL_EXISTS compound_scope declaration ACSL_binding_expression + | ATOK_ACSL_EXISTS compound_scope declaration ACSL_binding_expression { $$=$1; set($$, ID_exists); @@ -846,7 +852,7 @@ ACSL_binding_expression: mto($$, $4); PARSER.pop_scope(); } - | TOK_ACSL_LAMBDA compound_scope declaration ACSL_binding_expression + | ATOK_ACSL_LAMBDA compound_scope declaration ACSL_binding_expression { $$=$1; set($$, ID_lambda); @@ -878,25 +884,25 @@ assignment_expression: ACSL_binding_expression /* usually conditional_expression */ | cast_expression '=' assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign); } - | cast_expression TOK_MULTASSIGN assignment_expression + | cast_expression ATOK_MULTASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_mult); } - | cast_expression TOK_DIVASSIGN assignment_expression + | cast_expression ATOK_DIVASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_div); } - | cast_expression TOK_MODASSIGN assignment_expression + | cast_expression ATOK_MODASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_mod); } - | cast_expression TOK_PLUSASSIGN assignment_expression + | cast_expression ATOK_PLUSASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_plus); } - | cast_expression TOK_MINUSASSIGN assignment_expression + | cast_expression ATOK_MINUSASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_minus); } - | cast_expression TOK_SHLASSIGN assignment_expression + | cast_expression ATOK_SHLASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_shl); } - | cast_expression TOK_SHRASSIGN assignment_expression + | cast_expression ATOK_SHRASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_shr); } - | cast_expression TOK_ANDASSIGN assignment_expression + | cast_expression ATOK_ANDASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_bitand); } - | cast_expression TOK_XORASSIGN assignment_expression + | cast_expression ATOK_XORASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_bitxor); } - | cast_expression TOK_ORASSIGN assignment_expression + | cast_expression ATOK_ORASSIGN assignment_expression { binary($$, $1, $2, ID_side_effect, $3); parser_stack($$).set(ID_statement, ID_assign_bitor); } ; @@ -937,7 +943,7 @@ declaration: ; static_assert_declaration: - TOK_STATIC_ASSERT '(' assignment_expression ',' assignment_expression ')' + ATOK_STATIC_ASSERT '(' assignment_expression ',' assignment_expression ')' { $$=$1; set($$, ID_declaration); @@ -988,7 +994,7 @@ default_declaring_list: ; post_declarator_attribute: - TOK_GCC_ASM_PAREN volatile_or_goto_opt '(' gcc_asm_commands ')' + ATOK_GCC_ASM_PAREN volatile_or_goto_opt '(' gcc_asm_commands ')' { $$=$1; parser_stack($$).id(ID_asm); @@ -1047,7 +1053,7 @@ declaring_list: $$=$4; to_ansi_c_declaration(parser_stack($$)).add_initializer(parser_stack($5)); } - | TOK_GCC_AUTO_TYPE declarator + | ATOK_GCC_AUTO_TYPE declarator post_declarator_attributes_opt '=' initializer { // handled as typeof(initializer) @@ -1141,24 +1147,24 @@ declaration_qualifier: ; type_qualifier: - TOK_ATOMIC_TYPE_QUALIFIER { $$=$1; set($$, ID_atomic); } - | TOK_CONST { $$=$1; set($$, ID_const); } - | TOK_RESTRICT { $$=$1; set($$, ID_restrict); } - | TOK_VOLATILE { $$=$1; set($$, ID_volatile); } - | TOK_CPROVER_ATOMIC { $$=$1; set($$, ID_cprover_atomic); } - | TOK_PTR32 { $$=$1; set($$, ID_ptr32); } - | TOK_PTR64 { $$=$1; set($$, ID_ptr64); } - | TOK_MSC_BASED '(' comma_expression ')' { $$=$1; set($$, ID_msc_based); mto($$, $3); } + ATOK_ATOMIC_TYPE_QUALIFIER { $$=$1; set($$, ID_atomic); } + | ATOK_CONST { $$=$1; set($$, ID_const); } + | ATOK_RESTRICT { $$=$1; set($$, ID_restrict); } + | ATOK_VOLATILE { $$=$1; set($$, ID_volatile); } + | ATOK_CPROVER_ATOMIC { $$=$1; set($$, ID_cprover_atomic); } + | ATOK_PTR32 { $$=$1; set($$, ID_ptr32); } + | ATOK_PTR64 { $$=$1; set($$, ID_ptr64); } + | ATOK_MSC_BASED '(' comma_expression ')' { $$=$1; set($$, ID_msc_based); mto($$, $3); } | alignas_specifier ; alignas_specifier: - TOK_ALIGNAS '(' comma_expression ')' + ATOK_ALIGNAS '(' comma_expression ')' { $$ = $1; parser_stack($$).id(ID_aligned); parser_stack($$).set(ID_size, parser_stack($3)); } - | TOK_ALIGNAS '(' type_name ')' + | ATOK_ALIGNAS '(' type_name ')' { $$ = $1; parser_stack($$).id(ID_aligned); parser_stack($3).set(ID_type_arg, parser_stack($3)); @@ -1310,12 +1316,12 @@ typedef_type_specifier: ; typeof_specifier: - TOK_TYPEOF '(' comma_expression ')' + ATOK_TYPEOF '(' comma_expression ')' { $$ = $1; parser_stack($$).id(ID_typeof); mto($$, $3); } - | TOK_TYPEOF '(' type_name ')' + | ATOK_TYPEOF '(' type_name ')' { $$ = $1; parser_stack($$).id(ID_typeof); parser_stack($$).set(ID_type_arg, parser_stack($3)); @@ -1339,7 +1345,7 @@ typeof_type_specifier: ; atomic_specifier: - TOK_ATOMIC_TYPE_SPECIFIER '(' type_name ')' + ATOK_ATOMIC_TYPE_SPECIFIER '(' type_name ')' { $$=$1; parser_stack($$).id(ID_atomic_type_specifier); @@ -1364,15 +1370,15 @@ atomic_type_specifier: ; msc_decl_identifier: - TOK_MSC_IDENTIFIER + ATOK_MSC_IDENTIFIER { parser_stack($$).id(parser_stack($$).get(ID_identifier)); } - | TOK_TYPEDEFNAME + | ATOK_TYPEDEFNAME { parser_stack($$).id(parser_stack($$).get(ID_identifier)); } - | TOK_RESTRICT + | ATOK_RESTRICT { parser_stack($$).id(ID_restrict); } @@ -1380,11 +1386,11 @@ msc_decl_identifier: msc_decl_modifier: msc_decl_identifier - | msc_decl_identifier '(' TOK_STRING ')' + | msc_decl_identifier '(' ATOK_STRING ')' { $$=$1; mto($$, $3); } - | msc_decl_identifier '(' TOK_INTEGER ')' + | msc_decl_identifier '(' ATOK_INTEGER ')' { $$=$1; mto($$, $3); } @@ -1411,12 +1417,12 @@ msc_declspec_seq: ; msc_declspec: - TOK_MSC_DECLSPEC '(' msc_declspec_seq ')' + ATOK_MSC_DECLSPEC '(' msc_declspec_seq ')' { $$=$1; set($$, ID_msc_declspec); parser_stack($$).operands().swap(parser_stack($3).operands()); } - | TOK_MSC_DECLSPEC '(' ')' + | ATOK_MSC_DECLSPEC '(' ')' { $$=$1; set($$, ID_msc_declspec); } @@ -1444,16 +1450,16 @@ msc_declspec_opt: ; storage_class: - TOK_TYPEDEF { $$=$1; set($$, ID_typedef); } - | TOK_EXTERN { $$=$1; set($$, ID_extern); } - | TOK_STATIC { $$=$1; set($$, ID_static); } - | TOK_AUTO { $$=$1; set($$, ID_auto); } - | TOK_REGISTER { $$=$1; set($$, ID_register); } - | TOK_INLINE { $$=$1; set($$, ID_inline); } - | TOK_THREAD_LOCAL { $$=$1; set($$, ID_thread_local); } - | TOK_GCC_ASM { $$=$1; set($$, ID_asm); } + ATOK_TYPEDEF { $$=$1; set($$, ID_typedef); } + | ATOK_EXTERN { $$=$1; set($$, ID_extern); } + | ATOK_STATIC { $$=$1; set($$, ID_static); } + | ATOK_AUTO { $$=$1; set($$, ID_auto); } + | ATOK_REGISTER { $$=$1; set($$, ID_register); } + | ATOK_INLINE { $$=$1; set($$, ID_inline); } + | ATOK_THREAD_LOCAL { $$=$1; set($$, ID_thread_local); } + | ATOK_GCC_ASM { $$=$1; set($$, ID_asm); } | msc_declspec { $$=$1; } - | TOK_MSC_FORCEINLINE + | ATOK_MSC_FORCEINLINE { // equivalent to always_inline, and seemingly also has the semantics // of extern inline in that multiple definitions can be provided in @@ -1475,54 +1481,54 @@ storage_class: ; basic_type_name: - TOK_INT { $$=$1; set($$, ID_int); } - | TOK_INT8 { $$=$1; set($$, ID_int8); } - | TOK_INT16 { $$=$1; set($$, ID_int16); } - | TOK_INT32 { $$=$1; set($$, ID_int32); } - | TOK_INT64 { $$=$1; set($$, ID_int64); } - | TOK_CHAR { $$=$1; set($$, ID_char); } - | TOK_SHORT { $$=$1; set($$, ID_short); } - | TOK_LONG { $$=$1; set($$, ID_long); } - | TOK_FLOAT { $$=$1; set($$, ID_float); } - | TOK_GCC_FLOAT16 { $$=$1; set($$, ID_gcc_float16); } - | TOK_GCC_FLOAT32 { $$=$1; set($$, ID_gcc_float32); } - | TOK_GCC_FLOAT32X { $$=$1; set($$, ID_gcc_float32x); } - | TOK_GCC_FLOAT64 { $$=$1; set($$, ID_gcc_float64); } - | TOK_GCC_FLOAT64X { $$=$1; set($$, ID_gcc_float64x); } - | TOK_GCC_FLOAT80 { $$=$1; set($$, ID_gcc_float80); } - | TOK_GCC_FLOAT128 { $$=$1; set($$, ID_gcc_float128); } - | TOK_GCC_FLOAT128X { $$=$1; set($$, ID_gcc_float128x); } - | TOK_GCC_INT128 { $$=$1; set($$, ID_gcc_int128); } - | TOK_GCC_DECIMAL32 { $$=$1; set($$, ID_gcc_decimal32); } - | TOK_GCC_DECIMAL64 { $$=$1; set($$, ID_gcc_decimal64); } - | TOK_GCC_DECIMAL128 { $$=$1; set($$, ID_gcc_decimal128); } - | TOK_DOUBLE { $$=$1; set($$, ID_double); } - | TOK_SIGNED { $$=$1; set($$, ID_signed); } - | TOK_UNSIGNED { $$=$1; set($$, ID_unsigned); } - | TOK_VOID { $$=$1; set($$, ID_void); } - | TOK_BOOL { $$=$1; set($$, ID_c_bool); } - | TOK_COMPLEX { $$=$1; set($$, ID_complex); } - | TOK_CPROVER_BITVECTOR '[' comma_expression ']' + ATOK_INT { $$=$1; set($$, ID_int); } + | ATOK_INT8 { $$=$1; set($$, ID_int8); } + | ATOK_INT16 { $$=$1; set($$, ID_int16); } + | ATOK_INT32 { $$=$1; set($$, ID_int32); } + | ATOK_INT64 { $$=$1; set($$, ID_int64); } + | ATOK_CHAR { $$=$1; set($$, ID_char); } + | ATOK_SHORT { $$=$1; set($$, ID_short); } + | ATOK_LONG { $$=$1; set($$, ID_long); } + | ATOK_FLOAT { $$=$1; set($$, ID_float); } + | ATOK_GCC_FLOAT16 { $$=$1; set($$, ID_gcc_float16); } + | ATOK_GCC_FLOAT32 { $$=$1; set($$, ID_gcc_float32); } + | ATOK_GCC_FLOAT32X { $$=$1; set($$, ID_gcc_float32x); } + | ATOK_GCC_FLOAT64 { $$=$1; set($$, ID_gcc_float64); } + | ATOK_GCC_FLOAT64X { $$=$1; set($$, ID_gcc_float64x); } + | ATOK_GCC_FLOAT80 { $$=$1; set($$, ID_gcc_float80); } + | ATOK_GCC_FLOAT128 { $$=$1; set($$, ID_gcc_float128); } + | ATOK_GCC_FLOAT128X { $$=$1; set($$, ID_gcc_float128x); } + | ATOK_GCC_INT128 { $$=$1; set($$, ID_gcc_int128); } + | ATOK_GCC_DECIMAL32 { $$=$1; set($$, ID_gcc_decimal32); } + | ATOK_GCC_DECIMAL64 { $$=$1; set($$, ID_gcc_decimal64); } + | ATOK_GCC_DECIMAL128 { $$=$1; set($$, ID_gcc_decimal128); } + | ATOK_DOUBLE { $$=$1; set($$, ID_double); } + | ATOK_SIGNED { $$=$1; set($$, ID_signed); } + | ATOK_UNSIGNED { $$=$1; set($$, ID_unsigned); } + | ATOK_VOID { $$=$1; set($$, ID_void); } + | ATOK_BOOL { $$=$1; set($$, ID_c_bool); } + | ATOK_COMPLEX { $$=$1; set($$, ID_complex); } + | ATOK_CPROVER_BITVECTOR '[' comma_expression ']' { $$=$1; set($$, ID_custom_bv); parser_stack($$).add(ID_size).swap(parser_stack($3)); } - | TOK_CPROVER_FLOATBV '[' comma_expression ']' '[' comma_expression ']' + | ATOK_CPROVER_FLOATBV '[' comma_expression ']' '[' comma_expression ']' { $$=$1; set($$, ID_custom_floatbv); parser_stack($$).add(ID_size).swap(parser_stack($3)); parser_stack($$).add(ID_f).swap(parser_stack($6)); } - | TOK_CPROVER_FIXEDBV '[' comma_expression ']' '[' comma_expression ']' + | ATOK_CPROVER_FIXEDBV '[' comma_expression ']' '[' comma_expression ']' { $$=$1; set($$, ID_custom_fixedbv); parser_stack($$).add(ID_size).swap(parser_stack($3)); parser_stack($$).add(ID_f).swap(parser_stack($6)); } - | TOK_CPROVER_BOOL { $$=$1; set($$, ID_proper_bool); } + | ATOK_CPROVER_BOOL { $$=$1; set($$, ID_proper_bool); } ; elaborated_type_name: @@ -1532,7 +1538,7 @@ elaborated_type_name: ; array_of_construct: - TOK_ARRAY_OF '<' type_name '>' + ATOK_ARRAY_OF '<' type_name '>' { $$=$1; stack_type($$).add_subtype().swap(parser_stack($2)); } ; @@ -1600,40 +1606,40 @@ aggregate_name: ; aggregate_key: - TOK_STRUCT + ATOK_STRUCT { $$=$1; set($$, ID_struct); } - | TOK_UNION + | ATOK_UNION { $$=$1; set($$, ID_union); } ; gcc_type_attribute: - TOK_GCC_ATTRIBUTE_PACKED + ATOK_GCC_ATTRIBUTE_PACKED { $$=$1; set($$, ID_packed); } - | TOK_GCC_ATTRIBUTE_TRANSPARENT_UNION + | ATOK_GCC_ATTRIBUTE_TRANSPARENT_UNION { $$=$1; set($$, ID_transparent_union); } - | TOK_GCC_ATTRIBUTE_VECTOR_SIZE '(' comma_expression ')' + | ATOK_GCC_ATTRIBUTE_VECTOR_SIZE '(' comma_expression ')' { $$=$1; set($$, ID_frontend_vector); parser_stack($$).add(ID_size)=parser_stack($3); } - | TOK_GCC_ATTRIBUTE_ALIGNED + | ATOK_GCC_ATTRIBUTE_ALIGNED { $$=$1; set($$, ID_aligned); } - | TOK_GCC_ATTRIBUTE_ALIGNED '(' comma_expression ')' + | ATOK_GCC_ATTRIBUTE_ALIGNED '(' comma_expression ')' { $$=$1; set($$, ID_aligned); parser_stack($$).set(ID_size, parser_stack($3)); } - | TOK_GCC_ATTRIBUTE_MODE '(' identifier ')' + | ATOK_GCC_ATTRIBUTE_MODE '(' identifier ')' { $$=$1; set($$, ID_gcc_attribute_mode); parser_stack($$).set(ID_size, parser_stack($3).get(ID_identifier)); } - | TOK_GCC_ATTRIBUTE_GNU_INLINE + | ATOK_GCC_ATTRIBUTE_GNU_INLINE { $$=$1; set($$, ID_static); } /* GCC extern inline - cleanup in ansi_c_declarationt::to_symbol */ - | TOK_GCC_ATTRIBUTE_WEAK + | ATOK_GCC_ATTRIBUTE_WEAK { $$=$1; set($$, ID_weak); } - | TOK_GCC_ATTRIBUTE_ALIAS '(' TOK_STRING ')' + | ATOK_GCC_ATTRIBUTE_ALIAS '(' ATOK_STRING ')' { $$=$1; set($$, ID_alias); mto($$, $3); } - | TOK_GCC_ATTRIBUTE_SECTION '(' TOK_STRING ')' + | ATOK_GCC_ATTRIBUTE_SECTION '(' ATOK_STRING ')' { $$=$1; set($$, ID_section); mto($$, $3); } - | TOK_GCC_ATTRIBUTE_NORETURN + | ATOK_GCC_ATTRIBUTE_NORETURN { $$=$1; set($$, ID_noreturn); } - | TOK_GCC_ATTRIBUTE_CONSTRUCTOR + | ATOK_GCC_ATTRIBUTE_CONSTRUCTOR { $$=$1; set($$, ID_constructor); } - | TOK_GCC_ATTRIBUTE_DESTRUCTOR + | ATOK_GCC_ATTRIBUTE_DESTRUCTOR { $$=$1; set($$, ID_destructor); } - | TOK_GCC_ATTRIBUTE_USED + | ATOK_GCC_ATTRIBUTE_USED { $$=$1; set($$, ID_used); } ; @@ -1642,7 +1648,7 @@ gcc_attribute: { init($$); } - | TOK_GCC_ATTRIBUTE_FALLTHROUGH + | ATOK_GCC_ATTRIBUTE_FALLTHROUGH { // attribute ignored init($$); @@ -1659,9 +1665,9 @@ gcc_attribute_list: ; gcc_attribute_specifier: - TOK_GCC_ATTRIBUTE '(' '(' gcc_attribute_list ')' ')' + ATOK_GCC_ATTRIBUTE '(' '(' gcc_attribute_list ')' ')' { $$=$4; } - | TOK_NORETURN + | ATOK_NORETURN { $$=$1; set($$, ID_noreturn); } ; @@ -1916,7 +1922,7 @@ braced_enumerator_list_opt: $$=$2; } -enum_key: TOK_ENUM +enum_key: ATOK_ENUM { $$=$1; set($$, ID_c_enum); @@ -1972,7 +1978,7 @@ enumerator_value_opt: parameter_type_list: parameter_list - | parameter_list ',' TOK_ELLIPSIS + | parameter_list ',' ATOK_ELLIPSIS { typet tmp(ID_ellipsis); $$=$1; @@ -2254,7 +2260,7 @@ designator: mto($1, $2); mto($$, $1); } - | '[' comma_expression TOK_ELLIPSIS comma_expression ']' + | '[' comma_expression ATOK_ELLIPSIS comma_expression ']' { // TODO init($$); @@ -2269,7 +2275,7 @@ designator: mto($2, $3); mto($$, $2); } - | designator '[' comma_expression TOK_ELLIPSIS comma_expression ']' + | designator '[' comma_expression ATOK_ELLIPSIS comma_expression ']' { // TODO $$=$1; @@ -2326,12 +2332,12 @@ gcc_attribute_specifier_opt: ; msc_label_identifier: - TOK_MSC_IDENTIFIER - | TOK_TYPEDEFNAME + ATOK_MSC_IDENTIFIER + | ATOK_TYPEDEFNAME ; labeled_statement: - TOK_GCC_IDENTIFIER ':' gcc_attribute_specifier_opt stmt_not_decl_or_attr + ATOK_GCC_IDENTIFIER ':' gcc_attribute_specifier_opt stmt_not_decl_or_attr { // we ignore the GCC attribute $$=$2; @@ -2348,14 +2354,14 @@ labeled_statement: parser_stack($$).set(ID_label, identifier); mto($$, $3); } - | TOK_CASE constant_expression ':' statement + | ATOK_CASE constant_expression ':' statement { $$=$1; statement($$, ID_switch_case); mto($$, $2); mto($$, $4); } - | TOK_CASE constant_expression TOK_ELLIPSIS constant_expression ':' statement + | ATOK_CASE constant_expression ATOK_ELLIPSIS constant_expression ':' statement { // this is a GCC extension $$=$1; @@ -2364,7 +2370,7 @@ labeled_statement: mto($$, $4); mto($$, $6); } - | TOK_DEFAULT ':' statement + | ATOK_DEFAULT ':' statement { $$=$1; statement($$, ID_switch_case); @@ -2377,7 +2383,7 @@ labeled_statement: statement_attribute: gcc_attribute_specifier ';' { - // Really should only be TOK_GCC_ATTRIBUTE_FALLTHROUGH or a label + // Really should only be ATOK_GCC_ATTRIBUTE_FALLTHROUGH or a label // attribute. Only semicolons permitted after the attribute: // https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html // We ignore all such attributes. @@ -2402,7 +2408,7 @@ compound_statement: parser_stack($$).operands().swap(parser_stack($3).operands()); PARSER.pop_scope(); } - | compound_scope '{' TOK_ASM_STRING '}' + | compound_scope '{' ATOK_ASM_STRING '}' { $$=$2; statement($$, ID_asm); @@ -2448,21 +2454,21 @@ expression_statement: ; selection_statement: - TOK_IF '(' comma_expression ')' statement + ATOK_IF '(' comma_expression ')' statement { $$=$1; statement($$, ID_ifthenelse); parser_stack($$).add_to_operands( std::move(parser_stack($3)), std::move(parser_stack($5)), nil_exprt()); } - | TOK_IF '(' comma_expression ')' statement TOK_ELSE statement + | ATOK_IF '(' comma_expression ')' statement ATOK_ELSE statement { $$=$1; statement($$, ID_ifthenelse); parser_stack($$).add_to_operands( std::move(parser_stack($3)), std::move(parser_stack($5)), std::move(parser_stack($7))); } - | TOK_SWITCH '(' comma_expression ')' statement + | ATOK_SWITCH '(' comma_expression ')' statement { $$=$1; statement($$, ID_switch); @@ -2476,7 +2482,7 @@ declaration_or_expression_statement: ; iteration_statement: - TOK_WHILE '(' comma_expression_opt ')' + ATOK_WHILE '(' comma_expression_opt ')' cprover_contract_assigns_opt cprover_contract_loop_invariant_list_opt cprover_contract_decreases_opt @@ -2495,12 +2501,12 @@ iteration_statement: if(!parser_stack($7).operands().empty()) static_cast(parser_stack($$).add(ID_C_spec_decreases)).operands().swap(parser_stack($7).operands()); } - | TOK_DO + | ATOK_DO cprover_contract_assigns_opt cprover_contract_loop_invariant_list_opt cprover_contract_decreases_opt statement - TOK_WHILE '(' comma_expression ')' ';' + ATOK_WHILE '(' comma_expression ')' ';' { $$=$1; statement($$, ID_dowhile); @@ -2515,7 +2521,7 @@ iteration_statement: if(!parser_stack($4).operands().empty()) static_cast(parser_stack($$).add(ID_C_spec_decreases)).operands().swap(parser_stack($4).operands()); } - | TOK_FOR + | ATOK_FOR { // In C99 and upwards, for(;;) has a scope if(PARSER.for_has_scope) @@ -2555,7 +2561,7 @@ iteration_statement: ; jump_statement: - TOK_GOTO comma_expression ';' + ATOK_GOTO comma_expression ';' { $$=$1; if(parser_stack($2).id()==ID_symbol) @@ -2572,29 +2578,29 @@ jump_statement: mto($$, $2); } } - | TOK_GOTO typedef_name ';' + | ATOK_GOTO typedef_name ';' { $$=$1; statement($$, ID_goto); irep_idt identifier=PARSER.lookup_label(parser_stack($2).get(ID_C_base_name)); parser_stack($$).set(ID_destination, identifier); } - | TOK_CONTINUE ';' + | ATOK_CONTINUE ';' { $$=$1; statement($$, ID_continue); } - | TOK_BREAK ';' + | ATOK_BREAK ';' { $$=$1; statement($$, ID_break); } - | TOK_RETURN ';' + | ATOK_RETURN ';' { $$=$1; statement($$, ID_return); parser_stack($$).operands().push_back(nil_exprt()); } - | TOK_RETURN comma_expression ';' + | ATOK_RETURN comma_expression ';' { $$=$1; statement($$, ID_return); mto($$, $2); } ; gcc_local_label_statement: - TOK_GCC_LABEL gcc_local_label_list ';' + ATOK_GCC_LABEL gcc_local_label_list ';' { $$=$1; statement($$, ID_gcc_local_label); @@ -2632,13 +2638,13 @@ gcc_local_label: identifier_or_typedef_name ; gcc_asm_statement: - TOK_GCC_ASM_PAREN volatile_or_goto_opt '(' gcc_asm_commands ')' ';' + ATOK_GCC_ASM_PAREN volatile_or_goto_opt '(' gcc_asm_commands ')' ';' { $$=$1; statement($$, ID_asm); parser_stack($$).set(ID_flavor, ID_gcc); parser_stack($$).operands().swap(parser_stack($4).operands()); } - | TOK_GCC_ASM_PAREN volatile_or_goto_opt '{' TOK_ASM_STRING '}' + | ATOK_GCC_ASM_PAREN volatile_or_goto_opt '{' ATOK_ASM_STRING '}' { $$=$1; statement($$, ID_asm); @@ -2649,13 +2655,13 @@ gcc_asm_statement: ; msc_asm_statement: - TOK_MSC_ASM '{' TOK_ASM_STRING '}' + ATOK_MSC_ASM '{' ATOK_ASM_STRING '}' { $$=$1; statement($$, ID_asm); parser_stack($$).set(ID_flavor, ID_msc); mto($$, $3); } - | TOK_MSC_ASM TOK_ASM_STRING + | ATOK_MSC_ASM ATOK_ASM_STRING { $$=$1; statement($$, ID_asm); parser_stack($$).set(ID_flavor, ID_msc); @@ -2664,8 +2670,8 @@ msc_asm_statement: ; msc_seh_statement: - TOK_MSC_TRY compound_statement - TOK_MSC_EXCEPT '(' comma_expression ')' compound_statement + ATOK_MSC_TRY compound_statement + ATOK_MSC_EXCEPT '(' comma_expression ')' compound_statement { $$=$1; statement($$, ID_msc_try_except); @@ -2673,15 +2679,15 @@ msc_seh_statement: mto($$, $5); mto($$, $7); } - | TOK_MSC_TRY compound_statement - TOK_MSC_FINALLY compound_statement + | ATOK_MSC_TRY compound_statement + ATOK_MSC_FINALLY compound_statement { $$=$1; statement($$, ID_msc_try_finally); mto($$, $2); mto($$, $4); } - | TOK_MSC_LEAVE + | ATOK_MSC_LEAVE { $$=$1; statement($$, ID_msc_leave); @@ -2689,21 +2695,21 @@ msc_seh_statement: ; cprover_exception_statement: - TOK_CPROVER_THROW ';' + ATOK_CPROVER_THROW ';' { $$=$1; statement($$, ID_CPROVER_throw); } - | TOK_CPROVER_TRY compound_statement - TOK_CPROVER_CATCH compound_statement + | ATOK_CPROVER_TRY compound_statement + ATOK_CPROVER_CATCH compound_statement { $$=$1; statement($$, ID_CPROVER_try_catch); mto($$, $2); mto($$, $4); } - | TOK_CPROVER_TRY compound_statement - TOK_CPROVER_FINALLY compound_statement + | ATOK_CPROVER_TRY compound_statement + ATOK_CPROVER_FINALLY compound_statement { $$=$1; statement($$, ID_CPROVER_try_finally); @@ -2714,9 +2720,9 @@ cprover_exception_statement: volatile_or_goto_opt: /* nothing */ - | volatile_or_goto_opt TOK_VOLATILE - | volatile_or_goto_opt TOK_GOTO - | volatile_or_goto_opt TOK_INLINE + | volatile_or_goto_opt ATOK_VOLATILE + | volatile_or_goto_opt ATOK_GOTO + | volatile_or_goto_opt ATOK_INLINE ; /* asm ( assembler template @@ -2931,11 +2937,11 @@ external_definition: ; asm_definition: - TOK_GCC_ASM_PAREN '(' string ')' ';' + ATOK_GCC_ASM_PAREN '(' string ')' ';' { // Not obvious what to do with this. } - | '{' TOK_ASM_STRING '}' + | '{' ATOK_ASM_STRING '}' { // Not obvious what to do with this. } @@ -3319,13 +3325,13 @@ parameter_abstract_declarator: ; cprover_function_contract: - TOK_CPROVER_ENSURES '(' ACSL_binding_expression ')' + ATOK_CPROVER_ENSURES '(' ACSL_binding_expression ')' { $$=$1; set($$, ID_C_spec_ensures); mto($$, $3); } - | TOK_CPROVER_REQUIRES '(' ACSL_binding_expression ')' + | ATOK_CPROVER_REQUIRES '(' ACSL_binding_expression ')' { $$=$1; set($$, ID_C_spec_requires); @@ -3390,13 +3396,13 @@ conditional_target_list_opt_semicol: } cprover_contract_assigns: - TOK_CPROVER_ASSIGNS '(' conditional_target_list_opt_semicol ')' + ATOK_CPROVER_ASSIGNS '(' conditional_target_list_opt_semicol ')' { $$=$1; set($$, ID_C_spec_assigns); mto($$, $3); } - | TOK_CPROVER_ASSIGNS '(' ')' + | ATOK_CPROVER_ASSIGNS '(' ')' { $$=$1; set($$, ID_C_spec_assigns); @@ -3411,13 +3417,13 @@ cprover_contract_assigns_opt: ; cprover_contract_frees: - TOK_CPROVER_FREES '(' conditional_target_list_opt_semicol ')' + ATOK_CPROVER_FREES '(' conditional_target_list_opt_semicol ')' { $$=$1; set($$, ID_C_spec_frees); mto($$, $3); } - | TOK_CPROVER_FREES '(' ')' + | ATOK_CPROVER_FREES '(' ')' { $$=$1; set($$, ID_C_spec_frees); diff --git a/src/ansi-c/scanner.l b/src/ansi-c/scanner.l index a55fc3b1fc0b..f6182c87e9a3 100644 --- a/src/ansi-c/scanner.l +++ b/src/ansi-c/scanner.l @@ -87,7 +87,7 @@ int make_identifier() parser_stack(yyansi_clval).id(ID_symbol); parser_stack(yyansi_clval).set(ID_C_base_name, final_base_name); return PARSER.mode == configt::ansi_ct::flavourt::VISUAL_STUDIO ? - TOK_MSC_IDENTIFIER : TOK_GCC_IDENTIFIER; + ATOK_MSC_IDENTIFIER : ATOK_GCC_IDENTIFIER; } else { @@ -108,13 +108,13 @@ int make_identifier() if(result==ansi_c_id_classt::ANSI_C_TYPEDEF) { parser_stack(yyansi_clval).id(ID_typedef_type); - return TOK_TYPEDEFNAME; + return ATOK_TYPEDEFNAME; } else { parser_stack(yyansi_clval).id(ID_symbol); return PARSER.mode == configt::ansi_ct::flavourt::VISUAL_STUDIO ? - TOK_MSC_IDENTIFIER : TOK_GCC_IDENTIFIER; + ATOK_MSC_IDENTIFIER : ATOK_GCC_IDENTIFIER; } } } @@ -174,7 +174,7 @@ int cpp_operator(int token) else { yyansi_cerror("C++ operator not allowed in C mode"); - return TOK_SCANNER_ERROR; + return ATOK_SCANNER_ERROR; } } @@ -286,7 +286,7 @@ void ansi_c_scanner_init() { "*/" { BEGIN(GRAMMAR); } /* end comment state, back to GRAMMAR */ "/*" { yyansi_cerror("Probably nested comments"); } - <> { yyansi_cerror("Unterminated comment"); return TOK_SCANNER_ERROR; } + <> { yyansi_cerror("Unterminated comment"); return ATOK_SCANNER_ERROR; } [^*/\n]* { /* ignore every char except '*' and NL (performance!) */ } . { } /* all single characters within comments are ignored */ \n { } @@ -295,7 +295,7 @@ void ansi_c_scanner_init() { "*/" { yy_pop_state(); } /* end comment state, back to STRING_LITERAL */ "/*" { yyansi_cerror("Probably nested comments"); } - <> { yyansi_cerror("Unterminated comment"); return TOK_SCANNER_ERROR; } + <> { yyansi_cerror("Unterminated comment"); return ATOK_SCANNER_ERROR; } [^*/\n]* { /* ignore every char except '*' and NL (performance!) */ } . { } /* all single characters within comments are ignored */ \n { } @@ -312,7 +312,7 @@ void ansi_c_scanner_init() loc(); source_locationt l=parser_stack(yyansi_clval).source_location(); parser_stack(yyansi_clval)=convert_character_literal(yytext, true, l); - return TOK_CHARACTER; + return ATOK_CHARACTER; } {string_lit} { @@ -342,7 +342,7 @@ void ansi_c_scanner_init() parser_stack(yyansi_clval).add_source_location().swap(l); yy_pop_state(); // back to normal yyless(0); // put back - return TOK_STRING; + return ATOK_STRING; } {newline} { } /* skipped */ @@ -427,7 +427,7 @@ void ansi_c_scanner_init() yyansi_cerror( "Found enable and disable pragmas for " + id2string(check_name)); - return TOK_SCANNER_ERROR; + return ATOK_SCANNER_ERROR; } PARSER.pragma_cprover_add_check(check_name, enable); PARSER.set_pragma_cprover(); @@ -435,7 +435,7 @@ void ansi_c_scanner_init() . { yyansi_cerror("Unsupported #pragma CPROVER"); - return TOK_SCANNER_ERROR; + return ATOK_SCANNER_ERROR; } {cppstart}"pragma" { BEGIN(OTHER_PRAGMA); } @@ -467,7 +467,7 @@ void ansi_c_scanner_init() {cppdirective} { yyansi_cerror("Preprocessor directive found"); - return TOK_SCANNER_ERROR; + return ATOK_SCANNER_ERROR; } %{ @@ -475,175 +475,175 @@ void ansi_c_scanner_init() %} { -"auto" { loc(); return TOK_AUTO; } +"auto" { loc(); return ATOK_AUTO; } "_Bool" { if(PARSER.cpp98) return make_identifier(); else - { loc(); return TOK_BOOL; } - } -"break" { loc(); return TOK_BREAK; } -"case" { loc(); return TOK_CASE; } -"char" { loc(); return TOK_CHAR; } -"_Complex" { loc(); return TOK_COMPLEX; } -"const" { loc(); return TOK_CONST; } -"continue" { loc(); return TOK_CONTINUE; } -"default" { loc(); return TOK_DEFAULT; } -"do" { loc(); return TOK_DO; } -"double" { loc(); return TOK_DOUBLE; } -"else" { loc(); return TOK_ELSE; } -"enum" { loc(); PARSER.tag_following=true; return TOK_ENUM; } -"extern" { loc(); return TOK_EXTERN; } -"float" { loc(); return TOK_FLOAT; } -"for" { loc(); return TOK_FOR; } -"goto" { loc(); return TOK_GOTO; } -"if" { loc(); return TOK_IF; } -"inline" { loc(); return TOK_INLINE; } -"int" { loc(); return TOK_INT; } -"long" { loc(); return TOK_LONG; } -"register" { loc(); return TOK_REGISTER; } -"restrict" { loc(); return TOK_RESTRICT; } -"return" { loc(); return TOK_RETURN; } -"short" { loc(); return TOK_SHORT; } -"signed" { loc(); return TOK_SIGNED; } -"sizeof" { loc(); return TOK_SIZEOF; } -"static" { loc(); return TOK_STATIC; } -"struct" { loc(); PARSER.tag_following=true; return TOK_STRUCT; } -"switch" { loc(); return TOK_SWITCH; } -"typedef" { loc(); return TOK_TYPEDEF; } -"union" { loc(); PARSER.tag_following=true; return TOK_UNION; } -"unsigned" { loc(); return TOK_UNSIGNED; } -"void" { loc(); return TOK_VOID; } -"volatile" { loc(); return TOK_VOLATILE; } -"while" { loc(); return TOK_WHILE; } + { loc(); return ATOK_BOOL; } + } +"break" { loc(); return ATOK_BREAK; } +"case" { loc(); return ATOK_CASE; } +"char" { loc(); return ATOK_CHAR; } +"_Complex" { loc(); return ATOK_COMPLEX; } +"const" { loc(); return ATOK_CONST; } +"continue" { loc(); return ATOK_CONTINUE; } +"default" { loc(); return ATOK_DEFAULT; } +"do" { loc(); return ATOK_DO; } +"double" { loc(); return ATOK_DOUBLE; } +"else" { loc(); return ATOK_ELSE; } +"enum" { loc(); PARSER.tag_following=true; return ATOK_ENUM; } +"extern" { loc(); return ATOK_EXTERN; } +"float" { loc(); return ATOK_FLOAT; } +"for" { loc(); return ATOK_FOR; } +"goto" { loc(); return ATOK_GOTO; } +"if" { loc(); return ATOK_IF; } +"inline" { loc(); return ATOK_INLINE; } +"int" { loc(); return ATOK_INT; } +"long" { loc(); return ATOK_LONG; } +"register" { loc(); return ATOK_REGISTER; } +"restrict" { loc(); return ATOK_RESTRICT; } +"return" { loc(); return ATOK_RETURN; } +"short" { loc(); return ATOK_SHORT; } +"signed" { loc(); return ATOK_SIGNED; } +"sizeof" { loc(); return ATOK_SIZEOF; } +"static" { loc(); return ATOK_STATIC; } +"struct" { loc(); PARSER.tag_following=true; return ATOK_STRUCT; } +"switch" { loc(); return ATOK_SWITCH; } +"typedef" { loc(); return ATOK_TYPEDEF; } +"union" { loc(); PARSER.tag_following=true; return ATOK_UNION; } +"unsigned" { loc(); return ATOK_UNSIGNED; } +"void" { loc(); return ATOK_VOID; } +"volatile" { loc(); return ATOK_VOLATILE; } +"while" { loc(); return ATOK_WHILE; } "__auto_type" { if((PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG) && !PARSER.cpp98) - { loc(); return TOK_GCC_AUTO_TYPE; } + { loc(); return ATOK_GCC_AUTO_TYPE; } else return make_identifier(); } "_Float16" { if(PARSER.ts_18661_3_Floatn_types) - { loc(); return TOK_GCC_FLOAT16; } + { loc(); return ATOK_GCC_FLOAT16; } else return make_identifier(); } "__bf16" { if(PARSER.ts_18661_3_Floatn_types) - { loc(); return TOK_GCC_FLOAT16; } + { loc(); return ATOK_GCC_FLOAT16; } else return make_identifier(); } "_Float32" { if(PARSER.ts_18661_3_Floatn_types) - { loc(); return TOK_GCC_FLOAT32; } + { loc(); return ATOK_GCC_FLOAT32; } else return make_identifier(); } "_Float32x" { if(PARSER.ts_18661_3_Floatn_types) - { loc(); return TOK_GCC_FLOAT32X; } + { loc(); return ATOK_GCC_FLOAT32X; } else return make_identifier(); } "_Float64" { if(PARSER.ts_18661_3_Floatn_types) - { loc(); return TOK_GCC_FLOAT64; } + { loc(); return ATOK_GCC_FLOAT64; } else return make_identifier(); } "_Float64x" { if(PARSER.ts_18661_3_Floatn_types) - { loc(); return TOK_GCC_FLOAT64X; } + { loc(); return ATOK_GCC_FLOAT64X; } else return make_identifier(); } {CPROVER_PREFIX}"Float64x" { - loc(); return TOK_GCC_FLOAT64X; + loc(); return ATOK_GCC_FLOAT64X; } {CPROVER_PREFIX}"Float80" { - loc(); return TOK_GCC_FLOAT80; + loc(); return ATOK_GCC_FLOAT80; } "__float128" { // This is a keyword for CLANG, // but a typedef for GCC if(PARSER.mode==configt::ansi_ct::flavourt::CLANG) - { loc(); return TOK_GCC_FLOAT128; } + { loc(); return ATOK_GCC_FLOAT128; } else return make_identifier(); } "_Float128" { if(PARSER.ts_18661_3_Floatn_types) - { loc(); return TOK_GCC_FLOAT128; } + { loc(); return ATOK_GCC_FLOAT128; } else return make_identifier(); } {CPROVER_PREFIX}"Float128" { - loc(); return TOK_GCC_FLOAT128; + loc(); return ATOK_GCC_FLOAT128; } "_Float128x" { if(PARSER.ts_18661_3_Floatn_types) - { loc(); return TOK_GCC_FLOAT128X; } + { loc(); return ATOK_GCC_FLOAT128X; } else return make_identifier(); } "__int128" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG) - { loc(); return TOK_GCC_INT128; } + { loc(); return ATOK_GCC_INT128; } else return make_identifier(); } "_Decimal32" { // clang doesn't have it if(PARSER.mode==configt::ansi_ct::flavourt::GCC) - { loc(); return TOK_GCC_DECIMAL32; } + { loc(); return ATOK_GCC_DECIMAL32; } else return make_identifier(); } "_Decimal64" { // clang doesn't have it if(PARSER.mode==configt::ansi_ct::flavourt::GCC) - { loc(); return TOK_GCC_DECIMAL64; } + { loc(); return ATOK_GCC_DECIMAL64; } else return make_identifier(); } "_Decimal128" { // clang doesn't have it if(PARSER.mode==configt::ansi_ct::flavourt::GCC) - { loc(); return TOK_GCC_DECIMAL128; } + { loc(); return ATOK_GCC_DECIMAL128; } else return make_identifier(); } -"__int8" { return MSC_Keyword(TOK_INT8); } -"__int16" { return MSC_Keyword(TOK_INT16); } -"__int32" { return MSC_Keyword(TOK_INT32); } +"__int8" { return MSC_Keyword(ATOK_INT8); } +"__int16" { return MSC_Keyword(ATOK_INT16); } +"__int32" { return MSC_Keyword(ATOK_INT32); } "__int64" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO || PARSER.mode==configt::ansi_ct::flavourt::ARM || PARSER.mode==configt::ansi_ct::flavourt::CODEWARRIOR) - { loc(); return TOK_INT64; } + { loc(); return ATOK_INT64; } else return make_identifier(); } "_int64" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) - { loc(); return TOK_INT64; } + { loc(); return ATOK_INT64; } else return make_identifier(); } -"__ptr32" { return MSC_Keyword(TOK_PTR32); } -"__ptr64" { return MSC_Keyword(TOK_PTR64); } +"__ptr32" { return MSC_Keyword(ATOK_PTR32); } +"__ptr64" { return MSC_Keyword(ATOK_PTR64); } %{ /* -"__stdcall" { return MSC_Keyword(TOK_STDCALL); } -"__fastcall" { return MSC_Keyword(TOK_FASTCALL); } -"__clrcall" { return MSC_Keyword(TOK_CLRCALL); } +"__stdcall" { return MSC_Keyword(ATOK_STDCALL); } +"__fastcall" { return MSC_Keyword(ATOK_FASTCALL); } +"__clrcall" { return MSC_Keyword(ATOK_CLRCALL); } */ %} @@ -651,7 +651,7 @@ void ansi_c_scanner_init() "__complex" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_COMPLEX; } + { loc(); return ATOK_COMPLEX; } else return make_identifier(); } @@ -660,7 +660,7 @@ void ansi_c_scanner_init() "__real" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_REAL; } + { loc(); return ATOK_REAL; } else return make_identifier(); } @@ -669,7 +669,7 @@ void ansi_c_scanner_init() "__imag" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_IMAG; } + { loc(); return ATOK_IMAG; } else return make_identifier(); } @@ -680,7 +680,7 @@ void ansi_c_scanner_init() %} "_var_arg_typeof" { if(PARSER.mode==configt::ansi_ct::flavourt::CODEWARRIOR) - { loc(); return TOK_CW_VAR_ARG_TYPEOF; } + { loc(); return ATOK_CW_VAR_ARG_TYPEOF; } else return make_identifier(); } @@ -688,7 +688,7 @@ void ansi_c_scanner_init() "__builtin_va_arg" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_BUILTIN_VA_ARG; } + { loc(); return ATOK_BUILTIN_VA_ARG; } else return make_identifier(); } @@ -698,7 +698,7 @@ void ansi_c_scanner_init() "offsetof" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_OFFSETOF; } + { loc(); return ATOK_OFFSETOF; } else return make_identifier(); } @@ -707,7 +707,7 @@ void ansi_c_scanner_init() if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_GCC_BUILTIN_TYPES_COMPATIBLE_P; } + { loc(); return ATOK_GCC_BUILTIN_TYPES_COMPATIBLE_P; } else return make_identifier(); } @@ -715,7 +715,7 @@ void ansi_c_scanner_init() "__builtin_convertvector" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG) - { loc(); return TOK_CLANG_BUILTIN_CONVERTVECTOR; } + { loc(); return ATOK_CLANG_BUILTIN_CONVERTVECTOR; } else return make_identifier(); } @@ -723,7 +723,7 @@ void ansi_c_scanner_init() "__alignof__" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_ALIGNOF; } + { loc(); return ATOK_ALIGNOF; } else return make_identifier(); } @@ -734,13 +734,13 @@ void ansi_c_scanner_init() PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_ALIGNOF; } + { loc(); return ATOK_ALIGNOF; } else return make_identifier(); } "__ALIGNOF__" { if(PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_ALIGNOF; } + { loc(); return ATOK_ALIGNOF; } else return make_identifier(); } @@ -750,7 +750,7 @@ void ansi_c_scanner_init() // but Visual Studio does! if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_ALIGNOF; } + { loc(); return ATOK_ALIGNOF; } else return make_identifier(); } @@ -759,12 +759,12 @@ void ansi_c_scanner_init() { loc(); BEGIN(MSC_ASM); - return TOK_MSC_ASM; + return ATOK_MSC_ASM; } else if(PARSER.cpp98) { loc(); - return TOK_GCC_ASM; + return ATOK_GCC_ASM; } else BEGIN(GCC_ASM); @@ -777,7 +777,7 @@ void ansi_c_scanner_init() if(PARSER.cpp98) { loc(); - return TOK_GCC_ASM; + return ATOK_GCC_ASM; } else BEGIN(GCC_ASM); @@ -794,7 +794,7 @@ void ansi_c_scanner_init() if(PARSER.cpp98) { loc(); - return TOK_GCC_ASM; + return ATOK_GCC_ASM; } else BEGIN(GCC_ASM); @@ -804,7 +804,7 @@ void ansi_c_scanner_init() } "__based" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) - { loc(); return TOK_MSC_BASED; } + { loc(); return ATOK_MSC_BASED; } else return make_identifier(); } @@ -816,7 +816,7 @@ void ansi_c_scanner_init() } "__wchar_t" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) - { loc(); return TOK_WCHAR_T; } + { loc(); return ATOK_WCHAR_T; } else return make_identifier(); } @@ -825,77 +825,77 @@ void ansi_c_scanner_init() /* C++ Keywords and Operators */ %} -alignas { return cpp11_keyword(TOK_ALIGNAS); } // C++11 -alignof { return cpp11_keyword(TOK_ALIGNOF); } // C++11 -and { return cpp98_keyword(TOK_ANDAND); } -and_eq { return cpp98_keyword(TOK_ANDASSIGN); } -bool { return cpp98_keyword(TOK_BOOL); } -catch { return cpp98_keyword(TOK_CATCH); } +alignas { return cpp11_keyword(ATOK_ALIGNAS); } // C++11 +alignof { return cpp11_keyword(ATOK_ALIGNOF); } // C++11 +and { return cpp98_keyword(ATOK_ANDAND); } +and_eq { return cpp98_keyword(ATOK_ANDASSIGN); } +bool { return cpp98_keyword(ATOK_BOOL); } +catch { return cpp98_keyword(ATOK_CATCH); } char16_t { // C++11, but Visual Studio uses typedefs if(PARSER.mode == configt::ansi_ct::flavourt::VISUAL_STUDIO) return make_identifier(); else - return cpp11_keyword(TOK_CHAR16_T); + return cpp11_keyword(ATOK_CHAR16_T); } char32_t { // C++11, but Visual Studio uses typedefs if(PARSER.mode == configt::ansi_ct::flavourt::VISUAL_STUDIO) return make_identifier(); else - return cpp11_keyword(TOK_CHAR32_T); + return cpp11_keyword(ATOK_CHAR32_T); } -class { return cpp98_keyword(TOK_CLASS); } +class { return cpp98_keyword(ATOK_CLASS); } compl { return cpp98_keyword('~'); } -constexpr { return cpp11_keyword(TOK_CONSTEXPR); } // C++11 -delete { return cpp98_keyword(TOK_DELETE); } -decltype { return cpp11_keyword(TOK_DECLTYPE); } // C++11 -explicit { return cpp98_keyword(TOK_EXPLICIT); } -false { return cpp98_keyword(TOK_FALSE); } -friend { return cpp98_keyword(TOK_FRIEND); } -mutable { return cpp98_keyword(TOK_MUTABLE); } -namespace { return cpp98_keyword(TOK_NAMESPACE); } -new { return cpp98_keyword(TOK_NEW); } -noexcept { return cpp11_keyword(TOK_NOEXCEPT); } // C++11 -noreturn { return cpp11_keyword(TOK_NORETURN); } // C++11 +constexpr { return cpp11_keyword(ATOK_CONSTEXPR); } // C++11 +delete { return cpp98_keyword(ATOK_DELETE); } +decltype { return cpp11_keyword(ATOK_DECLTYPE); } // C++11 +explicit { return cpp98_keyword(ATOK_EXPLICIT); } +false { return cpp98_keyword(ATOK_FALSE); } +friend { return cpp98_keyword(ATOK_FRIEND); } +mutable { return cpp98_keyword(ATOK_MUTABLE); } +namespace { return cpp98_keyword(ATOK_NAMESPACE); } +new { return cpp98_keyword(ATOK_NEW); } +noexcept { return cpp11_keyword(ATOK_NOEXCEPT); } // C++11 +noreturn { return cpp11_keyword(ATOK_NORETURN); } // C++11 not { return cpp98_keyword('!'); } -not_eq { return cpp98_keyword(TOK_NE); } -nullptr { return cpp11_keyword(TOK_NULLPTR); } // C++11 -operator { return cpp98_keyword(TOK_OPERATOR); } -or { return cpp98_keyword(TOK_OROR); } -or_eq { return cpp98_keyword(TOK_ORASSIGN); } -private { return cpp98_keyword(TOK_PRIVATE); } -protected { return cpp98_keyword(TOK_PROTECTED); } -public { return cpp98_keyword(TOK_PUBLIC); } +not_eq { return cpp98_keyword(ATOK_NE); } +nullptr { return cpp11_keyword(ATOK_NULLPTR); } // C++11 +operator { return cpp98_keyword(ATOK_OPERATOR); } +or { return cpp98_keyword(ATOK_OROR); } +or_eq { return cpp98_keyword(ATOK_ORASSIGN); } +private { return cpp98_keyword(ATOK_PRIVATE); } +protected { return cpp98_keyword(ATOK_PROTECTED); } +public { return cpp98_keyword(ATOK_PUBLIC); } static_assert { // C++11, but Visual Studio supports it in all modes (and // doesn't support _Static_assert) if(PARSER.mode == configt::ansi_ct::flavourt::VISUAL_STUDIO) { - loc(); return TOK_STATIC_ASSERT; + loc(); return ATOK_STATIC_ASSERT; } else - return cpp11_keyword(TOK_STATIC_ASSERT); + return cpp11_keyword(ATOK_STATIC_ASSERT); } -template { return cpp98_keyword(TOK_TEMPLATE); } -this { return cpp98_keyword(TOK_THIS); } -thread_local { return cpp11_keyword(TOK_THREAD_LOCAL); } // C++11 -throw { return cpp98_keyword(TOK_THROW); } -true { return cpp98_keyword(TOK_TRUE); } -typeid { return cpp98_keyword(TOK_TYPEID); } -typename { return cpp98_keyword(TOK_TYPENAME); } -using { return cpp98_keyword(TOK_USING); } -virtual { return cpp98_keyword(TOK_VIRTUAL); } +template { return cpp98_keyword(ATOK_TEMPLATE); } +this { return cpp98_keyword(ATOK_THIS); } +thread_local { return cpp11_keyword(ATOK_THREAD_LOCAL); } // C++11 +throw { return cpp98_keyword(ATOK_THROW); } +true { return cpp98_keyword(ATOK_TRUE); } +typeid { return cpp98_keyword(ATOK_TYPEID); } +typename { return cpp98_keyword(ATOK_TYPENAME); } +using { return cpp98_keyword(ATOK_USING); } +virtual { return cpp98_keyword(ATOK_VIRTUAL); } wchar_t { // CodeWarrior doesn't have wchar_t built in, // and MSC has a command-line option to turn it off if(PARSER.mode==configt::ansi_ct::flavourt::CODEWARRIOR) return make_identifier(); else - return cpp98_keyword(TOK_WCHAR_T); + return cpp98_keyword(ATOK_WCHAR_T); } xor { return cpp98_keyword('^'); } -xor_eq { return cpp98_keyword(TOK_XORASSIGN); } -".*" { return cpp_operator(TOK_DOTPM); } -"->*" { return cpp_operator(TOK_ARROWPM); } +xor_eq { return cpp98_keyword(ATOK_XORASSIGN); } +".*" { return cpp_operator(ATOK_DOTPM); } +"->*" { return cpp_operator(ATOK_ARROWPM); } "::" { if(PARSER.cpp98) - return cpp_operator(TOK_SCOPE); + return cpp_operator(ATOK_SCOPE); else { yyless(1); // puts all but one : back into stream @@ -908,7 +908,7 @@ xor_eq { return cpp98_keyword(TOK_XORASSIGN); } __decltype { if(PARSER.cpp98 && (PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG)) - return cpp98_keyword(TOK_DECLTYPE); + return cpp98_keyword(ATOK_DECLTYPE); else return make_identifier(); } @@ -920,38 +920,38 @@ __decltype { if(PARSER.cpp98 && http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-type-trait-primitives */ %} -"__has_assign" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_copy" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_finalizer" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_nothrow_assign" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_nothrow_constructor" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_nothrow_copy" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_trivial_assign" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_trivial_constructor" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_trivial_copy" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_trivial_destructor" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_user_destructor" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__has_virtual_destructor" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_abstract" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_base_of" { loc(); return cpp98_keyword(TOK_BINARY_TYPE_PREDICATE); } -"__is_class" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_convertible_to" { loc(); return cpp98_keyword(TOK_BINARY_TYPE_PREDICATE); } -"__is_delegate" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_empty" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_enum" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_interface_class" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_pod" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_polymorphic" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_ref_array" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_ref_class" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_sealed" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_simple_value_class" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_union" { loc(); return cpp98_keyword(TOK_UNARY_TYPE_PREDICATE); } -"__is_value_class" { loc(); return MSC_cpp_keyword(TOK_UNARY_TYPE_PREDICATE); } - -"__if_exists" { loc(); return MSC_cpp_keyword(TOK_MSC_IF_EXISTS); } -"__if_not_exists" { loc(); return MSC_cpp_keyword(TOK_MSC_IF_NOT_EXISTS); } -"__underlying_type" { loc(); return cpp98_keyword(TOK_UNDERLYING_TYPE); } +"__has_assign" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_copy" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_finalizer" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_nothrow_assign" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_nothrow_constructor" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_nothrow_copy" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_trivial_assign" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_trivial_constructor" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_trivial_copy" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_trivial_destructor" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_user_destructor" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__has_virtual_destructor" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_abstract" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_base_of" { loc(); return cpp98_keyword(ATOK_BINARY_TYPE_PREDICATE); } +"__is_class" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_convertible_to" { loc(); return cpp98_keyword(ATOK_BINARY_TYPE_PREDICATE); } +"__is_delegate" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_empty" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_enum" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_interface_class" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_pod" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_polymorphic" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_ref_array" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_ref_class" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_sealed" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_simple_value_class" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_union" { loc(); return cpp98_keyword(ATOK_UNARY_TYPE_PREDICATE); } +"__is_value_class" { loc(); return MSC_cpp_keyword(ATOK_UNARY_TYPE_PREDICATE); } + +"__if_exists" { loc(); return MSC_cpp_keyword(ATOK_MSC_IF_EXISTS); } +"__if_not_exists" { loc(); return MSC_cpp_keyword(ATOK_MSC_IF_NOT_EXISTS); } +"__underlying_type" { loc(); return cpp98_keyword(ATOK_UNDERLYING_TYPE); } "["{ws}"repeatable" | "["{ws}"source_annotation_attribute" | @@ -976,28 +976,28 @@ __decltype { if(PARSER.cpp98 && "__char16_t" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG) - return cpp98_keyword(TOK_CHAR16_T); // GNU extension + return cpp98_keyword(ATOK_CHAR16_T); // GNU extension else return make_identifier(); } "__nullptr" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG) - return cpp98_keyword(TOK_NULLPTR); // GNU extension + return cpp98_keyword(ATOK_NULLPTR); // GNU extension else return make_identifier(); } "__null" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG) - return cpp98_keyword(TOK_NULLPTR); // GNU extension + return cpp98_keyword(ATOK_NULLPTR); // GNU extension else return make_identifier(); } "__char32_t" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG) - return cpp98_keyword(TOK_CHAR32_T); // GNU extension + return cpp98_keyword(ATOK_CHAR32_T); // GNU extension else return make_identifier(); } @@ -1011,13 +1011,13 @@ __decltype { if(PARSER.cpp98 && PARSER.mode==configt::ansi_ct::flavourt::CODEWARRIOR || PARSER.mode==configt::ansi_ct::flavourt::ARM) { - loc(); return TOK_MSC_DECLSPEC; + loc(); return ATOK_MSC_DECLSPEC; } else if(PARSER.mode==configt::ansi_ct::flavourt::GCC) { // GCC supports this on Windows as an exception! // Should likely reject on other targets. - loc(); return TOK_MSC_DECLSPEC; + loc(); return ATOK_MSC_DECLSPEC; } else return make_identifier(); @@ -1040,7 +1040,7 @@ __decltype { if(PARSER.cpp98 && { BEGIN(GCC_ATTRIBUTE1); loc(); - return TOK_GCC_ATTRIBUTE; + return ATOK_GCC_ATTRIBUTE; } else return make_identifier(); @@ -1051,8 +1051,8 @@ __decltype { if(PARSER.cpp98 && "__extension__" { /* ignore */ } -"__restrict" { loc(); return TOK_RESTRICT; } -"__restrict__" { loc(); return TOK_RESTRICT; } +"__restrict" { loc(); return ATOK_RESTRICT; } +"__restrict__" { loc(); return ATOK_RESTRICT; } "_cdecl" { /* ignore */ } "__cdecl" { /* ignore */ } @@ -1066,14 +1066,14 @@ __decltype { if(PARSER.cpp98 && "__vectorcall" { /* ignore */ } "__w64" { /* ignore */ } -"__const" { loc(); return TOK_CONST; } -"__const__" { loc(); return TOK_CONST; } +"__const" { loc(); return ATOK_CONST; } +"__const__" { loc(); return ATOK_CONST; } -"__signed" { loc(); return TOK_SIGNED; } -"__signed__" { loc(); return TOK_SIGNED; } +"__signed" { loc(); return ATOK_SIGNED; } +"__signed__" { loc(); return ATOK_SIGNED; } -"__volatile" { loc(); return TOK_VOLATILE; } -"__volatile__" { loc(); return TOK_VOLATILE; } +"__volatile" { loc(); return ATOK_VOLATILE; } +"__volatile__" { loc(); return ATOK_VOLATILE; } "__pure" { /* an ARM extension */ if(PARSER.mode==configt::ansi_ct::flavourt::ARM) @@ -1212,146 +1212,146 @@ __decltype { if(PARSER.cpp98 && PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::CODEWARRIOR || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_TYPEOF; } + { loc(); return ATOK_TYPEOF; } else return make_identifier(); } "__typeof" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_TYPEOF; } + { loc(); return ATOK_TYPEOF; } else return make_identifier(); } -"__typeof__" { loc(); return TOK_TYPEOF; } +"__typeof__" { loc(); return ATOK_TYPEOF; } "__forceinline" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_MSC_FORCEINLINE; } + { loc(); return ATOK_MSC_FORCEINLINE; } else return make_identifier(); } "_inline" { // http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) - { loc(); return TOK_INLINE; } + { loc(); return ATOK_INLINE; } else return make_identifier(); } -"__inline" { loc(); return TOK_INLINE; } -"__inline__" { loc(); return TOK_INLINE; } +"__inline" { loc(); return ATOK_INLINE; } +"__inline__" { loc(); return ATOK_INLINE; } "__label__" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_GCC_LABEL; } + { loc(); return ATOK_GCC_LABEL; } else return make_identifier(); } "__try" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) - { loc(); return TOK_MSC_TRY; } + { loc(); return ATOK_MSC_TRY; } else return make_identifier(); } "try" { if(PARSER.cpp98) // C++? - { loc(); return TOK_TRY; } + { loc(); return ATOK_TRY; } else return make_identifier(); } "__finally" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) - { loc(); return TOK_MSC_FINALLY; } + { loc(); return ATOK_MSC_FINALLY; } else return make_identifier(); } "__except" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) - { loc(); return TOK_MSC_EXCEPT; } + { loc(); return ATOK_MSC_EXCEPT; } else return make_identifier(); } "__leave" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) - { loc(); return TOK_MSC_LEAVE; } - else - return make_identifier(); - } - -{CPROVER_PREFIX}"atomic" { loc(); return TOK_CPROVER_ATOMIC; } -{CPROVER_PREFIX}"forall" { loc(); return TOK_FORALL; } -{CPROVER_PREFIX}"exists" { loc(); return TOK_EXISTS; } -{CPROVER_PREFIX}"array_of" { loc(); return TOK_ARRAY_OF; } -{CPROVER_PREFIX}"thread_local" { loc(); return TOK_THREAD_LOCAL; } -{CPROVER_PREFIX}"bitvector" { loc(); return TOK_CPROVER_BITVECTOR; } -{CPROVER_PREFIX}"floatbv" { loc(); return TOK_CPROVER_FLOATBV; } -{CPROVER_PREFIX}"fixedbv" { loc(); return TOK_CPROVER_FIXEDBV; } -{CPROVER_PREFIX}"bool" { loc(); return TOK_CPROVER_BOOL; } -{CPROVER_PREFIX}"throw" { loc(); return TOK_CPROVER_THROW; } -{CPROVER_PREFIX}"catch" { loc(); return TOK_CPROVER_CATCH; } -{CPROVER_PREFIX}"try" { loc(); return TOK_CPROVER_TRY; } -{CPROVER_PREFIX}"finally" { loc(); return TOK_CPROVER_FINALLY; } -{CPROVER_PREFIX}"ID" { loc(); return TOK_CPROVER_ID; } -{CPROVER_PREFIX}"loop_invariant" { loc(); return TOK_CPROVER_LOOP_INVARIANT; } -{CPROVER_PREFIX}"decreases" { loc(); return TOK_CPROVER_DECREASES; } -{CPROVER_PREFIX}"requires" { loc(); return TOK_CPROVER_REQUIRES; } -{CPROVER_PREFIX}"ensures" { loc(); return TOK_CPROVER_ENSURES; } -{CPROVER_PREFIX}"assigns" { loc(); return TOK_CPROVER_ASSIGNS; } -{CPROVER_PREFIX}"frees" { loc(); return TOK_CPROVER_FREES; } + { loc(); return ATOK_MSC_LEAVE; } + else + return make_identifier(); + } + +{CPROVER_PREFIX}"atomic" { loc(); return ATOK_CPROVER_ATOMIC; } +{CPROVER_PREFIX}"forall" { loc(); return ATOK_FORALL; } +{CPROVER_PREFIX}"exists" { loc(); return ATOK_EXISTS; } +{CPROVER_PREFIX}"array_of" { loc(); return ATOK_ARRAY_OF; } +{CPROVER_PREFIX}"thread_local" { loc(); return ATOK_THREAD_LOCAL; } +{CPROVER_PREFIX}"bitvector" { loc(); return ATOK_CPROVER_BITVECTOR; } +{CPROVER_PREFIX}"floatbv" { loc(); return ATOK_CPROVER_FLOATBV; } +{CPROVER_PREFIX}"fixedbv" { loc(); return ATOK_CPROVER_FIXEDBV; } +{CPROVER_PREFIX}"bool" { loc(); return ATOK_CPROVER_BOOL; } +{CPROVER_PREFIX}"throw" { loc(); return ATOK_CPROVER_THROW; } +{CPROVER_PREFIX}"catch" { loc(); return ATOK_CPROVER_CATCH; } +{CPROVER_PREFIX}"try" { loc(); return ATOK_CPROVER_TRY; } +{CPROVER_PREFIX}"finally" { loc(); return ATOK_CPROVER_FINALLY; } +{CPROVER_PREFIX}"ID" { loc(); return ATOK_CPROVER_ID; } +{CPROVER_PREFIX}"loop_invariant" { loc(); return ATOK_CPROVER_LOOP_INVARIANT; } +{CPROVER_PREFIX}"decreases" { loc(); return ATOK_CPROVER_DECREASES; } +{CPROVER_PREFIX}"requires" { loc(); return ATOK_CPROVER_REQUIRES; } +{CPROVER_PREFIX}"ensures" { loc(); return ATOK_CPROVER_ENSURES; } +{CPROVER_PREFIX}"assigns" { loc(); return ATOK_CPROVER_ASSIGNS; } +{CPROVER_PREFIX}"frees" { loc(); return ATOK_CPROVER_FREES; } "\xe2\x88\x80" | "\\forall" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_ACSL_FORALL; + loc(); return ATOK_ACSL_FORALL; } "\xe2\x88\x83" | "\\exists" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_ACSL_EXISTS; + loc(); return ATOK_ACSL_EXISTS; } "\\lambda" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_ACSL_LAMBDA; + loc(); return ATOK_ACSL_LAMBDA; } "\\let" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_ACSL_LET; + loc(); return ATOK_ACSL_LET; } "\xe2\x87\x92" | "==>" { /* Non-standard, obviously. Found in Spec# and ACSL syntax. */ - loc(); return TOK_IMPLIES; + loc(); return ATOK_IMPLIES; } "\xe2\x87\x94" | "<==>" { /* Non-standard, obviously. Found in Spec# and ACSL syntax. */ - loc(); return TOK_EQUIVALENT; + loc(); return ATOK_EQUIVALENT; } "\xe2\x89\xa5" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_GE; + loc(); return ATOK_GE; } "\xe2\x89\xa1" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_EQ; + loc(); return ATOK_EQ; } "\xe2\x89\xa2" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_NE; + loc(); return ATOK_NE; } "\xe2\x89\xa4" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_LE; + loc(); return ATOK_LE; } "\xe2\x88\xa7" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_ANDAND; + loc(); return ATOK_ANDAND; } "\xe2\x88\xa8" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_OROR; + loc(); return ATOK_OROR; } "\xc2\xac" { /* Non-standard, obviously. Found in ACSL syntax. */ @@ -1360,7 +1360,7 @@ __decltype { if(PARSER.cpp98 && "\xe2\x8a\xbb" | "^^" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_XORXOR; + loc(); return ATOK_XORXOR; } "\xe2\x88\x92" { /* Non-standard, obviously. Found in ACSL syntax. */ @@ -1368,17 +1368,17 @@ __decltype { if(PARSER.cpp98 && } "\\true" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_TRUE; + loc(); return ATOK_TRUE; } "\\false" { /* Non-standard, obviously. Found in ACSL syntax. */ - loc(); return TOK_FALSE; + loc(); return ATOK_FALSE; } "__thread" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM) - { loc(); return TOK_THREAD_LOCAL; } + { loc(); return ATOK_THREAD_LOCAL; } else return make_identifier(); } @@ -1389,7 +1389,7 @@ __decltype { if(PARSER.cpp98 && (PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM)) - { loc(); return TOK_ALIGNAS; } + { loc(); return ATOK_ALIGNAS; } else return make_identifier(); } @@ -1401,7 +1401,7 @@ __decltype { if(PARSER.cpp98 && PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM || PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO)) - { loc(); return TOK_ALIGNOF; } + { loc(); return ATOK_ALIGNOF; } else return make_identifier(); } @@ -1422,7 +1422,7 @@ __decltype { if(PARSER.cpp98 && (PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM)) - { loc(); return TOK_ATOMIC_TYPE_SPECIFIER; } + { loc(); return ATOK_ATOMIC_TYPE_SPECIFIER; } else return make_identifier(); } @@ -1431,7 +1431,7 @@ __decltype { if(PARSER.cpp98 && (PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM)) - { loc(); return TOK_ATOMIC_TYPE_QUALIFIER; } + { loc(); return ATOK_ATOMIC_TYPE_QUALIFIER; } else return make_identifier(); } @@ -1442,7 +1442,7 @@ __decltype { if(PARSER.cpp98 && (PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM)) - { loc(); return TOK_GENERIC; } + { loc(); return ATOK_GENERIC; } else return make_identifier(); } @@ -1453,7 +1453,7 @@ __decltype { if(PARSER.cpp98 && (PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM)) - { loc(); return TOK_IMAGINARY; } + { loc(); return ATOK_IMAGINARY; } else return make_identifier(); } @@ -1464,7 +1464,7 @@ __decltype { if(PARSER.cpp98 && (PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM)) - { loc(); return TOK_NORETURN; } + { loc(); return ATOK_NORETURN; } else return make_identifier(); } @@ -1475,7 +1475,7 @@ __decltype { if(PARSER.cpp98 && (PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM)) - { loc(); return TOK_STATIC_ASSERT; } + { loc(); return ATOK_STATIC_ASSERT; } else return make_identifier(); } @@ -1486,7 +1486,7 @@ __decltype { if(PARSER.cpp98 && (PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG || PARSER.mode==configt::ansi_ct::flavourt::ARM)) - { loc(); return TOK_THREAD_LOCAL; } + { loc(); return ATOK_THREAD_LOCAL; } else return make_identifier(); } @@ -1520,29 +1520,29 @@ __decltype { if(PARSER.cpp98 && /* operators following */ { -"->" { loc(); return TOK_ARROW; } -"++" { loc(); return TOK_INCR; } -"--" { loc(); return TOK_DECR; } -"<<" { loc(); return TOK_SHIFTLEFT; } -">>" { loc(); return TOK_SHIFTRIGHT; } -"<=" { loc(); return TOK_LE; } -">=" { loc(); return TOK_GE; } -"==" { loc(); return TOK_EQ; } -"!=" { loc(); return TOK_NE; } -"&&" { loc(); return TOK_ANDAND; } -"||" { loc(); return TOK_OROR; } -"..." { loc(); return TOK_ELLIPSIS; } - -"*=" { loc(); return TOK_MULTASSIGN; } -"/=" { loc(); return TOK_DIVASSIGN; } -"%=" { loc(); return TOK_MODASSIGN; } -"+=" { loc(); return TOK_PLUSASSIGN; } -"-=" { loc(); return TOK_MINUSASSIGN; } -"<<=" { loc(); return TOK_SHLASSIGN; } -">>=" { loc(); return TOK_SHRASSIGN; } -"&=" { loc(); return TOK_ANDASSIGN; } -"^=" { loc(); return TOK_XORASSIGN; } -"|=" { loc(); return TOK_ORASSIGN; } +"->" { loc(); return ATOK_ARROW; } +"++" { loc(); return ATOK_INCR; } +"--" { loc(); return ATOK_DECR; } +"<<" { loc(); return ATOK_SHIFTLEFT; } +">>" { loc(); return ATOK_SHIFTRIGHT; } +"<=" { loc(); return ATOK_LE; } +">=" { loc(); return ATOK_GE; } +"==" { loc(); return ATOK_EQ; } +"!=" { loc(); return ATOK_NE; } +"&&" { loc(); return ATOK_ANDAND; } +"||" { loc(); return ATOK_OROR; } +"..." { loc(); return ATOK_ELLIPSIS; } + +"*=" { loc(); return ATOK_MULTASSIGN; } +"/=" { loc(); return ATOK_DIVASSIGN; } +"%=" { loc(); return ATOK_MODASSIGN; } +"+=" { loc(); return ATOK_PLUSASSIGN; } +"-=" { loc(); return ATOK_MINUSASSIGN; } +"<<=" { loc(); return ATOK_SHLASSIGN; } +">>=" { loc(); return ATOK_SHRASSIGN; } +"&=" { loc(); return ATOK_ANDASSIGN; } +"^=" { loc(); return ATOK_XORASSIGN; } +"|=" { loc(); return ATOK_ORASSIGN; } /* digraphs */ "<:" { loc(); return '['; } @@ -1558,24 +1558,24 @@ __decltype { if(PARSER.cpp98 && {integer_s} { newstack(yyansi_clval); parser_stack(yyansi_clval)=convert_integer_literal(yytext); PARSER.set_source_location(parser_stack(yyansi_clval)); - return TOK_INTEGER; + return ATOK_INTEGER; } {gcc_ext_float_s} { if(PARSER.mode!=configt::ansi_ct::flavourt::GCC) { yyansi_cerror("Preprocessor directive found"); - return TOK_SCANNER_ERROR; + return ATOK_SCANNER_ERROR; } newstack(yyansi_clval); parser_stack(yyansi_clval)=convert_float_literal(yytext); PARSER.set_source_location(parser_stack(yyansi_clval)); - return TOK_FLOATING; + return ATOK_FLOATING; } {float_s} { newstack(yyansi_clval); parser_stack(yyansi_clval)=convert_float_literal(yytext); PARSER.set_source_location(parser_stack(yyansi_clval)); - return TOK_FLOATING; + return ATOK_FLOATING; } "{" { @@ -1613,7 +1613,7 @@ __decltype { if(PARSER.cpp98 && parser_stack(yyansi_clval)=string_constantt(yytext); parser_stack(yyansi_clval).add_source_location()=l; BEGIN(GRAMMAR); - return TOK_ASM_STRING; + return ATOK_ASM_STRING; } { @@ -1627,7 +1627,7 @@ __decltype { if(PARSER.cpp98 && parser_stack(yyansi_clval)=string_constantt(PARSER.string_literal); BEGIN(GRAMMAR); yyless(0); // put back - return TOK_ASM_STRING; + return ATOK_ASM_STRING; } } @@ -1652,16 +1652,16 @@ __decltype { if(PARSER.cpp98 && } {ws} { /* ignore */ } {newline} { /* ignore */ } -"{" { yyless(0); BEGIN(GRAMMAR); loc(); PARSER.asm_block_following=true; return TOK_GCC_ASM_PAREN; } -"(" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } -"volatile" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } -"__volatile" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } -"__volatile__" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } -"goto" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } -"inline" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } -"__inline" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } -"__inline__" { yyless(0); BEGIN(GRAMMAR); loc(); return TOK_GCC_ASM_PAREN; } -. { yyless(0); BEGIN(GRAMMAR); loc(); PARSER.asm_block_following=true; return TOK_GCC_ASM; } +"{" { yyless(0); BEGIN(GRAMMAR); loc(); PARSER.asm_block_following=true; return ATOK_GCC_ASM_PAREN; } +"(" { yyless(0); BEGIN(GRAMMAR); loc(); return ATOK_GCC_ASM_PAREN; } +"volatile" { yyless(0); BEGIN(GRAMMAR); loc(); return ATOK_GCC_ASM_PAREN; } +"__volatile" { yyless(0); BEGIN(GRAMMAR); loc(); return ATOK_GCC_ASM_PAREN; } +"__volatile__" { yyless(0); BEGIN(GRAMMAR); loc(); return ATOK_GCC_ASM_PAREN; } +"goto" { yyless(0); BEGIN(GRAMMAR); loc(); return ATOK_GCC_ASM_PAREN; } +"inline" { yyless(0); BEGIN(GRAMMAR); loc(); return ATOK_GCC_ASM_PAREN; } +"__inline" { yyless(0); BEGIN(GRAMMAR); loc(); return ATOK_GCC_ASM_PAREN; } +"__inline__" { yyless(0); BEGIN(GRAMMAR); loc(); return ATOK_GCC_ASM_PAREN; } +. { yyless(0); BEGIN(GRAMMAR); loc(); PARSER.asm_block_following=true; return ATOK_GCC_ASM; } } { @@ -1689,45 +1689,45 @@ __decltype { if(PARSER.cpp98 && { // an attribute is following -- these may be keywords! "aligned" | -"__aligned__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_ALIGNED; } +"__aligned__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_ALIGNED; } "packed" | -"__packed__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_PACKED; } +"__packed__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_PACKED; } "transparent_union" | -"__transparent_union__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_TRANSPARENT_UNION; } +"__transparent_union__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_TRANSPARENT_UNION; } "vector_size" | -"__vector_size__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_VECTOR_SIZE; } +"__vector_size__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_VECTOR_SIZE; } "mode" | -"__mode__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_MODE; } +"__mode__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_MODE; } -"__gnu_inline__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_GNU_INLINE; } +"__gnu_inline__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_GNU_INLINE; } "weak" | -"__weak__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_WEAK; } +"__weak__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_WEAK; } "alias" | -"__alias__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_ALIAS; } +"__alias__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_ALIAS; } "section" | -"__section__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_SECTION; } +"__section__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_SECTION; } "noreturn" | -"__noreturn__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_NORETURN; } +"__noreturn__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_NORETURN; } "constructor" | -"__constructor__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_CONSTRUCTOR; } +"__constructor__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_CONSTRUCTOR; } "destructor" | -"__destructor__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_DESTRUCTOR; } +"__destructor__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_DESTRUCTOR; } "fallthrough" | -"__fallthrough__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_FALLTHROUGH; } +"__fallthrough__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_FALLTHROUGH; } "used" | -"__used__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_USED; } +"__used__" { BEGIN(GCC_ATTRIBUTE3); loc(); return ATOK_GCC_ATTRIBUTE_USED; } {ws} { /* ignore */ } {newline} { /* ignore */ } @@ -1770,7 +1770,7 @@ __decltype { if(PARSER.cpp98 && {integer_s} { newstack(yyansi_clval); parser_stack(yyansi_clval)=convert_integer_literal(yytext); PARSER.set_source_location(parser_stack(yyansi_clval)); - return TOK_INTEGER; + return ATOK_INTEGER; } {ws} { /* ignore */ } {newline} { /* ignore */ } diff --git a/src/common b/src/common index 742f872abffa..bf4190c5bd5f 100644 --- a/src/common +++ b/src/common @@ -99,7 +99,6 @@ ifeq ($(origin LEX),default) LEX = flex endif - else ifeq ($(BUILD_ENV_),Cygwin) # use these for Cygwin: LIBEXT = .a diff --git a/src/cpp/parse.cpp b/src/cpp/parse.cpp index c16a92a6d12b..32daff4cfaca 100644 --- a/src/cpp/parse.cpp +++ b/src/cpp/parse.cpp @@ -34,7 +34,7 @@ struct indenter // NOLINT(readability/identifiers) ~indenter() { __indent-=2; } }; -#define TOK_TEXT \ +#define ATOK_TEXT \ { \ cpp_tokent _tk; \ lex.LookAhead(0, _tk); \ @@ -412,7 +412,7 @@ class Parser // NOLINT(readability/identifiers) static bool is_identifier(int token) { - return token == TOK_GCC_IDENTIFIER || token == TOK_MSC_IDENTIFIER; + return token == ATOK_GCC_IDENTIFIER || token == ATOK_MSC_IDENTIFIER; } new_scopet &Parser::add_id(const irept &cpp_name, new_scopet::kindt kind) @@ -453,7 +453,7 @@ void Parser::make_sub_scope(const irep_idt &id, new_scopet::kindt kind) bool Parser::rString(cpp_tokent &tk) { - if(lex.get_token(tk)!=TOK_STRING) + if(lex.get_token(tk)!=ATOK_STRING) return false; return true; @@ -561,27 +561,27 @@ bool Parser::rDefinition(cpp_itemt &item) if(t==';') return rNullDeclaration(item.make_declaration()); - else if(t==TOK_TYPEDEF) + else if(t==ATOK_TYPEDEF) return rTypedef(item.make_declaration()); - else if(t==TOK_TEMPLATE) + else if(t==ATOK_TEMPLATE) return rTemplateDecl(item.make_declaration()); - else if(t==TOK_EXTERN && lex.LookAhead(1)==TOK_STRING) + else if(t==ATOK_EXTERN && lex.LookAhead(1)==ATOK_STRING) return rLinkageSpec(item.make_linkage_spec()); - else if(t==TOK_EXTERN && lex.LookAhead(1)==TOK_TEMPLATE) + else if(t==ATOK_EXTERN && lex.LookAhead(1)==ATOK_TEMPLATE) return rExternTemplateDecl(item.make_declaration()); - else if(t==TOK_NAMESPACE) + else if(t==ATOK_NAMESPACE) return rNamespaceSpec(item.make_namespace_spec()); - else if(t==TOK_INLINE && lex.LookAhead(1)==TOK_NAMESPACE) + else if(t==ATOK_INLINE && lex.LookAhead(1)==ATOK_NAMESPACE) return rNamespaceSpec(item.make_namespace_spec()); else if( - t == TOK_USING && is_identifier(lex.LookAhead(1)) && + t == ATOK_USING && is_identifier(lex.LookAhead(1)) && lex.LookAhead(2) == '=') { return rTypedefUsing(item.make_declaration()); } - else if(t==TOK_USING) + else if(t==ATOK_USING) return rUsing(item.make_using()); - else if(t==TOK_STATIC_ASSERT) + else if(t==ATOK_STATIC_ASSERT) return rStaticAssert(item.make_static_assert()); else return rDeclaration(item.make_declaration()); @@ -607,7 +607,7 @@ bool Parser::rTypedef(cpp_declarationt &declaration) { cpp_tokent tk; - if(lex.get_token(tk)!=TOK_TYPEDEF) + if(lex.get_token(tk)!=ATOK_TYPEDEF) return false; #ifdef DEBUG @@ -636,7 +636,7 @@ bool Parser::rTypedefUsing(cpp_declarationt &declaration) cpp_tokent tk; typet type_name; - if(lex.get_token(tk)!=TOK_USING) + if(lex.get_token(tk)!=ATOK_USING) return false; #ifdef DEBUG @@ -758,19 +758,19 @@ bool Parser::isTypeSpecifier() { int t=lex.LookAhead(0); - return is_identifier(t) || t == TOK_SCOPE || t == TOK_CONSTEXPR || - t == TOK_CONST || t == TOK_VOLATILE || t == TOK_RESTRICT || - t == TOK_CHAR || t == TOK_INT || t == TOK_SHORT || t == TOK_LONG || - t == TOK_CHAR16_T || t == TOK_CHAR32_T || t == TOK_WCHAR_T || - t == TOK_COMPLEX // new !!! - || t == TOK_SIGNED || t == TOK_UNSIGNED || t == TOK_FLOAT || - t == TOK_DOUBLE || t == TOK_INT8 || t == TOK_INT16 || t == TOK_INT32 || - t == TOK_INT64 || t == TOK_GCC_INT128 || t == TOK_PTR32 || - t == TOK_PTR64 || t == TOK_GCC_FLOAT80 || t == TOK_GCC_FLOAT128 || - t == TOK_VOID || t == TOK_BOOL || t == TOK_CPROVER_BOOL || - t == TOK_CLASS || t == TOK_STRUCT || t == TOK_UNION || t == TOK_ENUM || - t == TOK_INTERFACE || t == TOK_TYPENAME || t == TOK_TYPEOF || - t == TOK_DECLTYPE || t == TOK_UNDERLYING_TYPE; + return is_identifier(t) || t == ATOK_SCOPE || t == ATOK_CONSTEXPR || + t == ATOK_CONST || t == ATOK_VOLATILE || t == ATOK_RESTRICT || + t == ATOK_CHAR || t == ATOK_INT || t == ATOK_SHORT || t == ATOK_LONG || + t == ATOK_CHAR16_T || t == ATOK_CHAR32_T || t == ATOK_WCHAR_T || + t == ATOK_COMPLEX // new !!! + || t == ATOK_SIGNED || t == ATOK_UNSIGNED || t == ATOK_FLOAT || + t == ATOK_DOUBLE || t == ATOK_INT8 || t == ATOK_INT16 || t == ATOK_INT32 || + t == ATOK_INT64 || t == ATOK_GCC_INT128 || t == ATOK_PTR32 || + t == ATOK_PTR64 || t == ATOK_GCC_FLOAT80 || t == ATOK_GCC_FLOAT128 || + t == ATOK_VOID || t == ATOK_BOOL || t == ATOK_CPROVER_BOOL || + t == ATOK_CLASS || t == ATOK_STRUCT || t == ATOK_UNION || t == ATOK_ENUM || + t == ATOK_INTERFACE || t == ATOK_TYPENAME || t == ATOK_TYPEOF || + t == ATOK_DECLTYPE || t == ATOK_UNDERLYING_TYPE; } /* @@ -782,7 +782,7 @@ bool Parser::rLinkageSpec(cpp_linkage_spect &linkage_spec) { cpp_tokent tk1, tk2; - if(lex.get_token(tk1)!=TOK_EXTERN) + if(lex.get_token(tk1)!=ATOK_EXTERN) return false; if(!rString(tk2)) @@ -823,13 +823,13 @@ bool Parser::rNamespaceSpec(cpp_namespace_spect &namespace_spec) cpp_tokent tk1, tk2; bool is_inline=false; - if(lex.LookAhead(0)==TOK_INLINE) + if(lex.LookAhead(0)==ATOK_INLINE) { lex.get_token(tk1); is_inline=true; } - if(lex.get_token(tk1)!=TOK_NAMESPACE) + if(lex.get_token(tk1)!=ATOK_NAMESPACE) return false; irep_idt name; @@ -878,13 +878,13 @@ bool Parser::rUsing(cpp_usingt &cpp_using) { cpp_tokent tk; - if(lex.get_token(tk)!=TOK_USING) + if(lex.get_token(tk)!=ATOK_USING) return false; cpp_using=cpp_usingt(); set_location(cpp_using, tk); - if(lex.LookAhead(0)==TOK_NAMESPACE) + if(lex.LookAhead(0)==ATOK_NAMESPACE) { lex.get_token(tk); cpp_using.set_namespace(true); @@ -906,7 +906,7 @@ bool Parser::rStaticAssert(cpp_static_assertt &cpp_static_assert) { cpp_tokent tk; - if(lex.get_token(tk)!=TOK_STATIC_ASSERT) + if(lex.get_token(tk)!=ATOK_STATIC_ASSERT) return false; if(lex.get_token(tk)!='(') @@ -1003,7 +1003,7 @@ bool Parser::rTemplateDecl(cpp_declarationt &decl) return false; cpp_declarationt body; - if(lex.LookAhead(0)==TOK_USING) + if(lex.LookAhead(0)==ATOK_USING) { if(!rTypedefUsing(body)) return false; @@ -1051,7 +1051,7 @@ bool Parser::rTemplateDecl2(typet &decl, TemplateDeclKind &kind) { cpp_tokent tk; - if(lex.get_token(tk)!=TOK_TEMPLATE) + if(lex.get_token(tk)!=ATOK_TEMPLATE) return false; decl=typet(ID_template); @@ -1076,7 +1076,7 @@ bool Parser::rTemplateDecl2(typet &decl, TemplateDeclKind &kind) return false; // ignore nested TEMPLATE - while(lex.LookAhead(0)==TOK_TEMPLATE) + while(lex.LookAhead(0)==ATOK_TEMPLATE) { lex.get_token(tk); if(lex.LookAhead(0)!='<') @@ -1149,7 +1149,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration) int t0=lex.LookAhead(0); - if((t0==TOK_CLASS || t0==TOK_TYPENAME)) + if((t0==ATOK_CLASS || t0==ATOK_TYPENAME)) { cpp_token_buffert::post pos=lex.Save(); @@ -1172,7 +1172,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration) bool has_ellipsis=false; - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { cpp_tokent tk2; lex.get_token(tk2); @@ -1222,7 +1222,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration) std::cout << std::string(__indent, ' ') << "Parser::rTempArgDeclaration 1\n"; #endif - if(t0==TOK_TEMPLATE) + if(t0==ATOK_TEMPLATE) { TemplateDeclKind kind; @@ -1235,7 +1235,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration) cpp_tokent tk1, tk2; - if(lex.get_token(tk1) != TOK_CLASS || !is_identifier(lex.get_token(tk2))) + if(lex.get_token(tk1) != ATOK_CLASS || !is_identifier(lex.get_token(tk2))) return false; // Ptree cspec=new PtreeClassSpec(new LeafReserved(tk1), @@ -1273,7 +1273,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration) bool has_ellipsis=false; - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { cpp_tokent tk2; lex.get_token(tk2); @@ -1327,10 +1327,10 @@ bool Parser::rExternTemplateDecl(cpp_declarationt &decl) { cpp_tokent tk1, tk2; - if(lex.get_token(tk1)!=TOK_EXTERN) + if(lex.get_token(tk1)!=ATOK_EXTERN) return false; - if(lex.get_token(tk2)!=TOK_TEMPLATE) + if(lex.get_token(tk2)!=ATOK_TEMPLATE) return false; if(!rDeclaration(decl)) @@ -1869,7 +1869,7 @@ bool Parser::isConstructorDecl() int t=lex.LookAhead(1); if(t=='*' || t=='&' || t=='(') return false; // it's a declarator - else if(t==TOK_STDCALL || t==TOK_FASTCALL || t==TOK_CLRCALL || t==TOK_CDECL) + else if(t==ATOK_STDCALL || t==ATOK_FASTCALL || t==ATOK_CLRCALL || t==ATOK_CDECL) return false; // it's a declarator else if(isPtrToMember(1)) return false; // declarator (::*) @@ -1894,7 +1894,7 @@ bool Parser::isPtrToMember(int i) { int t0=lex.LookAhead(i++); - if(t0==TOK_SCOPE) + if(t0==ATOK_SCOPE) t0=lex.LookAhead(i++); while(is_identifier(t0)) @@ -1931,7 +1931,7 @@ bool Parser::isPtrToMember(int i) t=lex.LookAhead(i++); } - if(t!=TOK_SCOPE) + if(t!=ATOK_SCOPE) return false; t0=lex.LookAhead(i++); @@ -1954,21 +1954,21 @@ bool Parser::optMemberSpec(cpp_member_spect &member_spec) int t=lex.LookAhead(0); while( - t == TOK_FRIEND || t == TOK_INLINE || t == TOK_VIRTUAL || - t == TOK_EXPLICIT || t == TOK_MSC_FORCEINLINE) + t == ATOK_FRIEND || t == ATOK_INLINE || t == ATOK_VIRTUAL || + t == ATOK_EXPLICIT || t == ATOK_MSC_FORCEINLINE) { cpp_tokent tk; lex.get_token(tk); switch(t) { - case TOK_INLINE: - case TOK_MSC_FORCEINLINE: + case ATOK_INLINE: + case ATOK_MSC_FORCEINLINE: member_spec.set_inline(true); break; - case TOK_VIRTUAL: member_spec.set_virtual(true); break; - case TOK_FRIEND: member_spec.set_friend(true); break; - case TOK_EXPLICIT: member_spec.set_explicit(true); break; + case ATOK_VIRTUAL: member_spec.set_virtual(true); break; + case ATOK_FRIEND: member_spec.set_friend(true); break; + case ATOK_EXPLICIT: member_spec.set_explicit(true); break; default: UNREACHABLE; } @@ -1986,26 +1986,26 @@ bool Parser::optStorageSpec(cpp_storage_spect &storage_spec) { int t=lex.LookAhead(0); - if(t==TOK_STATIC || - t==TOK_EXTERN || - (t == TOK_AUTO && !ansi_c_parser.cpp11) || - t==TOK_REGISTER || - t==TOK_MUTABLE || - t==TOK_GCC_ASM || - t==TOK_THREAD_LOCAL) + if(t==ATOK_STATIC || + t==ATOK_EXTERN || + (t == ATOK_AUTO && !ansi_c_parser.cpp11) || + t==ATOK_REGISTER || + t==ATOK_MUTABLE || + t==ATOK_GCC_ASM || + t==ATOK_THREAD_LOCAL) { cpp_tokent tk; lex.get_token(tk); switch(t) { - case TOK_STATIC: storage_spec.set_static(); break; - case TOK_EXTERN: storage_spec.set_extern(); break; - case TOK_AUTO: storage_spec.set_auto(); break; - case TOK_REGISTER: storage_spec.set_register(); break; - case TOK_MUTABLE: storage_spec.set_mutable(); break; - case TOK_GCC_ASM: storage_spec.set_asm(); break; - case TOK_THREAD_LOCAL: storage_spec.set_thread_local(); break; + case ATOK_STATIC: storage_spec.set_static(); break; + case ATOK_EXTERN: storage_spec.set_extern(); break; + case ATOK_AUTO: storage_spec.set_auto(); break; + case ATOK_REGISTER: storage_spec.set_register(); break; + case ATOK_MUTABLE: storage_spec.set_mutable(); break; + case ATOK_GCC_ASM: storage_spec.set_asm(); break; + case ATOK_THREAD_LOCAL: storage_spec.set_thread_local(); break; default: UNREACHABLE; } @@ -2023,10 +2023,10 @@ bool Parser::optCvQualify(typet &cv) for(;;) { int t=lex.LookAhead(0); - if(t==TOK_CONSTEXPR || - t==TOK_CONST || t==TOK_VOLATILE || t==TOK_RESTRICT || - t==TOK_PTR32 || t==TOK_PTR64 || - t==TOK_GCC_ATTRIBUTE || t==TOK_GCC_ASM) + if(t==ATOK_CONSTEXPR || + t==ATOK_CONST || t==ATOK_VOLATILE || t==ATOK_RESTRICT || + t==ATOK_PTR32 || t==ATOK_PTR64 || + t==ATOK_GCC_ATTRIBUTE || t==ATOK_GCC_ASM) { cpp_tokent tk; lex.get_token(tk); @@ -2034,48 +2034,48 @@ bool Parser::optCvQualify(typet &cv) switch(t) { - case TOK_CONSTEXPR: + case ATOK_CONSTEXPR: p=typet(ID_constexpr); set_location(p, tk); merge_types(p, cv); break; - case TOK_CONST: + case ATOK_CONST: p=typet(ID_const); set_location(p, tk); merge_types(p, cv); break; - case TOK_VOLATILE: + case ATOK_VOLATILE: p=typet(ID_volatile); set_location(p, tk); merge_types(p, cv); break; - case TOK_RESTRICT: + case ATOK_RESTRICT: p=typet(ID_restrict); set_location(p, tk); merge_types(p, cv); break; - case TOK_PTR32: + case ATOK_PTR32: p=typet(ID_ptr32); set_location(p, tk); merge_types(p, cv); break; - case TOK_PTR64: + case ATOK_PTR64: p=typet(ID_ptr64); set_location(p, tk); merge_types(p, cv); break; - case TOK_GCC_ATTRIBUTE: + case ATOK_GCC_ATTRIBUTE: if(!rGCCAttribute(cv)) return false; break; - case TOK_GCC_ASM: + case ATOK_GCC_ASM: // asm post-declarator // this is stuff like // int x __asm("asd")=1, y; @@ -2106,7 +2106,7 @@ bool Parser::optCvQualify(typet &cv) */ bool Parser::optAlignas(typet &cv) { - if(lex.LookAhead(0)!=TOK_ALIGNAS) + if(lex.LookAhead(0)!=ATOK_ALIGNAS) return true; cpp_tokent tk; @@ -2181,7 +2181,7 @@ bool Parser::rGCCAttribute(typet &t) lex.get_token(tk); return true; - case TOK_GCC_ATTRIBUTE_PACKED: + case ATOK_GCC_ATTRIBUTE_PACKED: { typet attr(ID_packed); set_location(attr, tk); @@ -2189,7 +2189,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_TRANSPARENT_UNION: + case ATOK_GCC_ATTRIBUTE_TRANSPARENT_UNION: { typet attr(ID_transparent_union); set_location(attr, tk); @@ -2197,7 +2197,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_VECTOR_SIZE: + case ATOK_GCC_ATTRIBUTE_VECTOR_SIZE: { cpp_tokent tk2, tk3; @@ -2218,7 +2218,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_ALIGNED: + case ATOK_GCC_ATTRIBUTE_ALIGNED: { typet attr(ID_aligned); set_location(attr, tk); @@ -2244,7 +2244,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_MODE: + case ATOK_GCC_ATTRIBUTE_MODE: { cpp_tokent tk2, tk3; @@ -2265,7 +2265,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_GNU_INLINE: + case ATOK_GCC_ATTRIBUTE_GNU_INLINE: { typet attr(ID_static); set_location(attr, tk); @@ -2273,7 +2273,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_WEAK: + case ATOK_GCC_ATTRIBUTE_WEAK: { typet attr(ID_weak); set_location(attr, tk); @@ -2281,7 +2281,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_ALIAS: + case ATOK_GCC_ATTRIBUTE_ALIAS: { cpp_tokent tk2, tk3, tk4; @@ -2301,7 +2301,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_SECTION: + case ATOK_GCC_ATTRIBUTE_SECTION: { cpp_tokent tk2, tk3, tk4; @@ -2321,7 +2321,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_NORETURN: + case ATOK_GCC_ATTRIBUTE_NORETURN: { typet attr(ID_noreturn); set_location(attr, tk); @@ -2329,7 +2329,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_CONSTRUCTOR: + case ATOK_GCC_ATTRIBUTE_CONSTRUCTOR: { typet attr(ID_constructor); set_location(attr, tk); @@ -2337,7 +2337,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_DESTRUCTOR: + case ATOK_GCC_ATTRIBUTE_DESTRUCTOR: { typet attr(ID_destructor); set_location(attr, tk); @@ -2363,7 +2363,7 @@ bool Parser::rGCCAttribute(typet &t) bool Parser::optAttribute(typet &t) { - if(lex.LookAhead(0) == TOK_GCC_ATTRIBUTE) + if(lex.LookAhead(0) == ATOK_GCC_ATTRIBUTE) { lex.get_token(); @@ -2389,7 +2389,7 @@ bool Parser::optAttribute(typet &t) lex.get_token(); return true; - case TOK_NORETURN: + case ATOK_NORETURN: { typet attr(ID_noreturn); set_location(attr, tk); @@ -2423,7 +2423,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) #endif // DEBUG // This makes no sense, but is used in Visual Studio header files. - if(lex.LookAhead(0)==TOK_TYPENAME) + if(lex.LookAhead(0)==ATOK_TYPENAME) { cpp_tokent tk; lex.get_token(tk); @@ -2447,31 +2447,31 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) switch(t) { - case TOK_CHAR: type_id=ID_char; break; - case TOK_CHAR16_T: type_id=ID_char16_t; break; - case TOK_CHAR32_T: type_id=ID_char32_t; break; - case TOK_INT: type_id=ID_int; break; - case TOK_SHORT: type_id=ID_short; break; - case TOK_LONG: type_id=ID_long; break; - case TOK_SIGNED: type_id=ID_signed; break; - case TOK_WCHAR_T: type_id=ID_wchar_t; break; - case TOK_COMPLEX: type_id=ID_complex; break; - case TOK_UNSIGNED: type_id=ID_unsigned; break; - case TOK_FLOAT: type_id=ID_float; break; - case TOK_DOUBLE: type_id=ID_double; break; - case TOK_VOID: type_id=ID_void; break; - case TOK_INT8: type_id=ID_int8; break; - case TOK_INT16: type_id=ID_int16; break; - case TOK_INT32: type_id=ID_int32; break; - case TOK_INT64: type_id=ID_int64; break; - case TOK_GCC_INT128: type_id=ID_gcc_int128; break; - case TOK_GCC_FLOAT80: type_id=ID_gcc_float80; break; - case TOK_GCC_FLOAT128: type_id=ID_gcc_float128; break; - case TOK_BOOL: + case ATOK_CHAR: type_id=ID_char; break; + case ATOK_CHAR16_T: type_id=ID_char16_t; break; + case ATOK_CHAR32_T: type_id=ID_char32_t; break; + case ATOK_INT: type_id=ID_int; break; + case ATOK_SHORT: type_id=ID_short; break; + case ATOK_LONG: type_id=ID_long; break; + case ATOK_SIGNED: type_id=ID_signed; break; + case ATOK_WCHAR_T: type_id=ID_wchar_t; break; + case ATOK_COMPLEX: type_id=ID_complex; break; + case ATOK_UNSIGNED: type_id=ID_unsigned; break; + case ATOK_FLOAT: type_id=ID_float; break; + case ATOK_DOUBLE: type_id=ID_double; break; + case ATOK_VOID: type_id=ID_void; break; + case ATOK_INT8: type_id=ID_int8; break; + case ATOK_INT16: type_id=ID_int16; break; + case ATOK_INT32: type_id=ID_int32; break; + case ATOK_INT64: type_id=ID_int64; break; + case ATOK_GCC_INT128: type_id=ID_gcc_int128; break; + case ATOK_GCC_FLOAT80: type_id=ID_gcc_float80; break; + case ATOK_GCC_FLOAT128: type_id=ID_gcc_float128; break; + case ATOK_BOOL: type_id = ID_c_bool; break; - case TOK_CPROVER_BOOL: type_id=ID_proper_bool; break; - case TOK_AUTO: type_id = ID_auto; break; + case ATOK_CPROVER_BOOL: type_id=ID_proper_bool; break; + case ATOK_AUTO: type_id = ID_auto; break; default: type_id=irep_idt(); } @@ -2504,11 +2504,11 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) << "Parser::optIntegralTypeOrClassSpec 3\n"; #endif // DEBUG - if(t==TOK_CLASS || t==TOK_STRUCT || t==TOK_UNION || t==TOK_INTERFACE) + if(t==ATOK_CLASS || t==ATOK_STRUCT || t==ATOK_UNION || t==ATOK_INTERFACE) return rClassSpec(p); - else if(t==TOK_ENUM) + else if(t==ATOK_ENUM) return rEnumSpec(p); - else if(t==TOK_TYPEOF) + else if(t==ATOK_TYPEOF) { #ifdef DEBUG std::cout << std::string(__indent, ' ') @@ -2574,7 +2574,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) return true; } - else if(t==TOK_DECLTYPE) + else if(t==ATOK_DECLTYPE) { cpp_tokent decltype_tk; lex.get_token(decltype_tk); @@ -2599,7 +2599,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) return true; } - else if(t==TOK_UNDERLYING_TYPE) + else if(t==ATOK_UNDERLYING_TYPE) { // A Visual Studio extension that returns the underlying // type of an enum. @@ -2682,7 +2682,7 @@ bool Parser::rConstructorDecl( optThrowDecl(constructor.throw_decl()); - if(lex.LookAhead(0)==TOK_ARROW) + if(lex.LookAhead(0)==ATOK_ARROW) { #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rConstructorDecl 3\n"; @@ -2721,14 +2721,14 @@ bool Parser::rConstructorDecl( switch(lex.get_token(value)) { - case TOK_INTEGER: + case ATOK_INTEGER: { constructor.value()=codet("cpp-pure-virtual"); set_location(constructor.value(), value); } break; - case TOK_DEFAULT: // C++0x + case ATOK_DEFAULT: // C++0x { if(!ansi_c_parser.cpp11) { @@ -2741,7 +2741,7 @@ bool Parser::rConstructorDecl( } break; - case TOK_DELETE: // C++0x + case ATOK_DELETE: // C++0x { if(!ansi_c_parser.cpp11) { @@ -2775,7 +2775,7 @@ bool Parser::optThrowDecl(irept &throw_decl) int t; irept p=get_nil_irep(); - if(lex.LookAhead(0)==TOK_THROW) + if(lex.LookAhead(0)==ATOK_THROW) { lex.get_token(tk); // p=Ptree::Snoc(p, new LeafReserved(tk)); @@ -2793,7 +2793,7 @@ bool Parser::optThrowDecl(irept &throw_decl) return false; else if(t==')') break; - else if(t==TOK_ELLIPSIS) + else if(t==ATOK_ELLIPSIS) { lex.get_token(tk); } @@ -2818,7 +2818,7 @@ bool Parser::optThrowDecl(irept &throw_decl) // p=Ptree::Snoc(p, new Leaf(tk)); } - else if(lex.LookAhead(0)==TOK_NOEXCEPT) + else if(lex.LookAhead(0)==ATOK_NOEXCEPT) { exprt expr; @@ -2905,7 +2905,7 @@ bool Parser::rDeclaratorWithInit( cpp_tokent tk; lex.get_token(tk); - if(lex.LookAhead(0)==TOK_DEFAULT) // C++0x + if(lex.LookAhead(0)==ATOK_DEFAULT) // C++0x { if(!ansi_c_parser.cpp11) { @@ -2917,7 +2917,7 @@ bool Parser::rDeclaratorWithInit( declarator.value()=codet(ID_default); set_location(declarator.value(), tk); } - else if(lex.LookAhead(0)==TOK_DELETE) // C++0x + else if(lex.LookAhead(0)==ATOK_DELETE) // C++0x { if(!ansi_c_parser.cpp11) { @@ -2981,7 +2981,7 @@ bool Parser::rDeclaratorQualifier() // we just eat these - while(t==TOK_STDCALL || t==TOK_FASTCALL || t==TOK_CLRCALL || t==TOK_CDECL) + while(t==ATOK_STDCALL || t==ATOK_FASTCALL || t==ATOK_CLRCALL || t==ATOK_CDECL) { cpp_tokent op; lex.get_token(op); @@ -3086,7 +3086,7 @@ bool Parser::rDeclarator( } else if( kind != kCastDeclarator && - (kind == kDeclarator || is_identifier(t) || t == TOK_SCOPE)) + (kind == kDeclarator || is_identifier(t) || t == ATOK_SCOPE)) { #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rDeclarator2 6\n"; @@ -3154,7 +3154,7 @@ bool Parser::rDeclarator( irept throw_decl; optThrowDecl(throw_decl); // ignore in this version - if(lex.LookAhead(0)==TOK_ARROW) + if(lex.LookAhead(0)==ATOK_ARROW) { #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rDeclarator2 10\n"; @@ -3348,7 +3348,7 @@ bool Parser::optPtrOperator(typet &ptrs) set_location(op, tk); t_list.push_front(op); } - else if(t==TOK_ANDAND) // &&, these are C++0x rvalue refs + else if(t==ATOK_ANDAND) // &&, these are C++0x rvalue refs { cpp_tokent tk; lex.get_token(tk); @@ -3479,7 +3479,7 @@ bool Parser::rMemberInit(exprt &init) return false; } - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { lex.get_token(); @@ -3510,7 +3510,7 @@ bool Parser::rName(irept &name) name=cpp_namet(); irept::subt &components=name.get_sub(); - if(lex.LookAhead(0)==TOK_TYPENAME) + if(lex.LookAhead(0)==ATOK_TYPENAME) { cpp_tokent tk; lex.get_token(tk); @@ -3538,7 +3538,7 @@ bool Parser::rName(irept &name) switch(lex.LookAhead(0)) { - case TOK_TEMPLATE: + case ATOK_TEMPLATE: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rName 3\n"; #endif @@ -3561,13 +3561,13 @@ bool Parser::rName(irept &name) components.back().add(ID_arguments).swap(args); // done unless scope is next - if(lex.LookAhead(0)!=TOK_SCOPE) + if(lex.LookAhead(0)!=ATOK_SCOPE) return true; } break; - case TOK_GCC_IDENTIFIER: - case TOK_MSC_IDENTIFIER: + case ATOK_GCC_IDENTIFIER: + case ATOK_MSC_IDENTIFIER: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rName 5\n"; #endif @@ -3578,12 +3578,12 @@ bool Parser::rName(irept &name) { int t=lex.LookAhead(0); // done unless scope or template args is next - if(t!=TOK_SCOPE && t!='<') + if(t!=ATOK_SCOPE && t!='<') return true; } break; - case TOK_SCOPE: + case ATOK_SCOPE: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rName 6\n"; #endif @@ -3606,7 +3606,7 @@ bool Parser::rName(irept &name) set_location(components.back(), tk); break; - case TOK_OPERATOR: + case ATOK_OPERATOR: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rName 8\n"; #endif @@ -3671,43 +3671,43 @@ bool Parser::rOperatorName(irept &name) operator_id = std::string(1, static_cast(t)); break; - case TOK_MULTASSIGN: operator_id="*="; break; - case TOK_DIVASSIGN: operator_id="/="; break; - case TOK_MODASSIGN: operator_id="%="; break; - case TOK_PLUSASSIGN: operator_id="+="; break; - case TOK_MINUSASSIGN: operator_id="-="; break; - case TOK_SHLASSIGN: operator_id="<<="; break; - case TOK_SHRASSIGN: operator_id=">>="; break; - case TOK_ANDASSIGN: operator_id="&="; break; - case TOK_XORASSIGN: operator_id="^="; break; - case TOK_ORASSIGN: operator_id="|="; break; - case TOK_SHIFTLEFT: operator_id="<<"; break; - case TOK_SHIFTRIGHT: operator_id=">>"; break; - case TOK_EQ: operator_id="=="; break; - case TOK_NE: operator_id="!="; break; - case TOK_LE: operator_id="<="; break; - case TOK_GE: operator_id=">="; break; - case TOK_ANDAND: operator_id="&&"; break; - case TOK_OROR: operator_id="||"; break; - case TOK_INCR: operator_id="++"; break; - case TOK_DECR: operator_id="--"; break; - case TOK_DOTPM: operator_id=".*"; break; - case TOK_ARROWPM: operator_id="->*"; break; - case TOK_ARROW: operator_id="->"; break; - - case TOK_NEW: - case TOK_DELETE: + case ATOK_MULTASSIGN: operator_id="*="; break; + case ATOK_DIVASSIGN: operator_id="/="; break; + case ATOK_MODASSIGN: operator_id="%="; break; + case ATOK_PLUSASSIGN: operator_id="+="; break; + case ATOK_MINUSASSIGN: operator_id="-="; break; + case ATOK_SHLASSIGN: operator_id="<<="; break; + case ATOK_SHRASSIGN: operator_id=">>="; break; + case ATOK_ANDASSIGN: operator_id="&="; break; + case ATOK_XORASSIGN: operator_id="^="; break; + case ATOK_ORASSIGN: operator_id="|="; break; + case ATOK_SHIFTLEFT: operator_id="<<"; break; + case ATOK_SHIFTRIGHT: operator_id=">>"; break; + case ATOK_EQ: operator_id="=="; break; + case ATOK_NE: operator_id="!="; break; + case ATOK_LE: operator_id="<="; break; + case ATOK_GE: operator_id=">="; break; + case ATOK_ANDAND: operator_id="&&"; break; + case ATOK_OROR: operator_id="||"; break; + case ATOK_INCR: operator_id="++"; break; + case ATOK_DECR: operator_id="--"; break; + case ATOK_DOTPM: operator_id=".*"; break; + case ATOK_ARROWPM: operator_id="->*"; break; + case ATOK_ARROW: operator_id="->"; break; + + case ATOK_NEW: + case ATOK_DELETE: { lex.get_token(tk); if(lex.LookAhead(0)!='[') { - name=irept(t==TOK_NEW?ID_cpp_new:ID_cpp_delete); + name=irept(t==ATOK_NEW?ID_cpp_new:ID_cpp_delete); set_location(name, tk); } else { - name=irept(t==TOK_NEW?ID_cpp_new_array:ID_cpp_delete_array); + name=irept(t==ATOK_NEW?ID_cpp_new_array:ID_cpp_delete_array); set_location(name, tk); lex.get_token(tk); @@ -3813,7 +3813,7 @@ bool Parser::rPtrToMember(irept &ptr_to_mem) switch(lex.LookAhead(0)) { - case TOK_TEMPLATE: + case ATOK_TEMPLATE: lex.get_token(tk); // Skip template token, next will be identifier if(!is_identifier(lex.LookAhead(0))) @@ -3829,27 +3829,27 @@ bool Parser::rPtrToMember(irept &ptr_to_mem) components.push_back(irept(ID_template_args)); components.back().add(ID_arguments).swap(args); - if(lex.LookAhead(0) != TOK_SCOPE) + if(lex.LookAhead(0) != ATOK_SCOPE) return false; break; } - case TOK_GCC_IDENTIFIER: - case TOK_MSC_IDENTIFIER: + case ATOK_GCC_IDENTIFIER: + case ATOK_MSC_IDENTIFIER: { lex.get_token(tk); components.push_back(cpp_namet::namet(tk.data.get(ID_C_base_name))); set_location(components.back(), tk); int t = lex.LookAhead(0); - if(t != TOK_SCOPE && t != '<') + if(t != ATOK_SCOPE && t != '<') return false; break; } - case TOK_SCOPE: + case ATOK_SCOPE: lex.get_token(tk); components.push_back(irept("::")); set_location(components.back(), tk); @@ -3932,10 +3932,10 @@ bool Parser::rTemplateArgs(irept &template_args) // try type name first if(rTypeNameOrFunctionType(a) && ((lex.LookAhead(0) == '>' || lex.LookAhead(0) == ',' || - lex.LookAhead(0)==TOK_SHIFTRIGHT) || - (lex.LookAhead(0)==TOK_ELLIPSIS && + lex.LookAhead(0)==ATOK_SHIFTRIGHT) || + (lex.LookAhead(0)==ATOK_ELLIPSIS && (lex.LookAhead(1) == '>' || - lex.LookAhead(1)==TOK_SHIFTRIGHT))) + lex.LookAhead(1)==ATOK_SHIFTRIGHT))) ) { #ifdef DEBUG @@ -3958,7 +3958,7 @@ bool Parser::rTemplateArgs(irept &template_args) lex.Restore(pos); rTypeNameOrFunctionType(a); - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { lex.get_token(tk1); @@ -3981,7 +3981,7 @@ bool Parser::rTemplateArgs(irept &template_args) if(!rConditionalExpr(exp, true)) return false; - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { lex.get_token(tk1); @@ -4006,7 +4006,7 @@ bool Parser::rTemplateArgs(irept &template_args) case ',': break; - case TOK_SHIFTRIGHT: // turn >> into > > + case ATOK_SHIFTRIGHT: // turn >> into > > lex.Restore(pos); tk2.kind='>'; tk2.text='>'; @@ -4087,7 +4087,7 @@ bool Parser::rArgDeclList(irept &arglist) int t=lex.LookAhead(0); if(t==')') break; - else if(t==TOK_ELLIPSIS) + else if(t==ATOK_ELLIPSIS) { cpp_tokent tk; lex.get_token(tk); @@ -4103,12 +4103,12 @@ bool Parser::rArgDeclList(irept &arglist) t=lex.LookAhead(0); if(t==',') lex.get_token(tk); - else if(t==TOK_ELLIPSIS) + else if(t==ATOK_ELLIPSIS) { lex.get_token(tk); list.get_sub().push_back(irept(ID_ellipsis)); } - else if(t!=')' && t!=TOK_ELLIPSIS) + else if(t!=')' && t!=ATOK_ELLIPSIS) return false; } else @@ -4135,7 +4135,7 @@ bool Parser::rArgDeclaration(cpp_declarationt &declaration) switch(lex.LookAhead(0)) { - case TOK_REGISTER: + case ATOK_REGISTER: lex.get_token(tk); header=typet(ID_register); break; @@ -4194,8 +4194,8 @@ bool Parser::rInitializeExpr(exprt &expr) { exprt tmp; - if(t==TOK_MSC_IF_EXISTS || - t==TOK_MSC_IF_NOT_EXISTS) + if(t==ATOK_MSC_IF_EXISTS || + t==ATOK_MSC_IF_NOT_EXISTS) { // TODO exprt name; @@ -4277,7 +4277,7 @@ bool Parser::rFunctionArguments(exprt &args) args.add_to_operands(std::move(exp)); - if(lex.LookAhead(0)==TOK_ELLIPSIS && + if(lex.LookAhead(0)==ATOK_ELLIPSIS && (lex.LookAhead(1)==')' || lex.LookAhead(1)==',')) { lex.get_token(tk); @@ -4310,7 +4310,7 @@ bool Parser::rEnumSpec(typet &spec) cpp_tokent tk; - if(lex.get_token(tk)!=TOK_ENUM) + if(lex.get_token(tk)!=ATOK_ENUM) return false; spec=cpp_enum_typet(); @@ -4319,7 +4319,7 @@ bool Parser::rEnumSpec(typet &spec) spec.add_subtype().make_nil(); // C++11 enum classes - if(lex.LookAhead(0)==TOK_CLASS) + if(lex.LookAhead(0)==ATOK_CLASS) { lex.get_token(tk); spec.set(ID_C_class, true); @@ -4450,27 +4450,27 @@ bool Parser::rClassSpec(typet &spec) #endif int t=lex.get_token(tk); - if(t!=TOK_CLASS && t!=TOK_STRUCT && - t!=TOK_UNION && t!=TOK_INTERFACE) + if(t!=ATOK_CLASS && t!=ATOK_STRUCT && + t!=ATOK_UNION && t!=ATOK_INTERFACE) return false; #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rClassSpec 2\n"; #endif - if(t==TOK_CLASS) + if(t==ATOK_CLASS) { spec=typet(ID_struct); spec.set(ID_C_class, true); } - else if(t==TOK_INTERFACE) // MS-specific + else if(t==ATOK_INTERFACE) // MS-specific { spec=typet(ID_struct); spec.set(ID_C_interface, true); } - else if(t==TOK_STRUCT) + else if(t==ATOK_STRUCT) spec=typet(ID_struct); - else if(t==TOK_UNION) + else if(t==ATOK_UNION) spec=typet(ID_union); else UNREACHABLE; @@ -4562,26 +4562,26 @@ bool Parser::rBaseSpecifiers(irept &bases) int t=lex.LookAhead(0); irept base(ID_base); - if(t==TOK_VIRTUAL) + if(t==ATOK_VIRTUAL) { lex.get_token(tk); base.set(ID_virtual, true); t=lex.LookAhead(0); } - if(t==TOK_PUBLIC || t==TOK_PROTECTED || t==TOK_PRIVATE) + if(t==ATOK_PUBLIC || t==ATOK_PROTECTED || t==ATOK_PRIVATE) { switch(lex.get_token(tk)) { - case TOK_PUBLIC: + case ATOK_PUBLIC: base.set(ID_protection, ID_public); break; - case TOK_PROTECTED: + case ATOK_PROTECTED: base.set(ID_protection, ID_protected); break; - case TOK_PRIVATE: + case ATOK_PRIVATE: base.set(ID_protection, ID_private); break; @@ -4592,7 +4592,7 @@ bool Parser::rBaseSpecifiers(irept &bases) t=lex.LookAhead(0); } - if(t==TOK_VIRTUAL) + if(t==ATOK_VIRTUAL) { lex.get_token(tk); base.set(ID_virtual, true); @@ -4601,7 +4601,7 @@ bool Parser::rBaseSpecifiers(irept &bases) if(!rName(base.add(ID_name))) return false; - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { lex.get_token(); @@ -4693,19 +4693,19 @@ bool Parser::rClassMember(cpp_itemt &member) << '\n'; #endif // DEBUG - if(t==TOK_PUBLIC || t==TOK_PROTECTED || t==TOK_PRIVATE) + if(t==ATOK_PUBLIC || t==ATOK_PROTECTED || t==ATOK_PRIVATE) { switch(lex.get_token(tk1)) { - case TOK_PUBLIC: + case ATOK_PUBLIC: member.id("cpp-public"); break; - case TOK_PROTECTED: + case ATOK_PROTECTED: member.id("cpp-protected"); break; - case TOK_PRIVATE: + case ATOK_PRIVATE: member.id("cpp-private"); break; @@ -4722,19 +4722,19 @@ bool Parser::rClassMember(cpp_itemt &member) } else if(t==';') return rNullDeclaration(member.make_declaration()); - else if(t==TOK_TYPEDEF) + else if(t==ATOK_TYPEDEF) return rTypedef(member.make_declaration()); - else if(t==TOK_TEMPLATE) + else if(t==ATOK_TEMPLATE) return rTemplateDecl(member.make_declaration()); else if( - t == TOK_USING && is_identifier(lex.LookAhead(1)) && + t == ATOK_USING && is_identifier(lex.LookAhead(1)) && lex.LookAhead(2) == '=') { return rTypedefUsing(member.make_declaration()); } - else if(t==TOK_USING) + else if(t==ATOK_USING) return rUsing(member.make_using()); - else if(t==TOK_STATIC_ASSERT) + else if(t==ATOK_STATIC_ASSERT) return rStaticAssert(member.make_static_assert()); else { @@ -4838,10 +4838,10 @@ bool Parser::rExpression(exprt &exp, bool template_args) int t=lex.LookAhead(0); if(t=='=' || - t==TOK_MULTASSIGN || t==TOK_DIVASSIGN || t==TOK_MODASSIGN || - t==TOK_PLUSASSIGN || t==TOK_MINUSASSIGN || t==TOK_SHLASSIGN || - t==TOK_SHRASSIGN || t==TOK_ANDASSIGN || - t==TOK_XORASSIGN || t==TOK_ORASSIGN) + t==ATOK_MULTASSIGN || t==ATOK_DIVASSIGN || t==ATOK_MODASSIGN || + t==ATOK_PLUSASSIGN || t==ATOK_MINUSASSIGN || t==ATOK_SHLASSIGN || + t==ATOK_SHRASSIGN || t==ATOK_ANDASSIGN || + t==ATOK_XORASSIGN || t==ATOK_ORASSIGN) { lex.get_token(tk); @@ -4864,25 +4864,25 @@ bool Parser::rExpression(exprt &exp, bool template_args) if(t=='=') exp.set(ID_statement, ID_assign); - else if(t==TOK_PLUSASSIGN) + else if(t==ATOK_PLUSASSIGN) exp.set(ID_statement, ID_assign_plus); - else if(t==TOK_MINUSASSIGN) + else if(t==ATOK_MINUSASSIGN) exp.set(ID_statement, ID_assign_minus); - else if(t==TOK_MULTASSIGN) + else if(t==ATOK_MULTASSIGN) exp.set(ID_statement, ID_assign_mult); - else if(t==TOK_DIVASSIGN) + else if(t==ATOK_DIVASSIGN) exp.set(ID_statement, ID_assign_div); - else if(t==TOK_MODASSIGN) + else if(t==ATOK_MODASSIGN) exp.set(ID_statement, ID_assign_mod); - else if(t==TOK_SHLASSIGN) + else if(t==ATOK_SHLASSIGN) exp.set(ID_statement, ID_assign_shl); - else if(t==TOK_SHRASSIGN) + else if(t==ATOK_SHRASSIGN) exp.set(ID_statement, ID_assign_shr); - else if(t==TOK_ANDASSIGN) + else if(t==ATOK_ANDASSIGN) exp.set(ID_statement, ID_assign_bitand); - else if(t==TOK_XORASSIGN) + else if(t==ATOK_XORASSIGN) exp.set(ID_statement, ID_assign_bitxor); - else if(t==TOK_ORASSIGN) + else if(t==ATOK_ORASSIGN) exp.set(ID_statement, ID_assign_bitor); exp.add_to_operands(std::move(left), std::move(right)); @@ -4963,7 +4963,7 @@ bool Parser::rLogicalOrExpr(exprt &exp, bool template_args) std::cout << std::string(__indent, ' ') << "Parser::rLogicalOrExpr 1\n"; #endif - while(lex.LookAhead(0)==TOK_OROR) + while(lex.LookAhead(0)==ATOK_OROR) { cpp_tokent tk; lex.get_token(tk); @@ -5002,7 +5002,7 @@ bool Parser::rLogicalAndExpr(exprt &exp, bool template_args) std::cout << std::string(__indent, ' ') << "Parser::rLogicalAndExpr 1\n"; #endif - while(lex.LookAhead(0)==TOK_ANDAND) + while(lex.LookAhead(0)==ATOK_ANDAND) { cpp_tokent tk; lex.get_token(tk); @@ -5158,8 +5158,8 @@ bool Parser::rEqualityExpr(exprt &exp, bool template_args) std::cout << std::string(__indent, ' ') << "Parser::rEqualityExpr 1\n"; #endif - while(lex.LookAhead(0)==TOK_EQ || - lex.LookAhead(0)==TOK_NE) + while(lex.LookAhead(0)==ATOK_EQ || + lex.LookAhead(0)==ATOK_NE) { cpp_tokent tk; lex.get_token(tk); @@ -5171,7 +5171,7 @@ bool Parser::rEqualityExpr(exprt &exp, bool template_args) exprt left; left.swap(exp); - exp=exprt(tk.kind==TOK_EQ?ID_equal:ID_notequal); + exp=exprt(tk.kind==ATOK_EQ?ID_equal:ID_notequal); exp.add_to_operands(std::move(left), std::move(right)); set_location(exp, tk); } @@ -5201,7 +5201,7 @@ bool Parser::rRelationalExpr(exprt &exp, bool template_args) int t; while(t=lex.LookAhead(0), - (t==TOK_LE || t==TOK_GE || t=='<' || (t=='>' && !template_args))) + (t==ATOK_LE || t==ATOK_GE || t=='<' || (t=='>' && !template_args))) { cpp_tokent tk; lex.get_token(tk); @@ -5217,8 +5217,8 @@ bool Parser::rRelationalExpr(exprt &exp, bool template_args) switch(t) { - case TOK_LE: id=ID_le; break; - case TOK_GE: id=ID_ge; break; + case ATOK_LE: id=ID_le; break; + case ATOK_GE: id=ID_ge; break; case '<': id=ID_lt; break; case '>': id=ID_gt; break; } @@ -5250,8 +5250,8 @@ bool Parser::rShiftExpr(exprt &exp, bool template_args) std::cout << std::string(__indent, ' ') << "Parser::rShiftExpr 1\n"; #endif - while(lex.LookAhead(0)==TOK_SHIFTLEFT || - (lex.LookAhead(0)==TOK_SHIFTRIGHT && !template_args)) + while(lex.LookAhead(0)==ATOK_SHIFTLEFT || + (lex.LookAhead(0)==ATOK_SHIFTRIGHT && !template_args)) { cpp_tokent tk; lex.get_token(tk); @@ -5263,7 +5263,7 @@ bool Parser::rShiftExpr(exprt &exp, bool template_args) exprt left; left.swap(exp); - exp=exprt((tk.kind==TOK_SHIFTRIGHT)?ID_shr:ID_shl); + exp=exprt((tk.kind==ATOK_SHIFTRIGHT)?ID_shr:ID_shl); exp.add_to_operands(std::move(left), std::move(right)); set_location(exp, tk); } @@ -5390,8 +5390,8 @@ bool Parser::rPmExpr(exprt &exp) std::cout << std::string(__indent, ' ') << "Parser::rPmExpr 1\n"; #endif - while(lex.LookAhead(0)==TOK_DOTPM || - lex.LookAhead(0)==TOK_ARROWPM) + while(lex.LookAhead(0)==ATOK_DOTPM || + lex.LookAhead(0)==ATOK_ARROWPM) { cpp_tokent tk; lex.get_token(tk); @@ -5451,7 +5451,7 @@ bool Parser::rCastExpr(exprt &exp) if(lex.get_token(tk2)==')') { if(lex.LookAhead(0)=='&' && - lex.LookAhead(1)==TOK_INTEGER) + lex.LookAhead(1)==ATOK_INTEGER) { // we have (x) & 123 // This is likely a binary bit-wise 'and' @@ -5586,7 +5586,7 @@ bool Parser::rTypeNameOrFunctionType(typet &tname) // struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), // true, false> if( - is_identifier(lex.LookAhead(0)) && lex.LookAhead(1) == TOK_SCOPE && + is_identifier(lex.LookAhead(0)) && lex.LookAhead(1) == ATOK_SCOPE && lex.LookAhead(2) == '*' && lex.LookAhead(3) == ')' && lex.LookAhead(4) == '(') { @@ -5628,7 +5628,7 @@ bool Parser::rTypeNameOrFunctionType(typet &tname) int t=lex.LookAhead(0); if(t==')') break; - else if(t==TOK_ELLIPSIS) + else if(t==ATOK_ELLIPSIS) { cpp_tokent tk; lex.get_token(tk); @@ -5650,7 +5650,7 @@ bool Parser::rTypeNameOrFunctionType(typet &tname) cpp_tokent tk; lex.get_token(tk); } - else if(t==TOK_ELLIPSIS) + else if(t==ATOK_ELLIPSIS) { // TODO -- this is actually ambiguous as it could refer to a // template parameter pack or declare a variadic function @@ -5715,7 +5715,7 @@ bool Parser::rUnaryExpr(exprt &exp) if(t=='*' || t=='&' || t=='+' || t=='-' || t=='!' || t=='~' || - t==TOK_INCR || t==TOK_DECR) + t==ATOK_INCR || t==ATOK_DECR) { cpp_tokent tk; lex.get_token(tk); @@ -5758,12 +5758,12 @@ bool Parser::rUnaryExpr(exprt &exp) exp=exprt(ID_bitnot); break; - case TOK_INCR: + case ATOK_INCR: exp=exprt(ID_side_effect); exp.set(ID_statement, ID_preincrement); break; - case TOK_DECR: + case ATOK_DECR: exp=exprt(ID_side_effect); exp.set(ID_statement, ID_predecrement); break; @@ -5777,15 +5777,15 @@ bool Parser::rUnaryExpr(exprt &exp) return true; } - else if(t==TOK_SIZEOF) + else if(t==ATOK_SIZEOF) return rSizeofExpr(exp); - else if(t==TOK_ALIGNOF) + else if(t==ATOK_ALIGNOF) return rAlignofExpr(exp); - else if(t==TOK_THROW) + else if(t==ATOK_THROW) return rThrowExpr(exp); - else if(t==TOK_NOEXCEPT) + else if(t==ATOK_NOEXCEPT) return rNoexceptExpr(exp); - else if(t==TOK_REAL || t==TOK_IMAG) + else if(t==ATOK_REAL || t==ATOK_IMAG) { // a GCC extension for complex floating-point arithmetic cpp_tokent tk; @@ -5796,7 +5796,7 @@ bool Parser::rUnaryExpr(exprt &exp) if(!rUnaryExpr(unary)) return false; - exp=exprt(t==TOK_REAL?ID_complex_real:ID_complex_imag); + exp=exprt(t==ATOK_REAL?ID_complex_real:ID_complex_imag); exp.add_to_operands(std::move(unary)); set_location(exp, tk); return true; @@ -5820,7 +5820,7 @@ bool Parser::rThrowExpr(exprt &exp) std::cout << std::string(__indent, ' ') << "Parser::rThrowExpr 0\n"; #endif - if(lex.get_token(tk)!=TOK_THROW) + if(lex.get_token(tk)!=ATOK_THROW) return false; int t=lex.LookAhead(0); @@ -5859,7 +5859,7 @@ bool Parser::rTypeidExpr(exprt &exp) std::cout << std::string(__indent, ' ') << "Parser::rTypeidExpr 0\n"; #endif - if(lex.get_token(tk)!=TOK_TYPEID) + if(lex.get_token(tk)!=ATOK_TYPEID) return false; if(lex.LookAhead(0)=='(') @@ -5925,7 +5925,7 @@ bool Parser::rSizeofExpr(exprt &exp) std::cout << std::string(__indent, ' ') << "Parser::rSizeofExpr 0\n"; #endif - if(lex.get_token(tk)!=TOK_SIZEOF) + if(lex.get_token(tk)!=ATOK_SIZEOF) return false; if(lex.LookAhead(0)=='(') @@ -5949,7 +5949,7 @@ bool Parser::rSizeofExpr(exprt &exp) lex.Restore(pos); } - else if(lex.LookAhead(0)==TOK_ELLIPSIS) + else if(lex.LookAhead(0)==ATOK_ELLIPSIS) { typet tname; cpp_tokent ell, op, cp; @@ -5992,7 +5992,7 @@ bool Parser::rAlignofExpr(exprt &exp) { cpp_tokent tk; - if(lex.get_token(tk)!=TOK_ALIGNOF) + if(lex.get_token(tk)!=ATOK_ALIGNOF) return false; typet tname; @@ -6025,7 +6025,7 @@ bool Parser::rNoexceptExpr(exprt &exp) std::cout << std::string(__indent, ' ') << "Parser::rNoexceptExpr 0\n"; #endif - if(lex.get_token(tk)!=TOK_NOEXCEPT) + if(lex.get_token(tk)!=ATOK_NOEXCEPT) return false; if(lex.LookAhead(0)=='(') @@ -6055,10 +6055,10 @@ bool Parser::rNoexceptExpr(exprt &exp) bool Parser::isAllocateExpr(int t) { - if(t==TOK_SCOPE) + if(t==ATOK_SCOPE) t=lex.LookAhead(1); - return t==TOK_NEW || t==TOK_DELETE; + return t==ATOK_NEW || t==ATOK_DELETE; } /* @@ -6077,7 +6077,7 @@ bool Parser::rAllocateExpr(exprt &exp) #endif int t=lex.LookAhead(0); - if(t==TOK_SCOPE) + if(t==ATOK_SCOPE) { lex.get_token(tk); // TODO one can put 'new'/'delete' into a namespace! @@ -6093,7 +6093,7 @@ bool Parser::rAllocateExpr(exprt &exp) std::cout << std::string(__indent, ' ') << "Parser::rAllocateExpr 2\n"; #endif - if(t==TOK_DELETE) + if(t==ATOK_DELETE) { exprt obj; @@ -6122,7 +6122,7 @@ bool Parser::rAllocateExpr(exprt &exp) return true; } - else if(t==TOK_NEW) + else if(t==ATOK_NEW) { #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rAllocateExpr 3\n"; @@ -6304,7 +6304,7 @@ bool Parser::rAllocateInitializer(exprt &init) init.add_to_operands(std::move(exp)); - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { lex.get_token(); // TODO @@ -6413,7 +6413,7 @@ bool Parser::rPostfixExpr(exprt &exp) } break; - case TOK_INCR: + case ATOK_INCR: lex.get_token(op); { @@ -6424,7 +6424,7 @@ bool Parser::rPostfixExpr(exprt &exp) } break; - case TOK_DECR: + case ATOK_DECR: lex.get_token(op); { @@ -6436,7 +6436,7 @@ bool Parser::rPostfixExpr(exprt &exp) break; case '.': - case TOK_ARROW: + case ATOK_ARROW: t2=lex.get_token(op); #ifdef DEBUG @@ -6483,7 +6483,7 @@ bool Parser::rMSCuuidof(exprt &expr) { cpp_tokent tk; - if(lex.get_token(tk)!=TOK_MSC_UUIDOF) + if(lex.get_token(tk)!=ATOK_MSC_UUIDOF) return false; if(lex.get_token(tk)!='(') @@ -6534,8 +6534,8 @@ bool Parser::rMSC_if_existsExpr(exprt &expr) lex.get_token(tk1); - if(tk1.kind!=TOK_MSC_IF_EXISTS && - tk1.kind!=TOK_MSC_IF_NOT_EXISTS) + if(tk1.kind!=ATOK_MSC_IF_EXISTS && + tk1.kind!=ATOK_MSC_IF_NOT_EXISTS) return false; cpp_tokent tk2; @@ -6563,7 +6563,7 @@ bool Parser::rMSC_if_existsExpr(exprt &expr) return false; expr=exprt( - tk1.kind==TOK_MSC_IF_EXISTS?ID_msc_if_exists: + tk1.kind==ATOK_MSC_IF_EXISTS?ID_msc_if_exists: ID_msc_if_not_exists); expr.add_to_operands(std::move(name), std::move(op)); @@ -6579,7 +6579,7 @@ std::optional Parser::rMSC_if_existsStatement() lex.get_token(tk1); - if(tk1.kind != TOK_MSC_IF_EXISTS && tk1.kind != TOK_MSC_IF_NOT_EXISTS) + if(tk1.kind != ATOK_MSC_IF_EXISTS && tk1.kind != ATOK_MSC_IF_NOT_EXISTS) return {}; cpp_tokent tk2; @@ -6612,7 +6612,7 @@ std::optional Parser::rMSC_if_existsStatement() return {}; codet code( - tk1.kind == TOK_MSC_IF_EXISTS ? ID_msc_if_exists : ID_msc_if_not_exists); + tk1.kind == ATOK_MSC_IF_EXISTS ? ID_msc_if_exists : ID_msc_if_not_exists); code.add_to_operands(std::move(name), std::move(block)); @@ -6641,7 +6641,7 @@ bool Parser::rTypePredicate(exprt &expr) switch(tk.kind) { - case TOK_UNARY_TYPE_PREDICATE: + case ATOK_UNARY_TYPE_PREDICATE: if(lex.get_token(tk)!='(') return false; if(!rTypeName(tname1)) @@ -6651,7 +6651,7 @@ bool Parser::rTypePredicate(exprt &expr) expr.add(ID_type_arg).swap(tname1); break; - case TOK_BINARY_TYPE_PREDICATE: + case ATOK_BINARY_TYPE_PREDICATE: if(lex.get_token(tk)!='(') return false; if(!rTypeName(tname1)) @@ -6702,9 +6702,9 @@ bool Parser::rPrimaryExpr(exprt &exp) switch(lex.LookAhead(0)) { - case TOK_INTEGER: - case TOK_CHARACTER: - case TOK_FLOATING: + case ATOK_INTEGER: + case ATOK_CHARACTER: + case ATOK_FLOATING: lex.get_token(tk); exp.swap(tk.data); set_location(exp, tk); @@ -6713,7 +6713,7 @@ bool Parser::rPrimaryExpr(exprt &exp) #endif return true; - case TOK_STRING: + case ATOK_STRING: rString(tk); exp.swap(tk.data); set_location(exp, tk); @@ -6722,7 +6722,7 @@ bool Parser::rPrimaryExpr(exprt &exp) #endif return true; - case TOK_THIS: + case ATOK_THIS: lex.get_token(tk); exp=exprt("cpp-this"); set_location(exp, tk); @@ -6731,7 +6731,7 @@ bool Parser::rPrimaryExpr(exprt &exp) #endif return true; - case TOK_TRUE: + case ATOK_TRUE: lex.get_token(tk); exp = typecast_exprt(true_exprt(), c_bool_type()); set_location(exp, tk); @@ -6740,7 +6740,7 @@ bool Parser::rPrimaryExpr(exprt &exp) #endif return true; - case TOK_FALSE: + case ATOK_FALSE: lex.get_token(tk); exp = typecast_exprt(false_exprt(), c_bool_type()); set_location(exp, tk); @@ -6749,7 +6749,7 @@ bool Parser::rPrimaryExpr(exprt &exp) #endif return true; - case TOK_NULLPTR: + case ATOK_NULLPTR: lex.get_token(tk); // as an exception, we set the width of pointer exp = null_pointer_exprt{pointer_type(typet(ID_nullptr))}; @@ -6808,17 +6808,17 @@ bool Parser::rPrimaryExpr(exprt &exp) #endif return rInitializeExpr(exp); - case TOK_TYPEID: + case ATOK_TYPEID: return rTypeidExpr(exp); - case TOK_UNARY_TYPE_PREDICATE: - case TOK_BINARY_TYPE_PREDICATE: + case ATOK_UNARY_TYPE_PREDICATE: + case ATOK_BINARY_TYPE_PREDICATE: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rPrimaryExpr 11\n"; #endif return rTypePredicate(exp); - case TOK_MSC_UUIDOF: + case ATOK_MSC_UUIDOF: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rPrimaryExpr 12\n"; #endif @@ -6826,8 +6826,8 @@ bool Parser::rPrimaryExpr(exprt &exp) // not quite appropriate: these allow more general // token streams, not just expressions - case TOK_MSC_IF_EXISTS: - case TOK_MSC_IF_NOT_EXISTS: + case ATOK_MSC_IF_EXISTS: + case ATOK_MSC_IF_NOT_EXISTS: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rPrimaryExpr 13\n"; #endif @@ -6847,7 +6847,7 @@ bool Parser::rPrimaryExpr(exprt &exp) std::cout << std::string(__indent, ' ') << "Parser::rPrimaryExpr 15\n"; #endif - if(type.is_not_nil() && lex.LookAhead(0)==TOK_SCOPE) + if(type.is_not_nil() && lex.LookAhead(0)==ATOK_SCOPE) { lex.get_token(tk); lex.get_token(tk); @@ -6896,7 +6896,7 @@ bool Parser::rPrimaryExpr(exprt &exp) if(!rVarName(exp)) return false; - if(lex.LookAhead(0)==TOK_SCOPE) + if(lex.LookAhead(0)==ATOK_SCOPE) { lex.get_token(tk); @@ -6947,7 +6947,7 @@ bool Parser::rVarNameCore(exprt &name) name = cpp_namet().as_expr(); irept::subt &components=name.get_sub(); - if(lex.LookAhead(0)==TOK_TYPENAME) + if(lex.LookAhead(0)==ATOK_TYPENAME) { cpp_tokent tk; lex.get_token(tk); @@ -6976,7 +6976,7 @@ bool Parser::rVarNameCore(exprt &name) switch(lex.LookAhead(0)) { - case TOK_TEMPLATE: + case ATOK_TEMPLATE: // this may be a template member function, for example #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rVarNameCore 2\n"; @@ -6987,8 +6987,8 @@ bool Parser::rVarNameCore(exprt &name) return false; break; - case TOK_GCC_IDENTIFIER: - case TOK_MSC_IDENTIFIER: + case ATOK_GCC_IDENTIFIER: + case ATOK_MSC_IDENTIFIER: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rVarNameCore 3\n"; #endif @@ -7021,7 +7021,7 @@ bool Parser::rVarNameCore(exprt &name) return true; break; - case TOK_SCOPE: + case ATOK_SCOPE: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rVarNameCore 5\n"; #endif @@ -7045,7 +7045,7 @@ bool Parser::rVarNameCore(exprt &name) set_location(components.back(), tk); break; - case TOK_OPERATOR: + case ATOK_OPERATOR: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rVarNameCore 7\n"; #endif @@ -7072,10 +7072,10 @@ bool Parser::rVarNameCore(exprt &name) bool Parser::moreVarName() { - if(lex.LookAhead(0)==TOK_SCOPE) + if(lex.LookAhead(0)==ATOK_SCOPE) { int t=lex.LookAhead(1); - if(is_identifier(t) || t == '~' || t == TOK_OPERATOR || t == TOK_TEMPLATE) + if(is_identifier(t) || t == '~' || t == ATOK_OPERATOR || t == ATOK_TEMPLATE) return true; } @@ -7105,8 +7105,8 @@ bool Parser::maybeTemplateArgs() int u=lex.LookAhead(i++); if(u=='\0' || u==';' || u=='}') return false; - else if((u=='>' || u==TOK_SHIFTRIGHT) && - (lex.LookAhead(i)==TOK_SCOPE || lex.LookAhead(i)=='(' || + else if((u=='>' || u==ATOK_SHIFTRIGHT) && + (lex.LookAhead(i)==ATOK_SCOPE || lex.LookAhead(i)=='(' || lex.LookAhead(i)==')')) return true; } @@ -7153,7 +7153,7 @@ bool Parser::maybeTemplateArgs() } else if(u=='\0' || u==';' || u=='}') return false; - else if(u==TOK_SHIFTRIGHT && n>=2) + else if(u==ATOK_SHIFTRIGHT && n>=2) n-=2; #ifdef DEBUG @@ -7172,7 +7172,7 @@ bool Parser::maybeTemplateArgs() std::cout << std::string(__indent, ' ') << "Parser::maybeTemplateArgs 6\n"; #endif - return t==TOK_SCOPE || t=='('; + return t==ATOK_SCOPE || t=='('; #endif } @@ -7194,7 +7194,7 @@ bool Parser::rFunctionBody(cpp_declaratort &declarator) // ARMCC, CodeWarrior... if(lex.LookAhead(0)=='{' && - lex.LookAhead(1)==TOK_ASM_STRING) + lex.LookAhead(1)==ATOK_ASM_STRING) { cpp_tokent ob, tk, cb; lex.get_token(ob); @@ -7312,39 +7312,39 @@ std::optional Parser::rStatement() case '{': return rCompoundStatement(); - case TOK_TYPEDEF: + case ATOK_TYPEDEF: return rTypedefStatement(); - case TOK_IF: + case ATOK_IF: return rIfStatement(); - case TOK_SWITCH: + case ATOK_SWITCH: return rSwitchStatement(); - case TOK_WHILE: + case ATOK_WHILE: return rWhileStatement(); - case TOK_DO: + case ATOK_DO: return rDoStatement(); - case TOK_FOR: + case ATOK_FOR: return rForStatement(); - case TOK_TRY: + case ATOK_TRY: return rTryStatement(); - case TOK_MSC_TRY: + case ATOK_MSC_TRY: return rMSC_tryStatement(); - case TOK_MSC_LEAVE: + case ATOK_MSC_LEAVE: return rMSC_leaveStatement(); - case TOK_BREAK: - case TOK_CONTINUE: + case ATOK_BREAK: + case ATOK_CONTINUE: { lex.get_token(tk1); - codet statement(k == TOK_BREAK ? ID_break : ID_continue); + codet statement(k == ATOK_BREAK ? ID_break : ID_continue); set_location(statement, tk1); if(lex.get_token(tk2)!=';') @@ -7352,7 +7352,7 @@ std::optional Parser::rStatement() return std::move(statement); } - case TOK_RETURN: + case ATOK_RETURN: { #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rStatement RETURN 0\n"; @@ -7392,7 +7392,7 @@ std::optional Parser::rStatement() return std::move(statement); } - case TOK_GOTO: + case ATOK_GOTO: { lex.get_token(tk1); @@ -7407,7 +7407,7 @@ std::optional Parser::rStatement() return std::move(statement); } - case TOK_CASE: + case ATOK_CASE: { lex.get_token(tk1); @@ -7415,7 +7415,7 @@ std::optional Parser::rStatement() if(!rExpression(case_expr, false)) return {}; - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { // This is a gcc extension for case ranges. // Should really refuse in non-GCC modes. @@ -7455,7 +7455,7 @@ std::optional Parser::rStatement() } } - case TOK_DEFAULT: + case ATOK_DEFAULT: { lex.get_token(tk1); @@ -7473,18 +7473,18 @@ std::optional Parser::rStatement() return {}; } - case TOK_GCC_ASM: + case ATOK_GCC_ASM: return rGCCAsmStatement(); - case TOK_MSC_ASM: + case ATOK_MSC_ASM: return rMSCAsmStatement(); - case TOK_MSC_IF_EXISTS: - case TOK_MSC_IF_NOT_EXISTS: + case ATOK_MSC_IF_EXISTS: + case ATOK_MSC_IF_NOT_EXISTS: return rMSC_if_existsStatement(); - case TOK_GCC_IDENTIFIER: - case TOK_MSC_IDENTIFIER: + case ATOK_GCC_IDENTIFIER: + case ATOK_MSC_IDENTIFIER: if(lex.LookAhead(1)==':') // label statement { // the label @@ -7504,7 +7504,7 @@ std::optional Parser::rStatement() return rExprStatement(); - case TOK_USING: + case ATOK_USING: { if(is_identifier(lex.LookAhead(1)) && lex.LookAhead(2) == '=') { @@ -7525,7 +7525,7 @@ std::optional Parser::rStatement() UNIMPLEMENTED; } - case TOK_STATIC_ASSERT: + case ATOK_STATIC_ASSERT: { cpp_static_assertt cpp_static_assert{nil_exprt(), nil_exprt()}; @@ -7552,7 +7552,7 @@ std::optional Parser::rIfStatement() { cpp_tokent tk1, tk2, tk3, tk4; - if(lex.get_token(tk1)!=TOK_IF) + if(lex.get_token(tk1)!=ATOK_IF) return {}; if(lex.get_token(tk2)!='(') @@ -7569,7 +7569,7 @@ std::optional Parser::rIfStatement() if(!then.has_value()) return {}; - if(lex.LookAhead(0)==TOK_ELSE) + if(lex.LookAhead(0)==ATOK_ELSE) { lex.get_token(tk4); @@ -7599,7 +7599,7 @@ std::optional Parser::rSwitchStatement() { cpp_tokent tk1, tk2, tk3; - if(lex.get_token(tk1)!=TOK_SWITCH) + if(lex.get_token(tk1)!=ATOK_SWITCH) return {}; if(lex.get_token(tk2)!='(') @@ -7630,7 +7630,7 @@ std::optional Parser::rWhileStatement() { cpp_tokent tk1, tk2, tk3; - if(lex.get_token(tk1)!=TOK_WHILE) + if(lex.get_token(tk1)!=ATOK_WHILE) return {}; if(lex.get_token(tk2)!='(') @@ -7661,14 +7661,14 @@ std::optional Parser::rDoStatement() { cpp_tokent tk0, tk1, tk2, tk3, tk4; - if(lex.get_token(tk0)!=TOK_DO) + if(lex.get_token(tk0)!=ATOK_DO) return {}; auto body = rStatement(); if(!body.has_value()) return {}; - if(lex.get_token(tk1)!=TOK_WHILE) + if(lex.get_token(tk1)!=ATOK_WHILE) return {}; if(lex.get_token(tk2)!='(') @@ -7698,7 +7698,7 @@ std::optional Parser::rForStatement() { cpp_tokent tk1, tk2, tk3, tk4; - if(lex.get_token(tk1)!=TOK_FOR) + if(lex.get_token(tk1)!=ATOK_FOR) return {}; if(lex.get_token(tk2)!='(') @@ -7756,7 +7756,7 @@ std::optional Parser::rTryStatement() cpp_tokent try_token; // The 'try' block - if(lex.get_token(try_token) != TOK_TRY) + if(lex.get_token(try_token) != ATOK_TRY) return {}; auto try_body = rCompoundStatement(); @@ -7771,7 +7771,7 @@ std::optional Parser::rTryStatement() { cpp_tokent catch_token, op_token, cp_token; - if(lex.get_token(catch_token)!=TOK_CATCH) + if(lex.get_token(catch_token)!=ATOK_CATCH) return {}; if(lex.get_token(op_token)!='(') @@ -7779,7 +7779,7 @@ std::optional Parser::rTryStatement() std::optional catch_op; - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { cpp_tokent ellipsis_token; lex.get_token(ellipsis_token); @@ -7822,7 +7822,7 @@ std::optional Parser::rTryStatement() else return {}; } - while(lex.LookAhead(0)==TOK_CATCH); + while(lex.LookAhead(0)==ATOK_CATCH); return std::move(statement); } @@ -7834,7 +7834,7 @@ std::optional Parser::rMSC_tryStatement() cpp_tokent tk, tk2, tk3; - if(lex.get_token(tk)!=TOK_MSC_TRY) + if(lex.get_token(tk)!=ATOK_MSC_TRY) return {}; auto body1 = rCompoundStatement(); @@ -7842,7 +7842,7 @@ std::optional Parser::rMSC_tryStatement() if(!body1.has_value()) return {}; - if(lex.LookAhead(0)==TOK_MSC_EXCEPT) + if(lex.LookAhead(0)==ATOK_MSC_EXCEPT) { codet statement(ID_msc_try_except); set_location(statement, tk); @@ -7870,7 +7870,7 @@ std::optional Parser::rMSC_tryStatement() else return {}; } - else if(lex.LookAhead(0)==TOK_MSC_FINALLY) + else if(lex.LookAhead(0)==ATOK_MSC_FINALLY) { codet statement(ID_msc_try_finally); set_location(statement, tk); @@ -7896,7 +7896,7 @@ std::optional Parser::rMSC_leaveStatement() cpp_tokent tk; - if(lex.get_token(tk)!=TOK_MSC_LEAVE) + if(lex.get_token(tk)!=ATOK_MSC_LEAVE) return {}; codet statement(ID_msc_leave); @@ -7916,13 +7916,13 @@ std::optional Parser::rGCCAsmStatement() // asm [volatile] ("stuff" [ : ["=S" [(__res)], ... ]]) ; - if(lex.get_token(tk)!=TOK_GCC_ASM) + if(lex.get_token(tk)!=ATOK_GCC_ASM) return {}; code_asm_gcct statement; set_location(statement, tk); - if(lex.LookAhead(0)==TOK_VOLATILE) + if(lex.LookAhead(0)==ATOK_VOLATILE) lex.get_token(tk); #ifdef DEBUG @@ -7952,7 +7952,7 @@ std::optional Parser::rGCCAsmStatement() for(;;) { - if(lex.LookAhead(0)!=TOK_STRING) + if(lex.LookAhead(0)!=ATOK_STRING) break; // get String @@ -8016,7 +8016,7 @@ std::optional Parser::rMSCAsmStatement() // asm "STUFF" // asm { "STUFF" } - if(lex.get_token(tk)!=TOK_MSC_ASM) + if(lex.get_token(tk)!=ATOK_MSC_ASM) return {}; code_asmt statement; @@ -8035,7 +8035,7 @@ std::optional Parser::rMSCAsmStatement() std::cout << std::string(__indent, ' ') << "Parser::rMSCAsmStatement 3\n"; #endif // DEBUG - if(lex.LookAhead(0)!=TOK_ASM_STRING) + if(lex.LookAhead(0)!=ATOK_ASM_STRING) return {}; lex.get_token(tk); @@ -8054,7 +8054,7 @@ std::optional Parser::rMSCAsmStatement() std::cout << std::string(__indent, ' ') << "Parser::rMSCAsmStatement 5\n"; #endif // DEBUG - if(lex.LookAhead(0)!=TOK_ASM_STRING) + if(lex.LookAhead(0)!=ATOK_ASM_STRING) return std::move(statement); lex.get_token(tk); diff --git a/src/jsil/parser.y b/src/jsil/parser.y index 31c96d972edd..2b9253addfd8 100644 --- a/src/jsil/parser.y +++ b/src/jsil/parser.y @@ -29,6 +29,13 @@ int yyjsilerror(const std::string &error) #include +/* To avoid LTO -Wodr clashes with ansi-c */ +#define YYTOKENTYPE 1 +#define YYEMPTY -2 +#define YYEOF 0 /* "end of file" */ +#define YYerror 256 /* error */ +#define YYUNDEF 257 /* "invalid token" */ + #include "jsil_y.tab.h" #ifdef _MSC_VER @@ -49,80 +56,80 @@ int yyjsilerror(const std::string &error) /*** special scanner reports ***/ -%token TOK_SCANNER_ERROR /* used by scanner to report errors */ -%token TOK_NEWLINE "" +%token JTOK_SCANNER_ERROR /* used by scanner to report errors */ +%token JTOK_NEWLINE "" /*** keywords ***/ -%token TOK_PROCEDURE "procedure" -%token TOK_RETURNS "returns" -%token TOK_TO "to" -%token TOK_THROWS "throws" -%token TOK_EVAL "eval" -%token TOK_LABEL "label" -%token TOK_GOTO "goto" -%token TOK_SKIP "skip" -%token TOK_WITH "with" -%token TOK_NEW "new" -%token TOK_HAS_FIELD "hasField" -%token TOK_DELETE "delete" -%token TOK_PROTO_FIELD "protoField" -%token TOK_PROTO_OBJ "protoObj" -%token TOK_REF "ref" -%token TOK_FIELD "field" -%token TOK_BASE "base" -%token TOK_TYPEOF "typeOf" -%token TOK_NULL "null" -%token TOK_UNDEFINED "#undefined" -%token TOK_EMPTY "#empty" -%token TOK_TRUE "true" -%token TOK_FALSE "false" -%token TOK_PROTO "#proto" -%token TOK_FID "#fid" -%token TOK_SCOPE "#scope" -%token TOK_CONSTRUCTID "#constructid" -%token TOK_PRIMVALUE "#primvalue" -%token TOK_TARGETFUNCTION "#targetfunction" -%token TOK_CLASS "#class" -%token TOK_NUM_TO_STRING "num_to_string" -%token TOK_STRING_TO_NUM "string_to_num" -%token TOK_NUM_TO_INT32 "num_to_int32" -%token TOK_NUM_TO_UINT32 "num_to_uint32" -%token TOK_MEMBER_REFERENCE "#MemberReference" -%token TOK_VARIABLE_REFERENCE "#VariableReference" +%token JTOK_PROCEDURE "procedure" +%token JTOK_RETURNS "returns" +%token JTOK_TO "to" +%token JTOK_THROWS "throws" +%token JTOK_EVAL "eval" +%token JTOK_LABEL "label" +%token JTOK_GOTO "goto" +%token JTOK_SKIP "skip" +%token JTOK_WITH "with" +%token JTOK_NEW "new" +%token JTOK_HAS_FIELD "hasField" +%token JTOK_DELETE "delete" +%token JTOK_PROTO_FIELD "protoField" +%token JTOK_PROTO_OBJ "protoObj" +%token JTOK_REF "ref" +%token JTOK_FIELD "field" +%token JTOK_BASE "base" +%token JTOK_TYPEOF "typeOf" +%token JTOK_NULL "null" +%token JTOK_UNDEFINED "#undefined" +%token JTOK_EMPTY "#empty" +%token JTOK_TRUE "true" +%token JTOK_FALSE "false" +%token JTOK_PROTO "#proto" +%token JTOK_FID "#fid" +%token JTOK_SCOPE "#scope" +%token JTOK_CONSTRUCTID "#constructid" +%token JTOK_PRIMVALUE "#primvalue" +%token JTOK_TARGETFUNCTION "#targetfunction" +%token JTOK_CLASS "#class" +%token JTOK_NUM_TO_STRING "num_to_string" +%token JTOK_STRING_TO_NUM "string_to_num" +%token JTOK_NUM_TO_INT32 "num_to_int32" +%token JTOK_NUM_TO_UINT32 "num_to_uint32" +%token JTOK_MEMBER_REFERENCE "#MemberReference" +%token JTOK_VARIABLE_REFERENCE "#VariableReference" /*** type classes ***/ -%token TOK_T_NULL "#Null" -%token TOK_T_UNDEFINED "#Undefined" -%token TOK_T_BOOLEAN "#Boolean" -%token TOK_T_STRING "#String" -%token TOK_T_NUMBER "#Number" -%token TOK_T_BUILTIN_OBJECT "#BuiltinObject" -%token TOK_T_USER_OBJECT "#UserObject" -%token TOK_T_OBJECT "#Object" -%token TOK_T_REFERENCE "#Reference" +%token JTOK_T_NULL "#Null" +%token JTOK_T_UNDEFINED "#Undefined" +%token JTOK_T_BOOLEAN "#Boolean" +%token JTOK_T_STRING "#String" +%token JTOK_T_NUMBER "#Number" +%token JTOK_T_BUILTIN_OBJECT "#BuiltinObject" +%token JTOK_T_USER_OBJECT "#UserObject" +%token JTOK_T_OBJECT "#Object" +%token JTOK_T_REFERENCE "#Reference" /*** multi-character operators ***/ -%token TOK_DEFEQ ":=" -%token TOK_LEQ "<=" -%token TOK_AND "and" -%token TOK_OR "or" -%token TOK_SUBTYPE_OF "<:" -%token TOK_LEFT_SHIFT "<<" -%token TOK_SIGNED_RIGHT_SHIFT ">>" -%token TOK_UNSIGNED_RIGHT_SHIFT ">>>" -%token TOK_NOT "not" +%token JTOK_DEFEQ ":=" +%token JTOK_LEQ "<=" +%token JTOK_AND "and" +%token JTOK_OR "or" +%token JTOK_SUBTYPE_OF "<:" +%token JTOK_LEFT_SHIFT "<<" +%token JTOK_SIGNED_RIGHT_SHIFT ">>" +%token JTOK_UNSIGNED_RIGHT_SHIFT ">>>" +%token JTOK_NOT "not" /*** scanner parsed tokens (these have a value!) ***/ -%token TOK_IDENTIFIER -%token TOK_FLOATING -%token TOK_STRING -%token TOK_BUILTIN_LOC -%token TOK_BUILTIN_IDENTIFIER -%token TOK_SPEC_IDENTIFIER +%token JTOK_IDENTIFIER +%token JTOK_FLOATING +%token JTOK_STRING +%token JTOK_BUILTIN_LOC +%token JTOK_BUILTIN_IDENTIFIER +%token JTOK_SPEC_IDENTIFIER /*** priority, associativity, etc. definitions **************************/ @@ -139,9 +146,9 @@ procedure_decls: procedure_decl | procedure_decls procedure_decl ; -procedure_decl: TOK_PROCEDURE proc_ident '(' parameters_opt ')' - TOK_RETURNS TOK_IDENTIFIER TOK_TO TOK_IDENTIFIER - TOK_THROWS TOK_IDENTIFIER TOK_TO TOK_IDENTIFIER +procedure_decl: JTOK_PROCEDURE proc_ident '(' parameters_opt ')' + JTOK_RETURNS JTOK_IDENTIFIER JTOK_TO JTOK_IDENTIFIER + JTOK_THROWS JTOK_IDENTIFIER JTOK_TO JTOK_IDENTIFIER '{' statements_opt '}' { symbol_exprt proc(to_symbol_expr(parser_stack($2))); @@ -172,24 +179,24 @@ procedure_decl: TOK_PROCEDURE proc_ident '(' parameters_opt ')' } ; -proc_ident: TOK_IDENTIFIER - | TOK_EVAL +proc_ident: JTOK_IDENTIFIER + | JTOK_EVAL { symbol_exprt e = symbol_exprt::typeless("eval"); newstack($$).swap(e); } - | TOK_BUILTIN_IDENTIFIER + | JTOK_BUILTIN_IDENTIFIER { parser_stack($$).set("proc_type", "builtin"); } - | TOK_SPEC_IDENTIFIER + | JTOK_SPEC_IDENTIFIER { parser_stack($$).set("proc_type", "spec"); } ; proc_ident_expr: proc_ident - | TOK_STRING + | JTOK_STRING { symbol_exprt s = symbol_exprt::typeless( to_string_constant(parser_stack($$)).value()); @@ -204,12 +211,12 @@ parameters_opt: /* empty */ | parameters ; -parameters: TOK_IDENTIFIER +parameters: JTOK_IDENTIFIER { newstack($$).id(ID_parameters); parser_stack($$).add_to_operands(std::move(parser_stack($1))); } - | parameters ',' TOK_IDENTIFIER + | parameters ',' JTOK_IDENTIFIER { $$=$1; parser_stack($$).add_to_operands(std::move(parser_stack($3))); @@ -235,29 +242,29 @@ statements: statement } ; -statement: TOK_NEWLINE +statement: JTOK_NEWLINE { newstack($$)=code_skipt(); } - | instruction TOK_NEWLINE + | instruction JTOK_NEWLINE { $$=$1; } ; -instruction: TOK_LABEL TOK_IDENTIFIER +instruction: JTOK_LABEL JTOK_IDENTIFIER { code_labelt l( to_symbol_expr(parser_stack($2)).get_identifier(), code_skipt()); newstack($$).swap(l); } - | TOK_GOTO TOK_IDENTIFIER + | JTOK_GOTO JTOK_IDENTIFIER { code_gotot g(to_symbol_expr(parser_stack($2)).get_identifier()); newstack($$).swap(g); } - | TOK_GOTO '[' expression ']' TOK_IDENTIFIER ',' TOK_IDENTIFIER + | JTOK_GOTO '[' expression ']' JTOK_IDENTIFIER ',' JTOK_IDENTIFIER { code_gotot lt(to_symbol_expr(parser_stack($5)).get_identifier()); code_gotot lf(to_symbol_expr(parser_stack($7)).get_identifier()); @@ -266,16 +273,16 @@ instruction: TOK_LABEL TOK_IDENTIFIER newstack($$).swap(ite); } - | TOK_SKIP + | JTOK_SKIP { newstack($$)=code_skipt(); } - | TOK_IDENTIFIER TOK_DEFEQ rhs + | JTOK_IDENTIFIER JTOK_DEFEQ rhs { code_assignt a(parser_stack($1), parser_stack($3)); newstack($$).swap(a); } - | '[' expression ',' expression ']' TOK_DEFEQ expression + | '[' expression ',' expression ']' JTOK_DEFEQ expression { index_exprt i(parser_stack($2), parser_stack($4)); code_assignt a(i, parser_stack($7)); @@ -298,12 +305,12 @@ rhs: expression parser_stack($$).swap(w); } } - | TOK_NEW '(' ')' + | JTOK_NEW '(' ')' { exprt n("new"); newstack($$).swap(n); } - | TOK_HAS_FIELD '(' expression ',' expression ')' + | JTOK_HAS_FIELD '(' expression ',' expression ')' { exprt has_field("hasField"); has_field.add_to_operands(std::move(parser_stack($3)), std::move(parser_stack($5))); @@ -315,21 +322,21 @@ rhs: expression index_exprt i(parser_stack($2), parser_stack($4)); newstack($$).swap(i); } - | TOK_DELETE '(' expression ',' expression ')' + | JTOK_DELETE '(' expression ',' expression ')' { exprt d("delete"); d.add_to_operands(std::move(parser_stack($3)), std::move(parser_stack($5))); newstack($$).swap(d); } - | TOK_PROTO_FIELD '(' expression ',' expression ')' + | JTOK_PROTO_FIELD '(' expression ',' expression ')' { exprt proto_field("protoField"); proto_field.add_to_operands(std::move(parser_stack($3)), std::move(parser_stack($5))); newstack($$).swap(proto_field); } - | TOK_PROTO_OBJ '(' expression ',' expression ')' + | JTOK_PROTO_OBJ '(' expression ',' expression ')' { exprt proto_obj("protoObj"); proto_obj.add_to_operands(std::move(parser_stack($3)), std::move(parser_stack($5))); @@ -342,7 +349,7 @@ with_opt: /* empty */ { newstack($$); } - | TOK_WITH TOK_IDENTIFIER + | JTOK_WITH JTOK_IDENTIFIER { $$=$2; } @@ -385,7 +392,7 @@ atom_expression: literal { $$=$2; } - | TOK_REF '(' expression ',' expression ',' ref_type ')' + | JTOK_REF '(' expression ',' expression ',' ref_type ')' { exprt ref("ref"); ref.add_to_operands( @@ -395,21 +402,21 @@ atom_expression: literal newstack($$).swap(ref); } - | TOK_FIELD '(' expression ')' + | JTOK_FIELD '(' expression ')' { exprt field("field"); field.add_to_operands(std::move(parser_stack($3))); newstack($$).swap(field); } - | TOK_BASE '(' expression ')' + | JTOK_BASE '(' expression ')' { exprt base(ID_base); base.add_to_operands(std::move(parser_stack($3))); newstack($$).swap(base); } - | TOK_TYPEOF '(' expression ')' + | JTOK_TYPEOF '(' expression ')' { exprt typeof_expr(ID_typeof); typeof_expr.add_to_operands(std::move(parser_stack($3))); @@ -418,64 +425,64 @@ atom_expression: literal } ; -literal: TOK_IDENTIFIER - | TOK_NULL +literal: JTOK_IDENTIFIER + | JTOK_NULL { newstack($$).id(ID_null); } - | TOK_UNDEFINED + | JTOK_UNDEFINED { newstack($$).id("undefined"); } - | TOK_EMPTY + | JTOK_EMPTY { newstack($$).id(ID_empty); } - | TOK_TRUE + | JTOK_TRUE { newstack($$) = true_exprt(); } - | TOK_FALSE + | JTOK_FALSE { newstack($$) = false_exprt(); } - | TOK_FLOATING - | TOK_STRING + | JTOK_FLOATING + | JTOK_STRING { constant_exprt c(to_string_constant(parser_stack($$)) .value(), string_typet()); parser_stack($$).swap(c); } - | TOK_BUILTIN_LOC + | JTOK_BUILTIN_LOC | jsil_type | builtin_field ; -builtin_field: TOK_PROTO +builtin_field: JTOK_PROTO { newstack($$).id("proto"); } - | TOK_FID + | JTOK_FID { newstack($$).id("fid"); } - | TOK_SCOPE + | JTOK_SCOPE { newstack($$).id("scope"); } - | TOK_CONSTRUCTID + | JTOK_CONSTRUCTID { newstack($$).id("constructid"); } - | TOK_PRIMVALUE + | JTOK_PRIMVALUE { newstack($$).id("primvalue"); } - | TOK_TARGETFUNCTION + | JTOK_TARGETFUNCTION { newstack($$).id("targetfunction"); } - | TOK_CLASS + | JTOK_CLASS { newstack($$).id(ID_class); } @@ -495,7 +502,7 @@ compare_op: '=' { newstack($$).id(ID_lt); } - | TOK_LEQ + | JTOK_LEQ { newstack($$).id(ID_le); } @@ -523,15 +530,15 @@ arithmetic_op: '+' } ; -boolean_op: TOK_AND +boolean_op: JTOK_AND { newstack($$).id(ID_and); } - | TOK_OR + | JTOK_OR { newstack($$).id(ID_or); } - | TOK_SUBTYPE_OF + | JTOK_SUBTYPE_OF { newstack($$).id("subtype_of"); } @@ -553,21 +560,21 @@ bitwise_op: '&' { newstack($$).id(ID_bitxor); } - | TOK_LEFT_SHIFT + | JTOK_LEFT_SHIFT { newstack($$).id(ID_shl); } - | TOK_SIGNED_RIGHT_SHIFT + | JTOK_SIGNED_RIGHT_SHIFT { newstack($$).id(ID_shr); } - | TOK_UNSIGNED_RIGHT_SHIFT + | JTOK_UNSIGNED_RIGHT_SHIFT { newstack($$).id(ID_lshr); } ; -unary_op: TOK_NOT +unary_op: JTOK_NOT { newstack($$).id(ID_not); } @@ -575,19 +582,19 @@ unary_op: TOK_NOT { newstack($$).id(ID_unary_minus); } - | TOK_NUM_TO_STRING + | JTOK_NUM_TO_STRING { newstack($$).id("num_to_string"); } - | TOK_STRING_TO_NUM + | JTOK_STRING_TO_NUM { newstack($$).id("string_to_num"); } - | TOK_NUM_TO_INT32 + | JTOK_NUM_TO_INT32 { newstack($$).id("num_to_int32"); } - | TOK_NUM_TO_UINT32 + | JTOK_NUM_TO_UINT32 { newstack($$).id("num_to_uint32"); } @@ -597,51 +604,51 @@ unary_op: TOK_NOT } ; -jsil_type: TOK_T_NULL +jsil_type: JTOK_T_NULL { newstack($$).id("null_type"); } - | TOK_T_UNDEFINED + | JTOK_T_UNDEFINED { newstack($$).id("undefined_type"); } - | TOK_T_BOOLEAN + | JTOK_T_BOOLEAN { newstack($$).id(ID_boolean); } - | TOK_T_STRING + | JTOK_T_STRING { newstack($$).id(ID_string); } - | TOK_T_NUMBER + | JTOK_T_NUMBER { newstack($$).id("number"); } - | TOK_T_BUILTIN_OBJECT + | JTOK_T_BUILTIN_OBJECT { newstack($$).id("builtin_object"); } - | TOK_T_USER_OBJECT + | JTOK_T_USER_OBJECT { newstack($$).id("user_object"); } - | TOK_T_OBJECT + | JTOK_T_OBJECT { newstack($$).id("object"); } | ref_type - | TOK_T_REFERENCE + | JTOK_T_REFERENCE { newstack($$).id(ID_pointer); newstack($$).set(ID_C_reference, true); } ; -ref_type: TOK_MEMBER_REFERENCE +ref_type: JTOK_MEMBER_REFERENCE { newstack($$).id(ID_member); } - | TOK_VARIABLE_REFERENCE + | JTOK_VARIABLE_REFERENCE { newstack($$).id("variable"); } diff --git a/src/jsil/scanner.l b/src/jsil/scanner.l index 4ec6cef93360..1a10800628a7 100755 --- a/src/jsil/scanner.l +++ b/src/jsil/scanner.l @@ -47,7 +47,7 @@ static int make_identifier() parser_stack(yyjsillval).id(ID_symbol); parser_stack(yyjsillval).set(ID_C_base_name, base_name); parser_stack(yyjsillval).set(ID_identifier, base_name); - return TOK_IDENTIFIER; + return JTOK_IDENTIFIER; } #include // IWYU pragma: keep @@ -101,7 +101,7 @@ string_lit ["]{s_char}*["] { "*/" { yy_pop_state(); } /* end comment state, back to GRAMMAR */ "/*" { yyjsilerror("Probably nested comments"); } - <> { yyjsilerror("Unterminated comment"); return TOK_SCANNER_ERROR; } + <> { yyjsilerror("Unterminated comment"); return JTOK_SCANNER_ERROR; } [^*/\n]* { } /* ignore every char except '*' and NL (performance!) */ . { } /* all single characters within comments are ignored */ \n { } @@ -110,7 +110,7 @@ string_lit ["]{s_char}*["] { "*/" { yy_pop_state(); } /* end comment state, back to STRING_LITERAL */ "/*" { yyjsilerror("Probably nested comments"); } - <> { yyjsilerror("Unterminated comment"); return TOK_SCANNER_ERROR; } + <> { yyjsilerror("Unterminated comment"); return JTOK_SCANNER_ERROR; } [^*/\n]* { } /* ignore every char except '*' and NL (performance!) */ . { } /* all single characters within comments are ignored */ \n { } @@ -137,70 +137,70 @@ string_lit ["]{s_char}*["] parser_stack(yyjsillval).add_source_location().swap(l); yy_pop_state(); // back to normal yyless(0); // put back - return TOK_STRING; + return JTOK_STRING; } } { - "#global_is_nan" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#global_is_finite" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#boolean_call" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#boolean_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#boolean_prototype_to_string" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#boolean_prototype_value_of" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#object_call" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#object_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#object_prototype_to_string" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#object_prototype_value_of" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#object_prototype_is_prototype_of" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#object_get_prototype_of" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#number_call" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#number_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#number_prototype_to_string" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#number_prototype_value_of" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#string_call" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#string_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#string_prototype_to_string" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#string_prototype_value_of" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#error_call_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#terror_call_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#rerror_call_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#serror_call_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#evalerror_call_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#rangeerror_call_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#urierror_call_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#function_call" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#function_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#function_protottype_call" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#array_call" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - "#array_construct" { make_identifier(); return TOK_BUILTIN_IDENTIFIER; } - - "#[[GetOwnPropertyDefault]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[GetOwnPropertyString]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#GetValue" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#PutValue" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[Get]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[GetDefault]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[GetFunction]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[Put]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[HasProperty]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[DefaultValue]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[DefineOwnPropery]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[DefineOwnProperyDefault]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#[[DefineOwnProperyArray]]" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#ToPrimitive" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#ToBoolean" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#ToNumber" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#ToNumberPrim" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#ToUint32" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#ToString" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#ToStringPrim" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#ToObject" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#CheckObjectCoercible" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#IsCallable" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#AbstractRelation" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#StrictEquality" { make_identifier(); return TOK_SPEC_IDENTIFIER; } - "#StrictEqualitySameType" { make_identifier(); return TOK_SPEC_IDENTIFIER; } + "#global_is_nan" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#global_is_finite" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#boolean_call" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#boolean_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#boolean_prototype_to_string" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#boolean_prototype_value_of" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#object_call" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#object_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#object_prototype_to_string" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#object_prototype_value_of" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#object_prototype_is_prototype_of" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#object_get_prototype_of" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#number_call" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#number_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#number_prototype_to_string" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#number_prototype_value_of" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#string_call" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#string_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#string_prototype_to_string" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#string_prototype_value_of" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#error_call_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#terror_call_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#rerror_call_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#serror_call_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#evalerror_call_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#rangeerror_call_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#urierror_call_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#function_call" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#function_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#function_protottype_call" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#array_call" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + "#array_construct" { make_identifier(); return JTOK_BUILTIN_IDENTIFIER; } + + "#[[GetOwnPropertyDefault]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[GetOwnPropertyString]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#GetValue" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#PutValue" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[Get]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[GetDefault]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[GetFunction]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[Put]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[HasProperty]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[DefaultValue]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[DefineOwnPropery]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[DefineOwnProperyDefault]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#[[DefineOwnProperyArray]]" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#ToPrimitive" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#ToBoolean" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#ToNumber" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#ToNumberPrim" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#ToUint32" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#ToString" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#ToStringPrim" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#ToObject" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#CheckObjectCoercible" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#IsCallable" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#AbstractRelation" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#StrictEquality" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } + "#StrictEqualitySameType" { make_identifier(); return JTOK_SPEC_IDENTIFIER; } } { @@ -209,10 +209,10 @@ string_lit ["]{s_char}*["] /*** keywords ***/ - "procedure" { loc(); return TOK_PROCEDURE; } - "returns" { loc(); return TOK_RETURNS; } - "to" { loc(); return TOK_TO; } - "throws" { loc(); return TOK_THROWS; } + "procedure" { loc(); return JTOK_PROCEDURE; } + "returns" { loc(); return JTOK_RETURNS; } + "to" { loc(); return JTOK_TO; } + "throws" { loc(); return JTOK_THROWS; } /*** scanner parsed tokens (these have a value!) ***/ @@ -224,65 +224,65 @@ string_lit ["]{s_char}*["] } { - {newline} { loc(); return TOK_NEWLINE; } + {newline} { loc(); return JTOK_NEWLINE; } {whitespace} { } /* skipped */ - "eval" { loc(); return TOK_EVAL; } - "label" { loc(); return TOK_LABEL; } - "goto" { loc(); return TOK_GOTO; } - "skip" { loc(); return TOK_SKIP; } - "with" { loc(); return TOK_WITH; } - "new" { loc(); return TOK_NEW; } - "hasField" { loc(); return TOK_HAS_FIELD; } - "delete" { loc(); return TOK_DELETE; } - "protoField" { loc(); return TOK_PROTO_FIELD; } - "protoObj" { loc(); return TOK_PROTO_OBJ; } - "ref" { loc(); return TOK_REF; } - "field" { loc(); return TOK_FIELD; } - "base" { loc(); return TOK_BASE; } - "typeOf" { loc(); return TOK_TYPEOF; } - "null" { loc(); return TOK_NULL; } - "#undefined" { loc(); return TOK_UNDEFINED; } - "#empty" { loc(); return TOK_EMPTY; } - "true" { loc(); return TOK_TRUE; } - "false" { loc(); return TOK_FALSE; } - "#proto" { loc(); return TOK_PROTO; } - "#fid" { loc(); return TOK_FID; } - "#scope" { loc(); return TOK_SCOPE; } - "#constructid" { loc(); return TOK_CONSTRUCTID; } - "#primvalue" { loc(); return TOK_PRIMVALUE; } - "#targetfunction" { loc(); return TOK_TARGETFUNCTION; } - "#class" { loc(); return TOK_CLASS; } - "num_to_string" { loc(); return TOK_NUM_TO_STRING; } - "string_to_num" { loc(); return TOK_STRING_TO_NUM; } - "num_to_int32" { loc(); return TOK_NUM_TO_INT32; } - "num_to_uint32" { loc(); return TOK_NUM_TO_UINT32; } - "#MemberReference" { loc(); return TOK_MEMBER_REFERENCE; } - "#VariableReference" { loc(); return TOK_VARIABLE_REFERENCE; } + "eval" { loc(); return JTOK_EVAL; } + "label" { loc(); return JTOK_LABEL; } + "goto" { loc(); return JTOK_GOTO; } + "skip" { loc(); return JTOK_SKIP; } + "with" { loc(); return JTOK_WITH; } + "new" { loc(); return JTOK_NEW; } + "hasField" { loc(); return JTOK_HAS_FIELD; } + "delete" { loc(); return JTOK_DELETE; } + "protoField" { loc(); return JTOK_PROTO_FIELD; } + "protoObj" { loc(); return JTOK_PROTO_OBJ; } + "ref" { loc(); return JTOK_REF; } + "field" { loc(); return JTOK_FIELD; } + "base" { loc(); return JTOK_BASE; } + "typeOf" { loc(); return JTOK_TYPEOF; } + "null" { loc(); return JTOK_NULL; } + "#undefined" { loc(); return JTOK_UNDEFINED; } + "#empty" { loc(); return JTOK_EMPTY; } + "true" { loc(); return JTOK_TRUE; } + "false" { loc(); return JTOK_FALSE; } + "#proto" { loc(); return JTOK_PROTO; } + "#fid" { loc(); return JTOK_FID; } + "#scope" { loc(); return JTOK_SCOPE; } + "#constructid" { loc(); return JTOK_CONSTRUCTID; } + "#primvalue" { loc(); return JTOK_PRIMVALUE; } + "#targetfunction" { loc(); return JTOK_TARGETFUNCTION; } + "#class" { loc(); return JTOK_CLASS; } + "num_to_string" { loc(); return JTOK_NUM_TO_STRING; } + "string_to_num" { loc(); return JTOK_STRING_TO_NUM; } + "num_to_int32" { loc(); return JTOK_NUM_TO_INT32; } + "num_to_uint32" { loc(); return JTOK_NUM_TO_UINT32; } + "#MemberReference" { loc(); return JTOK_MEMBER_REFERENCE; } + "#VariableReference" { loc(); return JTOK_VARIABLE_REFERENCE; } /*** type classes ***/ - "#Null" { loc(); return TOK_T_NULL; } - "#Undefined" { loc(); return TOK_T_UNDEFINED; } - "#Boolean" { loc(); return TOK_T_BOOLEAN; } - "#String" { loc(); return TOK_T_STRING; } - "#Number" { loc(); return TOK_T_NUMBER; } - "#BuiltinObject" { loc(); return TOK_T_BUILTIN_OBJECT; } - "#UserObject" { loc(); return TOK_T_USER_OBJECT; } - "#Object" { loc(); return TOK_T_OBJECT; } - "#Reference" { loc(); return TOK_T_REFERENCE; } + "#Null" { loc(); return JTOK_T_NULL; } + "#Undefined" { loc(); return JTOK_T_UNDEFINED; } + "#Boolean" { loc(); return JTOK_T_BOOLEAN; } + "#String" { loc(); return JTOK_T_STRING; } + "#Number" { loc(); return JTOK_T_NUMBER; } + "#BuiltinObject" { loc(); return JTOK_T_BUILTIN_OBJECT; } + "#UserObject" { loc(); return JTOK_T_USER_OBJECT; } + "#Object" { loc(); return JTOK_T_OBJECT; } + "#Reference" { loc(); return JTOK_T_REFERENCE; } /*** multi-character operators ***/ - ":=" { loc(); return TOK_DEFEQ; } - "<=" { loc(); return TOK_LEQ; } - "and" { loc(); return TOK_AND; } - "or" { loc(); return TOK_OR; } - "<:" { loc(); return TOK_SUBTYPE_OF; } - "<<" { loc(); return TOK_LEFT_SHIFT; } - ">>" { loc(); return TOK_SIGNED_RIGHT_SHIFT; } - ">>>" { loc(); return TOK_UNSIGNED_RIGHT_SHIFT; } - "not" { loc(); return TOK_NOT; } + ":=" { loc(); return JTOK_DEFEQ; } + "<=" { loc(); return JTOK_LEQ; } + "and" { loc(); return JTOK_AND; } + "or" { loc(); return JTOK_OR; } + "<:" { loc(); return JTOK_SUBTYPE_OF; } + "<<" { loc(); return JTOK_LEFT_SHIFT; } + ">>" { loc(); return JTOK_SIGNED_RIGHT_SHIFT; } + ">>>" { loc(); return JTOK_UNSIGNED_RIGHT_SHIFT; } + "not" { loc(); return JTOK_NOT; } /*** scanner parsed tokens (these have a value!) ***/ @@ -292,51 +292,51 @@ string_lit ["]{s_char}*["] newstack(yyjsillval); parser_stack(yyjsillval)=convert_float_literal(yytext); PARSER.set_source_location(parser_stack(yyjsillval)); - return TOK_FLOATING; + return JTOK_FLOATING; } - "#lg" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lg_isNan" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lg_isFinite" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lop" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lop_toString" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lop_valueOf" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lop_isPrototypeOf" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lfunction" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lfp" { make_identifier(); return TOK_BUILTIN_LOC; } - "#leval" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lerror" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lep" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lrerror" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lrep" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lterror" { make_identifier(); return TOK_BUILTIN_LOC; } - "#ltep" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lserror" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lsep" { make_identifier(); return TOK_BUILTIN_LOC; } - "#levalerror" { make_identifier(); return TOK_BUILTIN_LOC; } - "#levalerrorp" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lrangeerror" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lrangeerrorp" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lurierror" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lurierrorp" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lobject" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lobject_get_prototype_of" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lboolean" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lbp" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lbp_toString" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lbp_valueOf" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lnumber" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lnp" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lnp_toString" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lnp_valueOf" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lmath" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lstring" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lsp" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lsp_toString" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lsp_valueOf" { make_identifier(); return TOK_BUILTIN_LOC; } - "#larray" { make_identifier(); return TOK_BUILTIN_LOC; } - "#lap" { make_identifier(); return TOK_BUILTIN_LOC; } - "#ljson" { make_identifier(); return TOK_BUILTIN_LOC; } + "#lg" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lg_isNan" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lg_isFinite" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lop" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lop_toString" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lop_valueOf" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lop_isPrototypeOf" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lfunction" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lfp" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#leval" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lerror" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lep" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lrerror" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lrep" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lterror" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#ltep" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lserror" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lsep" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#levalerror" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#levalerrorp" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lrangeerror" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lrangeerrorp" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lurierror" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lurierrorp" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lobject" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lobject_get_prototype_of" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lboolean" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lbp" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lbp_toString" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lbp_valueOf" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lnumber" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lnp" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lnp_toString" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lnp_valueOf" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lmath" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lstring" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lsp" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lsp_toString" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lsp_valueOf" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#larray" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#lap" { make_identifier(); return JTOK_BUILTIN_LOC; } + "#ljson" { make_identifier(); return JTOK_BUILTIN_LOC; } "}" { loc(); BEGIN(GRAMMAR); return '}'; } /* This catches all one-character operators */ diff --git a/src/statement-list/parser.y b/src/statement-list/parser.y index 70b2ccce9696..4a47640e3ef3 100644 --- a/src/statement-list/parser.y +++ b/src/statement-list/parser.y @@ -29,6 +29,12 @@ extern char *yystatement_listtext; #define YYSTYPE unsigned #define YYSTYPE_IS_TRIVIAL 1 +/* To avoid LTO -Wodr clashes with ansi-c */ +#define YYTOKENTYPE 1 +#define YYEMPTY -2 +#define YYEOF 0 /* "end of file" */ +#define YYerror 256 /* error */ +#define YYUNDEF 257 /* "invalid token" */ #include "statement_list_y.tab.h" // Visual Studio @@ -48,99 +54,99 @@ extern char *yystatement_listtext; %} /*** STL file structure keywords *********************************************/ -%token TOK_VERSION "VERSION" -%token TOK_BEGIN "BEGIN" -%token TOK_FUNCTION_BLOCK "FUNCTION_BLOCK" -%token TOK_END_FUNCTION_BLOCK "END_FUNCTION_BLOCK" -%token TOK_FUNCTION "FUNCTION" -%token TOK_END_FUNCTION "END_FUNCTION" -%token TOK_VAR_INPUT "VAR_INPUT" -%token TOK_VAR_INOUT "VAR_IN_OUT" -%token TOK_VAR_OUTPUT "VAR_OUTPUT" -%token TOK_VAR_STATIC "VAR" -%token TOK_VAR_TEMP "VAR_TEMP" -%token TOK_VAR_CONSTANT "VAR CONSTANT" -%token TOK_END_VAR "END_VAR" -%token TOK_NETWORK "NETWORK" -%token TOK_TITLE "TITLE" -%token TOK_TAG "TAG" -%token TOK_END_TAG "END_TAG" +%token STOK_VERSION "VERSION" +%token STOK_BEGIN "BEGIN" +%token STOK_FUNCTION_BLOCK "FUNCTION_BLOCK" +%token STOK_END_FUNCTION_BLOCK "END_FUNCTION_BLOCK" +%token STOK_FUNCTION "FUNCTION" +%token STOK_END_FUNCTION "END_FUNCTION" +%token STOK_VAR_INPUT "VAR_INPUT" +%token STOK_VAR_INOUT "VAR_IN_OUT" +%token STOK_VAR_OUTPUT "VAR_OUTPUT" +%token STOK_VAR_STATIC "VAR" +%token STOK_VAR_TEMP "VAR_TEMP" +%token STOK_VAR_CONSTANT "VAR CONSTANT" +%token STOK_END_VAR "END_VAR" +%token STOK_NETWORK "NETWORK" +%token STOK_TITLE "TITLE" +%token STOK_TAG "TAG" +%token STOK_END_TAG "END_TAG" /*** Siemens types ***********************************************************/ -%token TOK_INT "Int" -%token TOK_DINT "DInt" -%token TOK_REAL "Real" -%token TOK_BOOL "Bool" -%token TOK_VOID "Void" +%token STOK_INT "Int" +%token STOK_DINT "DInt" +%token STOK_REAL "Real" +%token STOK_BOOL "Bool" +%token STOK_VOID "Void" /*** Operators ***************************************************************/ -%token TOK_LOAD "L" -%token TOK_TRANSFER "T" -%token TOK_CALL "CALL" -%token TOK_NOP "NOP" -%token TOK_SET_RLO "SET" -%token TOK_CLR_RLO "CLR" -%token TOK_SET "S" -%token TOK_RESET "R" -%token TOK_NOT "NOT" -%token TOK_AND "A" -%token TOK_AND_NOT "AN" -%token TOK_OR "O" -%token TOK_OR_NOT "ON" -%token TOK_XOR "X" -%token TOK_XOR_NOT "XN" -%token TOK_AND_NESTED "A(" -%token TOK_AND_NOT_NESTED "AN(" -%token TOK_OR_NESTED "O(" -%token TOK_OR_NOT_NESTED "ON(" -%token TOK_XOR_NESTED "X(" -%token TOK_XOR_NOT_NESTED "XN(" -%token TOK_NESTING_CLOSED ")" -%token TOK_ASSIGN "=" -%token TOK_CONST_ADD "+" -%token TOK_ACCU_INT_ADD "+I" -%token TOK_ACCU_INT_SUB "-I" -%token TOK_ACCU_INT_MUL "*I" -%token TOK_ACCU_INT_DIV "/I" -%token TOK_ACCU_INT_EQ "==I" -%token TOK_ACCU_INT_NEQ "<>I" -%token TOK_ACCU_INT_GT ">I" -%token TOK_ACCU_INT_LT "=I" -%token TOK_ACCU_INT_LTE "<=I" -%token TOK_ACCU_REAL_ADD "+R" -%token TOK_ACCU_REAL_SUB "-R" -%token TOK_ACCU_REAL_MUL "*R" -%token TOK_ACCU_REAL_DIV "/R" -%token TOK_ACCU_REAL_EQ "==R" -%token TOK_ACCU_REAL_NEQ "<>R" -%token TOK_ACCU_REAL_GT ">R" -%token TOK_ACCU_REAL_LT "=R" -%token TOK_ACCU_REAL_LTE "<=R" -%token TOK_ACCU_DINT_ADD "+D" -%token TOK_ACCU_DINT_SUB "-D" -%token TOK_ACCU_DINT_MUL "*D" -%token TOK_ACCU_DINT_DIV "/D" -%token TOK_ACCU_DINT_EQ "==D" -%token TOK_ACCU_DINT_NEQ "<>D" -%token TOK_ACCU_DINT_GT ">D" -%token TOK_ACCU_DINT_LT "=D" -%token TOK_ACCU_DINT_LTE "<=D" -%token TOK_ASSIGNMENT ":=" -%token TOK_JUMP_UNCONDITIONAL "JU" -%token TOK_JUMP_CONDITIONAL "JC" -%token TOK_JUMP_CONDITIONAL_NOT "JCN" +%token STOK_LOAD "L" +%token STOK_TRANSFER "T" +%token STOK_CALL "CALL" +%token STOK_NOP "NOP" +%token STOK_SET_RLO "SET" +%token STOK_CLR_RLO "CLR" +%token STOK_SET "S" +%token STOK_RESET "R" +%token STOK_NOT "NOT" +%token STOK_AND "A" +%token STOK_AND_NOT "AN" +%token STOK_OR "O" +%token STOK_OR_NOT "ON" +%token STOK_XOR "X" +%token STOK_XOR_NOT "XN" +%token STOK_AND_NESTED "A(" +%token STOK_AND_NOT_NESTED "AN(" +%token STOK_OR_NESTED "O(" +%token STOK_OR_NOT_NESTED "ON(" +%token STOK_XOR_NESTED "X(" +%token STOK_XOR_NOT_NESTED "XN(" +%token STOK_NESTING_CLOSED ")" +%token STOK_ASSIGN "=" +%token STOK_CONST_ADD "+" +%token STOK_ACCU_INT_ADD "+I" +%token STOK_ACCU_INT_SUB "-I" +%token STOK_ACCU_INT_MUL "*I" +%token STOK_ACCU_INT_DIV "/I" +%token STOK_ACCU_INT_EQ "==I" +%token STOK_ACCU_INT_NEQ "<>I" +%token STOK_ACCU_INT_GT ">I" +%token STOK_ACCU_INT_LT "=I" +%token STOK_ACCU_INT_LTE "<=I" +%token STOK_ACCU_REAL_ADD "+R" +%token STOK_ACCU_REAL_SUB "-R" +%token STOK_ACCU_REAL_MUL "*R" +%token STOK_ACCU_REAL_DIV "/R" +%token STOK_ACCU_REAL_EQ "==R" +%token STOK_ACCU_REAL_NEQ "<>R" +%token STOK_ACCU_REAL_GT ">R" +%token STOK_ACCU_REAL_LT "=R" +%token STOK_ACCU_REAL_LTE "<=R" +%token STOK_ACCU_DINT_ADD "+D" +%token STOK_ACCU_DINT_SUB "-D" +%token STOK_ACCU_DINT_MUL "*D" +%token STOK_ACCU_DINT_DIV "/D" +%token STOK_ACCU_DINT_EQ "==D" +%token STOK_ACCU_DINT_NEQ "<>D" +%token STOK_ACCU_DINT_GT ">D" +%token STOK_ACCU_DINT_LT "=D" +%token STOK_ACCU_DINT_LTE "<=D" +%token STOK_ASSIGNMENT ":=" +%token STOK_JUMP_UNCONDITIONAL "JU" +%token STOK_JUMP_CONDITIONAL "JC" +%token STOK_JUMP_CONDITIONAL_NOT "JCN" /*** Value tokens ***/ -%token TOK_INT_LITERAL -%token TOK_BOOL_LITERAL -%token TOK_REAL_LITERAL -%token TOK_IDENTIFIER -%token TOK_TITLE_VALUE -%token TOK_VERSION_VALUE -%token TOK_LABEL +%token STOK_INT_LITERAL +%token STOK_BOOL_LITERAL +%token STOK_REAL_LITERAL +%token STOK_IDENTIFIER +%token STOK_TITLE_VALUE +%token STOK_VERSION_VALUE +%token STOK_LABEL /*** Priority, associativity, etc. definitions *******************************/ @@ -196,7 +202,7 @@ Zom_Separated_Variable_Name: ; Variable_Name: - TOK_IDENTIFIER + STOK_IDENTIFIER { newstack($$); parser_stack($$) = @@ -228,7 +234,7 @@ Int_Type_Name: ; Sign_Int_Type_Name: - TOK_INT + STOK_INT { $$ = $1; parser_stack($$).type() = get_int_type(); @@ -240,7 +246,7 @@ DInt_Type_Name: ; Sign_DInt_Type_Name: - TOK_DINT + STOK_DINT { $$ = $1; parser_stack($$).type() = get_dint_type(); @@ -248,7 +254,7 @@ Sign_DInt_Type_Name: ; Real_Type_Name: - TOK_REAL + STOK_REAL { $$ = $1; parser_stack($$).type() = get_real_type(); @@ -256,14 +262,14 @@ Real_Type_Name: ; Bool_Type_Name: - TOK_BOOL + STOK_BOOL { $$ = $1; parser_stack($$).type() = get_bool_type(); } Opt_Assignment: - TOK_ASSIGNMENT Constant + STOK_ASSIGNMENT Constant { $$ = $2; } @@ -274,12 +280,12 @@ Opt_Assignment: // Function Block declaration Derived_FB_Name: - TOK_IDENTIFIER + STOK_IDENTIFIER ; FB_Decl: - TOK_FUNCTION_BLOCK Derived_FB_Name Version_Label Zom_FB_General_Var_Decls - FB_Body TOK_END_FUNCTION_BLOCK + STOK_FUNCTION_BLOCK Derived_FB_Name Version_Label Zom_FB_General_Var_Decls + FB_Body STOK_END_FUNCTION_BLOCK { newstack($$); parser_stack($$).id(ID_statement_list_function_block); @@ -292,7 +298,7 @@ FB_Decl: ; Version_Label: - TOK_VERSION ':' TOK_VERSION_VALUE + STOK_VERSION ':' STOK_VERSION_VALUE { $$ = $3; } @@ -325,7 +331,7 @@ FB_IO_Var_Decls: ; FB_Input_Decls: - TOK_VAR_INPUT Zom_FB_Input_Decl TOK_END_VAR + STOK_VAR_INPUT Zom_FB_Input_Decl STOK_END_VAR { $$ = $2; } @@ -353,7 +359,7 @@ FB_Input_Decl: ; FB_Output_Decls: - TOK_VAR_OUTPUT Zom_FB_Output_Decl TOK_END_VAR + STOK_VAR_OUTPUT Zom_FB_Output_Decl STOK_END_VAR { $$ = $2; } @@ -381,7 +387,7 @@ FB_Output_Decl: ; FB_Inout_Decls: - TOK_VAR_INOUT Zom_FB_Inout_Decl TOK_END_VAR + STOK_VAR_INOUT Zom_FB_Inout_Decl STOK_END_VAR { $$ = $2; } @@ -409,7 +415,7 @@ FB_Inout_Decl: ; FB_Static_Decls: - TOK_VAR_STATIC Zom_FB_Static_Decl TOK_END_VAR + STOK_VAR_STATIC Zom_FB_Static_Decl STOK_END_VAR { $$ = $2; } @@ -437,7 +443,7 @@ FB_Static_Decl: ; FB_Body: - TOK_BEGIN Zom_IL_Network + STOK_BEGIN Zom_IL_Network { $$ = $2; } @@ -445,8 +451,8 @@ FB_Body: // Function declaration Func_Decl: - TOK_FUNCTION Derived_Func_Name ':' Func_Return_Value Version_Label - Zom_Func_General_Var_Decls Func_Body TOK_END_FUNCTION + STOK_FUNCTION Derived_Func_Name ':' Func_Return_Value Version_Label + Zom_Func_General_Var_Decls Func_Body STOK_END_FUNCTION { newstack($$); parser_stack($$).id(ID_statement_list_function); @@ -459,11 +465,11 @@ Func_Decl: ; Derived_Func_Name: - TOK_IDENTIFIER + STOK_IDENTIFIER ; Func_Return_Value: - TOK_VOID + STOK_VOID { parser_stack($$).set(ID_statement_list_type, ID_statement_list_return); } @@ -499,7 +505,7 @@ IO_Var_Decls: ; Input_Decls: - TOK_VAR_INPUT Zom_Input_Decl TOK_END_VAR + STOK_VAR_INPUT Zom_Input_Decl STOK_END_VAR { $$ = $2; } @@ -523,7 +529,7 @@ Input_Decl: ; Inout_Decls: - TOK_VAR_INOUT Zom_Inout_Decl TOK_END_VAR + STOK_VAR_INOUT Zom_Inout_Decl STOK_END_VAR { $$ = $2; } @@ -547,7 +553,7 @@ Inout_Decl: ; Output_Decls: - TOK_VAR_OUTPUT Zom_Output_Decl TOK_END_VAR + STOK_VAR_OUTPUT Zom_Output_Decl STOK_END_VAR { $$ = $2; } @@ -571,7 +577,7 @@ Output_Decl: ; Temp_Decls: - TOK_VAR_TEMP Zom_Temp_Decl TOK_END_VAR + STOK_VAR_TEMP Zom_Temp_Decl STOK_END_VAR { $$ = $2; } @@ -595,7 +601,7 @@ Temp_Decl: ; Constant_Decls: - TOK_VAR_CONSTANT Zom_Constant_Decl TOK_END_VAR + STOK_VAR_CONSTANT Zom_Constant_Decl STOK_END_VAR { $$ = $2; } @@ -623,7 +629,7 @@ Constant_Decl: ; Func_Body: - TOK_BEGIN Zom_IL_Network + STOK_BEGIN Zom_IL_Network { $$ = $2; } @@ -644,7 +650,7 @@ Zom_IL_Network: ; IL_Network: - TOK_NETWORK TOK_TITLE TOK_ASSIGN Opt_TITLE_VALUE Opt_Instruction_List + STOK_NETWORK STOK_TITLE STOK_ASSIGN Opt_TITLE_VALUE Opt_Instruction_List { newstack($$); parser_stack($$).id(ID_statement_list_network); @@ -655,7 +661,7 @@ IL_Network: Opt_TITLE_VALUE: - TOK_TITLE_VALUE + STOK_TITLE_VALUE | /* nothing */ { newstack($$); @@ -709,7 +715,7 @@ Opt_Label: ; IL_Label: - TOK_LABEL + STOK_LABEL ; Instruction: @@ -737,282 +743,282 @@ Opt_Operand: ; IL_Simple_Operator: - TOK_LOAD + STOK_LOAD { $$ = $1; parser_stack($$).id(ID_statement_list_load); } - | TOK_TRANSFER + | STOK_TRANSFER { $$ = $1; parser_stack($$).id(ID_statement_list_transfer); } - | TOK_NOP + | STOK_NOP { $$ = $1; parser_stack($$).id(ID_statement_list_nop); } - | TOK_CONST_ADD + | STOK_CONST_ADD { $$ = $1; parser_stack($$).id(ID_statement_list_const_add); } - | TOK_ACCU_INT_ADD + | STOK_ACCU_INT_ADD { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_add); } - | TOK_ACCU_INT_SUB + | STOK_ACCU_INT_SUB { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_sub); } - | TOK_ACCU_INT_MUL + | STOK_ACCU_INT_MUL { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_mul); } - | TOK_ACCU_INT_DIV + | STOK_ACCU_INT_DIV { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_div); } - | TOK_ACCU_INT_EQ + | STOK_ACCU_INT_EQ { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_eq); } - | TOK_ACCU_INT_NEQ + | STOK_ACCU_INT_NEQ { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_neq); } - | TOK_ACCU_INT_GT + | STOK_ACCU_INT_GT { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_gt); } - | TOK_ACCU_INT_LT + | STOK_ACCU_INT_LT { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_lt); } - | TOK_ACCU_INT_GTE + | STOK_ACCU_INT_GTE { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_gte); } - | TOK_ACCU_INT_LTE + | STOK_ACCU_INT_LTE { $$ = $1; parser_stack($$).id(ID_statement_list_accu_int_lte); } - | TOK_ACCU_REAL_ADD + | STOK_ACCU_REAL_ADD { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_add); } - | TOK_ACCU_REAL_SUB + | STOK_ACCU_REAL_SUB { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_sub); } - | TOK_ACCU_REAL_MUL + | STOK_ACCU_REAL_MUL { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_mul); } - | TOK_ACCU_REAL_DIV + | STOK_ACCU_REAL_DIV { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_div); } - | TOK_ACCU_REAL_EQ + | STOK_ACCU_REAL_EQ { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_eq); } - | TOK_ACCU_REAL_NEQ + | STOK_ACCU_REAL_NEQ { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_neq); } - | TOK_ACCU_REAL_GT + | STOK_ACCU_REAL_GT { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_gt); } - | TOK_ACCU_REAL_LT + | STOK_ACCU_REAL_LT { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_lt); } - | TOK_ACCU_REAL_GTE + | STOK_ACCU_REAL_GTE { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_gte); } - | TOK_ACCU_REAL_LTE + | STOK_ACCU_REAL_LTE { $$ = $1; parser_stack($$).id(ID_statement_list_accu_real_lte); } - | TOK_ACCU_DINT_ADD + | STOK_ACCU_DINT_ADD { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_add); } - | TOK_ACCU_DINT_SUB + | STOK_ACCU_DINT_SUB { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_sub); } - | TOK_ACCU_DINT_MUL + | STOK_ACCU_DINT_MUL { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_mul); } - | TOK_ACCU_DINT_DIV + | STOK_ACCU_DINT_DIV { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_div); } - | TOK_ACCU_DINT_EQ + | STOK_ACCU_DINT_EQ { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_eq); } - | TOK_ACCU_DINT_NEQ + | STOK_ACCU_DINT_NEQ { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_neq); } - | TOK_ACCU_DINT_GT + | STOK_ACCU_DINT_GT { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_gt); } - | TOK_ACCU_DINT_LT + | STOK_ACCU_DINT_LT { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_lt); } - | TOK_ACCU_DINT_GTE + | STOK_ACCU_DINT_GTE { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_gte); } - | TOK_ACCU_DINT_LTE + | STOK_ACCU_DINT_LTE { $$ = $1; parser_stack($$).id(ID_statement_list_accu_dint_lte); } - | TOK_AND + | STOK_AND { $$ = $1; parser_stack($$).id(ID_statement_list_and); } - | TOK_AND_NOT + | STOK_AND_NOT { $$ = $1; parser_stack($$).id(ID_statement_list_and_not); } - | TOK_OR + | STOK_OR { $$ = $1; parser_stack($$).id(ID_statement_list_or); } - | TOK_OR_NOT + | STOK_OR_NOT { $$ = $1; parser_stack($$).id(ID_statement_list_or_not); } - | TOK_XOR + | STOK_XOR { $$ = $1; parser_stack($$).id(ID_statement_list_xor); } - | TOK_XOR_NOT + | STOK_XOR_NOT { $$ = $1; parser_stack($$).id(ID_statement_list_xor_not); } - | TOK_AND_NESTED + | STOK_AND_NESTED { $$ = $1; parser_stack($$).id(ID_statement_list_and_nested); } - | TOK_AND_NOT_NESTED + | STOK_AND_NOT_NESTED { $$ = $1; parser_stack($$).id(ID_statement_list_and_not_nested); } - | TOK_OR_NESTED + | STOK_OR_NESTED { $$ = $1; parser_stack($$).id(ID_statement_list_or_nested); } - | TOK_OR_NOT_NESTED + | STOK_OR_NOT_NESTED { $$ = $1; parser_stack($$).id(ID_statement_list_or_not_nested); } - | TOK_XOR_NESTED + | STOK_XOR_NESTED { $$ = $1; parser_stack($$).id(ID_statement_list_xor_nested); } - | TOK_XOR_NOT_NESTED + | STOK_XOR_NOT_NESTED { $$ = $1; parser_stack($$).id(ID_statement_list_xor_not_nested); } - | TOK_NESTING_CLOSED + | STOK_NESTING_CLOSED { $$ = $1; parser_stack($$).id(ID_statement_list_nesting_closed); } - | TOK_ASSIGN + | STOK_ASSIGN { $$ = $1; parser_stack($$).id(ID_statement_list_assign); } - | TOK_SET_RLO + | STOK_SET_RLO { $$ = $1; parser_stack($$).id(ID_statement_list_set_rlo); } - | TOK_CLR_RLO + | STOK_CLR_RLO { $$ = $1; parser_stack($$).id(ID_statement_list_clr_rlo); } - | TOK_SET + | STOK_SET { $$ = $1; parser_stack($$).id(ID_statement_list_set); } - | TOK_RESET + | STOK_RESET { $$ = $1; parser_stack($$).id(ID_statement_list_reset); } - | TOK_NOT + | STOK_NOT { $$ = $1; parser_stack($$).id(ID_statement_list_not); } - | TOK_JUMP_UNCONDITIONAL + | STOK_JUMP_UNCONDITIONAL { $$ = $1; parser_stack($$).id(ID_statement_list_jump_unconditional); } - | TOK_JUMP_CONDITIONAL + | STOK_JUMP_CONDITIONAL { $$ = $1; parser_stack($$).id(ID_statement_list_jump_conditional); } - | TOK_JUMP_CONDITIONAL_NOT + | STOK_JUMP_CONDITIONAL_NOT { $$ = $1; parser_stack($$).id(ID_statement_list_jump_conditional_not); @@ -1036,9 +1042,9 @@ Variable_Access: ; Constant: - TOK_INT_LITERAL - | TOK_BOOL_LITERAL - | TOK_REAL_LITERAL + STOK_INT_LITERAL + | STOK_BOOL_LITERAL + | STOK_REAL_LITERAL ; IL_Invocation: @@ -1055,7 +1061,7 @@ IL_Invocation: ; Call: - TOK_CALL + STOK_CALL { $$ = $1; parser_stack($$).id(ID_statement_list_call); @@ -1072,7 +1078,7 @@ Callee_Name: ; Opt_Param_List: - '(' Oom_Param_Assignment TOK_NESTING_CLOSED + '(' Oom_Param_Assignment STOK_NESTING_CLOSED { $$ = $2; } @@ -1096,7 +1102,7 @@ Oom_Param_Assignment: ; Param_Assignment: - Variable_Name TOK_ASSIGNMENT IL_Operand + Variable_Name STOK_ASSIGNMENT IL_Operand { newstack($$); parser_stack($$) = code_frontend_assignt(std::move(parser_stack($1)), @@ -1118,7 +1124,7 @@ Opt_Data_Block: // Tag declaration Tag_Decl: - TOK_TAG Opt_Tag_List TOK_END_TAG + STOK_TAG Opt_Tag_List STOK_END_TAG { PARSER.add_tag_list(parser_stack($2)); } diff --git a/src/statement-list/scanner.l b/src/statement-list/scanner.l index a06e11cf1f68..2df2465414eb 100644 --- a/src/statement-list/scanner.l +++ b/src/statement-list/scanner.l @@ -89,85 +89,85 @@ void statement_list_scanner_init() { [\(:\.,;#] { loc(); return yytext[0]; } [\t\r\n ] ; - := { loc(); return TOK_ASSIGNMENT; } - TAG { loc(); BEGIN(TAG_NAME); return TOK_TAG; } - BEGIN { loc(); return TOK_BEGIN; } - VERSION { loc(); BEGIN(VERSION_ANNOTATION); return TOK_VERSION; } - FUNCTION_BLOCK { loc(); BEGIN(MODULE_NAME); return TOK_FUNCTION_BLOCK; } - END_FUNCTION_BLOCK { loc(); return TOK_END_FUNCTION_BLOCK; } - FUNCTION { loc(); BEGIN(MODULE_NAME); return TOK_FUNCTION; } - END_FUNCTION { loc(); return TOK_END_FUNCTION; } - VAR_INPUT { loc(); return TOK_VAR_INPUT; } - VAR_OUTPUT { loc(); return TOK_VAR_OUTPUT; } - VAR_IN_OUT { loc(); return TOK_VAR_INOUT; } - VAR { loc(); return TOK_VAR_STATIC; } - VAR[ ]CONSTANT { loc(); return TOK_VAR_CONSTANT; } - VAR_TEMP { loc(); return TOK_VAR_TEMP; } - END_VAR { loc(); return TOK_END_VAR; } - NETWORK { loc(); return TOK_NETWORK; } - TITLE { loc(); return TOK_TITLE; } - Int { loc(); return TOK_INT; } - DInt { loc(); return TOK_DINT; } - Bool { loc(); return TOK_BOOL; } - Real { loc(); return TOK_REAL; } - Void { loc(); return TOK_VOID; } - L { loc(); return TOK_LOAD; } - T { loc(); return TOK_TRANSFER; } - CALL { loc(); BEGIN(MODULE_NAME); return TOK_CALL; } - NOP { loc(); return TOK_NOP; } - SET { loc(); return TOK_SET_RLO; } - CLR { loc(); return TOK_CLR_RLO; } - S { loc(); return TOK_SET; } - R { loc(); return TOK_RESET; } - NOT { loc(); return TOK_NOT; } - A { loc(); return TOK_AND; } - AN { loc(); return TOK_AND_NOT; } - O { loc(); return TOK_OR; } - ON { loc(); return TOK_OR_NOT; } - X { loc(); return TOK_XOR; } - XN { loc(); return TOK_XOR_NOT; } - A\( { loc(); return TOK_AND_NESTED; } - AN\( { loc(); return TOK_AND_NOT_NESTED; } - O\( { loc(); return TOK_OR_NESTED; } - ON\( { loc(); return TOK_OR_NOT_NESTED; } - X\( { loc(); return TOK_XOR_NESTED; } - XN\( { loc(); return TOK_XOR_NOT_NESTED; } - \) { loc(); return TOK_NESTING_CLOSED; } - = { loc(); return TOK_ASSIGN; } - \+ { loc(); return TOK_CONST_ADD; } - \+I { loc(); return TOK_ACCU_INT_ADD; } - \-I { loc(); return TOK_ACCU_INT_SUB; } - \*I { loc(); return TOK_ACCU_INT_MUL; } - \/I { loc(); return TOK_ACCU_INT_DIV; } - ==I { loc(); return TOK_ACCU_INT_EQ; } - \<\>I { loc(); return TOK_ACCU_INT_NEQ; } - \>I { loc(); return TOK_ACCU_INT_GT; } - \=I { loc(); return TOK_ACCU_INT_GTE; } - \<=I { loc(); return TOK_ACCU_INT_LTE; } - \+R { loc(); return TOK_ACCU_REAL_ADD; } - \-R { loc(); return TOK_ACCU_REAL_SUB; } - \*R { loc(); return TOK_ACCU_REAL_MUL; } - \/R { loc(); return TOK_ACCU_REAL_DIV; } - ==R { loc(); return TOK_ACCU_REAL_EQ; } - \<\>R { loc(); return TOK_ACCU_REAL_NEQ; } - \>R { loc(); return TOK_ACCU_REAL_GT; } - \=R { loc(); return TOK_ACCU_REAL_GTE; } - \<=R { loc(); return TOK_ACCU_REAL_LTE; } - \+D { loc(); return TOK_ACCU_DINT_ADD; } - \-D { loc(); return TOK_ACCU_DINT_SUB; } - \*D { loc(); return TOK_ACCU_DINT_MUL; } - \/D { loc(); return TOK_ACCU_DINT_DIV; } - ==D { loc(); return TOK_ACCU_DINT_EQ; } - \<\>D { loc(); return TOK_ACCU_DINT_NEQ; } - \>D { loc(); return TOK_ACCU_DINT_GT; } - \=D { loc(); return TOK_ACCU_DINT_GTE; } - \<=D { loc(); return TOK_ACCU_DINT_LTE; } - JU { loc(); return TOK_JUMP_UNCONDITIONAL; } - JC { loc(); return TOK_JUMP_CONDITIONAL; } - JCN { loc(); return TOK_JUMP_CONDITIONAL_NOT; } + := { loc(); return STOK_ASSIGNMENT; } + TAG { loc(); BEGIN(TAG_NAME); return STOK_TAG; } + BEGIN { loc(); return STOK_BEGIN; } + VERSION { loc(); BEGIN(VERSION_ANNOTATION); return STOK_VERSION; } + FUNCTION_BLOCK { loc(); BEGIN(MODULE_NAME); return STOK_FUNCTION_BLOCK; } + END_FUNCTION_BLOCK { loc(); return STOK_END_FUNCTION_BLOCK; } + FUNCTION { loc(); BEGIN(MODULE_NAME); return STOK_FUNCTION; } + END_FUNCTION { loc(); return STOK_END_FUNCTION; } + VAR_INPUT { loc(); return STOK_VAR_INPUT; } + VAR_OUTPUT { loc(); return STOK_VAR_OUTPUT; } + VAR_IN_OUT { loc(); return STOK_VAR_INOUT; } + VAR { loc(); return STOK_VAR_STATIC; } + VAR[ ]CONSTANT { loc(); return STOK_VAR_CONSTANT; } + VAR_TEMP { loc(); return STOK_VAR_TEMP; } + END_VAR { loc(); return STOK_END_VAR; } + NETWORK { loc(); return STOK_NETWORK; } + TITLE { loc(); return STOK_TITLE; } + Int { loc(); return STOK_INT; } + DInt { loc(); return STOK_DINT; } + Bool { loc(); return STOK_BOOL; } + Real { loc(); return STOK_REAL; } + Void { loc(); return STOK_VOID; } + L { loc(); return STOK_LOAD; } + T { loc(); return STOK_TRANSFER; } + CALL { loc(); BEGIN(MODULE_NAME); return STOK_CALL; } + NOP { loc(); return STOK_NOP; } + SET { loc(); return STOK_SET_RLO; } + CLR { loc(); return STOK_CLR_RLO; } + S { loc(); return STOK_SET; } + R { loc(); return STOK_RESET; } + NOT { loc(); return STOK_NOT; } + A { loc(); return STOK_AND; } + AN { loc(); return STOK_AND_NOT; } + O { loc(); return STOK_OR; } + ON { loc(); return STOK_OR_NOT; } + X { loc(); return STOK_XOR; } + XN { loc(); return STOK_XOR_NOT; } + A\( { loc(); return STOK_AND_NESTED; } + AN\( { loc(); return STOK_AND_NOT_NESTED; } + O\( { loc(); return STOK_OR_NESTED; } + ON\( { loc(); return STOK_OR_NOT_NESTED; } + X\( { loc(); return STOK_XOR_NESTED; } + XN\( { loc(); return STOK_XOR_NOT_NESTED; } + \) { loc(); return STOK_NESTING_CLOSED; } + = { loc(); return STOK_ASSIGN; } + \+ { loc(); return STOK_CONST_ADD; } + \+I { loc(); return STOK_ACCU_INT_ADD; } + \-I { loc(); return STOK_ACCU_INT_SUB; } + \*I { loc(); return STOK_ACCU_INT_MUL; } + \/I { loc(); return STOK_ACCU_INT_DIV; } + ==I { loc(); return STOK_ACCU_INT_EQ; } + \<\>I { loc(); return STOK_ACCU_INT_NEQ; } + \>I { loc(); return STOK_ACCU_INT_GT; } + \=I { loc(); return STOK_ACCU_INT_GTE; } + \<=I { loc(); return STOK_ACCU_INT_LTE; } + \+R { loc(); return STOK_ACCU_REAL_ADD; } + \-R { loc(); return STOK_ACCU_REAL_SUB; } + \*R { loc(); return STOK_ACCU_REAL_MUL; } + \/R { loc(); return STOK_ACCU_REAL_DIV; } + ==R { loc(); return STOK_ACCU_REAL_EQ; } + \<\>R { loc(); return STOK_ACCU_REAL_NEQ; } + \>R { loc(); return STOK_ACCU_REAL_GT; } + \=R { loc(); return STOK_ACCU_REAL_GTE; } + \<=R { loc(); return STOK_ACCU_REAL_LTE; } + \+D { loc(); return STOK_ACCU_DINT_ADD; } + \-D { loc(); return STOK_ACCU_DINT_SUB; } + \*D { loc(); return STOK_ACCU_DINT_MUL; } + \/D { loc(); return STOK_ACCU_DINT_DIV; } + ==D { loc(); return STOK_ACCU_DINT_EQ; } + \<\>D { loc(); return STOK_ACCU_DINT_NEQ; } + \>D { loc(); return STOK_ACCU_DINT_GT; } + \=D { loc(); return STOK_ACCU_DINT_GTE; } + \<=D { loc(); return STOK_ACCU_DINT_LTE; } + JU { loc(); return STOK_JUMP_UNCONDITIONAL; } + JC { loc(); return STOK_JUMP_CONDITIONAL; } + JCN { loc(); return STOK_JUMP_CONDITIONAL_NOT; } (10#)?[\+-]?[0-9]+ { newstack(yystatement_listlval); @@ -175,7 +175,7 @@ void statement_list_scanner_init() convert_int_dec_literal(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_INT_LITERAL; + return STOK_INT_LITERAL; } INT#(10#)?[\+-]?[0-9]+ { newstack(yystatement_listlval); @@ -183,7 +183,7 @@ void statement_list_scanner_init() convert_int_dec_literal_value(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_INT_LITERAL; + return STOK_INT_LITERAL; } ((DINT#(10#)?)|(L#))[\+-]?[0-9]+ { @@ -192,7 +192,7 @@ void statement_list_scanner_init() convert_dint_dec_literal_value(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_INT_LITERAL; + return STOK_INT_LITERAL; } 16#[0-9A-Fa-f]+ { @@ -201,7 +201,7 @@ void statement_list_scanner_init() convert_int_hex_literal(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_INT_LITERAL; + return STOK_INT_LITERAL; } INT#16#[0-9A-Fa-f]+ { newstack(yystatement_listlval); @@ -209,7 +209,7 @@ void statement_list_scanner_init() convert_int_hex_literal_value(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_INT_LITERAL; + return STOK_INT_LITERAL; } DINT#16#[0-9A-Fa-f]+ { @@ -218,7 +218,7 @@ void statement_list_scanner_init() convert_dint_hex_literal_value(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_INT_LITERAL; + return STOK_INT_LITERAL; } 2#[0|1]+ { @@ -227,7 +227,7 @@ void statement_list_scanner_init() convert_int_bit_literal(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_INT_LITERAL; + return STOK_INT_LITERAL; } INT#2#[0|1]+ { @@ -236,7 +236,7 @@ void statement_list_scanner_init() convert_int_bit_literal_value(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_INT_LITERAL; + return STOK_INT_LITERAL; } DINT#2#[0|1]+ { @@ -245,7 +245,7 @@ void statement_list_scanner_init() convert_dint_bit_literal_value(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_INT_LITERAL; + return STOK_INT_LITERAL; } ([Tt][Rr][Uu][Ee])|([Ff][Aa][Ll][Ss][Ee]) { @@ -254,7 +254,7 @@ void statement_list_scanner_init() convert_bool_literal(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_BOOL_LITERAL; + return STOK_BOOL_LITERAL; } (\+|-)?[0-9]+\.[0-9]+ { @@ -263,7 +263,7 @@ void statement_list_scanner_init() convert_real_literal(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_REAL_LITERAL; + return STOK_REAL_LITERAL; } (\"[^\"\r\t\n]+\")|([a-zA-Z][a-zA-Z0-9_]*) { @@ -272,7 +272,7 @@ void statement_list_scanner_init() convert_identifier(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_IDENTIFIER; + return STOK_IDENTIFIER; } [a-zA-Z_][a-zA-Z0-9_]*: { @@ -281,7 +281,7 @@ void statement_list_scanner_init() convert_label(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_LABEL; + return STOK_LABEL; } } @@ -294,9 +294,9 @@ void statement_list_scanner_init() PARSER.set_source_location( parser_stack(yystatement_listlval)); BEGIN(TAG_ATTRIBUTES); - return TOK_IDENTIFIER; + return STOK_IDENTIFIER; } - END_TAG { loc(); BEGIN(GRAMMAR); return TOK_END_TAG; } + END_TAG { loc(); BEGIN(GRAMMAR); return STOK_END_TAG; } } { @@ -312,7 +312,7 @@ void statement_list_scanner_init() PARSER.set_source_location( parser_stack(yystatement_listlval)); BEGIN(GRAMMAR); - return TOK_IDENTIFIER; + return STOK_IDENTIFIER; } } @@ -320,10 +320,10 @@ void statement_list_scanner_init() [\t\r," ] ; ([t|T][R|r][u|U][e|E])|([f|F][a|A][l|L][s|S][e|E]) ; %[A-Za-z][0-9\.]+ ; - Int { loc(); return TOK_INT; } - DInt { loc(); return TOK_DINT; } - Bool { loc(); return TOK_BOOL; } - Real { loc(); return TOK_REAL; } + Int { loc(); return STOK_INT; } + DInt { loc(); return STOK_DINT; } + Bool { loc(); return STOK_BOOL; } + Real { loc(); return STOK_REAL; } \n { BEGIN(TAG_NAME); } } @@ -336,7 +336,7 @@ void statement_list_scanner_init() convert_version(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_VERSION_VALUE; + return STOK_VERSION_VALUE; } \n { BEGIN(GRAMMAR); } }