【正文】
Node and any other nodes used in the grammar.MULTI (default: false)Generate a multi mode parse tree. The default for this is false, generating a simple mode parse tree.NODE_DEFAULT_VOID (default: false)Instead of making each nondecorated production an indefinite node, make it void instead.NODE_CLASS (default: )If set defines the name of a usersupplied class that will extend SimpleNode. Any tree nodes created will then be subclasses of NODE_CLASS.NODE_FACTORY (default: )Specify a class containing a factory method with following signature to construct nodes: public static Node jjtCreate(int id) For backwards patibility, the value false may also be specified, meaning that SimpleNode will be used as the factory class. NODE_PACKAGE (default: )The package to generate the node classes into. The default for this is the parser package.NODE_EXTENDS (default: ) DeprecatedThe superclass for the SimpleNode class. By providing a custom superclass you may be able to avoid the need to edit the generated . See the examples/Interpreter for an example usage.NODE_PREFIX (default: AST)The prefix used to construct node class names from node identifiers in multi mode. The default for this is AST.NODE_SCOPE_HOOK (default: false)Insert calls to userdefined parser methods on entry and exit of every node scope. See Node Scope Hooks above.NODE_USES_PARSER (default: false)JJTree will use an alternate form of the node construction routines where it passes the parser object in. For example, public static Node (MyParser p, int id)。 MyNode(MyParser p, int id)。 TRACK_TOKENS (default: false Insert jjtGetFirstToken(), jjtSetFirstToken(), getLastToken(), and jjtSetLastToken() methods in SimpleNode. The FirstToken is automatically set up on entry to a node scope。 the LastToken is automatically set up on exit from a node scope. STATIC (default: true)Generate code for a static parser. The default for this is true. This must be used consistently with the equivalent JavaCC options. The value of this option is emitted in the JavaCC source.VISITOR (default: false)Insert a jjtAccept() method in the node classes, and generate a visitor implementation with an entry for every node type used in the grammar.VISITOR_DATA_TYPE (default: Object)If this option is set, it is used in the signature of the generated jjtAccept() methods and the visit() methods as the type of the data argument. VISITOR_RETURN_TYPE (default: Object)If this option is set, it is used in the signature of the generated jjtAccept() methods and the visit() methods as the return type of the method. VISITOR_EXCEPTION (default: )If this option is set, it is used in the signature of the generated jjtAccept() methods and the visit() methods. Note: this option will be removed in a later version of JJTree. Don39。t use it if that bothers you.JJTREE_OUTPUT_DIRECTORY (default: use value of OUTPUT_DIRECTORY)By default, JJTree generates its output in the directory specified in the global OUTPUT_DIRECTORY setting. Explicitly setting this option allows the user to separate the parser from the tree files. jjTreeState final class JJTreeState { /* 初始化節(jié)點棧 */ void reset()。 /* 返回抽象語法樹的根節(jié)點. */ Node rootNode()。 /* 判斷當前的節(jié)點是否入棧 */ boolean nodeCreated()。 /* 返回節(jié)點域中已入棧的節(jié)點數(shù)*/ int arity()。 /* 入棧 */ void pushNode(Node n)。 /* 出棧 */ Node popNode()。 /* 返回棧頂節(jié)點 */ Node peekNode()。 }5 案例介紹 整數(shù)四則運算的例子bnf范式為: expression ::= ( ( newline )* simple_expression newline )* eof simple_expression ::= term ( addop term )* addop ::= plus | minus term ::= factor ( mulop factor )* mulop ::= timers | over factor ::= id | num | minus | plus | lparen simple_expression rparen 完整的例子在expression目錄下