help-bison
[Top][All Lists]
Advanced

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

Re: Bison invalid input '\r' question and C++ in YACC/BISON (Hiren)


From: Jonathon Duerig
Subject: Re: Bison invalid input '\r' question and C++ in YACC/BISON (Hiren)
Date: Fri, 14 Feb 2003 11:22:13 -0700 (MST)

> From: Hiren <address@hidden>

> I'm trying to work on a parser using C++.  I've read some documentation
> that indicated that I need to use the extern "C" {...} command to allow
> C++ headers to function correctly.  I am not sure how that works exactly
> though.  If someone can kindly help.

I'm doing something similar. I am using a C++ compiler, and have had no
troubles including all of the proper header files. I don't recall exactly
where 'extern "C" {...}' is used, but I believe that it has to do with
seperate compilation. If you just compile everything with a C++ compiler,
it should be unnecessary.

There are still some annoying things that remain, though. For instance,
everything is in the global namespace and all the semantic values for
tokens and such are created using '#define' rather than 'enum' or 'const'.
For my own parser, I was able to set it up as a class and fix much of
this with a little help from a perl script.

> Furthermore, I wrote my initial parser in yacc and I believe using bison
> would have no problem except I get a invalid input '\r' on every line I
> have written.  I don't see any extra characters so I'm a little
> confused.  The Bison version I'm using is 1.35.

To get rid of the carriage returns, you could run this command from the
unix shell:

sed -i 's/\r//' myfile.c

'-i' says change this file in place
's/\r//' says substitute any instance of a carriage return with nothing
myfile.c is the filename of the program you wish to change.

This will change the file 'myfile.c' in place. If you have an older
version (< 4.0) of sed, you may have to transmogrify the command such that
there is a seperate output file because the ability to change a file in
place is new.

---
Most of what I read is fiction, but the authors don't admit it.
    -Jonathon Duerig




reply via email to

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