🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1539

Re: lex & yacc questions

#1539
From: diamond
Date: Tue, 21 Aug 1990 04:46
25 lines
1825 bytes
In article <267@cti1.UUCP> mpledger@cti1.UUCP (Mark Pledger) writes:

>CTI-> cc -c main.c lex.yy.c
>CTI-> ld main.o lex.yy.o -ll -lc 2>&1 > ubtest.err
Try:   ld main.o lex.yy.o -ll -lc /lib/crt0.o 2>&1 > ubtest.err

>When I run yylex() from the sample code below, if no matching integer
>is found it prints the yytext[] anyway.  Why?
I think lex is defined as printing out input text if nothing else is
done to it.  You need to make a rule to dispose of unwanted text.
(I'm not sure though.  Have you looked in a lex book?)

>I am using letters  [A-Za-z'_'] to match upper or lower case characters
>and possibly the underscore.
This should also match the apostrophe.  Try [A-Za-z_] with no apostrophe.

>My question is this, how can you get lex to match a reserved word you
>have declared, whether it's upper case or not.
>"application", "APPLICATION", "Application", "APPlication", etc.
[Aa][Pp][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn]
If input other than reserved words is also case insensitive, then it is
probably faster to fold all input text into one case before lexing.
-- 
Norman Diamond, Nihon DEC     diamond@tkou02.enet.dec.com
This is me speaking.  If you want to hear the company speak, you need DECtalk.
Technical Details
Message-ID: <1930@tkou02.enet.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!samsung!uakari.primate.wisc.edu!sdd.hp.com!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!diamond
References: <267@cti1.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!samsung!uakari.primate.wisc.edu!sdd.hp.com!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!diamond
From: diamond@tkou02.enet.dec.com (diamond@tkovoa)
Newsgroups: comp.lang.misc
Subject: Re: lex & yacc questions
Keywords: lex, yacc
Message-ID: <1930@tkou02.enet.dec.com>
Date: 21 Aug 90 04:46:00 GMT
References: <267@cti1.UUCP>
Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa)
Distribution: comp
Organization: Digital Equipment Corporation Japan , Tokyo
Lines: 25