[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Parsing multiple files with same parser
From: |
Tadej Borovšak |
Subject: |
Parsing multiple files with same parser |
Date: |
Sat, 17 Nov 2012 23:48:10 +0100 |
Hi all!
I'm trying to create a simple processor emulator that uses flex/bison
combo to create parser/compiler for custom assembly language.
I managed to create a parser that compiles assembly into "machine code"
and it works just great. But now I'm getting an error when trying to run
my parser for the second time using the same file as input [1].
Relevant piece of code that causes my parser to error-out looks like
this (this code is placed in the last section of my parser.y file,
inside main function):
/* Open input stream etc. */
yyparse ();
/* Close input stream and reopen it */
/* Flush flex buffer using YY_FLUSH_BUFFER */
yyparse ();
What I get is this error:
syntax error, unexpected $undefined, expecting TYPESI or TYPEMU or SPACE
I thought that scanner is feeding junk to the bison, but when I debugged
my application, I discovered that flex provided bison with exactly the
same tokens on both runs.
Any idea what could cause my parser to break second time but not the
first time?
Thanks in advance for any hints/help.
Cheers,
Tadej
[1] Why am I doing that? My goal is to create a GUI app that will make
it possible for user to edit program and recompile it on demand.
--
Tadej Borovšak
address@hidden
address@hidden
blog.borovsak.si