I am learning compiler construction and want to implement the JavaScript grammar using JavaCC.
(I have already written my own JavaScript CodeModel which allows programmatic construction of the JavaScript code, now I want to write a JavaCC-based parser counterpart for that.)
My question is, is there a way to modularize the JavaCC grammar (.jj
-file) into several files?
I have very good experience with the JavaParser so I am learning from their java_1_5.jj
grammar. However, this is a 3000+ LoC file which is a bit hard to comprehend.
I would like to divide the grammar file into several parts so that it's easier to hande and understand. My Google searchen on "javacc modular", "javacc include", "javacc import" brought me some cryptic results which did not help much.
To be specific, how would I move the definition of the IDENTIFIER
(lines 380-1081) to another file?