aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/build.l50
1 files changed, 41 insertions, 9 deletions
diff --git a/src/build.l b/src/build.l
index 49275c8..15c4003 100644
--- a/src/build.l
+++ b/src/build.l
@@ -9,6 +9,7 @@ std::string strbuf;
9 9
10%x strsq 10%x strsq
11%x strdq 11%x strdq
12%x cmdstr
12%x comment 13%x comment
13%option noyywrap nounput batch debug 14%option noyywrap nounput batch debug
14 15
@@ -78,6 +79,10 @@ std::string strbuf;
78 BEGIN( strsq ); 79 BEGIN( strsq );
79 strbuf = ""; 80 strbuf = "";
80} 81}
82\` {
83 BEGIN( cmdstr );
84 strbuf = "";
85}
81 86
82<strdq>[^\\\n\"]+ { 87<strdq>[^\\\n\"]+ {
83 strbuf += yytext; 88 strbuf += yytext;
@@ -87,15 +92,20 @@ std::string strbuf;
87 strbuf += yytext; 92 strbuf += yytext;
88} 93}
89 94
90<strdq,strsq>\\n strbuf += "\n"; 95<cmdstr>[^\\\n\`]+ {
91<strdq,strsq>\\t strbuf += "\t"; 96 strbuf += yytext;
92<strdq,strsq>\\r strbuf += "\r"; 97}
93<strdq,strsq>\\b strbuf += "\b"; 98
94<strdq,strsq>\\f strbuf += "\f"; 99<strdq,strsq,cmdstr>\\n strbuf += "\n";
95<strdq,strsq>\\\\ strbuf += "\\"; 100<strdq,strsq,cmdstr>\\t strbuf += "\t";
96<strdq,strsq>\\\" strbuf += "\""; 101<strdq,strsq,cmdstr>\\r strbuf += "\r";
97<strdq,strsq>\\\' strbuf += "\'"; 102<strdq,strsq,cmdstr>\\b strbuf += "\b";
98<strdq,strsq>\\. bld.error( yylloc, "Invalid escape sequence."); 103<strdq,strsq,cmdstr>\\f strbuf += "\f";
104<strdq,strsq,cmdstr>\\\\ strbuf += "\\";
105<strdq,strsq,cmdstr>\\\" strbuf += "\"";
106<strdq,strsq,cmdstr>\\\' strbuf += "\'";
107<strdq,strsq,cmdstr>\\\` strbuf += "`";
108<strdq,strsq,cmdstr>\\. bld.error( yylloc, "Invalid escape sequence.");
99 109
100<strdq>\" { 110<strdq>\" {
101 BEGIN( INITIAL ); 111 BEGIN( INITIAL );
@@ -109,6 +119,28 @@ std::string strbuf;
109 return STRING; 119 return STRING;
110} 120}
111 121
122<cmdstr>\` {
123 BEGIN( INITIAL );
124 FILE *fpg = popen( strbuf.c_str(), "r" );
125 strbuf = "";
126 for(;;)
127 {
128 char buf[1024];
129 int nRead = fread( buf, 1, 1024, fpg );
130 if( nRead == 0 ) break;
131 for( int j = 0; j < nRead; j++ )
132 {
133 if( buf[j] == '\n' || buf[j] == '\r' )
134 buf[j] = ' ';
135 }
136 strbuf.append( buf, nRead );
137 if( nRead < 1024 ) break;
138 }
139 yylval->strval = stringdup( strbuf.c_str() );
140 pclose( fpg );
141 return STRING;
142}
143
112. { 144. {
113 char buf[] = {"Character x is out of place"}; 145 char buf[] = {"Character x is out of place"};
114 buf[10] = yytext[0]; 146 buf[10] = yytext[0];