Re: levcomp kicking my butt



Chris Morales <chrismorale@xxxxxxxxx> writes:
On Apr 22, 11:45 pm, pa...@xxxxxxx (Pasi Kallinen) wrote:
[lev_comp.l changes]
Hm. Are you using Windows? I seem to recall that compiling on Windows,
the compile process automagically uses a pregenerated lex file, in
sys/share/lev_lex.c, iirc. I can't remember where or how it's determined
whether to generate a new one or use the pregenerated one, though...
It's probably in one of the Makefiles.

I'm compiling on Windows Vista; using Visual C++. Most of what Visual
C++ does between me hitting "Rebuild" and the build finishing could be
magic for all I know about it.

If you're building from the Visual Studio IDE, you're probably using the
MSVC project files under win/win32. When you run sys/winnt/nhsetup.bat,
the nethack.dsw (Visual Studio workspace file) goes to your top level NH
directory, and the .dsp (project) files go into $NH/build.

Your problem is that you haven't told the makefile that's responsible
for the level compiler to actually rebuild the level compiler from your
new *.l and *.y files using lex and yacc (flex and bison). The changes
to your .l files are being ignored, as Pasi notes.

Here's what you likely need to do (I'm not on Windows, these steps are
not tested):

- Install flex and bison. You need flex to process your changed *.l, and
bison for your modifications to *.y. You can get flex and bison for
Windows at:
http://gnuwin32.sourceforge.net/packages.html

You should be able to just drop the executables somewhere in your
PATH.

- Edit win/win32/levstuff.mak and edit the first two lines to point at
your flex and bison (make sure they're in your PATH, or that you refer
to them with absolute paths):

YACC = bison -y
LEX = flex

bison usually needs the -y to make it behave like a classic POSIX
yacc. You could also get byacc from gnuwin32 and use that instead of
bison, in which case you should leave off the -y (YACC = byacc).

- Run sys/winnt/nhsetup.bat again to push your changed .mak to the right
place. This is important. :-)

I do have a lev_lex.c file. Visual C++ seems to generate a new one as
part of the rebuild process, since any changes I make are deleted
during the build process.

There's a canned lev_lex.c and friends in sys/share. That's what is used
(copied into util) unless you tell levstuff.mak the paths to your lex
and yacc.

Visual C++ seems to use the lev_comp.l file to generate the lev_lex.c
file, since when I rename lev_comp.l, that part of the build fails

The makefile depends on lev_comp.l, but if you don't have lex, it
doesn't actually *use* your modified lev_comp.l. However, it should say
"Using pre-built lev_lex.c" somewhere in your build output if it's
ignoring your changed lev_comp.l file.

However, the "<MAPC>[-|}{+ABCISHKPLYWTF\\#. 0123456789]*\r?\n {" line
is not in lev_lex.c, and I don't see any similar lines.

You won't see a recognisable corresponding line, since the generated
lexer will contain only state tables that are not human-readable.

--
Darshan Shaligram <scintilla@xxxxxxxxx> Deus vult
.



Relevant Pages

  • Re: Csup cvsmode build discussion
    ... lex and yacc files that I would like to discuss. ... I implemented the RCS parser required to operate on RCS files ... I've been compiling the parser and tokenizer with the help of bison ... Now, the base system already have flex, but the flex version in base is heavily ...
    (freebsd-hackers)
  • Csup cvsmode build discussion
    ... lex and yacc files that I would like to discuss. ... I implemented the RCS parser required to operate on RCS files ... I've been compiling the parser and tokenizer with the help of bison ... Now, the base system already have flex, but the flex version in base is heavily ...
    (freebsd-hackers)
  • Re: Flex&Bison: how to write a parser for this grammar?
    ... bison? ... it's better to rely on a parser generator than on hand-written ... a yacc parser will be simpler if the grammar is suitable so ... need for flex start conditions there as I feared there might be. ...
    (comp.programming)
  • Re: Patching... Whats next?
    ... bison (or the original yacc) and flex (or ... # If you have yacc and lex programs (or work-alike such as bison ...
    (rec.games.roguelike.nethack)
  • Looking for a Lex/Yacc free ebook
    ... lex is dead and everyone uses flex. ... For yacc vs. bison, if you need ... otherwise Berkeley Yacc is a lot smaller and simpler. ...
    (comp.compilers)