diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-07-30 06:39:27 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-07-30 06:39:27 +0000 |
commit | 900976d2d74e0de57858b265c2ef0d17a29e921a (patch) | |
tree | 3d7e0c804b2bb5163d2998158b7c1f6e1891240c /src/build.l | |
parent | 28e92029752693ffe33de12c10de3e7bd39a3c94 (diff) | |
download | build-900976d2d74e0de57858b265c2ef0d17a29e921a.tar.gz build-900976d2d74e0de57858b265c2ef0d17a29e921a.tar.bz2 build-900976d2d74e0de57858b265c2ef0d17a29e921a.tar.xz build-900976d2d74e0de57858b265c2ef0d17a29e921a.zip |
Found out all of the c++ stuff in bison broke in 2.2, now we have to pick a
version, there is no way around it nicely.
Diffstat (limited to '')
-rw-r--r-- | src/build.l | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/src/build.l b/src/build.l index 6daaa94..6a80f45 100644 --- a/src/build.l +++ b/src/build.l | |||
@@ -1,4 +1,20 @@ | |||
1 | int lineNum = 1; | 1 | %{ |
2 | # include <string> | ||
3 | # include "builder.h" | ||
4 | # include "build.tab.h" | ||
5 | # include "stringrep.h" | ||
6 | |||
7 | std::string strbuf; | ||
8 | %} | ||
9 | |||
10 | %x strsq | ||
11 | %x strdq | ||
12 | %x comment | ||
13 | %option noyywrap nounput batch debug | ||
14 | |||
15 | %{ | ||
16 | # define YY_USER_ACTION yylloc->columns (yyleng); | ||
17 | %} | ||
2 | %% | 18 | %% |
3 | 19 | ||
4 | [,:=] return yytext[0]; | 20 | [,:=] return yytext[0]; |
@@ -23,9 +39,62 @@ | |||
23 | "produces" return TOK_PRODUCES; | 39 | "produces" return TOK_PRODUCES; |
24 | "command" return TOK_COMMAND; | 40 | "command" return TOK_COMMAND; |
25 | 41 | ||
42 | "..."\n /* elipsis line continuation */ | ||
26 | \n+ return TOX_EOL; | 43 | \n+ return TOX_EOL; |
27 | [ \t\r]* | 44 | [ \t\r]* /* whitespace */ |
45 | |||
46 | \/\/.* /* single line comment */ | ||
47 | "#".* /* single line comment */ | ||
48 | |||
49 | [^ \t\r\n\'\"]+ { | ||
50 | yylval.strval = stringdup( yytext ); | ||
51 | return STRING; | ||
52 | } | ||
53 | |||
54 | \" { | ||
55 | BEGIN( strdq ); | ||
56 | strbuf = ""; | ||
57 | } | ||
58 | \' { | ||
59 | BEGIN( strsq ); | ||
60 | strbuf = ""; | ||
61 | } | ||
62 | |||
63 | <strdq>[^\\\n\"]+ { | ||
64 | strbuf += yytext; | ||
65 | } | ||
66 | |||
67 | <strsq>[^\\\n\']+ { | ||
68 | strbuf += yytext; | ||
69 | } | ||
70 | |||
71 | <strdq,strsq>\\n strbuf += "\n"; | ||
72 | <strdq,strsq>\\t strbuf += "\t"; | ||
73 | <strdq,strsq>\\r strbuf += "\r"; | ||
74 | <strdq,strsq>\\b strbuf += "\b"; | ||
75 | <strdq,strsq>\\f strbuf += "\f"; | ||
76 | |||
77 | <strdq>\" { | ||
78 | BEGIN( INITIAL ); | ||
79 | yylval->strval = stringdup( strbuf.c_str() ); | ||
80 | return STRING; | ||
81 | } | ||
82 | |||
83 | <strsq>\' { | ||
84 | BEGIN( INITIAL ); | ||
85 | yylval->strval = stringdup( strbuf.c_str() ); | ||
86 | return STRING; | ||
87 | } | ||
88 | |||
89 | |||
90 | void Builder::scanBegin() | ||
91 | { | ||
92 | if( !(yyin = fopen( file.c_str(), "r" )) ) | ||
93 | error( std::string("cannot open ") + file ); | ||
94 | } | ||
28 | 95 | ||
29 | \/\/.* | 96 | void Builder::scanEnd() |
30 | "#".* | 97 | { |
98 | fclose( yyin ); | ||
99 | } | ||
31 | 100 | ||