Xref: utzoo comp.unix.questions:25449 gnu.utils.bug:1375 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!decwrl!ads.com!potomac!jtn From: jtn@potomac.ads.com (John T. Nelson) Newsgroups: comp.unix.questions,gnu.utils.bug Subject: More questions abou YACC and LEX (Bison/Flex) Message-ID: <9156@potomac.ads.com> Date: 13 Sep 90 14:32:51 GMT Organization: Advanced Decision Systems, Arlington VA Lines: 55 First I'd like to thank everyone for your comments concerning my problem with YACC grammars. It looks like there is an ambiguity in the grammar because YACC implements an LALR(1) parser. Only one character lookahead so I'll have to find another way to represent the grammar. I do have a question about running YACC/Bison in programs though. I have a program that looks sort of like the following: main() { openInputFile(); if ( yyparse() ) errorRoutine1(); closeInputFIle(); openInputFile(); if ( yyparse() ) errorRoutine2(); closeInputFile(); } The parser works fine on the first pass through yyparse() however upon entering the parser a second time, I get a YACC parser error. Apparently, the parser still thinks it's in one of the old states it was in back in the first call to yyparse and bombs because it has an inappropriate token. Indeed it almost looks like the first token it reads fromthe grammar file the second time around is the LAST token it read fromthe file the first time around. Now that's wierd. How can I reset the state of the parser? Shouldn't all the state variables be properly initialized upon entry to yyparse? Tracing through the code it looks like they ARE being set properly, yet for some reason the first token is wrong and the state is wrong too. Oh.... once again I'm actually using GNU Bison and Flex, YACC and LEX lookalikes. Pretty good packages. Thanks in advance! -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ORGANIZATION: Advanced Decision Systems GEOGRAPHIC: Arlington, VA UUCP: kzin!speaker@mimsy.umd.edu INTERNET: jtn@potomac.ads.com SPOKEN: Yo... John! PHONE: (703) 243-1611 PROJECT: The Conrail Locomotive/Harpsichord Fusion Program =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=