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


From: K Stol
Subject: Re: Bison invalid input '\r' question and C++ in YACC/BISON
Date: Fri, 14 Feb 2003 09:04:33 +0100

----- Original Message -----
From: "Hiren" <address@hidden>
To: <address@hidden>
Sent: Thursday, February 13, 2003 8:31 PM
Subject: Bison invalid input '\r' question and C++ in YACC/BISON


> Hello,
>
> 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.

Don't know about that. I don't use c++.
>
> 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.

Do you perhaps use windows or cygwin? I got the same problem, but I added
'\r' to the lexer
to recognize. It has to do with windows-linux difference in line breaking.
Unix/Linux uses \n to goto a new
line, (Dos and) windows use \n\r to go to a new line (the '\r' is for return
carriage). I don't think it 'll do
much harm in adding '\r' to the lexer (maybe someone else does....)
>
> I have three files.
>
> ts.y - yacc grammer file
> ts.l - lexer file
> mymap.h - file that has includes of map, multimap and other structures.
>
> I need to know how to compile them together as well using which
> options.  Please direct me.

I did the following:
first compile your grammar like this:
bison -d <grammar file>
the -d option is to create a header file with all tokens you declared in the
grammar file.
Then, include this file using "#include "ts.tab.h" (don't know if name is
all right) in the ts.l, the lex file
Then you can compile with the "-c" option, which says to compile only, not
link.
I don't know if you have some kind of main file for your main(), then you
could compile that, and link the parser and lexer object files together.
Also when you're linking the lexer, you 'll also want to use a "-lfl" option
to use some kind of library, for declarations of some vars and procs.

good luck

KJ
>
> Thanks.
>
> Hiren
>
>
>
>
>
> _______________________________________________
> address@hidden http://mail.gnu.org/mailman/listinfo/help-bison
>




reply via email to

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