Re: lexical analysis question

Mats Kindahl <>
30 Mar 2003 21:23:56 -0500

          From comp.compilers

Related articles
lexical analysis question (2003-03-30)
Re: lexical analysis question (Mats Kindahl) (2003-03-30)
Re: lexical analysis question (Chris F Clark) (2003-03-30)
Re: lexical analysis question (2003-04-05)
| List of all articles for this month |

From: Mats Kindahl <>
Newsgroups: comp.compilers
Date: 30 Mar 2003 21:23:56 -0500
Organization: Telia Internet
References: 03-03-178
Keywords: lex
Posted-Date: 30 Mar 2003 21:23:55 EST (Drederick) writes:

> [Unless you use the fairly disreputable trailing context feature, lex
> doesn't look ahead at all. It makes a DFA which matches the union of
> all of the input patterns, and keeps finding the longest match of the
> input string. -John]

You need lookahead to match the longest match of an input string.
Consider the regular expression "[a-z]*foobar" (which does not contain
a trailing context pattern) and the input string
"xxxfoobaryyyyyyyfooba" (note the missing "r" last); you have to read
the suffix "yyyyyyyfooba" before you can decide that the longest match
is "xxxfoobar".

Mats Kindahl
IAR Systems in Uppsala, Sweden.

Any opinions expressed are my own and not those of my company.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.