From 811dd7d614c0af429e59600f818d23e7989f05f9 Mon Sep 17 00:00:00 2001 From: joerg_wunsch Date: Wed, 2 Nov 2005 21:49:52 +0000 Subject: [PATCH] Make the lexer work with Solaris' (10) default lex(1). While Solaris' lex understands start conditions, they cannot be grouped, so unfold the 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 --- ChangeLog | 2 ++ lexer.l | 35 +++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97ce4706..254c3592 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * config.h: change YYSTYPE to be a single word, to work around a bug in Solaris' yacc. + * lexer.l: remove incompatibilities with Solaris' default lex, + bump resource limits for lex. 2005-11-01 Joerg Wunsch diff --git a/lexer.l b/lexer.l index 5afa6154..b99ad3a4 100644 --- a/lexer.l +++ b/lexer.l @@ -50,6 +50,11 @@ SIGN [+-] %x incl %x comment +/* Bump resources for classic lex. */ +%e2000 +%p5000 +%n1000 + %% {SIGN}*{DIGIT}+ { yylval = number(yytext); return TKN_NUMBER; } @@ -64,7 +69,7 @@ SIGN [+-] # { /* The following eats '#' style comments to end of line */ BEGIN(comment); } -[^\n] /* eat comments */ +[^\n] { /* eat comments */ } \n { lineno++; BEGIN(INITIAL); } @@ -99,21 +104,19 @@ SIGN [+-] } -{ - \" { *string_buf_ptr = 0; string_buf_ptr = string_buf; - yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; } - \\n *string_buf_ptr++ = '\n'; - \\t *string_buf_ptr++ = '\t'; - \\r *string_buf_ptr++ = '\r'; - \\b *string_buf_ptr++ = '\b'; - \\f *string_buf_ptr++ = '\f'; - \\(.|\n) *(string_buf_ptr++) = yytext[1]; - [^\\\n\"]+ { char *yptr = yytext; while (*yptr) +\" { *string_buf_ptr = 0; string_buf_ptr = string_buf; + yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; } +\\n *string_buf_ptr++ = '\n'; +\\t *string_buf_ptr++ = '\t'; +\\r *string_buf_ptr++ = '\r'; +\\b *string_buf_ptr++ = '\b'; +\\f *string_buf_ptr++ = '\f'; +\\(.|\n) *(string_buf_ptr++) = yytext[1]; +[^\\\n\"]+ { char *yptr = yytext; while (*yptr) *(string_buf_ptr++) = *(yptr++); } - \n { fprintf(stderr, "error at line %d: unterminated character constant\n", - lineno); - exit(1); } -} +\n { fprintf(stderr, "error at line %d: unterminated character constant\n", + lineno); + exit(1); } allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; } 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; } "\n" { lineno++; } -[ \r\t]+ /* ignore whitespace */ +[ \r\t]+ { /* ignore whitespace */ } c: { fprintf(stderr, "error at %s:%d: possible old-style config file entry\n", infile, lineno);