How make multifinished DFA for merged regexps?

Christopher F Clark <christopher.f.clark@compiler-resources.com>
Fri, 20 Dec 2019 06:15:46 -0500

          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)
[1 later articles]
| List of all articles for this month |

From: Christopher F Clark <christopher.f.clark@compiler-resources.com>
Newsgroups: comp.compilers
Date: Fri, 20 Dec 2019 06:15:46 -0500
Organization: Compilers Central
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="51403"; mail-complaints-to="abuse@iecc.com"
Keywords: lex, DFA
Posted-Date: 20 Dec 2019 10:53:52 EST

Andy <borucki.andrzej@gmail.com> wrote:


> I can create DFA direct from regexp.
> But for language lexer I must have DFA for couple regexp.
> One solution is crating DFA with multi finished states.
example below
> How to check if r0 and r1 are disjoint?


> For example
> r0 = ab
                    ab(F0)
> r1 = ac
                      ac(F1)
> | 0 | 1
> a | 1 |
> b | | 2(F)
                          2(F0)
> c | | 3(F)
                          3(F1)


There are two solutions.


1, Don't just blindly merge your REs, keep the original regex name as
part of the final step. See, how I indicated it in my tweak to your
example.


2. Don't merge the REs at all, build the final DFA from the REs in parallel.


The easiest way to see how to do that is to do roughly what building
the LR(0) machine does when doing SLR/LALR parsing. That's a variant
of the subset construction algorithm that does essentially what you
want. That's how we made Yacc++ do ELR grammars.


--
******************************************************************************
Chris Clark email: christopher.f.clark@compiler-resources.com
Compiler Resources, Inc. Web Site: http://world.std.com/~compres
23 Bailey Rd voice: (508) 435-5016
Berlin, MA 01503 USA twitter: @intel_chris
------------------------------------------------------------------------------


Post a followup to this message

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