From 2bce339a72a7de287040f485e4fdbbbae5c48035 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Sat, 10 May 2008 00:49:29 +0000 Subject: [PATCH] Make the scriptvals_parser reentrant as well (the lexer was made reentrant already in r5009) git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5011 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/scriptvals_lexer.l | 30 +++++++++++++++--------------- src/scriptvals_parser.y | 1 + 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/scriptvals_lexer.l b/src/scriptvals_lexer.l index 1b989b329..bdcfc3cba 100644 --- a/src/scriptvals_lexer.l +++ b/src/scriptvals_lexer.l @@ -55,7 +55,7 @@ extern void scrv_set_column(int column_no, yyscan_t yyscanner); %} -%option reentrant +%option reentrant bison-bridge %option yylineno nounput %option warn nodefault %option prefix="scrv_" @@ -68,18 +68,18 @@ extern void scrv_set_column(int column_no, yyscan_t yyscanner); %% /* Keywords */ -int { scrv_lval.tval = VAL_INT; return TYPE; } -INT { scrv_lval.tval = VAL_INT; return TYPE; } -bool { scrv_lval.tval = VAL_BOOL; return TYPE; } -BOOL { scrv_lval.tval = VAL_BOOL; return TYPE; } +int { yylval->tval = VAL_INT; return TYPE; } +INT { yylval->tval = VAL_INT; return TYPE; } +bool { yylval->tval = VAL_BOOL; return TYPE; } +BOOL { yylval->tval = VAL_BOOL; return TYPE; } script return SCRIPT; store return STORE; run return RUN; -true { scrv_lval.bval = true; return BOOLEAN_T; } -TRUE { scrv_lval.bval = true; return BOOLEAN_T; } -false { scrv_lval.bval = false; return BOOLEAN_T; } -FALSE { scrv_lval.bval = false; return BOOLEAN_T; } +true { yylval->bval = true; return BOOLEAN_T; } +TRUE { yylval->bval = true; return BOOLEAN_T; } +false { yylval->bval = false; return BOOLEAN_T; } +FALSE { yylval->bval = false; return BOOLEAN_T; } /* Match text values */ [a-zA-Z][-0-9_a-zA-Z]* { @@ -89,30 +89,30 @@ FALSE { scrv_lval.bval = false; return BOOLEAN_T; } /* See if this is a variable id or a type */ if (scrvLookUpType(yytext, &type)) { - scrv_lval.tval = type; + yylval->tval = type; return TYPE; } else if (scrvLookUpVar(yytext, &index)) { - scrv_lval.vindex = index; + yylval->vindex = index; return VAR; } else if (scrvLookUpArray(yytext, &index)) { - scrv_lval.vindex = index; + yylval->vindex = index; return ARRAY; } else { strcpy(aText[currText], yytext); - scrv_lval.sval = aText[currText]; + yylval->sval = aText[currText]; currText = (currText + 1) % TEXT_BUFFERS; return IDENT; } } /* Match integer numbers */ --?[0-9]+ { scrv_lval.ival = atol(yytext); return INTEGER; } +-?[0-9]+ { yylval->ival = atol(yytext); return INTEGER; } /* Match quoted text */ \" { BEGIN QUOTE; } @@ -120,7 +120,7 @@ FALSE { scrv_lval.bval = false; return BOOLEAN_T; } \n { scrv_error(yyscanner, "Unexpected end of line in string"); } [^\"\n]* { strcpy(aText[currText], yytext); - scrv_lval.sval = aText[currText]; + yylval->sval = aText[currText]; currText = (currText + 1) % TEXT_BUFFERS; return QTEXT; } diff --git a/src/scriptvals_parser.y b/src/scriptvals_parser.y index f8e797b6f..c76a51772 100644 --- a/src/scriptvals_parser.y +++ b/src/scriptvals_parser.y @@ -102,6 +102,7 @@ static BOOL scrvCheckArrayIndex(yyscan_t yyscanner, SDWORD base, ARRAY_INDEXES * %name-prefix="scrv_" %defines %error-verbose +%pure-parser %parse-param {yyscan_t yyscanner} %lex-param {yyscan_t yyscanner}