Developer’s Guide¶
Updating the Grammar¶
The ANTLR pattern grammar is maintained in the stix2-json-schemas repository. If the grammar changes, the code in this repository should be updated to match. To do so, use the Java ANTLR package to generate new Python source files. (The .jar file is not needed for normal use of the validator).
Download antlr-4.7.1-complete.jar from http://www.antlr.org/download/
Clone the stix2-json-schemas repository or download the STIXPattern.g4 file.
Change to the directory containing the STIXPattern.g4 file.
Run the following command
$ java -jar "/path/to/antlr-4.7.1-complete.jar" -Dlanguage=Python2 STIXPattern.g4 -visitor -o /path/to/cti-pattern-validator/stix2patterns/grammars
Commit the resulting files to git.