Parsing, where can I learn about it

前端 未结 12 715
鱼传尺愫
鱼传尺愫 2020-12-13 14:56

I\'ve been given a job of \'translating\' one language into another. The source is too flexible (complex) for a simple line by line approach with regex. Where can I go to le

12条回答
  •  醉话见心
    2020-12-13 15:36

    flex and bison are the new lex and yacc though. The syntax for BNF is often derided for being a bit obtuse. Some have moved to ANTLR and Ragel for this reason.

    If you're not doing much translation, you may one to pull a one-off using multiline regexes with Perl or Ruby. Writing a compatible BNF grammar for an existing language is not a task to be taken lightly.

    On the other hand, it is entirely possible to leverage any given language's .l and .y files if they are available as open source. Then, you could construct new code from an existing parse tree.

提交回复
热议问题