简体   繁体   中英

JavaCC Lexer Generator Integration the NetBeans Platform

I am new in using JavaCC. I was trying to integrate editor for our company defined language. I need to change keywords and modify the syntax. I follow this link as a procedure. For testing i change the some lines below from the code link. I change keyword finally with require . I change following lines in code.

JavaParserConstants.java

    int FALSE = 25;
    /** RegularExpression Id. */
    int FINAL = 26;
    /** RegularExpression Id. */
    //int FINALLY = 27;
    int REQUIRE=27;
    /** RegularExpression Id. */
    int FLOAT = 28;
    /** RegularExpression Id. */

         *
         *
    String[] tokenImage = {
         *
    "\"false\"",
    "\"final\"",
    "\"require\"",//fınally
    "\"float\"",

SJLanguageHierarchy.java

 private static void init() {
  tokens = Arrays.<SJTokenId>asList(new SJTokenId[]{
         *
         *
   new SJTokenId("FALSE", "keyword", 25),
   new SJTokenId("FINAL", "keyword", 26),
   new SJTokenId("REQUIRE"/*"FINALLY"*/, "keyword", 27), 
   new SJTokenId("FLOAT", "keyword", 28)

Java1.5.jj

/* RESERVED WORDS AND LITERALS */
TOKEN :
{
*
*
| < FALSE: "false" >
| < FINAL: "final" >
| < REQUIRE: "require" >
| < FLOAT: "float" >

But it did not affect still when i am using new integrated "editor" it highlight the old syntax including keyword finally .Any suggestions or advice will be highly appreciated.

Thanks to @Theodore Norvell I find out that my code does not work if i change my keywords after generating code. The Java1.5.jj file should be first changed and then generated it was keypoint that i stacked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM