Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: YACC rules to regex rules ?

by perlfan (Vicar)
on Aug 31, 2020 at 18:17 UTC ( [id://11121229]=note: print w/replies, xml ) Need Help??


in reply to YACC rules to regex rules ? (UPDATED)

This may not help and is not what you asked for, but may lead you to a helpful path nonetheless. thread on converting YACC to ANTLR. The link of interest is 404'ing, but thankfully the Internet never forgets (most of the time). The link there provides a zip. So it's also Java I think, so sorry.

Replies are listed 'Best First'.
Re^2: YACC rules to regex rules ?
by LanX (Saint) on Aug 31, 2020 at 22:02 UTC
    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

      > 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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121229]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-19 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found