diff options
author | Kelly Washington <kelly@lindenlab.com> | 2007-06-21 22:40:22 +0000 |
---|---|---|
committer | Kelly Washington <kelly@lindenlab.com> | 2007-06-21 22:40:22 +0000 |
commit | e03bb0606a10f29c8b94909a713a5bb5c69e88b7 (patch) | |
tree | 6d8d07894579438c8cc70e08f5730c3c95dfe768 /indra/lscript/lscript_compile | |
parent | 2638f12f95eea692502836cf6548b4a0b234d009 (diff) |
merge -r62831:64079 branches/maintenance to release
Diffstat (limited to 'indra/lscript/lscript_compile')
-rw-r--r-- | indra/lscript/lscript_compile/indra.l | 17 | ||||
-rw-r--r-- | indra/lscript/lscript_compile/indra.y | 44 |
2 files changed, 43 insertions, 18 deletions
diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index 37435c2e97..e8aa073c63 100644 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -1,8 +1,7 @@ -D [-]?[0-9] N [0-9] L [a-zA-Z_] H [a-fA-F0-9] -E [Ee][+-]?{D}+ +E [Ee][+-]?{N}+ FS (f|F) %e 10000 %n 4000 @@ -41,7 +40,7 @@ void parse_string(); #define YYLMAX 16384 #define YY_NEVER_INTERACTIVE 1 /* stops flex from calling isatty() */ - + #if defined(__cplusplus) extern "C" { int yylex( void ); } extern "C" { int yyparse( void ); } @@ -111,7 +110,7 @@ extern "C" { int yyerror(const char *fmt, ...); } 0[xX]{H}+ { count(); yylval.ival = strtoul(yytext, NULL, 0); return(INTEGER_CONSTANT); } -{D}+ { count(); yylval.ival = strtoul(yytext, NULL, 10); return(INTEGER_CONSTANT); } +{N}+ { count(); yylval.ival = strtoul(yytext, NULL, 10); return(INTEGER_CONSTANT); } "TRUE" { count(); yylval.ival = 1; return(INTEGER_TRUE); } "FALSE" { count(); yylval.ival = 0; return(INTEGER_FALSE); } "STATUS_PHYSICS" { count(); yylval.ival = 0x1; return(INTEGER_CONSTANT); } @@ -571,9 +570,9 @@ extern "C" { int yyerror(const char *fmt, ...); } {L}({L}|{N})* { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(IDENTIFIER); } -{D}+{E} { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } -{D}*"."{D}+({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } -{D}+"."{D}*({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } +{N}+{E} { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } +{N}*"."{N}+({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } +{N}+"."{N}*({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } L?\"(\\.|[^\\"])*\" { parse_string(); count(); return(STRING_CONSTANT); } @@ -751,6 +750,10 @@ BOOL lscript_compile(char *filename, BOOL is_god_like = FALSE) S32 yywrap() { +#ifdef FLEX_SCANNER + // get gcc to stop complaining about lack of use of yyunput + (void) yyunput; +#endif return(1); } diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y index 7744649a92..c7a4fd6289 100644 --- a/indra/lscript/lscript_compile/indra.y +++ b/indra/lscript/lscript_compile/indra.y @@ -143,6 +143,8 @@ %type <assignable> simple_assignable %type <assignable> simple_assignable_no_list %type <constant> constant +%type <ival> integer_constant +%type <fval> fp_constant %type <assignable> special_constant %type <assignable> vector_constant %type <assignable> quaternion_constant @@ -352,30 +354,50 @@ simple_assignable_no_list ; constant - : INTEGER_CONSTANT + : integer_constant { $$ = new LLScriptConstantInteger(gLine, gColumn, $1); gAllocationManager->addAllocation($$); } - | INTEGER_TRUE + | fp_constant { - $$ = new LLScriptConstantInteger(gLine, gColumn, $1); + $$ = new LLScriptConstantFloat(gLine, gColumn, $1); gAllocationManager->addAllocation($$); } - | INTEGER_FALSE + | STRING_CONSTANT { - $$ = new LLScriptConstantInteger(gLine, gColumn, $1); + $$ = new LLScriptConstantString(gLine, gColumn, $1); gAllocationManager->addAllocation($$); } - | FP_CONSTANT + ; + +fp_constant + : FP_CONSTANT { - $$ = new LLScriptConstantFloat(gLine, gColumn, $1); - gAllocationManager->addAllocation($$); + $$ = $1; } - | STRING_CONSTANT + | '-' FP_CONSTANT { - $$ = new LLScriptConstantString(gLine, gColumn, $1); - gAllocationManager->addAllocation($$); + $$ = -$2; + } + ; + +integer_constant + : INTEGER_CONSTANT + { + $$ = $1; + } + | INTEGER_TRUE + { + $$ = $1; + } + | INTEGER_FALSE + { + $$ = $1; + } + | '-' INTEGER_CONSTANT + { + $$ = -$2; } ; |