From f24c0cf292eab9b84c26af3bc98107563abdb07d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 14 Mar 2010 04:03:07 +0000 Subject: [PATCH] - Merge scanner changes from the scripting branch, since I'm pretty sure the token names were out of sync here, too. SVN r2209 (trunk) --- src/sc_man.cpp | 114 +------------------------------------- src/sc_man.h | 116 +-------------------------------------- src/sc_man_scanner.re | 13 +++++ src/sc_man_tokens.h | 125 ++++++++++++++++++++++++++++++++++++++++++ zdoom.vcproj | 4 ++ 5 files changed, 148 insertions(+), 224 deletions(-) create mode 100644 src/sc_man_tokens.h diff --git a/src/sc_man.cpp b/src/sc_man.cpp index b69aa1ce0d..298676dc65 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -812,116 +812,8 @@ FString FScanner::TokenName (int token, const char *string) { static const char *const names[] = { - "identifier", - "string constant", - "name constant", - "integer constant", - "float constant", - "'...'", - "'>>='", - "'<<='", - "'+='", - "'-='", - "'*='", - "'/='", - "'%='", - "'&='", - "'^='", - "'|='", - "'>>'", - "'>>>'", - "'<<'", - "'++'", - "'--'", - "'&&'", - "'||'", - "'<='", - "'>='", - "'=='", - "'!='", - "'action'", - "'break'", - "'case'", - "'const'", - "'continue'", - "'default'", - "'do'", - "'else'", - "'for'", - "'if'", - "'return'", - "'states'", - "'switch'", - "'until'", - "'while'", - "'bool'", - "'float'", - "'double'", - "'char'", - "'byte'", - "'sbyte'", - "'short'", - "'ushort'", - "'int'", - "'uint'", - "'long'", - "'ulong'", - "'void'", - "'struct'", - "'class'", - "'mode'", - "'enum'", - "'name'", - "'string'", - "'sound'", - "'state'", - "'color'", - "'goto'", - "'abstract'", - "'foreach'", - "'true'", - "'false'", - "'none'", - "'new'", - "'instanceof'", - "'auto'", - "'exec'", - "'defaultproperties'", - "'native'", - "'out'", - "'ref'", - "'event'", - "'static'", - "'transient'", - "'volatile'", - "'final'", - "'throws'", - "'extends'", - "'public'", - "'protected'", - "'private'", - "'dot'", - "'cross'", - "'ignores'", - "'localized'", - "'latent'", - "'singular'", - "'config'", - "'coerce'", - "'iterator'", - "'optional'", - "'export'", - "'virtual'", - "'super'", - "'global'", - "'self'", - "'stop'", - "'#include'", - "'fixed_t'", - "'angle_t'", - "'abs'", - "'random'", - "'random2'" +#define xx(sym,str) str, +#include "sc_man_tokens.h" }; FString work; @@ -992,7 +884,7 @@ void STACK_ARGS FScanner::ScriptError (const char *message, ...) //========================================================================== // -// FScanner::ScriptError +// FScanner::ScriptMessage // //========================================================================== diff --git a/src/sc_man.h b/src/sc_man.h index 1e5dc289d6..777e8cdcd7 100644 --- a/src/sc_man.h +++ b/src/sc_man.h @@ -99,119 +99,9 @@ protected: enum { - TK_Identifier = 257, - TK_StringConst, - TK_NameConst, - TK_IntConst, - TK_FloatConst, - TK_Ellipsis, // ... - TK_RShiftEq, // >>= - TK_URShiftEq, // >>>= - TK_LShiftEq, // <<= - TK_AddEq, // += - TK_SubEq, // -= - TK_MulEq, // *= - TK_DivEq, // /= - TK_ModEq, // %= - TK_AndEq, // &= - TK_XorEq, // ^= - TK_OrEq, // |= - TK_RShift, // >> - TK_URShift, // >>> - TK_LShift, // << - TK_Incr, // ++ - TK_Decr, // -- - TK_AndAnd, // && - TK_OrOr, // || - TK_Leq, // <= - TK_Geq, // >= - TK_Eq, // == - TK_Neq, // != - TK_Action, - TK_Break, - TK_Case, - TK_Const, - TK_Continue, - TK_Default, - TK_Do, - TK_Else, - TK_For, - TK_If, - TK_Return, - TK_Switch, - TK_Until, - TK_While, - TK_Bool, - TK_Float, - TK_Double, - TK_Char, - TK_Byte, - TK_SByte, - TK_Short, - TK_UShort, - TK_Int, - TK_UInt, - TK_Long, - TK_ULong, - TK_Void, - TK_Struct, - TK_Class, - TK_Mode, - TK_Enum, - TK_Name, - TK_String, - TK_Sound, - TK_State, - TK_Color, - TK_Goto, - TK_Abstract, - TK_ForEach, - TK_True, - TK_False, - TK_None, - TK_New, - TK_InstanceOf, - TK_Auto, - TK_Exec, - TK_DefaultProperties, - TK_Native, - TK_Var, - TK_Out, - TK_Ref, - TK_Event, - TK_Static, - TK_Transient, - TK_Volatile, - TK_Final, - TK_Throws, - TK_Extends, - TK_Public, - TK_Protected, - TK_Private, - TK_Dot, - TK_Cross, - TK_Ignores, - TK_Localized, - TK_Latent, - TK_Singular, - TK_Config, - TK_Coerce, - TK_Iterator, - TK_Optional, - TK_Export, - TK_Virtual, - TK_Super, - TK_Global, - TK_Self, - TK_Stop, - TK_Include, - TK_Fixed_t, - TK_Angle_t, - TK_Abs, - TK_Random, - TK_Random2, - TK_FRandom, - + TK_SequenceStart = 256, +#define xx(sym,str) sym, +#include "sc_man_tokens.h" TK_LastToken }; diff --git a/src/sc_man_scanner.re b/src/sc_man_scanner.re index ff0945db35..66058ac8cd 100644 --- a/src/sc_man_scanner.re +++ b/src/sc_man_scanner.re @@ -96,6 +96,12 @@ std2: 'sound' { RET(TK_Sound); } 'state' { RET(TK_State); } 'color' { RET(TK_Color); } + 'vector' { RET(TK_Vector); } + 'map' { RET(TK_Map); } + 'array' { RET(TK_Array); } + 'in' { RET(TK_In); } + 'sizeof' { RET(TK_SizeOf); } + 'alignof' { RET(TK_AlignOf); } /* Other keywords from UnrealScript */ 'abstract' { RET(TK_Abstract); } @@ -138,6 +144,9 @@ std2: 'self' { RET(TK_Self); } 'stop' { RET(TK_Stop); } + 'is' { RET(TK_Is); } + 'replaces' { RET(TK_Replaces); } + /* Needed for decorate action functions */ 'action' { RET(TK_Action); } @@ -164,6 +173,7 @@ std2: (['] (any\[\n'])* [']) { RET(TK_NameConst); } + ".." { RET(TK_DotDot); } "..." { RET(TK_Ellipsis); } ">>>=" { RET(TK_URShiftEq); } ">>=" { RET(TK_RShiftEq); } @@ -187,6 +197,9 @@ std2: ">=" { RET(TK_Geq); } "==" { RET(TK_Eq); } "!=" { RET(TK_Neq); } + "~==" { RET(TK_ApproxEq); } + "<>=" { RET(TK_LtGtEq); } + "**" { RET(TK_MulMul); } ";" { RET(';'); } "{" { RET('{'); } "}" { RET('}'); } diff --git a/src/sc_man_tokens.h b/src/sc_man_tokens.h new file mode 100644 index 0000000000..9dde749723 --- /dev/null +++ b/src/sc_man_tokens.h @@ -0,0 +1,125 @@ +xx(TK_Identifier, "identifier") +xx(TK_StringConst, "string constant") +xx(TK_NameConst, "name constant") +xx(TK_IntConst, "integer constant") +xx(TK_FloatConst, "float constant") +xx(TK_DotDot, "'..'") +xx(TK_Ellipsis, "'...'") +xx(TK_RShiftEq, "'>>='") +xx(TK_URShiftEq, "'>>>='") +xx(TK_LShiftEq, "'<<='") +xx(TK_AddEq, "'+='") +xx(TK_SubEq, "'-='") +xx(TK_MulEq, "'*='") +xx(TK_DivEq, "'/='") +xx(TK_ModEq, "'%='") +xx(TK_AndEq, "'&='") +xx(TK_XorEq, "'^='") +xx(TK_OrEq, "'|='") +xx(TK_RShift, "'>>'") +xx(TK_URShift, "'>>>'") +xx(TK_LShift, "'<<'") +xx(TK_Incr, "'++'") +xx(TK_Decr, "'--'") +xx(TK_AndAnd, "'&&'") +xx(TK_OrOr, "'||'") +xx(TK_Leq, "'<='") +xx(TK_Geq, "'>='") +xx(TK_Eq, "'=='") +xx(TK_Neq, "'!='") +xx(TK_ApproxEq, "'~=='") +xx(TK_LtGtEq, "'<>='") +xx(TK_MulMul, "'**'") +xx(TK_Action, "'action'") +xx(TK_Break, "'break'") +xx(TK_Case, "'case'") +xx(TK_Const, "'const'") +xx(TK_Continue, "'continue'") +xx(TK_Default, "'default'") +xx(TK_Do, "'do'") +xx(TK_Else, "'else'") +xx(TK_For, "'for'") +xx(TK_If, "'if'") +xx(TK_Return, "'return'") +xx(TK_Switch, "'switch'") +xx(TK_Until, "'until'") +xx(TK_While, "'while'") +xx(TK_Bool, "'bool'") +xx(TK_Float, "'float'") +xx(TK_Double, "'double'") +xx(TK_Char, "'char'") +xx(TK_Byte, "'byte'") +xx(TK_SByte, "'sbyte'") +xx(TK_Short, "'short'") +xx(TK_UShort, "'ushort'") +xx(TK_Int, "'int'") +xx(TK_UInt, "'uint'") +xx(TK_Long, "'long'") +xx(TK_ULong, "'ulong'") +xx(TK_Void, "'void'") +xx(TK_Struct, "'struct'") +xx(TK_Class, "'class'") +xx(TK_Mode, "'mode'") +xx(TK_Enum, "'enum'") +xx(TK_Name, "'name'") +xx(TK_String, "'string'") +xx(TK_Sound, "'sound'") +xx(TK_State, "'state'") +xx(TK_Color, "'color'") +xx(TK_Goto, "'goto'") +xx(TK_Abstract, "'abstract'") +xx(TK_ForEach, "'foreach'") +xx(TK_True, "'true'") +xx(TK_False, "'false'") +xx(TK_None, "'none'") +xx(TK_New, "'new'") +xx(TK_InstanceOf, "'instanceof'") +xx(TK_Auto, "'auto'") +xx(TK_Exec, "'exec'") +xx(TK_DefaultProperties, "'defaultproperties'") +xx(TK_Native, "'native'") +xx(TK_Var, "'var'") +xx(TK_Out, "'out'") +xx(TK_Ref, "'ref'") +xx(TK_Event, "'event'") +xx(TK_Static, "'static'") +xx(TK_Transient, "'transient'") +xx(TK_Volatile, "'volatile'") +xx(TK_Final, "'final'") +xx(TK_Throws, "'throws'") +xx(TK_Extends, "'extends'") +xx(TK_Public, "'public'") +xx(TK_Protected, "'protected'") +xx(TK_Private, "'private'") +xx(TK_Dot, "'dot'") +xx(TK_Cross, "'cross'") +xx(TK_Ignores, "'ignores'") +xx(TK_Localized, "'localized'") +xx(TK_Latent, "'latent'") +xx(TK_Singular, "'singular'") +xx(TK_Config, "'config'") +xx(TK_Coerce, "'coerce'") +xx(TK_Iterator, "'iterator'") +xx(TK_Optional, "'optional'") +xx(TK_Export, "'expert'") +xx(TK_Virtual, "'virtual'") +xx(TK_Super, "'super'") +xx(TK_Global, "'global'") +xx(TK_Self, "'self'") +xx(TK_Stop, "'stop'") +xx(TK_Include, "'include'") +xx(TK_Fixed_t, "'fixed_t'") +xx(TK_Angle_t, "'angle_t'") +xx(TK_Abs, "'abs'") +xx(TK_Random, "'random'") +xx(TK_Random2, "'random2'") +xx(TK_FRandom, "'frandom'") +xx(TK_Is, "'is'") +xx(TK_Replaces, "'replaces'") +xx(TK_Vector, "'vector'") +xx(TK_Map, "'map'") +xx(TK_Array, "'array'") +xx(TK_In, "'in'") +xx(TK_SizeOf, "'sizeof'") +xx(TK_AlignOf, "'alignof'") +#undef xx diff --git a/zdoom.vcproj b/zdoom.vcproj index 793cce76c0..2cee5d4134 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -1501,6 +1501,10 @@ RelativePath=".\src\sc_man.h" > + +