The ActionScript code generation target
Note: The ActionScript target was last synced with the 3.2 version of ANTLR, and is no longer being actively maintained.
The ActionScript target closely follows the Java target. The API and runtime behavior are consistent to the extent possible.
Please send bug reports, feedback, patches to me or the to the antlr-interest mailing list.
Requirements
The runtime generates ActionScript 3 code designed to work with Flex version 2 or higher from Adobe. The runtime binary libraries are all compiled with the latest Flex 3.2 SDK.
To use generated code, you'll need to include ActionScript runtime package antlr3.swc
in your library path. There are no other dependencies beyond the standard Flex libraries. Note, that the library contains some Adobe AIR class references, to use the library in a pure Flex project use the -library-path
compiler option rather than the -include-library
option when compiling from the command line.
Usage
Selecting ActionScript output
...
For a grammar T.g
ANTLR3 will then create the files TLexer.as
and TParser.as
which contain the classes TLexer
and TParser
(or just one of those, if you have a pure lexer/parser). For tree parsers, ANTLR3 creates T.as
containing the class T
.
Specifying an ActionScript package for your recognizer
You can specify that your generated recognizer should be declared within a specific package as shown below. By default all recognizers are generated as top-level types with no enclosing package.
Code Block |
---|
grammar MyGrammar; options { language=ActionScript; } @parser::package { My.Custom.NameSpace.For.Parser.In.Combined.Grammar } // Or just @package { ... } @lexer::package { My.Custom.NameSpace.For.Lexer.In.Combined.Grammar } // rest of grammar follows .... |
Code Block |
---|
lexer grammar MyGrammar;
options
{
language=ActionScript;
}
@package { My.Custom.NameSpace.For.Lexer }
// rest of grammar follows
....
|
Code Block |
---|
parser grammar MyGrammar;
options
{
language=ActionScript;
}
@package { My.Custom.NameSpace.For.Parser }
// rest of grammar follows
....
|
Code Block |
---|
tree grammar MyGrammar;
options
{
language=ActionScript;
}
@package { My.Custom.NameSpace.For.TreeParser }
// rest of grammar follows
....
|
Using the generated classes
...
Anchor | ||||
---|---|---|---|---|
|
-debug
option: mostly useful for integration into ANTLRWorks.output=template
: StringTemplate has not been ported to ActionScript, so template-based recognizers are not supported.