- Merge scanner changes from the scripting branch, since I'm pretty sure the

token names were out of sync here, too.



SVN r2209 (trunk)
This commit is contained in:
Randy Heit 2010-03-14 04:03:07 +00:00
parent c191d95110
commit f24c0cf292
5 changed files with 148 additions and 224 deletions

View file

@ -812,116 +812,8 @@ FString FScanner::TokenName (int token, const char *string)
{ {
static const char *const names[] = static const char *const names[] =
{ {
"identifier", #define xx(sym,str) str,
"string constant", #include "sc_man_tokens.h"
"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'"
}; };
FString work; FString work;
@ -992,7 +884,7 @@ void STACK_ARGS FScanner::ScriptError (const char *message, ...)
//========================================================================== //==========================================================================
// //
// FScanner::ScriptError // FScanner::ScriptMessage
// //
//========================================================================== //==========================================================================

View file

@ -99,119 +99,9 @@ protected:
enum enum
{ {
TK_Identifier = 257, TK_SequenceStart = 256,
TK_StringConst, #define xx(sym,str) sym,
TK_NameConst, #include "sc_man_tokens.h"
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_LastToken TK_LastToken
}; };

View file

@ -96,6 +96,12 @@ std2:
'sound' { RET(TK_Sound); } 'sound' { RET(TK_Sound); }
'state' { RET(TK_State); } 'state' { RET(TK_State); }
'color' { RET(TK_Color); } '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 */ /* Other keywords from UnrealScript */
'abstract' { RET(TK_Abstract); } 'abstract' { RET(TK_Abstract); }
@ -138,6 +144,9 @@ std2:
'self' { RET(TK_Self); } 'self' { RET(TK_Self); }
'stop' { RET(TK_Stop); } 'stop' { RET(TK_Stop); }
'is' { RET(TK_Is); }
'replaces' { RET(TK_Replaces); }
/* Needed for decorate action functions */ /* Needed for decorate action functions */
'action' { RET(TK_Action); } 'action' { RET(TK_Action); }
@ -164,6 +173,7 @@ std2:
(['] (any\[\n'])* [']) (['] (any\[\n'])* ['])
{ RET(TK_NameConst); } { RET(TK_NameConst); }
".." { RET(TK_DotDot); }
"..." { RET(TK_Ellipsis); } "..." { RET(TK_Ellipsis); }
">>>=" { RET(TK_URShiftEq); } ">>>=" { RET(TK_URShiftEq); }
">>=" { RET(TK_RShiftEq); } ">>=" { RET(TK_RShiftEq); }
@ -187,6 +197,9 @@ std2:
">=" { RET(TK_Geq); } ">=" { RET(TK_Geq); }
"==" { RET(TK_Eq); } "==" { RET(TK_Eq); }
"!=" { RET(TK_Neq); } "!=" { RET(TK_Neq); }
"~==" { RET(TK_ApproxEq); }
"<>=" { RET(TK_LtGtEq); }
"**" { RET(TK_MulMul); }
";" { RET(';'); } ";" { RET(';'); }
"{" { RET('{'); } "{" { RET('{'); }
"}" { RET('}'); } "}" { RET('}'); }

125
src/sc_man_tokens.h Normal file
View file

@ -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

View file

@ -1501,6 +1501,10 @@
RelativePath=".\src\sc_man.h" RelativePath=".\src\sc_man.h"
> >
</File> </File>
<File
RelativePath=".\src\sc_man_tokens.h"
>
</File>
<File <File
RelativePath=".\src\skins.h" RelativePath=".\src\skins.h"
> >