How can I parse code to build a compiler in Java?

后端 未结 12 1175
时光说笑
时光说笑 2021-02-09 06:08

I need to write a compiler. It\'s homework at the univ. The teacher told us that we can use any API we want to do the parsing of the code, as long as it is a good one. That way

12条回答
  •  忘了有多久
    2021-02-09 07:10

    JFlex is a scanner generator which, according to the manual, is designed to work with the parser generator CUP.

    One of the main design goals of JFlex was to make interfacing with the free Java parser generator CUP as easy as possibly [sic].

    It also has support for BYACC/J, which, as its name suggests, is a port of Berkeley YACC to generate Java code.

    I have used JFlex itself and liked it. Howeveer, the project I was doing was simple enough that I wrote the parser by hand, so I don't know how good either CUP or BYACC/J is.

提交回复
热议问题