aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/lscript/lscript_compile
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:59 -0500
committerJacek Antonelli2008-08-15 23:44:59 -0500
commita408bac29378072fbf36864164149458c978cfcc (patch)
tree67feccf1a5d3816611ba48d6762f86f0f7f4b1f6 /linden/indra/lscript/lscript_compile
parentSecond Life viewer sources 1.17.0.12 (diff)
downloadmeta-impy-a408bac29378072fbf36864164149458c978cfcc.zip
meta-impy-a408bac29378072fbf36864164149458c978cfcc.tar.gz
meta-impy-a408bac29378072fbf36864164149458c978cfcc.tar.bz2
meta-impy-a408bac29378072fbf36864164149458c978cfcc.tar.xz
Second Life viewer sources 1.17.1.0
Diffstat (limited to 'linden/indra/lscript/lscript_compile')
-rw-r--r--linden/indra/lscript/lscript_compile/indra.l17
-rw-r--r--linden/indra/lscript/lscript_compile/indra.y44
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 @@
1D [-]?[0-9]
2N [0-9] 1N [0-9]
3L [a-zA-Z_] 2L [a-zA-Z_]
4H [a-fA-F0-9] 3H [a-fA-F0-9]
5E [Ee][+-]?{D}+ 4E [Ee][+-]?{N}+
6FS (f|F) 5FS (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)
46extern "C" { int yylex( void ); } 45extern "C" { int yylex( void ); }
47extern "C" { int yyparse( void ); } 46extern "C" { int yyparse( void ); }
@@ -111,7 +110,7 @@ extern "C" { int yyerror(const char *fmt, ...); }
111 110
112 111
1130[xX]{H}+ { count(); yylval.ival = strtoul(yytext, NULL, 0); return(INTEGER_CONSTANT); } 1120[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
578L?\"(\\.|[^\\"])*\" { parse_string(); count(); return(STRING_CONSTANT); } 577L?\"(\\.|[^\\"])*\" { parse_string(); count(); return(STRING_CONSTANT); }
579 578
@@ -751,6 +750,10 @@ BOOL lscript_compile(char *filename, BOOL is_god_like = FALSE)
751 750
752S32 yywrap() 751S32 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
354constant 356constant
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
374fp_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
385integer_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