diff options
author | David Walter Seikel | 2012-01-06 22:49:04 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-06 22:49:04 +1000 |
commit | 3c15f48358ffd67aa53d02489594c949964f24f5 (patch) | |
tree | a5d0ecbe2bb91774f28d78a8fc9054df868b2db1 | |
parent | Added most of the expression parser. (diff) | |
download | SledjHamr-3c15f48358ffd67aa53d02489594c949964f24f5.zip SledjHamr-3c15f48358ffd67aa53d02489594c949964f24f5.tar.gz SledjHamr-3c15f48358ffd67aa53d02489594c949964f24f5.tar.bz2 SledjHamr-3c15f48358ffd67aa53d02489594c949964f24f5.tar.xz |
Flex performance tweaks, and other options.
-rwxr-xr-x | LuaSL/build.sh | 2 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 4 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lexer.l | 23 |
3 files changed, 17 insertions, 12 deletions
diff --git a/LuaSL/build.sh b/LuaSL/build.sh index 2573073..b118f5a 100755 --- a/LuaSL/build.sh +++ b/LuaSL/build.sh | |||
@@ -74,7 +74,7 @@ $command | |||
74 | names="LuaSL_LSL_tree LuaSL_lexer LuaSL_yaccer.tab" | 74 | names="LuaSL_LSL_tree LuaSL_lexer LuaSL_yaccer.tab" |
75 | 75 | ||
76 | LFLAGS="-d" | 76 | LFLAGS="-d" |
77 | command="flex -dbpv --outfile=LuaSL_lexer.c --header-file=LuaSL_lexer.h LuaSL_lexer.l" | 77 | command="flex -C --outfile=LuaSL_lexer.c --header-file=LuaSL_lexer.h LuaSL_lexer.l" |
78 | echo $command | 78 | echo $command |
79 | $command | 79 | $command |
80 | 80 | ||
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 42cf0ac..271f4a8 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -4,10 +4,6 @@ | |||
4 | #ifndef __EXPRESSION_H__ | 4 | #ifndef __EXPRESSION_H__ |
5 | #define __EXPRESSION_H__ | 5 | #define __EXPRESSION_H__ |
6 | 6 | ||
7 | #ifndef YY_NO_UNISTD_H | ||
8 | #define YY_NO_UNISTD_H 1 | ||
9 | #endif // YY_NO_UNISTD_H | ||
10 | |||
11 | //#define LUASL_USE_ENUM | 7 | //#define LUASL_USE_ENUM |
12 | #define LUASL_DEBUG | 8 | #define LUASL_DEBUG |
13 | 9 | ||
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index 11c20a0..3eb59fb 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l | |||
@@ -13,10 +13,15 @@ | |||
13 | 13 | ||
14 | %} | 14 | %} |
15 | 15 | ||
16 | %option reentrant noyywrap never-interactive nounistd | 16 | %option reentrant never-interactive batch |
17 | %option bison-bridge | 17 | %option bison-bridge yylineno 8bit |
18 | %option noreject noyymore noyywrap | ||
19 | %option backup debug perf-report perf-report verbose warn | ||
20 | %option align full | ||
18 | 21 | ||
19 | SPACE [ \r\n\t]* | 22 | SPACE [ \r\n\t]* |
23 | ENDSPACE {SPACE}$ | ||
24 | |||
20 | LETTER [A-Za-z] | 25 | LETTER [A-Za-z] |
21 | DECIMAL [0-9] | 26 | DECIMAL [0-9] |
22 | HEX [0-9A-Fa-f] | 27 | HEX [0-9A-Fa-f] |
@@ -28,11 +33,14 @@ FLOAT {INTEGER}("."{INTEGER})?{EXPONANT}? | |||
28 | 33 | ||
29 | %% | 34 | %% |
30 | 35 | ||
31 | {SPACE} { ECHO; /* Skip blanks. */ } | 36 | /* Basic tokens */ |
32 | {NAME} { ECHO; /* yylval->nameValue=strdup(yytext); return LSL_NAME; */ } | 37 | {ENDSPACE} %{ /* Skip blanks at end of lines. */ %} |
33 | {INTEGER} { ECHO; yylval->integerValue = atoi(yytext); return LSL_INTEGER; } | 38 | {SPACE} %{ ECHO; /* Skip blanks. */ %} |
34 | {FLOAT} { ECHO; /* yylval->floatValue = atof(yytext); return LSL_FLOAT; */ } | 39 | {NAME} %{ ECHO; /* yylval->nameValue=strdup(yytext); return LSL_NAME; */ %} |
40 | {INTEGER} %{ ECHO; yylval->integerValue = atoi(yytext); return LSL_INTEGER; %} | ||
41 | {FLOAT} %{ ECHO; /* yylval->floatValue = atof(yytext); return LSL_FLOAT; */ %} | ||
35 | 42 | ||
43 | /* Expression tokens */ | ||
36 | "&&" { ECHO; return LSL_BOOL_AND; } | 44 | "&&" { ECHO; return LSL_BOOL_AND; } |
37 | "||" { ECHO; return LSL_BOOL_OR; } | 45 | "||" { ECHO; return LSL_BOOL_OR; } |
38 | "|" { ECHO; return LSL_BIT_OR; } | 46 | "|" { ECHO; return LSL_BIT_OR; } |
@@ -56,7 +64,8 @@ FLOAT {INTEGER}("."{INTEGER})?{EXPONANT}? | |||
56 | "(" { ECHO; return LSL_PARENTHESIS_OPEN; } | 64 | "(" { ECHO; return LSL_PARENTHESIS_OPEN; } |
57 | ")" { ECHO; return LSL_PARENTHESIS_CLOSE; } | 65 | ")" { ECHO; return LSL_PARENTHESIS_CLOSE; } |
58 | 66 | ||
59 | . { ECHO; printf(" unexpected character.\n"); } | 67 | /* Everything else */ |
68 | . %{ ECHO; printf(" unexpected character.\n"); %} | ||
60 | 69 | ||
61 | %% | 70 | %% |
62 | 71 | ||