...
Note: The C++ target was last synced with the 3.4 version of ANTLR
The ActionScript C++ target closely follows the C target. The API and runtime behavior are consistent to the extent possible.
...
// rest of grammar follows
....parser grammar MyGrammar;
options
{
language=ActionScriptCpp;
}
@includes
{
#include "UserTraits.hpp"
#include "TLexer.hpp"
}
@namespace{ UserNamespace }
...
using namespace UserNamespace;
int main(int argc, char* argv[])
{
TTraits::InputStreamType input(fName, ANTLR_ENC_8BIT);
TLexer lxr(&input); // TLexerNew is generated by ANTLR
TTraits::TokenStreamType tstream(ANTLR_SIZE_HINT, lxr.get_tokSource() );
TParser psr(&tstream); // TParserNew is generated by ANTLR3
...
namespace
-Wrap the generated classes with the specified namespace.header
- Will be inserted right after ANTLRs own imports at the top of the generated file.include
includes
,pre-includeincludes
,post-include
- same meaning as in C Targetinit
- Will be inserted at the end of the constructor of the lexer/parser. Here you can setup your own instance attributes.members
- Will be inserted in the class body of the lexer/parser. This is the right place for custom methods and class attributes.
...
-debug
option: mostly useful for integration into ANTLRWorks.output=template
: StringTemplate has not been ported to ActionScriptC++, so template-based recognizers are not supported.TreeParser(output = AST)
: useful for generating trees