@Test public void test_error() throws IOException { String file = "import anotherContract.sol" + "contract base {\n" + " "}"; try { new SolidityParsingPhase().parse(file); } catch (IllegalStateException e) { assertThat(e).isNotNull(); } }
public SourceUnitContext parse(String fileContents) { CharStream cs = CharStreams.fromString(fileContents); SolidityLexer sl = new SolidityLexer(cs); CommonTokenStream tokenStream = new CommonTokenStream(sl); tokenStream.fill(); SolidityParser parser = new SolidityParser(tokenStream); parser.setErrorHandler(new ErrorStrategy()); addCommentsToSet(tokenStream.getTokens()); this.tokens = parser.getTokenStream(); return parser.sourceUnit(); }
SolidityParsingPhase { public SourceUnitContext parse(String fileContents) { CharStream cs = CharStreams.fromString(fileContents); SolidityLexer sl = new SolidityLexer(cs); CommonTokenStream tokenStream = new CommonTokenStream(sl); tokenStream.fill(); SolidityParser parser = new SolidityParser(tokenStream); parser.setErrorHandler(new ErrorStrategy()); addCommentsToSet(tokenStream.getTokens()); this.tokens = parser.getTokenStream(); return parser.sourceUnit(); } }
SolidityParsingPhase { public SourceUnitContext parse(String fileContents) { CharStream cs = CharStreams.fromString(fileContents); SolidityLexer sl = new SolidityLexer(cs); CommonTokenStream tokenStream = new CommonTokenStream(sl); tokenStream.fill(); SolidityParser parser = new SolidityParser(tokenStream); parser.setErrorHandler(new ErrorStrategy()); addCommentsToSet(tokenStream.getTokens()); this.tokens = parser.getTokenStream(); return parser.sourceUnit(); } SolidityParsingPhase(); }
SolidityParsingPhase { public SourceUnitContext parse(String fileContents) { CharStream cs = CharStreams.fromString(fileContents); SolidityLexer sl = new SolidityLexer(cs); CommonTokenStream tokenStream = new CommonTokenStream(sl); tokenStream.fill(); SolidityParser parser = new SolidityParser(tokenStream); parser.setErrorHandler(new ErrorStrategy()); addCommentsToSet(tokenStream.getTokens()); this.tokens = parser.getTokenStream(); return parser.sourceUnit(); } SolidityParsingPhase(); SourceUnitContext parse(String fileContents); SourceUnitContext parse(CharStream cs); void addCommentsToSet(List<? extends Token> tokens); Integer getEmptyLines(); void setEmptyLines(Integer emptyLines); Integer getLinesOfComments(); TokenStream getTokens(); }
SolidityParsingPhase { public SourceUnitContext parse(String fileContents) { CharStream cs = CharStreams.fromString(fileContents); SolidityLexer sl = new SolidityLexer(cs); CommonTokenStream tokenStream = new CommonTokenStream(sl); tokenStream.fill(); SolidityParser parser = new SolidityParser(tokenStream); parser.setErrorHandler(new ErrorStrategy()); addCommentsToSet(tokenStream.getTokens()); this.tokens = parser.getTokenStream(); return parser.sourceUnit(); } SolidityParsingPhase(); SourceUnitContext parse(String fileContents); SourceUnitContext parse(CharStream cs); void addCommentsToSet(List<? extends Token> tokens); Integer getEmptyLines(); void setEmptyLines(Integer emptyLines); Integer getLinesOfComments(); TokenStream getTokens(); final Set<Token> comments; }