[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems with bison-flex

From: Laurence Finston
Subject: Re: problems with bison-flex
Date: Tue, 14 Oct 2008 08:46:12 +0200 (CEST)

On Mon, 13 Oct 2008, Jim Michaels wrote:

> "0" "END" 
> (ZERO T_END) happen to be in the lexer as part of a datum0 start sequence, of 
> which there are multiple items, because they all start with a 0.
> as it stands, there is no way to end with a 
> start : code0 code2 tagged_format ;
> tagged_format :
>     tagged_format codeminus5 |
>     tagged_format codeminus4 |
>     tagged_format codeminus3 |
>     ...    
>     tagged_format code0 |
>     ...
>     |
>     /* empty */
>     ;    
> tagged_format must by definition include code0.
> maybe I have dug myself into a hole.  

I have to start work soon.  I'll look at this again as soon as I have a 

> I found out how to use the <<EOF>> rule in flex.
> as I basically said before, My stack and dequeue template class is written in 
> C++.  I could possibly rewrite it in C (why?), but my compiler doesn't like 
> calling C++ code from within C files.  perhaps an extern "C++" {} is 
> necessary.  I don't know what will make it work.  even then it's extern.  I 
> am trying to include the header which has the class definition so I can use 
> it.
> If I make a tree that's going to be another matter entirely, but I think I've 
> already got a template class for that too.

It should be possible to generate a C parser and use C++ code in the 
actions.  What compiler are you using?  I definitely don't recommend 
trying to simulate classes from the STL using only C.

> >There should be a link to the main page for Bison attached to this
> message by Mailman.
> nope.

That's because it was just sent to me, not the help-bison list.  "Keeping 
it on the list" just means sending it to help-bison, either as the 
recipient or with "cc", it doesn't matter.  I'll get it anyway, if you 
send it to the list, but you can send anything directly to me, too, it 
doesn't matter.  I'll just get two copies.

> >I found one thing one does need to watch out for is if one is
> treating characters from the input as unsigned characters.  If 
> one is, they will never be `EOF' on a system where EOF is -1.
> I had a problem where a stream of characters read from a pipe never
> contained EOF, so I had to explicitly have the shell script that was
> generating the input write an EOF character (which looked like an
> a-umlaut in Emacs) to its standard output.  This problem has
> disappeared due to changes in my program.
> I am not sure what to do with this information.  in windows and DOS, a text 
> file may or may not contain an EOF character (^Z, on unix ^D).  either way, 
> when fgets is used to read a line, it interprets the EOF character as end of 
> file.  but not fread in binary mode.  I do not know what happens when fstream 
> is used, whether it is read as text or binary, and whether fstream's seek is 
> 64-bit or not.

I'll think about this when I've had a chance.  The easiest way to cope 
with this is by reading a character at a time.  I've written a couple of 
scanners by hand that do this.  If the problem lies with Flex, it's not 
hard to write a scanner by hand.

Laurence Finston

reply via email to

[Prev in Thread] Current Thread [Next in Thread]