diff options
Diffstat (limited to 'linden/indra/lscript/lscript_compile')
-rw-r--r-- | linden/indra/lscript/lscript_compile/indra.l | 17 | ||||
-rw-r--r-- | linden/indra/lscript/lscript_compile/indra.y | 44 |
2 files changed, 43 insertions, 18 deletions
diff --git a/linden/indra/lscript/lscript_compile/indra.l b/linden/indra/lscript/lscript_compile/indra.l index 6b4e67d..c219cec 100644 --- a/linden/indra/lscript/lscript_compile/indra.l +++ b/linden/indra/lscript/lscript_compile/indra.l | |||
@@ -1,8 +1,7 @@ | |||
1 | D [-]?[0-9] | ||
2 | N [0-9] | 1 | N [0-9] |
3 | L [a-zA-Z_] | 2 | L [a-zA-Z_] |
4 | H [a-fA-F0-9] | 3 | H [a-fA-F0-9] |
5 | E [Ee][+-]?{D}+ | 4 | E [Ee][+-]?{N}+ |
6 | FS (f|F) | 5 | FS (f|F) |
7 | %e 10000 | 6 | %e 10000 |
8 | %n 4000 | 7 | %n 4000 |
@@ -41,7 +40,7 @@ void parse_string(); | |||
41 | 40 | ||
42 | #define YYLMAX 16384 | 41 | #define YYLMAX 16384 |
43 | #define YY_NEVER_INTERACTIVE 1 /* stops flex from calling isatty() */ | 42 | #define YY_NEVER_INTERACTIVE 1 /* stops flex from calling isatty() */ |
44 | 43 | ||
45 | #if defined(__cplusplus) | 44 | #if defined(__cplusplus) |
46 | extern "C" { int yylex( void ); } | 45 | extern "C" { int yylex( void ); } |
47 | extern "C" { int yyparse( void ); } | 46 | extern "C" { int yyparse( void ); } |
@@ -111,7 +110,7 @@ extern "C" { int yyerror(const char *fmt, ...); } | |||
111 | 110 | ||
112 | 111 | ||
113 | 0[xX]{H}+ { count(); yylval.ival = strtoul(yytext, NULL, 0); return(INTEGER_CONSTANT); } | 112 | 0[xX]{H}+ { count(); yylval.ival = strtoul(yytext, NULL, 0); return(INTEGER_CONSTANT); } |
114 | {D}+ { count(); yylval.ival = strtoul(yytext, NULL, 10); return(INTEGER_CONSTANT); } | 113 | {N}+ { count(); yylval.ival = strtoul(yytext, NULL, 10); return(INTEGER_CONSTANT); } |
115 | "TRUE" { count(); yylval.ival = 1; return(INTEGER_TRUE); } | 114 | "TRUE" { count(); yylval.ival = 1; return(INTEGER_TRUE); } |
116 | "FALSE" { count(); yylval.ival = 0; return(INTEGER_FALSE); } | 115 | "FALSE" { count(); yylval.ival = 0; return(INTEGER_FALSE); } |
117 | "STATUS_PHYSICS" { count(); yylval.ival = 0x1; return(INTEGER_CONSTANT); } | 116 | "STATUS_PHYSICS" { count(); yylval.ival = 0x1; return(INTEGER_CONSTANT); } |
@@ -571,9 +570,9 @@ extern "C" { int yyerror(const char *fmt, ...); } | |||
571 | 570 | ||
572 | {L}({L}|{N})* { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(IDENTIFIER); } | 571 | {L}({L}|{N})* { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(IDENTIFIER); } |
573 | 572 | ||
574 | {D}+{E} { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } | 573 | {N}+{E} { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } |
575 | {D}*"."{D}+({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } | 574 | {N}*"."{N}+({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } |
576 | {D}+"."{D}*({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } | 575 | {N}+"."{N}*({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } |
577 | 576 | ||
578 | L?\"(\\.|[^\\"])*\" { parse_string(); count(); return(STRING_CONSTANT); } | 577 | L?\"(\\.|[^\\"])*\" { parse_string(); count(); return(STRING_CONSTANT); } |
579 | 578 | ||
@@ -751,6 +750,10 @@ BOOL lscript_compile(char *filename, BOOL is_god_like = FALSE) | |||
751 | 750 | ||
752 | S32 yywrap() | 751 | S32 yywrap() |
753 | { | 752 | { |
753 | #ifdef FLEX_SCANNER | ||
754 | // get gcc to stop complaining about lack of use of yyunput | ||
755 | (void) yyunput; | ||
756 | #endif | ||
754 | return(1); | 757 | return(1); |
755 | } | 758 | } |
756 | 759 | ||
diff --git a/linden/indra/lscript/lscript_compile/indra.y b/linden/indra/lscript/lscript_compile/indra.y index 7744649..c7a4fd6 100644 --- a/linden/indra/lscript/lscript_compile/indra.y +++ b/linden/indra/lscript/lscript_compile/indra.y | |||
@@ -143,6 +143,8 @@ | |||
143 | %type <assignable> simple_assignable | 143 | %type <assignable> simple_assignable |
144 | %type <assignable> simple_assignable_no_list | 144 | %type <assignable> simple_assignable_no_list |
145 | %type <constant> constant | 145 | %type <constant> constant |
146 | %type <ival> integer_constant | ||
147 | %type <fval> fp_constant | ||
146 | %type <assignable> special_constant | 148 | %type <assignable> special_constant |
147 | %type <assignable> vector_constant | 149 | %type <assignable> vector_constant |
148 | %type <assignable> quaternion_constant | 150 | %type <assignable> quaternion_constant |
@@ -352,30 +354,50 @@ simple_assignable_no_list | |||
352 | ; | 354 | ; |
353 | 355 | ||
354 | constant | 356 | constant |
355 | : INTEGER_CONSTANT | 357 | : integer_constant |
356 | { | 358 | { |
357 | $$ = new LLScriptConstantInteger(gLine, gColumn, $1); | 359 | $$ = new LLScriptConstantInteger(gLine, gColumn, $1); |
358 | gAllocationManager->addAllocation($$); | 360 | gAllocationManager->addAllocation($$); |
359 | } | 361 | } |
360 | | INTEGER_TRUE | 362 | | fp_constant |
361 | { | 363 | { |
362 | $$ = new LLScriptConstantInteger(gLine, gColumn, $1); | 364 | $$ = new LLScriptConstantFloat(gLine, gColumn, $1); |
363 | gAllocationManager->addAllocation($$); | 365 | gAllocationManager->addAllocation($$); |
364 | } | 366 | } |
365 | | INTEGER_FALSE | 367 | | STRING_CONSTANT |
366 | { | 368 | { |
367 | $$ = new LLScriptConstantInteger(gLine, gColumn, $1); | 369 | $$ = new LLScriptConstantString(gLine, gColumn, $1); |
368 | gAllocationManager->addAllocation($$); | 370 | gAllocationManager->addAllocation($$); |
369 | } | 371 | } |
370 | | FP_CONSTANT | 372 | ; |
373 | |||
374 | fp_constant | ||
375 | : FP_CONSTANT | ||
371 | { | 376 | { |
372 | $$ = new LLScriptConstantFloat(gLine, gColumn, $1); | 377 | $$ = $1; |
373 | gAllocationManager->addAllocation($$); | ||
374 | } | 378 | } |
375 | | STRING_CONSTANT | 379 | | '-' FP_CONSTANT |
376 | { | 380 | { |
377 | $$ = new LLScriptConstantString(gLine, gColumn, $1); | 381 | $$ = -$2; |
378 | gAllocationManager->addAllocation($$); | 382 | } |
383 | ; | ||
384 | |||
385 | integer_constant | ||
386 | : INTEGER_CONSTANT | ||
387 | { | ||
388 | $$ = $1; | ||
389 | } | ||
390 | | INTEGER_TRUE | ||
391 | { | ||
392 | $$ = $1; | ||
393 | } | ||
394 | | INTEGER_FALSE | ||
395 | { | ||
396 | $$ = $1; | ||
397 | } | ||
398 | | '-' INTEGER_CONSTANT | ||
399 | { | ||
400 | $$ = -$2; | ||
379 | } | 401 | } |
380 | ; | 402 | ; |
381 | 403 | ||