stop yyparse() at <<EOF>>

Jens Kallup <jkallup@web.de>
Tue, 22 Dec 2015 16:29:35 +0100

          From comp.compilers

Related articles
stop yyparse() at <<EOF>> jkallup@web.de (Jens Kallup) (2015-12-22)
Re: stop yyparse() at <<EOF>> kaz@kylheku.com (Kaz Kylheku) (2015-12-27)
| List of all articles for this month |
From: Jens Kallup <jkallup@web.de>
Newsgroups: comp.compilers
Date: Tue, 22 Dec 2015 16:29:35 +0100
Organization: Aioe.org NNTP Server
Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="69261"; mail-complaints-to="abuse@iecc.com"
Keywords: yacc, lex, question
Posted-Date: 22 Dec 2015 11:22:09 EST

Hello,


I work on multiple parser's in a GUI. When I start 1st, the code
generation is fine. But, when I start 2nd start, the code generator
produce some junk. I have used "yyterminate();" but this seems to not
help.


The source:
? "Ploppers" + "ppp" + "huhu"


The pre-processed text file:
? "Ploppers" + "ppp" + "huhu"


The first pass (flex):
1: "Ploppers"
    plus
    2: "ppp"
    plus
    2: "huhu"


The second pass:
    plus
    2: "ppp"
    plus
    2: "huhu"
Segmentation fault




\#"output cpp" { outype = 0; return _CPP_PARSER_; }
\#"output asm" { outype = 1; return _ASM_PARSER_; }
\#"output asm, cli" { outype = 1; return _ASM_PARSER_; }


(\"([a-zA-Z0-9_])*\")* {
      printf("1: %s\n",yytext); strcpy(yytext,"");
      BEGIN(STRINGER);
      strcpy(yytext,"");
}
<STRINGER>{
(\"([a-zA-Z0-9_])*\")* { printf("2: %s\n",yytext);
      strcpy(yytext,""); BEGIN(STRINGER); strcpy(yytext,"");
}
\+ { printf("plus\n"); BEGIN(STRINGER); }
\n
}




I would like use it in gnu "bison" so:


string_expr
          : _STRING_ { printf("---> %s\n",yylval.text); }
          ;




Is that a Bug, or my mistakes?


TIA
Jens


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.