• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Antlr (Java) Preprocessor

Status
Not open for further replies.
Antlr Compile

includes

-better TestRig

run without arguments to see how to use
-Antlr Grammar Preprocess

Pass in a list of files to preprocess (hopefully grammar files)

The new preprocessor command is #{ }, which is include.

#{filename}

The file can be any name, any directory, any extension. The #{ } also works in those files.

This is useful for splitting up your lexer grammra code (since it doesn't let you split the modes up). It's also useful for nice Java APIs (put everything in the tokens class for example ^_^).

Plus you can write a lot of reusable rules and just import them!

#{string.rule} { code??};

The thing is very lightweight and very fast. It does not use a parser and doesn't use any look ahead. The Antlr grammar doesn't have #{ }. No target Antlr language has #{ } :). This means that no look ahead stuff is needed in the lexer.
 

Attachments

  • AntlrCompile.7z
    16.9 KB · Views: 69
Last edited:
Status
Not open for further replies.
Top