javacc

Can JavaCC distinguish token by its context?

爷,独闯天下 提交于 2019-12-01 16:33:59
问题 Basic requirement is use keyword as identifier, so I want to distinguish the token from it's context.(e.g. class is a keyword, but we allowed a variable named class ). In java, this is possible, but it's so hard, here is how I do it TOKEN : { <I_CAL: "CAL"> : DO_CAL | <I_CALL: "CALL"> | <I_CMP: "CMP"> | <I_EXIT: "EXIT"> | <I_IN: "IN"> | <I_JMP: "JMP"> | <I_JPC: "JPC"> : NEED_CMP_OP | <I_LD: "LD"> : NEED_DATA_TYPE | <I_NOP: "NOP"> | <I_OUT: "OUT"> | <I_POP: "POP"> | <I_PUSH: "PUSH"> | <I_RET:

How to implement JJTree on grammar

China☆狼群 提交于 2019-11-30 12:07:33
问题 I have an assignment to use JavaCC to make a Top-Down Parser with Semantic Analysis for a language supplied by the lecturer. I have the production rules written out and no errors. I'm completely stuck on how to use JJTree for my code and my hours of scouring the internet for tutorials hasn't gotten me anywhere. Just wondering could anyone take some time out to explain how to implement JJTree in the code? Or if there's a hidden step-by-step tutorial out there somewhere that would be a great

What's better, ANTLR or JavaCC? [closed]

两盒软妹~` 提交于 2019-11-28 03:04:29
Concerns are documentation/learnability, eclipse integration, tooling, community support and performance (in roughly that order). Wilfred Springer There are a couple of alternatives you shouldn't rule out: JParsec is a parser combinator framework that allows you to construct your parser entirely from code. Scala's parser combinator framework addresses a similar concern; however, Scala's syntax makes all of this much more readable. Then there's also the parser combinator framework done by John Metsker, for his book Building Parsers With Java ; I don't remember exactly where the library is, but

Parser, Generator for Java with the following requirements

天涯浪子 提交于 2019-11-27 02:57:45
问题 I am looking for a parser generator for Java that does the following: My language project is pretty simple and only contains a small set of tokens. Output in pure READABLE Java code so that I can modify it (this why I wouldn't use ANTLR) Mature library, that will run and work with at least Java 1.4 I have looked at the following and they might work: JavaCC, jlex, Ragel? 回答1: You should use Rats... This way, you don't have to separate lexer and parser and then if you want to extend your