45 import static com.sun.tools.javac.parser.Tokens.TokenKind.CATCH; |
45 import static com.sun.tools.javac.parser.Tokens.TokenKind.CATCH; |
46 import static com.sun.tools.javac.parser.Tokens.TokenKind.EQ; |
46 import static com.sun.tools.javac.parser.Tokens.TokenKind.EQ; |
47 import static com.sun.tools.javac.parser.Tokens.TokenKind.GT; |
47 import static com.sun.tools.javac.parser.Tokens.TokenKind.GT; |
48 import static com.sun.tools.javac.parser.Tokens.TokenKind.IMPORT; |
48 import static com.sun.tools.javac.parser.Tokens.TokenKind.IMPORT; |
49 import static com.sun.tools.javac.parser.Tokens.TokenKind.LT; |
49 import static com.sun.tools.javac.parser.Tokens.TokenKind.LT; |
|
50 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
50 import static com.sun.tools.javac.util.ListBuffer.lb; |
51 import static com.sun.tools.javac.util.ListBuffer.lb; |
51 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
|
52 |
52 |
53 /** The parser maps a token sequence into an abstract syntax |
53 /** The parser maps a token sequence into an abstract syntax |
54 * tree. It operates by recursive descent, with code derived |
54 * tree. It operates by recursive descent, with code derived |
55 * systematically from an LL(1) grammar. For efficiency reasons, an |
55 * systematically from an LL(1) grammar. For efficiency reasons, an |
56 * operator precedence scheme is used for parsing binary operation |
56 * operator precedence scheme is used for parsing binary operation |
126 this.allowMethodReferences = source.allowMethodReferences() && |
126 this.allowMethodReferences = source.allowMethodReferences() && |
127 fac.options.isSet("allowMethodReferences"); //pre-lambda guard |
127 fac.options.isSet("allowMethodReferences"); //pre-lambda guard |
128 this.allowDefaultMethods = source.allowDefaultMethods() && |
128 this.allowDefaultMethods = source.allowDefaultMethods() && |
129 fac.options.isSet("allowDefaultMethods"); //pre-lambda guard |
129 fac.options.isSet("allowDefaultMethods"); //pre-lambda guard |
130 this.keepDocComments = keepDocComments; |
130 this.keepDocComments = keepDocComments; |
131 docComments = newDocCommentTable(keepDocComments); |
131 docComments = newDocCommentTable(keepDocComments, fac); |
132 this.keepLineMap = keepLineMap; |
132 this.keepLineMap = keepLineMap; |
133 this.errorTree = F.Erroneous(); |
133 this.errorTree = F.Erroneous(); |
134 endPosTable = newEndPosTable(keepEndPositions); |
134 endPosTable = newEndPosTable(keepEndPositions); |
135 } |
135 } |
136 |
136 |
138 return keepEndPositions |
138 return keepEndPositions |
139 ? new SimpleEndPosTable() |
139 ? new SimpleEndPosTable() |
140 : new EmptyEndPosTable(); |
140 : new EmptyEndPosTable(); |
141 } |
141 } |
142 |
142 |
143 protected DocCommentTable newDocCommentTable(boolean keepDocComments) { |
143 protected DocCommentTable newDocCommentTable(boolean keepDocComments, ParserFactory fac) { |
144 return keepDocComments ? new SimpleDocCommentTable() : null; |
144 return keepDocComments ? new LazyDocCommentTable(fac) : null; |
145 } |
145 } |
146 |
146 |
147 /** Switch: Should generics be recognized? |
147 /** Switch: Should generics be recognized? |
148 */ |
148 */ |
149 boolean allowGenerics; |
149 boolean allowGenerics; |