Re: How make multifinished DFA for merged regexps?

Hans-Peter Diettrich <DrDiettrich1@netscape.net>
Tue, 24 Dec 2019 02:15:40 +0100

          From comp.compilers

Related articles
How make multifinished DFA for merged regexps? borucki.andrzej@gmail.com (Andy) (2019-12-19)
Re: How make multifinished DFA for merged regexps? 493-878-3164@kylheku.com (Kaz Kylheku) (2019-12-20)
How make multifinished DFA for merged regexps? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2019-12-20)
Re: How make multifinished DFA for merged regexps? borucki.andrzej@gmail.com (Andy) (2019-12-20)
Re: How make multifinished DFA for merged regexps? 493-878-3164@kylheku.com (Kaz Kylheku) (2019-12-21)
How make multifinished DFA for merged regexps? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2019-12-23)
Re: How make multifinished DFA for merged regexps? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2019-12-24)
Re: How make multifinished DFA for merged regexps? matt.timmermans@gmail.com (Matt Timmermans) (2019-12-23)
Re: How make multifinished DFA for merged regexps? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2019-12-24)
Re: How make multifinished DFA for merged regexps? rockbrentwood@gmail.com (2019-12-29)
| List of all articles for this month |
From: Hans-Peter Diettrich <DrDiettrich1@netscape.net>
Newsgroups: comp.compilers
Date: Tue, 24 Dec 2019 02:15:40 +0100
Organization: Compilers Central
References: 19-12-005 19-12-010
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="60281"; mail-complaints-to="abuse@iecc.com"
Keywords: lex
Posted-Date: 23 Dec 2019 21:55:05 EST

Am 21.12.2019 um 01:29 schrieb Andy:
> Greedy algorithms match longest regexp. For example operators "+" and "++",
> int numbers "123" and float numbers "123.456e3".
> On '.' will finish state of number, but we will inside automata for float
> number. But can be errors: after '.' will 'a'. We must backtrack to last
> finished state?


Why should "123." not form a valid float number? In fact it's the C way
to force a possibly int number into a float.


If your lexer requires backtracking, because it e.g. is LR(n), then this
is the only solution. Unlike parsers, which may work based on
shift/reduce actions, a scanner should be made simpler.


> I want avoid backtracking. Maybe after backtracking we must
> read chars from auxiliary token buffer instead of stream up to previous
> position? But this complicated parsing.


Parsers require a lookahead of at least one token. So scanners should
implement at least a lookahead of one character, depending on the
complexity or weirdness of a language definition.


DoDi


Post a followup to this message

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