Builds a parse tree from the given source string. @return an AstRoot object representing the parsed program. If the parse fails, null will be returned. (The parse failure will result in a call to the ErrorReporter from CompilerEnvirons.)
(String sourceString, String sourceURI, int lineno)
| 612 | * ErrorReporter} from {@link CompilerEnvirons}.) |
| 613 | */ |
| 614 | public AstRoot parse(String sourceString, String sourceURI, int lineno) { |
| 615 | if (parseFinished) throw new IllegalStateException("parser reused"); |
| 616 | this.sourceURI = sourceURI; |
| 617 | if (compilerEnv.isIdeMode()) { |
| 618 | this.sourceChars = sourceString.toCharArray(); |
| 619 | } |
| 620 | currentPos = ts = new TokenStream(this, null, sourceString, lineno); |
| 621 | try { |
| 622 | return parse(); |
| 623 | } catch (IOException iox) { |
| 624 | // Should never happen |
| 625 | throw new IllegalStateException(); |
| 626 | } finally { |
| 627 | parseFinished = true; |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | /** |
| 632 | * Builds a parse tree from the given sourcereader. |