- 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.
includes
-better TestRig
run without arguments to see how to use
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
Last edited: