Skip to content

Commit

Permalink
Fix a bug in SyntaxTreeVisitor to handle return statements.
Browse files Browse the repository at this point in the history
--
MOS_MIGRATED_REVID=102237430
  • Loading branch information
laurentlb authored and damienmg committed Sep 3, 2015
1 parent f1ac099 commit 494eca9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import java.util.List;
import java.util.Map;

import javax.annotation.Nullable;

/**
* Recursive descent parser for LL(2) BUILD language.
* Loosely based on Python 2 grammar.
Expand Down Expand Up @@ -208,12 +210,14 @@ public static ParseResult parseFileForSkylark(
Lexer lexer,
EventHandler eventHandler,
CachingPackageLocator locator,
ValidationEnvironment validationEnvironment) {
@Nullable ValidationEnvironment validationEnvironment) {
Parser parser = new Parser(lexer, eventHandler, locator, SKYLARK);
List<Statement> statements = parser.parseFileInput();
boolean hasSemanticalErrors = false;
try {
validationEnvironment.validateAst(statements);
if (validationEnvironment != null) {
validationEnvironment.validateAst(statements);
}
} catch (EvalException e) {
// Do not report errors caused by a previous parsing error, as it has already been reported.
if (!e.isDueToIncompleteAST()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ public void visit(FunctionDefStatement node) {
visitAll(node.getStatements());
}

public void visit(ReturnStatement node) {
visit(node.getReturnExpression());
}

public void visit(DictionaryLiteral node) {
visitAll(node.getEntries());
}
Expand Down

0 comments on commit 494eca9

Please sign in to comment.