in reply to Re: YACC rules to regex rules ?
in thread YACC rules to regex rules ? (UPDATED)

Thanks.

I think I can solve it by myself, the format in a2p.y (which I had to google on github) looks a lot like perlretut#Defining-named-patterns plus embedded Perl code.

I'm just asking here before I reinvent the wheel.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: YACC rules to regex rules ?
by LanX (Saint) on Sep 02, 2020 at 13:01 UTC
    > perlretut#Defining-named-patterns plus embedded Perl code

    Unfortunately it's not obvious how to implement precedence and associativity with named patterns.

    This requires at least one lookahead for an operator.

    Reimplementing the C code from Yacc and Lex would be quite slow.

    I looked at CPAN for efficient recursive parsers allowing "precedence" but not much luck.

    I'm giving up here.

    While I'm sure it's possible to translate YACC rules to efficient regular expressions, it would be quite time consuming.

    Parser generators are not trivial.

    Update

    FWIW I found some good threads on the topic, but it'd be cool to transform YACC rules to efficient regexes, because we could easily adapt a parser to language changes.

    NB: There are multiple versions of AWK available.

    Some interesting threads

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      There is or used to be a Parse::Yapp