001 /*@bgen(jjtree) Generated By:JJTree: Do not edit this line. Javadoc.jj */
002 /*@egen*/
003 /*
004  *  JavaDoq 1.0 - DOCUment JAVA In Source
005  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.javadoq.com>
006  *  
007  *  This program is free software: you can redistribute it and/or modify
008  *  it under the terms of the GNU Affero General Public License as published by
009  *  the Free Software Foundation, either version 3 of the License, or
010  *  (at your option) any later version.
011  *  
012  *  This program is distributed in the hope that it will be useful,
013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015  *  GNU Affero General Public License for more details.
016  *  
017  *  You should have received a copy of the GNU Affero General Public License
018  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
019  */
020 
021 options {
022   JDK_VERSION = "1.5";
023   JAVA_UNICODE_ESCAPE = true;
024                
025                          
026                            
027                          
028                           
029   STATIC = false;
030   TOKEN_EXTENDS = "AbstractToken";
031   UNICODE_INPUT = true;
032 }
033 
034 PARSER_BEGIN(JavadocParser)
035 
036 package com.javadoq.javadoc;
037 
038 public class JavadocParser/*@bgen(jjtree)*/implements JavadocParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
039   protected JJTJavadocParserState jjtree = new JJTJavadocParserState();
040 
041 /*@egen*/
042 
043     void jjtreeOpenNodeScope(Node n) {
044         ((ASTNode)n).firstToken = getToken(1);
045     }
046 
047     void jjtreeCloseNodeScope(Node n) {
048         ((ASTNode)n).lastToken = getToken(0);
049     }
050 }
051 
052 PARSER_END(JavadocParser)
053 
054 TOKEN [IGNORE_CASE] :
055 {
056   < LINK_START: "{@link" ( [" ", "\t"] )+ > : IN_LINK_START
057 | < SEE_START: "@see" ( [" ", "\t"] )+ > : IN_SEE_START
058 | < ANCHOR_START: "<a" ( [" ", "\t"] )+ "href" ( [" ", "\t"])* "=" ( [" ", "\t"] )* > : IN_ANCHOR_START
059 | < SPACE:    ( <WS> )+ >
060 | < #WS:      [" ", "\t", "\r", "\n", "\f"] >
061 | < COMMENT: ~[] >
062 }
063 
064 <IN_LINK_START> TOKEN:
065 {
066   < LINK:  ( ~["{", "}", "(", ")", "<", ">", " ", "\t", "\r", "\n", "\f"] )+ >
067 | < LINK_CLOSE: ( "(" (~["(", ")"])* ")" )? ( [" ", "\t"] )* "}" > : DEFAULT
068 }
069 
070 <IN_SEE_START> TOKEN:
071 {
072   < SEE:  ( ~["{", "}", "(", ")", "<", ">", " ", "\t", "\r", "\n", "\f"] )+ >
073 | < SEE_CLOSE: ( "(" (~["(", ")"])* ")" )? ( [" ", "\t", "\r", "\n", "\f"] )+ > : DEFAULT
074 }
075 
076 <IN_ANCHOR_START> TOKEN:
077 {
078   < ANCHOR:  (~[">", " ", "\t", "\r", "\n", "\f"])+ >
079 | < ANCHOR_CLOSE: ">" | ( ( [" ", "\t"] )+ ( ~[">"] )* ">" ) > : DEFAULT
080 }
081 
082 ASTCompilationUnit CompilationUnit()                  :
083 {/*@bgen(jjtree) CompilationUnit */
084   ASTCompilationUnit jjtn000 = new ASTCompilationUnit(this, JJTCOMPILATIONUNIT);
085   boolean jjtc000 = true;
086   jjtree.openNodeScope(jjtn000);
087   jjtreeOpenNodeScope(jjtn000);
088 /*@egen*/}
089 {/*@bgen(jjtree) CompilationUnit */
090   try {
091 /*@egen*/
092   (
093     Link()
094 |   See()
095 |   Anchor()
096 |   < SPACE >
097 |   < COMMENT >
098   )*
099   < EOF >/*@bgen(jjtree)*/
100   {
101     jjtree.closeNodeScope(jjtn000, true);
102     jjtc000 = false;
103     jjtreeCloseNodeScope(jjtn000);
104   }
105 /*@egen*/
106   {
107     return jjtn000;
108   }/*@bgen(jjtree)*/
109   } catch (Throwable jjte000) {
110     if (jjtc000) {
111       jjtree.clearNodeScope(jjtn000);
112       jjtc000 = false;
113     } else {
114       jjtree.popNode();
115     }
116     if (jjte000 instanceof RuntimeException) {
117       throw (RuntimeException)jjte000;
118     }
119     if (jjte000 instanceof ParseException) {
120       throw (ParseException)jjte000;
121     }
122     throw (Error)jjte000;
123   } finally {
124     if (jjtc000) {
125       jjtree.closeNodeScope(jjtn000, true);
126       jjtreeCloseNodeScope(jjtn000);
127     }
128   }
129 /*@egen*/
130 }
131 
132 void Link() :
133 {}
134 {
135   < LINK_START >
136   ( < LINK > ) ?
137   < LINK_CLOSE >
138 }
139 
140 void See() :
141 {}
142 {
143   < SEE_START >
144   ( < SEE > ) ?
145   < SEE_CLOSE >
146 }
147 
148 void Anchor() :
149 {}
150 {
151   < ANCHOR_START >
152   ( < ANCHOR > ) ?
153   < ANCHOR_CLOSE >
154 }
155