diff options
author | Laurent Le Brun <laurentlb@google.com> | 2015-03-17 10:37:31 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2015-03-18 13:42:24 +0000 |
commit | 166e0455cd9b3e1600f541a1cfa3bacebe500af5 (patch) | |
tree | 4961570dca41d54c15ec4c5528ae13352d68ab84 /src/main/java/com/google/devtools/build/lib | |
parent | db16149bbd490c4693243ebe413a340ed7c905bb (diff) |
Parser: Update error message when using 'def' in a BUILD file.
--
MOS_MIGRATED_REVID=88813915
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/Constants.java | 7 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/Parser.java | 9 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/Constants.java b/src/main/java/com/google/devtools/build/lib/Constants.java index 7f6a518939..5437dae682 100644 --- a/src/main/java/com/google/devtools/build/lib/Constants.java +++ b/src/main/java/com/google/devtools/build/lib/Constants.java @@ -71,4 +71,11 @@ public class Constants { */ public static final ImmutableList<String> BASELINE_COVERAGE_OFFLINE_INSTRUMENTATION_SUFFIXES = ImmutableList.<String>of(); + + /** + * Error message from the parser. This happens when a BUILD file contains + * a block (e.g. a function). + */ + public static final String PARSER_ERROR_EXTENSION_NEEDED = + "Move this construct to a macro in a .bzl file and load it"; } diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Parser.java b/src/main/java/com/google/devtools/build/lib/syntax/Parser.java index 68a4425ef8..555f08a473 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/Parser.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/Parser.java @@ -19,6 +19,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.events.Location; @@ -139,9 +140,6 @@ class Parser { private List<Path> includedFiles; - private static final String PREPROCESSING_NEEDED = - "Add \"# PYTHON-PREPROCESSING-REQUIRED\" on the first line of the file"; - private Parser(Lexer lexer, EventHandler eventHandler, CachingPackageLocator locator, boolean parsePython) { this.lexer = lexer; @@ -740,8 +738,7 @@ class Parser { int end = token.right; if (multipleVariables && !parsePython) { reportError(lexer.createLocation(start, end), - "For loops with multiple variables are not yet supported. " - + PREPROCESSING_NEEDED); + "For loops with multiple variables are not yet supported"); } return multipleVariables ? makeErrorExpression(start, end) : firstIdent; } @@ -1317,7 +1314,7 @@ class Parser { if (!parsePython) { reportError(lexer.createLocation(start, token.right), "syntax error at '" + blockToken + "': This Python-style construct is not supported. " - + PREPROCESSING_NEEDED); + + Constants.PARSER_ERROR_EXTENSION_NEEDED); } expect(TokenKind.COLON); skipSuite(); |