🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.sys5
Article #1005

lex bug ?

#1005
From: Michael Henning
Date: Fri, 31 Mar 1989 06:35
47 lines
1653 bytes
I came across the following today. The problems show up both under AIX and
Xenix. Could anyone please enlighten me as to whether these are real bugs
or am I just overlooking something ?

Problem 1:

The following lex input file recognizes comments as a '*' at the beginning
of a line followed by any number of characters to the end of the line:

%%
^\*.*$	printf("comment: %s\n", yytext);

If the file is changed to

comment	^\*.*$
%%
{comment}	printf("comment: %s\n", yytext);

then comments are no longer recognised.


Problem 2:

The following lex input file is supposed to recognize empty lines.

{empty_line}	^$
%%
{empty_line}	printf("empty line\n");

The program compiles, but does not recognize empty lines. If the program
is changed to

%%
^$	printf("empty line\n");

then lex reports a syntax error on line 2.


Any help on these would be greatly appreciated, I have not used lex before,
and the documentation is somewhat terse in places...

					Michi.
-- 
               | The opinions expressed are my own, not those of my employer. |
               |                                                              |
               | Michael (Michi) Henning                                      |
               | - We have three Michaels here, that's why they call me Michi |
Technical Details
Message-ID: <294@anvil.oz>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!munnari!otc!metro!bunyip!uqcspe!qfagus!anvil!michi

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!munnari!otc!metro!bunyip!uqcspe!qfagus!anvil!michi
From: michi@anvil.oz (Michael Henning)
Newsgroups: comp.bugs.sys5
Subject: lex bug ?
Keywords: lex, parsing
Message-ID: <294@anvil.oz>
Date: 31 Mar 89 06:35:08 GMT
Organization: Anvil Designs Pty Ltd, Brisbane, Australia
Lines: 47