| 188 | #define yyprev() ( incp->string-- ) |
| 189 | |
| 190 | int yylex() |
| 191 | { |
| 192 | int c; |
| 193 | char buf[ BIGGEST_TOKEN ]; |
| 194 | char * b = buf; |
| 195 | |
| 196 | if ( !incp ) |
| 197 | goto eof; |
| 198 | |
| 199 | /* Get first character (whitespace or of token). */ |
| 200 | c = yychar(); |
| 201 | |
| 202 | if ( scanmode == SCAN_STRING ) |
| 203 | { |
| 204 | /* If scanning for a string (action's {}'s), look for the closing brace. |
| 205 | * We handle matching braces, if they match. |
| 206 | */ |
| 207 | |
| 208 | int nest = 1; |
| 209 | |
| 210 | while ( ( c != EOF ) && ( b < buf + sizeof( buf ) ) ) |
| 211 | { |
| 212 | if ( c == '{' ) |
| 213 | ++nest; |
| 214 | |
| 215 | if ( ( c == '}' ) && !--nest ) |
| 216 | break; |
| 217 | |
| 218 | *b++ = c; |
| 219 | |
| 220 | c = yychar(); |
| 221 | |
| 222 | /* Turn trailing "\r\n" sequences into plain "\n" for Cygwin. */ |
| 223 | if ( ( c == '\n' ) && ( b[ -1 ] == '\r' ) ) |
| 224 | --b; |
| 225 | } |
| 226 | |
| 227 | /* We ate the ending brace -- regurgitate it. */ |
| 228 | if ( c != EOF ) |
| 229 | yyprev(); |
| 230 | |
| 231 | /* Check for obvious errors. */ |
| 232 | if ( b == buf + sizeof( buf ) ) |
| 233 | { |
| 234 | yyerror( "action block too big" ); |
| 235 | goto eof; |
| 236 | } |
| 237 | |
| 238 | if ( nest ) |
| 239 | { |
| 240 | yyerror( "unmatched {} in action block" ); |
| 241 | goto eof; |
| 242 | } |
| 243 | |
| 244 | *b = 0; |
| 245 | yylval.type = STRING; |
| 246 | yylval.string = object_new( buf ); |
| 247 | yylval.file = incp->fname; |
nothing calls this directly
no test coverage detected