From 060bd05c1469d1886d44ea78351c1eeb319261b2 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Thu, 21 Dec 2023 08:08:25 +0100 Subject: [PATCH] lto: rename the bison tokens to ATOK, JTOK, and STOK to avoid -Wodr with LTO. --- src/CMakeLists.txt | 2 +- src/ansi-c/parser.y | 790 ++++++++++++++++++----------------- src/ansi-c/scanner.l | 608 +++++++++++++-------------- src/common | 1 - src/cpp/parse.cpp | 702 +++++++++++++++---------------- src/statement-list/parser.y | 362 ++++++++-------- src/statement-list/scanner.l | 200 ++++----- 7 files changed, 1338 insertions(+), 1327 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f36e64e06fe..cd793d8e1fe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,7 +24,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 59e320f7112..868ae83e6d7 100644 --- a/src/ansi-c/parser.y +++ b/src/ansi-c/parser.y @@ -34,6 +34,12 @@ int yyansi_cerror(const std::string &error); #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 @@ -60,225 +66,225 @@ int yyansi_cerror(const std::string &error); /*** 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 TOK_BIT_CAST "__builtin_bit_cast" +%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" +%token ATOK_BIT_CAST "__builtin_bit_cast" /*** 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_NODISCARD "nodiscard" -%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_NODISCARD "nodiscard" +%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 **************************/ @@ -306,9 +312,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 @@ -323,23 +329,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 **********************************************************/ @@ -367,7 +373,7 @@ primary_expression: ; generic_selection: - TOK_GENERIC '(' assignment_expression ',' generic_assoc_list ')' + ATOK_GENERIC '(' assignment_expression ',' generic_assoc_list ')' { $$=$1; set($$, ID_generic_selection); @@ -395,7 +401,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); @@ -405,14 +411,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; @@ -426,7 +432,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); @@ -436,7 +442,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); @@ -445,7 +451,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); @@ -477,7 +483,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); @@ -490,7 +496,7 @@ offsetof_member_designator: ; quantifier_expression: - TOK_FORALL compound_scope '{' declaration comma_expression '}' + ATOK_FORALL compound_scope '{' declaration comma_expression '}' { $$=$1; set($$, ID_forall); @@ -498,7 +504,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); @@ -509,7 +515,7 @@ quantifier_expression: ; cprover_contract_loop_invariant: - TOK_CPROVER_LOOP_INVARIANT '(' ACSL_binding_expression ')' + ATOK_CPROVER_LOOP_INVARIANT '(' ACSL_binding_expression ')' { $$=$3; } ; @@ -536,7 +542,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; } ; @@ -579,19 +585,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); @@ -641,13 +647,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); @@ -658,7 +664,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)); @@ -694,29 +700,29 @@ 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); parser_stack($$).add(ID_type_arg).swap(parser_stack($3)); } - | TOK_BIT_CAST '(' type_name ',' unary_expression ')' + | ATOK_BIT_CAST '(' type_name ',' unary_expression ')' { $$=$1; set($$, ID_bit_cast); mto($$, $5); @@ -733,12 +739,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); @@ -765,9 +771,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); } ; @@ -777,17 +783,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); } ; @@ -811,19 +817,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); } ; @@ -832,7 +838,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); } ; @@ -841,14 +847,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); @@ -856,7 +862,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); @@ -864,7 +870,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); @@ -896,25 +902,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); } ; @@ -955,7 +961,7 @@ declaration: ; static_assert_declaration: - TOK_STATIC_ASSERT '(' assignment_expression ',' assignment_expression ')' + ATOK_STATIC_ASSERT '(' assignment_expression ',' assignment_expression ')' { $$=$1; set($$, ID_declaration); @@ -1006,7 +1012,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); @@ -1065,7 +1071,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) @@ -1159,24 +1165,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)); @@ -1328,12 +1334,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)); @@ -1357,7 +1363,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); @@ -1382,15 +1388,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); } @@ -1398,11 +1404,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); } @@ -1429,12 +1435,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); } @@ -1462,16 +1468,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 @@ -1493,54 +1499,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: @@ -1550,7 +1556,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)); } ; @@ -1618,40 +1624,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); } ; @@ -1660,7 +1666,7 @@ gcc_attribute: { init($$); } - | TOK_GCC_ATTRIBUTE_FALLTHROUGH + | ATOK_GCC_ATTRIBUTE_FALLTHROUGH { // attribute ignored init($$); @@ -1677,9 +1683,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); } ; @@ -1934,7 +1940,7 @@ braced_enumerator_list_opt: $$=$2; } -enum_key: TOK_ENUM +enum_key: ATOK_ENUM { $$=$1; set($$, ID_c_enum); @@ -1990,7 +1996,7 @@ enumerator_value_opt: parameter_type_list: parameter_list - | parameter_list ',' TOK_ELLIPSIS + | parameter_list ',' ATOK_ELLIPSIS { typet tmp(ID_ellipsis); $$=$1; @@ -2272,7 +2278,7 @@ designator: mto($1, $2); mto($$, $1); } - | '[' comma_expression TOK_ELLIPSIS comma_expression ']' + | '[' comma_expression ATOK_ELLIPSIS comma_expression ']' { // TODO init($$); @@ -2287,7 +2293,7 @@ designator: mto($2, $3); mto($$, $2); } - | designator '[' comma_expression TOK_ELLIPSIS comma_expression ']' + | designator '[' comma_expression ATOK_ELLIPSIS comma_expression ']' { // TODO $$=$1; @@ -2344,12 +2350,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; @@ -2366,14 +2372,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; @@ -2382,7 +2388,7 @@ labeled_statement: mto($$, $4); mto($$, $6); } - | TOK_DEFAULT ':' statement + | ATOK_DEFAULT ':' statement { $$=$1; statement($$, ID_switch_case); @@ -2395,7 +2401,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. @@ -2420,7 +2426,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); @@ -2466,21 +2472,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); @@ -2494,7 +2500,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 @@ -2513,12 +2519,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); @@ -2533,7 +2539,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) @@ -2573,7 +2579,7 @@ iteration_statement: ; jump_statement: - TOK_GOTO comma_expression ';' + ATOK_GOTO comma_expression ';' { $$=$1; if(parser_stack($2).id()==ID_symbol) @@ -2590,29 +2596,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); @@ -2650,13 +2656,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); @@ -2667,13 +2673,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); @@ -2682,8 +2688,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); @@ -2691,15 +2697,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); @@ -2707,21 +2713,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); @@ -2732,9 +2738,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 @@ -2949,11 +2955,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. } @@ -3337,7 +3343,7 @@ parameter_abstract_declarator: ; cprover_function_contract: - TOK_CPROVER_ENSURES + ATOK_CPROVER_ENSURES { PARSER.new_scope("ensures::"); } @@ -3348,7 +3354,7 @@ cprover_function_contract: mto($$, $4); PARSER.pop_scope(); } - | TOK_CPROVER_REQUIRES + | ATOK_CPROVER_REQUIRES { PARSER.new_scope("requires::"); } @@ -3418,13 +3424,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); @@ -3439,13 +3445,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 ac122dd7612..2fe5a5680be 100644 --- a/src/ansi-c/scanner.l +++ b/src/ansi-c/scanner.l @@ -105,7 +105,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 { @@ -126,13 +126,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; } } } @@ -192,7 +192,7 @@ int cpp_operator(int token) else { yyansi_cerror("C++ operator not allowed in C mode"); - return TOK_SCANNER_ERROR; + return ATOK_SCANNER_ERROR; } } @@ -296,7 +296,7 @@ enable_or_disable ("enable"|"disable") { "*/" { 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 { } @@ -305,7 +305,7 @@ enable_or_disable ("enable"|"disable") { "*/" { 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 { } @@ -322,7 +322,7 @@ enable_or_disable ("enable"|"disable") 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} { @@ -352,7 +352,7 @@ enable_or_disable ("enable"|"disable") 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 */ @@ -437,7 +437,7 @@ enable_or_disable ("enable"|"disable") 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(); @@ -445,7 +445,7 @@ enable_or_disable ("enable"|"disable") . { yyansi_cerror("Unsupported #pragma CPROVER"); - return TOK_SCANNER_ERROR; + return ATOK_SCANNER_ERROR; } {cppstart}"pragma" { BEGIN(OTHER_PRAGMA); } @@ -477,7 +477,7 @@ enable_or_disable ("enable"|"disable") {cppdirective} { yyansi_cerror("Preprocessor directive found"); - return TOK_SCANNER_ERROR; + return ATOK_SCANNER_ERROR; } %{ @@ -485,183 +485,183 @@ enable_or_disable ("enable"|"disable") %} { -"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.float16_type) - { loc(); return TOK_GCC_FLOAT16; } + { loc(); return ATOK_GCC_FLOAT16; } else return make_identifier(); } {CPROVER_PREFIX}"Float16" { - loc(); return TOK_GCC_FLOAT16; + loc(); return ATOK_GCC_FLOAT16; } "__bf16" { if(PARSER.bf16_type) - { loc(); return TOK_GCC_FLOAT16; } + { loc(); return ATOK_GCC_FLOAT16; } else return make_identifier(); } "__fp16" { if(PARSER.fp16_type) - { 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" { if(PARSER.__float128_is_keyword) - { 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); } */ %} @@ -669,7 +669,7 @@ enable_or_disable ("enable"|"disable") "__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(); } @@ -678,7 +678,7 @@ enable_or_disable ("enable"|"disable") "__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(); } @@ -687,7 +687,7 @@ enable_or_disable ("enable"|"disable") "__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(); } @@ -698,7 +698,7 @@ enable_or_disable ("enable"|"disable") %} "_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(); } @@ -706,7 +706,7 @@ enable_or_disable ("enable"|"disable") "__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(); } @@ -716,7 +716,7 @@ enable_or_disable ("enable"|"disable") "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(); } @@ -725,7 +725,7 @@ enable_or_disable ("enable"|"disable") 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(); } @@ -733,7 +733,7 @@ enable_or_disable ("enable"|"disable") "__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(); } @@ -741,7 +741,7 @@ enable_or_disable ("enable"|"disable") "__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(); } @@ -752,13 +752,13 @@ enable_or_disable ("enable"|"disable") 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(); } @@ -768,7 +768,7 @@ enable_or_disable ("enable"|"disable") // 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(); } @@ -777,12 +777,12 @@ enable_or_disable ("enable"|"disable") { 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); @@ -795,7 +795,7 @@ enable_or_disable ("enable"|"disable") if(PARSER.cpp98) { loc(); - return TOK_GCC_ASM; + return ATOK_GCC_ASM; } else BEGIN(GCC_ASM); @@ -812,7 +812,7 @@ enable_or_disable ("enable"|"disable") if(PARSER.cpp98) { loc(); - return TOK_GCC_ASM; + return ATOK_GCC_ASM; } else BEGIN(GCC_ASM); @@ -822,7 +822,7 @@ enable_or_disable ("enable"|"disable") } "__based" { if(PARSER.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) - { loc(); return TOK_MSC_BASED; } + { loc(); return ATOK_MSC_BASED; } else return make_identifier(); } @@ -834,7 +834,7 @@ enable_or_disable ("enable"|"disable") } "__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(); } @@ -843,79 +843,79 @@ enable_or_disable ("enable"|"disable") /* 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); } -nodiscard { return cpp11_keyword(TOK_NODISCARD); } // C++11 -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); } +nodiscard { return cpp11_keyword(ATOK_NODISCARD); } // C++11 +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 // as a keyword, even though the documentation claims // it's a macro. 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 @@ -928,7 +928,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(); } @@ -940,38 +940,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" | @@ -996,28 +996,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(); } @@ -1031,13 +1031,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(); @@ -1060,7 +1060,7 @@ __decltype { if(PARSER.cpp98 && { BEGIN(GCC_ATTRIBUTE1); loc(); - return TOK_GCC_ATTRIBUTE; + return ATOK_GCC_ATTRIBUTE; } else return make_identifier(); @@ -1071,8 +1071,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 */ } @@ -1086,14 +1086,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) @@ -1232,71 +1232,71 @@ __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; } + { loc(); return ATOK_MSC_LEAVE; } else return make_identifier(); } @@ -1304,89 +1304,89 @@ __decltype { if(PARSER.cpp98 && "__nodiscard__" { 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_NODISCARD; } + { loc(); return ATOK_NODISCARD; } else return make_identifier(); } "__builtin_bit_cast" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC || PARSER.mode==configt::ansi_ct::flavourt::CLANG) - { loc(); return TOK_BIT_CAST; } + { loc(); return ATOK_BIT_CAST; } 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; } +{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. */ @@ -1395,7 +1395,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. */ @@ -1403,17 +1403,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(); } @@ -1424,7 +1424,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(); } @@ -1436,7 +1436,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(); } @@ -1457,7 +1457,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(); } @@ -1466,7 +1466,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(); } @@ -1477,7 +1477,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(); } @@ -1488,7 +1488,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(); } @@ -1499,7 +1499,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(); } @@ -1507,7 +1507,7 @@ __decltype { if(PARSER.cpp98 && /* This is a C11 keyword */ "_Static_assert" { if(!PARSER.cpp98) - { loc(); return TOK_STATIC_ASSERT; } + { loc(); return ATOK_STATIC_ASSERT; } else return make_identifier(); } @@ -1518,7 +1518,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(); } @@ -1552,29 +1552,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 '['; } @@ -1590,36 +1590,36 @@ __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; } {clang_ext_float_s} { if(PARSER.mode!=configt::ansi_ct::flavourt::GCC && PARSER.mode != configt::ansi_ct::flavourt::CLANG) { yyansi_cerror("Floating-point constant with unsupported extension"); - 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; } {gcc_ext_float_s} { if(PARSER.mode!=configt::ansi_ct::flavourt::GCC) { yyansi_cerror("Floating-point constant with unsupported extension"); - 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; } "{" { @@ -1657,7 +1657,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; } { @@ -1671,7 +1671,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; } } @@ -1696,16 +1696,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; } } { @@ -1733,45 +1733,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 */ } @@ -1814,7 +1814,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 742f872abff..bf4190c5bd5 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 777f4b2f0bd..4bc7373630a 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); \ @@ -420,7 +420,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) @@ -461,7 +461,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; @@ -570,21 +570,21 @@ 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) + else if(t==ATOK_USING) return rUsingOrTypedef(item); - else if(t==TOK_STATIC_ASSERT) + else if(t==ATOK_STATIC_ASSERT) return rStaticAssert(item.make_static_assert()); else return rDeclaration(item.make_declaration()); @@ -610,7 +610,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 @@ -639,7 +639,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 @@ -764,20 +764,20 @@ 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_FLOAT16 || 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_FLOAT16 || 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; } /* @@ -789,7 +789,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)) @@ -830,13 +830,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; @@ -885,13 +885,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); @@ -944,7 +944,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)!='(') @@ -1041,7 +1041,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; @@ -1089,7 +1089,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); @@ -1114,7 +1114,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)!='<') @@ -1187,7 +1187,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(); @@ -1210,7 +1210,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); @@ -1260,7 +1260,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; @@ -1273,7 +1273,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), @@ -1311,7 +1311,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); @@ -1365,10 +1365,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)) @@ -1907,7 +1907,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 (::*) @@ -1932,7 +1932,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)) @@ -1969,7 +1969,7 @@ bool Parser::isPtrToMember(int i) t=lex.LookAhead(i++); } - if(t!=TOK_SCOPE) + if(t!=ATOK_SCOPE) return false; t0=lex.LookAhead(i++); @@ -1992,21 +1992,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; } @@ -2025,22 +2025,22 @@ bool Parser::optStorageSpec(cpp_storage_spect &storage_spec) int t=lex.LookAhead(0); if( - t == TOK_STATIC || t == TOK_EXTERN || (t == TOK_AUTO && !cpp11) || - t == TOK_REGISTER || t == TOK_MUTABLE || t == TOK_GCC_ASM || - t == TOK_THREAD_LOCAL) + t == ATOK_STATIC || t == ATOK_EXTERN || (t == ATOK_AUTO && !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; } @@ -2058,10 +2058,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); @@ -2069,48 +2069,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; @@ -2141,7 +2141,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; @@ -2215,7 +2215,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); @@ -2223,7 +2223,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); @@ -2231,7 +2231,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_VECTOR_SIZE: + case ATOK_GCC_ATTRIBUTE_VECTOR_SIZE: { cpp_tokent tk2, tk3; @@ -2252,7 +2252,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); @@ -2278,7 +2278,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_MODE: + case ATOK_GCC_ATTRIBUTE_MODE: { cpp_tokent tk2, tk3; @@ -2299,7 +2299,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); @@ -2307,7 +2307,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); @@ -2315,7 +2315,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_ALIAS: + case ATOK_GCC_ATTRIBUTE_ALIAS: { cpp_tokent tk2, tk3, tk4; @@ -2335,7 +2335,7 @@ bool Parser::rGCCAttribute(typet &t) break; } - case TOK_GCC_ATTRIBUTE_SECTION: + case ATOK_GCC_ATTRIBUTE_SECTION: { cpp_tokent tk2, tk3, tk4; @@ -2355,7 +2355,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); @@ -2363,7 +2363,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); @@ -2371,7 +2371,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); @@ -2397,7 +2397,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(); @@ -2425,7 +2425,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); @@ -2433,7 +2433,7 @@ bool Parser::optAttribute(typet &t) break; } - case TOK_NODISCARD: + case ATOK_NODISCARD: { typet attr(ID_nodiscard); set_location(attr, tk); @@ -2469,7 +2469,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); @@ -2493,34 +2493,34 @@ 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_FLOAT16: + 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_FLOAT16: type_id = ID_gcc_float16; 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_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(); } @@ -2553,11 +2553,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, ' ') @@ -2623,7 +2623,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); @@ -2648,7 +2648,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. @@ -2731,7 +2731,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"; @@ -2770,14 +2770,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(!cpp11) { @@ -2790,7 +2790,7 @@ bool Parser::rConstructorDecl( } break; - case TOK_DELETE: // C++0x + case ATOK_DELETE: // C++0x { if(!cpp11) { @@ -2824,7 +2824,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)); @@ -2842,7 +2842,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); } @@ -2867,7 +2867,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; @@ -2954,7 +2954,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(!cpp11) { @@ -2966,7 +2966,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(!cpp11) { @@ -3030,7 +3030,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); @@ -3135,7 +3135,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"; @@ -3203,7 +3203,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"; @@ -3397,7 +3397,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); @@ -3528,7 +3528,7 @@ bool Parser::rMemberInit(exprt &init) return false; } - if(lex.LookAhead(0)==TOK_ELLIPSIS) + if(lex.LookAhead(0)==ATOK_ELLIPSIS) { lex.get_token(); @@ -3559,7 +3559,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); @@ -3587,7 +3587,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 @@ -3610,13 +3610,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 @@ -3627,12 +3627,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 @@ -3655,7 +3655,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 @@ -3720,43 +3720,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); @@ -3862,7 +3862,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))) @@ -3878,27 +3878,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); @@ -3981,10 +3981,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 @@ -4007,7 +4007,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); @@ -4030,7 +4030,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); @@ -4055,7 +4055,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='>'; @@ -4136,7 +4136,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); @@ -4152,12 +4152,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 @@ -4184,7 +4184,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; @@ -4243,8 +4243,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; @@ -4326,7 +4326,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); @@ -4359,7 +4359,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(); @@ -4368,7 +4368,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); @@ -4499,27 +4499,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; @@ -4611,26 +4611,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; @@ -4641,7 +4641,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); @@ -4650,7 +4650,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(); @@ -4742,19 +4742,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; @@ -4771,13 +4771,13 @@ 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) + else if(t==ATOK_USING) return rUsingOrTypedef(member); - else if(t==TOK_STATIC_ASSERT) + else if(t==ATOK_STATIC_ASSERT) return rStaticAssert(member.make_static_assert()); else { @@ -4881,10 +4881,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); @@ -4907,25 +4907,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)); @@ -5006,7 +5006,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); @@ -5045,7 +5045,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); @@ -5201,8 +5201,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); @@ -5214,7 +5214,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); } @@ -5244,7 +5244,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); @@ -5260,8 +5260,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; } @@ -5293,8 +5293,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); @@ -5306,7 +5306,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); } @@ -5433,8 +5433,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); @@ -5494,7 +5494,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' @@ -5629,7 +5629,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) == '(') { @@ -5671,7 +5671,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); @@ -5693,7 +5693,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 @@ -5758,7 +5758,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); @@ -5801,12 +5801,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; @@ -5820,15 +5820,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; @@ -5839,7 +5839,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; @@ -5863,7 +5863,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); @@ -5902,7 +5902,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)=='(') @@ -5968,7 +5968,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)=='(') @@ -5992,7 +5992,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; @@ -6035,7 +6035,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; @@ -6068,7 +6068,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)=='(') @@ -6098,10 +6098,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; } /* @@ -6120,7 +6120,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! @@ -6136,7 +6136,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; @@ -6165,7 +6165,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"; @@ -6347,7 +6347,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 @@ -6456,7 +6456,7 @@ bool Parser::rPostfixExpr(exprt &exp) } break; - case TOK_INCR: + case ATOK_INCR: lex.get_token(op); { @@ -6467,7 +6467,7 @@ bool Parser::rPostfixExpr(exprt &exp) } break; - case TOK_DECR: + case ATOK_DECR: lex.get_token(op); { @@ -6479,7 +6479,7 @@ bool Parser::rPostfixExpr(exprt &exp) break; case '.': - case TOK_ARROW: + case ATOK_ARROW: t2=lex.get_token(op); #ifdef DEBUG @@ -6526,7 +6526,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)!='(') @@ -6577,8 +6577,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; @@ -6606,7 +6606,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)); @@ -6622,7 +6622,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; @@ -6655,7 +6655,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)); @@ -6684,7 +6684,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)) @@ -6694,7 +6694,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)) @@ -6745,9 +6745,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); @@ -6756,7 +6756,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); @@ -6765,7 +6765,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); @@ -6774,7 +6774,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); @@ -6783,7 +6783,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); @@ -6792,7 +6792,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))}; @@ -6851,17 +6851,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 @@ -6869,8 +6869,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 @@ -6890,7 +6890,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); @@ -6939,7 +6939,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); @@ -6990,7 +6990,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); @@ -7019,7 +7019,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"; @@ -7030,8 +7030,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 @@ -7064,7 +7064,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 @@ -7088,7 +7088,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 @@ -7115,10 +7115,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; } @@ -7148,8 +7148,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; } @@ -7196,7 +7196,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 @@ -7215,7 +7215,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 } @@ -7237,7 +7237,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); @@ -7355,39 +7355,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)!=';') @@ -7395,7 +7395,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"; @@ -7435,7 +7435,7 @@ std::optional Parser::rStatement() return std::move(statement); } - case TOK_GOTO: + case ATOK_GOTO: { lex.get_token(tk1); @@ -7450,7 +7450,7 @@ std::optional Parser::rStatement() return std::move(statement); } - case TOK_CASE: + case ATOK_CASE: { lex.get_token(tk1); @@ -7458,7 +7458,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. @@ -7498,7 +7498,7 @@ std::optional Parser::rStatement() } } - case TOK_DEFAULT: + case ATOK_DEFAULT: { lex.get_token(tk1); @@ -7516,18 +7516,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 @@ -7547,7 +7547,7 @@ std::optional Parser::rStatement() return rExprStatement(); - case TOK_USING: + case ATOK_USING: { if(is_identifier(lex.LookAhead(1)) && lex.LookAhead(2) == '=') { @@ -7568,7 +7568,7 @@ std::optional Parser::rStatement() UNIMPLEMENTED; } - case TOK_STATIC_ASSERT: + case ATOK_STATIC_ASSERT: { cpp_static_assertt cpp_static_assert{nil_exprt(), nil_exprt()}; @@ -7595,7 +7595,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)!='(') @@ -7612,7 +7612,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); @@ -7642,7 +7642,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)!='(') @@ -7673,7 +7673,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)!='(') @@ -7704,14 +7704,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)!='(') @@ -7741,7 +7741,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)!='(') @@ -7799,7 +7799,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(); @@ -7814,7 +7814,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)!='(') @@ -7822,7 +7822,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); @@ -7865,7 +7865,7 @@ std::optional Parser::rTryStatement() else return {}; } - while(lex.LookAhead(0)==TOK_CATCH); + while(lex.LookAhead(0)==ATOK_CATCH); return std::move(statement); } @@ -7877,7 +7877,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(); @@ -7885,7 +7885,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); @@ -7913,7 +7913,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); @@ -7939,7 +7939,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); @@ -7959,13 +7959,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 @@ -7995,7 +7995,7 @@ std::optional Parser::rGCCAsmStatement() for(;;) { - if(lex.LookAhead(0)!=TOK_STRING) + if(lex.LookAhead(0)!=ATOK_STRING) break; // get String @@ -8059,7 +8059,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; @@ -8078,7 +8078,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); @@ -8097,7 +8097,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/statement-list/parser.y b/src/statement-list/parser.y index fa21cba3a09..9916e6f507c 100644 --- a/src/statement-list/parser.y +++ b/src/statement-list/parser.y @@ -38,6 +38,12 @@ int yystatement_listerror( #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 @@ -61,99 +67,99 @@ int yystatement_listerror( /*** Token declaration *******************************************************/ /*** 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 *******************************/ @@ -209,7 +215,7 @@ Zom_Separated_Variable_Name: ; Variable_Name: - TOK_IDENTIFIER + STOK_IDENTIFIER { newstack($$); parser_stack($$) = @@ -241,7 +247,7 @@ Int_Type_Name: ; Sign_Int_Type_Name: - TOK_INT + STOK_INT { $$ = $1; parser_stack($$).type() = get_int_type(); @@ -253,7 +259,7 @@ DInt_Type_Name: ; Sign_DInt_Type_Name: - TOK_DINT + STOK_DINT { $$ = $1; parser_stack($$).type() = get_dint_type(); @@ -261,7 +267,7 @@ Sign_DInt_Type_Name: ; Real_Type_Name: - TOK_REAL + STOK_REAL { $$ = $1; parser_stack($$).type() = get_real_type(); @@ -269,14 +275,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; } @@ -287,12 +293,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); @@ -305,7 +311,7 @@ FB_Decl: ; Version_Label: - TOK_VERSION ':' TOK_VERSION_VALUE + STOK_VERSION ':' STOK_VERSION_VALUE { $$ = $3; } @@ -338,7 +344,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; } @@ -366,7 +372,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; } @@ -394,7 +400,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; } @@ -422,7 +428,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; } @@ -450,7 +456,7 @@ FB_Static_Decl: ; FB_Body: - TOK_BEGIN Zom_IL_Network + STOK_BEGIN Zom_IL_Network { $$ = $2; } @@ -458,8 +464,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); @@ -472,11 +478,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); } @@ -512,7 +518,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; } @@ -536,7 +542,7 @@ Input_Decl: ; Inout_Decls: - TOK_VAR_INOUT Zom_Inout_Decl TOK_END_VAR + STOK_VAR_INOUT Zom_Inout_Decl STOK_END_VAR { $$ = $2; } @@ -560,7 +566,7 @@ Inout_Decl: ; Output_Decls: - TOK_VAR_OUTPUT Zom_Output_Decl TOK_END_VAR + STOK_VAR_OUTPUT Zom_Output_Decl STOK_END_VAR { $$ = $2; } @@ -584,7 +590,7 @@ Output_Decl: ; Temp_Decls: - TOK_VAR_TEMP Zom_Temp_Decl TOK_END_VAR + STOK_VAR_TEMP Zom_Temp_Decl STOK_END_VAR { $$ = $2; } @@ -608,7 +614,7 @@ Temp_Decl: ; Constant_Decls: - TOK_VAR_CONSTANT Zom_Constant_Decl TOK_END_VAR + STOK_VAR_CONSTANT Zom_Constant_Decl STOK_END_VAR { $$ = $2; } @@ -636,7 +642,7 @@ Constant_Decl: ; Func_Body: - TOK_BEGIN Zom_IL_Network + STOK_BEGIN Zom_IL_Network { $$ = $2; } @@ -657,7 +663,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); @@ -668,7 +674,7 @@ IL_Network: Opt_TITLE_VALUE: - TOK_TITLE_VALUE + STOK_TITLE_VALUE | /* nothing */ { newstack($$); @@ -722,7 +728,7 @@ Opt_Label: ; IL_Label: - TOK_LABEL + STOK_LABEL ; Instruction: @@ -750,282 +756,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); @@ -1049,9 +1055,9 @@ Variable_Access: ; Constant: - TOK_INT_LITERAL - | TOK_BOOL_LITERAL - | TOK_REAL_LITERAL + STOK_INT_LITERAL + | STOK_BOOL_LITERAL + | STOK_REAL_LITERAL ; IL_Invocation: @@ -1068,7 +1074,7 @@ IL_Invocation: ; Call: - TOK_CALL + STOK_CALL { $$ = $1; parser_stack($$).id(ID_statement_list_call); @@ -1085,7 +1091,7 @@ Callee_Name: ; Opt_Param_List: - '(' Oom_Param_Assignment TOK_NESTING_CLOSED + '(' Oom_Param_Assignment STOK_NESTING_CLOSED { $$ = $2; } @@ -1109,7 +1115,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)), @@ -1131,7 +1137,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 b6f080771d9..ad7ee683b98 100644 --- a/src/statement-list/scanner.l +++ b/src/statement-list/scanner.l @@ -79,85 +79,85 @@ static int isatty(int) { return 0; } { [\(:\.,;#] { 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); @@ -165,7 +165,7 @@ static int isatty(int) { return 0; } 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); @@ -173,7 +173,7 @@ static int isatty(int) { return 0; } 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]+ { @@ -182,7 +182,7 @@ static int isatty(int) { return 0; } 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]+ { @@ -191,7 +191,7 @@ static int isatty(int) { return 0; } 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); @@ -199,7 +199,7 @@ static int isatty(int) { return 0; } 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]+ { @@ -208,7 +208,7 @@ static int isatty(int) { return 0; } 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]+ { @@ -217,7 +217,7 @@ static int isatty(int) { return 0; } 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]+ { @@ -226,7 +226,7 @@ static int isatty(int) { return 0; } 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]+ { @@ -235,7 +235,7 @@ static int isatty(int) { return 0; } 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]) { @@ -244,7 +244,7 @@ static int isatty(int) { return 0; } convert_bool_literal(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_BOOL_LITERAL; + return STOK_BOOL_LITERAL; } (\+|-)?[0-9]+\.[0-9]+ { @@ -253,7 +253,7 @@ static int isatty(int) { return 0; } 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_]*) { @@ -262,7 +262,7 @@ static int isatty(int) { return 0; } convert_identifier(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_IDENTIFIER; + return STOK_IDENTIFIER; } [a-zA-Z_][a-zA-Z0-9_]*: { @@ -271,7 +271,7 @@ static int isatty(int) { return 0; } convert_label(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_LABEL; + return STOK_LABEL; } } @@ -284,9 +284,9 @@ static int isatty(int) { return 0; } 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; } } { @@ -302,7 +302,7 @@ static int isatty(int) { return 0; } PARSER.set_source_location( parser_stack(yystatement_listlval)); BEGIN(GRAMMAR); - return TOK_IDENTIFIER; + return STOK_IDENTIFIER; } } @@ -310,10 +310,10 @@ static int isatty(int) { return 0; } [\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); } } @@ -326,7 +326,7 @@ static int isatty(int) { return 0; } convert_version(yytext); PARSER.set_source_location( parser_stack(yystatement_listlval)); - return TOK_VERSION_VALUE; + return STOK_VERSION_VALUE; } \n { BEGIN(GRAMMAR); } }