Make the lexer work with Solaris' (10) default lex(1).

While Solaris' lex understands start conditions, they cannot be grouped,
so unfold the <strng> group.

All actions need braces, even if they only consist of a comment.

As the classic lex uses semi-static resource allocation, we need to bump
the resource limits quite a bit.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@541 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2005-11-02 21:49:52 +00:00
parent af52c74def
commit 811dd7d614
2 changed files with 21 additions and 16 deletions

View File

@ -2,6 +2,8 @@
* config.h: change YYSTYPE to be a single word, to work around * config.h: change YYSTYPE to be a single word, to work around
a bug in Solaris' yacc. a bug in Solaris' yacc.
* lexer.l: remove incompatibilities with Solaris' default lex,
bump resource limits for lex.
2005-11-01 Joerg Wunsch <j@uriah.heep.sax.de> 2005-11-01 Joerg Wunsch <j@uriah.heep.sax.de>

35
lexer.l
View File

@ -50,6 +50,11 @@ SIGN [+-]
%x incl %x incl
%x comment %x comment
/* Bump resources for classic lex. */
%e2000
%p5000
%n1000
%% %%
{SIGN}*{DIGIT}+ { yylval = number(yytext); return TKN_NUMBER; } {SIGN}*{DIGIT}+ { yylval = number(yytext); return TKN_NUMBER; }
@ -64,7 +69,7 @@ SIGN [+-]
# { /* The following eats '#' style comments to end of line */ # { /* The following eats '#' style comments to end of line */
BEGIN(comment); } BEGIN(comment); }
<comment>[^\n] /* eat comments */ <comment>[^\n] { /* eat comments */ }
<comment>\n { lineno++; BEGIN(INITIAL); } <comment>\n { lineno++; BEGIN(INITIAL); }
@ -99,21 +104,19 @@ SIGN [+-]
} }
<strng>{ <strng>\" { *string_buf_ptr = 0; string_buf_ptr = string_buf;
\" { *string_buf_ptr = 0; string_buf_ptr = string_buf; yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; }
yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; } <strng>\\n *string_buf_ptr++ = '\n';
\\n *string_buf_ptr++ = '\n'; <strng>\\t *string_buf_ptr++ = '\t';
\\t *string_buf_ptr++ = '\t'; <strng>\\r *string_buf_ptr++ = '\r';
\\r *string_buf_ptr++ = '\r'; <strng>\\b *string_buf_ptr++ = '\b';
\\b *string_buf_ptr++ = '\b'; <strng>\\f *string_buf_ptr++ = '\f';
\\f *string_buf_ptr++ = '\f'; <strng>\\(.|\n) *(string_buf_ptr++) = yytext[1];
\\(.|\n) *(string_buf_ptr++) = yytext[1]; <strng>[^\\\n\"]+ { char *yptr = yytext; while (*yptr)
[^\\\n\"]+ { char *yptr = yytext; while (*yptr)
*(string_buf_ptr++) = *(yptr++); } *(string_buf_ptr++) = *(yptr++); }
\n { fprintf(stderr, "error at line %d: unterminated character constant\n", <strng>\n { fprintf(stderr, "error at line %d: unterminated character constant\n",
lineno); lineno);
exit(1); } exit(1); }
}
allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; } allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; }
avr910 { yylval=NULL; return K_AVR910; } avr910 { yylval=NULL; return K_AVR910; }
@ -216,7 +219,7 @@ yes { yylval=new_token(K_YES); return K_YES; }
"~" { yylval = NULL; pyytext(); return TKN_TILDE; } "~" { yylval = NULL; pyytext(); return TKN_TILDE; }
"\n" { lineno++; } "\n" { lineno++; }
[ \r\t]+ /* ignore whitespace */ [ \r\t]+ { /* ignore whitespace */ }
c: { fprintf(stderr, "error at %s:%d: possible old-style config file entry\n", c: { fprintf(stderr, "error at %s:%d: possible old-style config file entry\n",
infile, lineno); infile, lineno);