001 
002 /*
003  *  JavaDoq 1.0 - DOCUment JAVA In Source
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.javadoq.com>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (at your option) any later version.
010  *  
011  *  This program is distributed in the hope that it will be useful,
012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  *  GNU Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 options {
021   JDK_VERSION = "1.5";
022   JAVA_UNICODE_ESCAPE = true;
023   MULTI = true;
024   NODE_CLASS = "ASTNode";
025   NODE_DEFAULT_VOID = true;
026   NODE_SCOPE_HOOK = true;
027   NODE_USES_PARSER = true;
028   STATIC = false;
029   TOKEN_EXTENDS = "AbstractToken";
030   UNICODE_INPUT = true;
031 }
032 
033 PARSER_BEGIN(JavadocParser)
034 
035 package com.javadoq.javadoc;
036 
037 public class JavadocParser {
038 
039     void jjtreeOpenNodeScope(Node n) {
040         ((ASTNode)n).firstToken = getToken(1);
041     }
042 
043     void jjtreeCloseNodeScope(Node n) {
044         ((ASTNode)n).lastToken = getToken(0);
045     }
046 }
047 
048 PARSER_END(JavadocParser)
049 
050 TOKEN [IGNORE_CASE] :
051 {
052   < LINK_START: "{@link" ( [" ", "\t"] )+ > : IN_LINK_START
053 | < SEE_START: "@see" ( [" ", "\t"] )+ > : IN_SEE_START
054 | < ANCHOR_START: "<a" ( [" ", "\t"] )+ "href" ( [" ", "\t"])* "=" ( [" ", "\t"] )* > : IN_ANCHOR_START
055 | < SPACE:    ( <WS> )+ >
056 | < #WS:      [" ", "\t", "\r", "\n", "\f"] >
057 | < COMMENT: ~[] >
058 }
059 
060 <IN_LINK_START> TOKEN:
061 {
062   < LINK:  ( ~["{", "}", "(", ")", "<", ">", " ", "\t", "\r", "\n", "\f"] )+ >
063 | < LINK_CLOSE: ( "(" (~["(", ")"])* ")" )? ( [" ", "\t"] )* "}" > : DEFAULT
064 }
065 
066 <IN_SEE_START> TOKEN:
067 {
068   < SEE:  ( ~["{", "}", "(", ")", "<", ">", " ", "\t", "\r", "\n", "\f"] )+ >
069 | < SEE_CLOSE: ( "(" (~["(", ")"])* ")" )? ( [" ", "\t", "\r", "\n", "\f"] )+ > : DEFAULT
070 }
071 
072 <IN_ANCHOR_START> TOKEN:
073 {
074   < ANCHOR:  (~[">", " ", "\t", "\r", "\n", "\f"])+ >
075 | < ANCHOR_CLOSE: ">" | ( ( [" ", "\t"] )+ ( ~[">"] )* ">" ) > : DEFAULT
076 }
077 
078 ASTCompilationUnit CompilationUnit() #CompilationUnit :
079 {}
080 {
081   (
082     Link()
083 |   See()
084 |   Anchor()
085 |   < SPACE >
086 |   < COMMENT >
087   )*
088   < EOF >
089   {
090     return jjtThis;
091   }
092 }
093 
094 void Link() :
095 {}
096 {
097   < LINK_START >
098   ( < LINK > ) ?
099   < LINK_CLOSE >
100 }
101 
102 void See() :
103 {}
104 {
105   < SEE_START >
106   ( < SEE > ) ?
107   < SEE_CLOSE >
108 }
109 
110 void Anchor() :
111 {}
112 {
113   < ANCHOR_START >
114   ( < ANCHOR > ) ?
115   < ANCHOR_CLOSE >
116 }
117