help-bison
[Top][All Lists]
Advanced

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

Re: Bison compatible with yacc/byacc/<whatever>yacc?


From: Hans Aberg
Subject: Re: Bison compatible with yacc/byacc/<whatever>yacc?
Date: Fri, 3 Aug 2001 11:54:08 +0200

At 05:23 +1000 2001/08/03, James Buchanan wrote:
>Thankyou for that Hans --- I actually wrote the grammar on Windows and put
>it on a floppy disk and moved it to my Linux box, because Microsoft's
>USELESS compiler Visual C++ 6 refused to compile the output from the flex
>and bison ports to Windows.
>
>It is probably the \r\n vs. \n problem? Yes, that must be it.

Here is an easy trick which I used to tweak my sources so that they can
read UNIX \n as line separators under MacOS, which uses \r:

My compiler works so that if a name is defined both in a library and in an
added source, the linker will choose the name defined by the added source.
This provides an easy way to tweak and debug libraries: Just add a new
definition in the project.

Then my compiler's IO library has a function providing the conversions:
  void __convert_to_newlines(unsigned char * buf, size_t * n);
The original version swapped the '\n' and '\r'. So I added a version that
converts both '\n' and '\r' to '\n'. Then it can read both MacOS and UNIX
files.

So you need to find the corresponding conversion function of your compiler,
and write a routine that converts both \r\n and \n to \n.

One can also do the opposite, to write UNIX files using \n, but I found
this perilous with console streams which would break. So I decided to not
alter the writes.

  Hans Aberg





reply via email to

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