• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Antlr (Java) Preprocessor

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
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: 68
Last edited:
Status
Not open for further replies.
Top