lex & yacc questions

R. Kym Horsell vu0310 at bingvaxu.cc.binghamton.edu
Tue Aug 21 03:56:24 AEST 1990


In article <266 at cti1.UUCP> mpledger at cti1.UUCP (Mark Pledger) writes:
\\\
>PROBLEM 1 ------------------------------------ :-(
>
>When I compile then link using the command line options below, I
>always get the "environ" referencing error.  The only way I've
\\\

Dont know -- what does your "main" look like? Does it really
have a main()? This looks like libc is trying to set up the
stuff to run your program but cant find it...

>PROBLEM 2 ------------------------------------ :-(
>
>When I run yylex() from the sample code below, if no matching integer
>is found it prints the yytext[] anyway.  Why?  I have it doing nothing
\\\

If something doesnt match any pattern it gets printed. Maybe
you should have a patten at the bottom like:

.|\n	;

So that anything else that matches a single character will
get flushed.

>PROBLEM 3 ------------------------------------ :-(
\\\
>and possibly the underscore.  My question is this, how can you get
>lex to match a reserved word you have declared, whether it's upper case
>or not.  For example, Unify has the reserved command word "application".
\\\

There are a couple of ways here. 

Firstly, you can define the input() macro to call your own character-
getting routine.  You may also have to redefine unput() as well if your method
of getting characters is significanly different from getc().
(I presume all you will do is a toupper(getc(f)) or something similar).

Secondly, I understand from the ``documentation'' for Lex that
you can define translate tables. This may be an ideal place to
learn how to use this feature, which I've managed to avoid for
a couple of decades!

-Kym Horsell
=====

Lexing and Yaccing for years and still sane(?)



More information about the Comp.lang.c mailing list