Big change to error messages themselves by removing single quotes for non input text stuff. Made cannot_find_tokens_file more specific (split it). Added offending token information to a lot of the messages. It now only prints the file name and not the full path to the file in error messages. Re-factored the ANTLRMessage hierarchy to share fields. Getting the offending token required number of methods to take different arguments. removed the default ST listener in the error manager as it is apparently unused. Cannot find imported grammar is now a grammar error not a tool error.

This commit is contained in:
Terence Parr 2014-06-29 21:39:15 -07:00
parent 5bd415b195
commit 36425dd59c
24 changed files with 462 additions and 447 deletions

View File

@ -593,9 +593,10 @@ public class Tool {
/**
* Try current dir then dir of g then lib dir
* @param g
* @param name The imported grammar name.
* @param nameNode The node associated with the imported grammar name.
*/
public Grammar loadImportedGrammar(Grammar g, String name) throws IOException {
public Grammar loadImportedGrammar(Grammar g, GrammarAST nameNode) throws IOException {
String name = nameNode.getText();
g.tool.log("grammar", "load " + name + " from " + g.fileName);
File importedFile = null;
for (String extension : ALL_GRAMMAR_EXTENSIONS) {
@ -606,12 +607,15 @@ public class Tool {
}
if ( importedFile==null ) {
errMgr.toolError(ErrorType.CANNOT_FIND_IMPORTED_GRAMMAR, name, g.fileName);
errMgr.grammarError(ErrorType.CANNOT_FIND_IMPORTED_GRAMMAR, g.fileName, nameNode.getToken(), name);
return null;
}
ANTLRFileStream in = new ANTLRFileStream(importedFile.getAbsolutePath(), grammarEncoding);
GrammarRootAST root = parse(g.fileName, in);
if ( root==null ) {
return null;
}
Grammar imported = createGrammar(root);
imported.fileName = importedFile.getAbsolutePath();
return imported;

View File

@ -74,7 +74,9 @@ public class LeftRecursionDetector {
}
//System.out.println("cycles="+listOfRecursiveCycles);
if ( !listOfRecursiveCycles.isEmpty() ) {
g.tool.errMgr.leftRecursionCycles(g.fileName, listOfRecursiveCycles);
RuleStartState firstRuleStartState = atn.ruleToStartState[0];
Rule r = g.getRule(firstRuleStartState.ruleIndex);
g.tool.errMgr.leftRecursionCycles(g.fileName, r.ast.getToken(), listOfRecursiveCycles);
}
}

View File

@ -131,7 +131,7 @@ public class LeftRecursiveRuleAnalyzer extends LeftRecursiveRuleWalker {
assoc = ASSOC.left;
}
else {
tool.errMgr.toolError(ErrorType.ILLEGAL_OPTION_VALUE, "assoc", assoc);
tool.errMgr.toolError(ErrorType.ILLEGAL_OPTION_VALUE, t.getToken(), "assoc", assoc);
}
}
}

View File

@ -34,6 +34,7 @@ import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.ParserRuleReturnScope;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;
import org.antlr.v4.Tool;
import org.antlr.v4.misc.OrderedHashMap;
import org.antlr.v4.parse.ANTLRLexer;
@ -177,7 +178,7 @@ public class LeftRecursiveRuleTransformer {
// update Rule to just one alt and add prec alt
ActionAST arg = (ActionAST)r.ast.getFirstChildWithType(ANTLRParser.ARG_ACTION);
if ( arg!=null ) {
r.args = ScopeParser.parseTypedArgList(arg, arg.getText(), g.tool.errMgr);
r.args = ScopeParser.parseTypedArgList(arg, arg.getText(), g);
r.args.type = AttributeDict.DictType.ARG;
r.args.ast = arg;
arg.resolver = r.alt[1]; // todo: isn't this Rule or something?
@ -206,15 +207,18 @@ public class LeftRecursiveRuleTransformer {
lexer.tokens = tokens;
ToolANTLRParser p = new ToolANTLRParser(tokens, tool);
p.setTreeAdaptor(adaptor);
Token ruleStart = null;
try {
ParserRuleReturnScope r = p.rule();
RuleAST tree = (RuleAST)r.getTree();
ruleStart = (Token)r.getStart();
GrammarTransformPipeline.setGrammarPtr(g, tree);
GrammarTransformPipeline.augmentTokensWithOriginalPosition(g, tree);
return tree;
}
catch (Exception e) {
tool.errMgr.toolError(ErrorType.INTERNAL_ERROR,
ruleStart,
"error parsing rule created during left-recursion detection: "+ruleText,
e);
}

View File

@ -306,7 +306,7 @@ public class ParserATNFactory implements ATNFactory {
public Handle _ruleRef(@NotNull GrammarAST node) {
Rule r = g.getRule(node.getText());
if ( r==null ) {
g.tool.errMgr.toolError(ErrorType.INTERNAL_ERROR, "Rule "+node.getText()+" undefined");
g.tool.errMgr.grammarError(ErrorType.INTERNAL_ERROR, g.fileName, node.getToken(), "Rule "+node.getText()+" undefined");
return null;
}
RuleStartState start = atn.ruleToStartState[r.index];

View File

@ -235,7 +235,8 @@ public class RuleFunction extends OutputModelObject {
}
return visitor.frequencies.peek();
} catch (RecognitionException ex) {
}
catch (RecognitionException ex) {
factory.getGrammar().tool.errMgr.toolError(ErrorType.INTERNAL_ERROR, ex);
return new FrequencySet<String>();
}

View File

@ -39,6 +39,7 @@ import org.antlr.v4.tool.Attribute;
import org.antlr.v4.tool.AttributeDict;
import org.antlr.v4.tool.ErrorManager;
import org.antlr.v4.tool.ErrorType;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.ast.ActionAST;
import java.util.ArrayList;
@ -62,17 +63,17 @@ public class ScopeParser {
*
* convert to an attribute scope.
*/
public static AttributeDict parseTypedArgList(@Nullable ActionAST action, String s, ErrorManager errMgr) {
return parse(action, s, ',', errMgr);
public static AttributeDict parseTypedArgList(@Nullable ActionAST action, String s, Grammar g) {
return parse(action, s, ',', g);
}
public static AttributeDict parse(@Nullable ActionAST action, String s, char separator, ErrorManager errMgr) {
public static AttributeDict parse(@Nullable ActionAST action, String s, char separator, Grammar g) {
AttributeDict dict = new AttributeDict();
List<Pair<String, Integer>> decls = splitDecls(s, separator);
for (Pair<String, Integer> decl : decls) {
// System.out.println("decl="+decl);
if ( decl.a.trim().length()>0 ) {
Attribute a = parseAttributeDef(action, decl, errMgr);
Attribute a = parseAttributeDef(action, decl, g);
dict.add(a);
}
}
@ -84,7 +85,7 @@ public class ScopeParser {
* but if the separator is ',' you cannot use ',' in the initvalue
* unless you escape use "\," escape.
*/
public static Attribute parseAttributeDef(@Nullable ActionAST action, @NotNull Pair<String, Integer> decl, ErrorManager errMgr) {
public static Attribute parseAttributeDef(@Nullable ActionAST action, @NotNull Pair<String, Integer> decl, Grammar g) {
if ( decl.a==null ) return null;
Attribute attr = new Attribute();
boolean inID = false;
@ -113,7 +114,7 @@ public class ScopeParser {
start = 0;
}
if ( start<0 ) {
errMgr.toolError(ErrorType.CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL,decl);
g.tool.errMgr.grammarError(ErrorType.CANNOT_FIND_ATTRIBUTE_NAME_IN_DECL, g.fileName, action.token, decl);
}
// walk forwards looking for end of an ID
int stop=-1;

View File

@ -34,6 +34,8 @@ import org.antlr.runtime.Token;
import org.antlr.v4.Tool;
import org.antlr.v4.codegen.CodeGenerator;
import org.antlr.v4.tool.ErrorType;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.ast.GrammarAST;
import java.io.BufferedReader;
import java.io.File;
@ -48,12 +50,10 @@ import java.util.regex.Pattern;
/** */
public class TokenVocabParser {
protected final Tool tool;
protected final String vocabName;
protected final Grammar g;
public TokenVocabParser(Tool tool, String vocabName) {
this.tool = tool;
this.vocabName = vocabName;
public TokenVocabParser(Grammar g) {
this.g = g;
}
/** Load a vocab file {@code <vocabName>.tokens} and return mapping. */
@ -63,6 +63,8 @@ public class TokenVocabParser {
File fullFile = getImportedVocabFile();
FileInputStream fis = null;
BufferedReader br = null;
Tool tool = g.tool;
String vocabName = g.getOptionString("tokenVocab");
try {
Pattern tokenDefPattern = Pattern.compile("([^\n]+?)[ \\t]*?=[ \\t]*?([0-9]+)");
fis = new FileInputStream(fullFile);
@ -102,7 +104,7 @@ public class TokenVocabParser {
if ( tokenDef.length()>0 ) { // ignore blank lines
tool.errMgr.toolError(ErrorType.TOKENS_FILE_SYNTAX_ERROR,
vocabName + CodeGenerator.VOCAB_FILE_EXTENSION,
" bad token def: "+tokenDef,
" bad token def: " + tokenDef,
lineNum);
}
}
@ -110,13 +112,25 @@ public class TokenVocabParser {
}
}
catch (FileNotFoundException fnfe) {
tool.errMgr.toolError(ErrorType.CANNOT_FIND_TOKENS_FILE,
fullFile);
GrammarAST inTree = g.ast.getOptionAST("tokenVocab");
String inTreeValue = inTree.getToken().getText();
if ( vocabName.equals(inTreeValue) ) {
tool.errMgr.grammarError(ErrorType.CANNOT_FIND_TOKENS_FILE_REFD_IN_GRAMMAR,
g.fileName,
inTree.getToken(),
fullFile);
}
else { // must be from -D option on cmd-line not token in tree
tool.errMgr.toolError(ErrorType.CANNOT_FIND_TOKENS_FILE_GIVEN_ON_CMDLINE,
fullFile,
g.name);
}
}
catch (Exception e) {
tool.errMgr.toolError(ErrorType.ERROR_READING_TOKENS_FILE,
e,
fullFile,
e);
e.getMessage());
}
finally {
try {
@ -124,8 +138,9 @@ public class TokenVocabParser {
}
catch (IOException ioe) {
tool.errMgr.toolError(ErrorType.ERROR_READING_TOKENS_FILE,
ioe,
fullFile,
ioe);
ioe.getMessage());
}
}
return tokens;
@ -141,8 +156,8 @@ public class TokenVocabParser {
* was no output directory specified.
*/
public File getImportedVocabFile() {
File f = new File(tool.libDirectory,
String vocabName = g.getOptionString("tokenVocab");
File f = new File(g.tool.libDirectory,
File.separator +
vocabName +
CodeGenerator.VOCAB_FILE_EXTENSION);
@ -154,7 +169,7 @@ public class TokenVocabParser {
// to look for it in the output directory which is where .tokens
// files are generated (in the base, not relative to the input
// location.)
f = new File(tool.outputDirectory, vocabName + CodeGenerator.VOCAB_FILE_EXTENSION);
f = new File(g.tool.outputDirectory, vocabName + CodeGenerator.VOCAB_FILE_EXTENSION);
return f;
}
}

View File

@ -81,20 +81,20 @@ public class RuleCollector extends GrammarTreeVisitor {
rules.put(r.name, r);
if ( arg!=null ) {
r.args = ScopeParser.parseTypedArgList(arg, arg.getText(), g.tool.errMgr);
r.args = ScopeParser.parseTypedArgList(arg, arg.getText(), g);
r.args.type = AttributeDict.DictType.ARG;
r.args.ast = arg;
arg.resolver = r.alt[currentOuterAltNumber];
}
if ( returns!=null ) {
r.retvals = ScopeParser.parseTypedArgList(returns, returns.getText(), g.tool.errMgr);
r.retvals = ScopeParser.parseTypedArgList(returns, returns.getText(), g);
r.retvals.type = AttributeDict.DictType.RET;
r.retvals.ast = returns;
}
if ( locals!=null ) {
r.locals = ScopeParser.parseTypedArgList(locals, locals.getText(), g.tool.errMgr);
r.locals = ScopeParser.parseTypedArgList(locals, locals.getText(), g);
r.locals.type = AttributeDict.DictType.LOCAL;
r.locals.ast = locals;
}

View File

@ -30,6 +30,7 @@
package org.antlr.v4.tool;
import org.antlr.runtime.Token;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.stringtemplate.v4.ST;
@ -50,18 +51,25 @@ public class ANTLRMessage {
public int line = -1;
public int charPosition = -1;
public ANTLRMessage(@NotNull ErrorType errorType) {
this(errorType, (Throwable)null);
public Grammar g;
/** Most of the time, we'll have a token such as an undefined rule ref
* and so this will be set.
*/
public Token offendingToken;
public ANTLRMessage(@NotNull ErrorType errorType) {
this(errorType, (Throwable)null, Token.INVALID_TOKEN);
}
public ANTLRMessage(@NotNull ErrorType errorType, Object... args) {
this(errorType, null, args);
}
public ANTLRMessage(@NotNull ErrorType errorType, Token offendingToken, Object... args) {
this(errorType, null, offendingToken, args);
}
public ANTLRMessage(@NotNull ErrorType errorType, @Nullable Throwable e, Object... args) {
public ANTLRMessage(@NotNull ErrorType errorType, @Nullable Throwable e, Token offendingToken, Object... args) {
this.errorType = errorType;
this.e = e;
this.args = args;
this.offendingToken = offendingToken;
}
@NotNull
@ -80,6 +88,7 @@ public class ANTLRMessage {
public ST getMessageTemplate(boolean verbose) {
ST messageST = new ST(getErrorType().msg);
messageST.impl.name = errorType.name();
messageST.add("verbose", verbose);
Object[] args = getArgs();

View File

@ -30,14 +30,14 @@
package org.antlr.v4.tool;
import org.antlr.runtime.Token;
import org.antlr.v4.Tool;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STErrorListener;
import org.stringtemplate.v4.STGroup;
import org.stringtemplate.v4.STGroupFile;
import org.stringtemplate.v4.misc.ErrorBuffer;
import org.stringtemplate.v4.misc.STMessage;
import java.io.File;
import java.net.URL;
import java.util.Collection;
import java.util.EnumSet;
@ -63,29 +63,6 @@ public class ErrorManager {
ErrorBuffer initSTListener = new ErrorBuffer();
STErrorListener theDefaultSTListener =
new STErrorListener() {
@Override
public void compileTimeError(STMessage msg) {
ErrorManager.internalError(msg.toString());
}
@Override
public void runTimeError(STMessage msg) {
ErrorManager.internalError(msg.toString());
}
@Override
public void IOError(STMessage msg) {
ErrorManager.internalError(msg.toString());
}
@Override
public void internalError(STMessage msg) {
ErrorManager.internalError(msg.toString());
}
};
public ErrorManager(Tool tool) {
this.tool = tool;
}
@ -111,7 +88,13 @@ public class ErrorManager {
locationValid = true;
}
if (msg.fileName != null) {
locationST.add("file", msg.fileName);
File f = new File(msg.fileName);
// Don't show path to file in messages; too long.
String displayFileName = msg.fileName;
if ( f.exists() ) {
displayFileName = f.getName();
}
locationST.add("file", displayFileName);
locationValid = true;
}
@ -181,12 +164,15 @@ public class ErrorManager {
* @param args The arguments to pass to the StringTemplate
*/
public void toolError(ErrorType errorType, Object... args) {
ToolMessage msg = new ToolMessage(errorType, args);
emit(errorType, msg);
toolError(errorType, null, Token.INVALID_TOKEN, args);
}
public void toolError(ErrorType errorType, Throwable e, Object... args) {
ToolMessage msg = new ToolMessage(errorType, e, args);
public void toolError(ErrorType errorType, Token offendingToken, Object... args) {
toolError(errorType, null, offendingToken, args);
}
public void toolError(ErrorType errorType, Throwable e, Token offendingToken, Object... args) {
ToolMessage msg = new ToolMessage(errorType, e, offendingToken, args);
emit(errorType, msg);
}
@ -200,9 +186,9 @@ public class ErrorManager {
}
public void leftRecursionCycles(String fileName, Collection<? extends Collection<Rule>> cycles) {
public void leftRecursionCycles(String fileName, Token startTokenOfFirstRuleInCycle, Collection<? extends Collection<Rule>> cycles) {
errors++;
ANTLRMessage msg = new LeftRecursionCyclesMessage(fileName, cycles);
ANTLRMessage msg = new LeftRecursionCyclesMessage(fileName, startTokenOfFirstRuleInCycle, cycles);
tool.error(msg);
}

View File

@ -16,7 +16,7 @@
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
@ -50,27 +50,27 @@ public enum ErrorType {
/**
* Compiler Error 1.
*
* <p>cannot write file '<em>filename</em>': <em>reason</em></p>
* <p>cannot write file <em>filename</em>: <em>reason</em></p>
*/
CANNOT_WRITE_FILE(1, "cannot write file '<arg>': <arg2>", ErrorSeverity.ERROR),
CANNOT_WRITE_FILE(1, "cannot write file <arg>: <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 2.
*
* <p>unknown command-line option '<em>option</em>'</p>
* <p>unknown command-line option <em>option</em></p>
*/
INVALID_CMDLINE_ARG(2, "unknown command-line option '<arg>'", ErrorSeverity.ERROR),
INVALID_CMDLINE_ARG(2, "unknown command-line option <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 3.
*
* <p>cannot find tokens file '<em>filename</em>'</p>
* <p>cannot find tokens file <em>filename</em></p>
*/
CANNOT_FIND_TOKENS_FILE(3, "cannot find tokens file '<arg>'", ErrorSeverity.ERROR),
CANNOT_FIND_TOKENS_FILE_GIVEN_ON_CMDLINE(3, "cannot find tokens file <arg> given for <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 4.
*
* <p>cannot find tokens file '<em>filename</em>': <em>reason</em></p>
* <p>cannot find tokens file <em>filename</em>: <em>reason</em></p>
*/
ERROR_READING_TOKENS_FILE(4, "cannot find tokens file '<arg>': <arg2>", ErrorSeverity.ERROR),
ERROR_READING_TOKENS_FILE(4, "error reading tokens file <arg>: <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 5.
*
@ -93,21 +93,27 @@ public enum ErrorType {
* Compiler Error 8.
*
* <p>
* grammar name '<em>name</em>' and file name '<em>filename</em>' differ</p>
* grammar name <em>name</em> and file name <em>filename</em> differ</p>
*/
FILE_AND_GRAMMAR_NAME_DIFFER(8, "grammar name '<arg>' and file name '<arg2>' differ", ErrorSeverity.ERROR),
FILE_AND_GRAMMAR_NAME_DIFFER(8, "grammar name <arg> and file name <arg2> differ", ErrorSeverity.ERROR),
/**
* Compiler Error 9.
*
* <p>invalid {@code -Dname=value} syntax: '<em>syntax</em>'</p>
* <p>invalid {@code -Dname=value} syntax: <em>syntax</em></p>
*/
BAD_OPTION_SET_SYNTAX(9, "invalid -Dname=value syntax: '<arg>'", ErrorSeverity.ERROR),
BAD_OPTION_SET_SYNTAX(9, "invalid -Dname=value syntax: <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 10.
*
* <p>warning treated as error</p>
*/
WARNING_TREATED_AS_ERROR(10, "warning treated as error", ErrorSeverity.ERROR_ONE_OFF),
/**
* Compiler Error 11.
*
* <p>cannot find tokens file <em>filename</em>: <em>reason</em></p>
*/
ERROR_READING_IMPORTED_GRAMMAR(11, "error reading imported grammar <arg> referenced in <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 20.
@ -144,35 +150,35 @@ public enum ErrorType {
* Compiler Error 31.
*
* <p>
* ANTLR cannot generate '<em>language</em>' code as of version
* ANTLR cannot generate <em>language</em> code as of version
* <em>version</em></p>
*/
CANNOT_CREATE_TARGET_GENERATOR(31, "ANTLR cannot generate '<arg>' code as of version "+ Tool.VERSION, ErrorSeverity.ERROR),
CANNOT_CREATE_TARGET_GENERATOR(31, "ANTLR cannot generate <arg> code as of version "+ Tool.VERSION, ErrorSeverity.ERROR),
/**
* Compiler Error 32.
*
* <p>
* code generation template '<em>template</em>' has missing, misnamed, or
* incomplete arg list; missing '<em>field</em>'</p>
* code generation template <em>template</em> has missing, misnamed, or
* incomplete arg list; missing <em>field</em></p>
*/
CODE_TEMPLATE_ARG_ISSUE(32, "code generation template '<arg>' has missing, misnamed, or incomplete arg list; missing '<arg2>'", ErrorSeverity.ERROR),
CODE_TEMPLATE_ARG_ISSUE(32, "code generation template <arg> has missing, misnamed, or incomplete arg list; missing <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 33.
*
* <p>missing code generation template '<em>template</em>'</p>
* <p>missing code generation template <em>template</em></p>
*/
CODE_GEN_TEMPLATES_INCOMPLETE(33, "missing code generation template '<arg>'", ErrorSeverity.ERROR),
CODE_GEN_TEMPLATES_INCOMPLETE(33, "missing code generation template <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 34.
*
* <p>
* no mapping to template name for output model class '<em>class</em>'</p>
* no mapping to template name for output model class <em>class</em></p>
*/
NO_MODEL_TO_TEMPLATE_MAPPING(34, "no mapping to template name for output model class '<arg>'", ErrorSeverity.ERROR),
NO_MODEL_TO_TEMPLATE_MAPPING(34, "no mapping to template name for output model class <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 35.
*
* <p>templates/target and tool aren't compatible</p>
* <p>templates/target and tool arent compatible</p>
*/
INCOMPATIBLE_TOOL_AND_TEMPLATES(35, "<arg3> code generation target requires ANTLR <arg2>; it can't be loaded by the current ANTLR <arg>", ErrorSeverity.ERROR),
@ -189,21 +195,21 @@ public enum ErrorType {
/**
* Compiler Error 51.
*
* <p>rule '<em>rule</em>' redefinition; previous at line <em>line</em></p>
* <p>rule <em>rule</em> redefinition; previous at line <em>line</em></p>
*/
RULE_REDEFINITION(51, "rule '<arg>' redefinition; previous at line <arg2>", ErrorSeverity.ERROR),
RULE_REDEFINITION(51, "rule <arg> redefinition; previous at line <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 52.
*
* <p>lexer rule '<em>rule</em>' not allowed in parser</p>
* <p>lexer rule <em>rule</em> not allowed in parser</p>
*/
LEXER_RULES_NOT_ALLOWED(52, "lexer rule '<arg>' not allowed in parser", ErrorSeverity.ERROR),
LEXER_RULES_NOT_ALLOWED(52, "lexer rule <arg> not allowed in parser", ErrorSeverity.ERROR),
/**
* Compiler Error 53.
*
* <p>parser rule '<em>rule</em>' not allowed in lexer</p>
* <p>parser rule <em>rule</em> not allowed in lexer</p>
*/
PARSER_RULES_NOT_ALLOWED(53, "parser rule '<arg>' not allowed in lexer", ErrorSeverity.ERROR),
PARSER_RULES_NOT_ALLOWED(53, "parser rule <arg> not allowed in lexer", ErrorSeverity.ERROR),
/**
* Compiler Error 54.
*
@ -222,10 +228,10 @@ public enum ErrorType {
* Compiler Error 57.
*
* <p>
* reference to undefined rule '<em>rule</em>' in non-local ref
* '<em>reference</em>'</p>
* reference to undefined rule <em>rule</em> in non-local ref
* <em>reference</em></p>
*/
UNDEFINED_RULE_IN_NONLOCAL_REF(57, "reference to undefined rule '<arg>' in non-local ref '<arg3>'", ErrorSeverity.ERROR),
UNDEFINED_RULE_IN_NONLOCAL_REF(57, "reference to undefined rule <arg> in non-local ref <arg3>", ErrorSeverity.ERROR),
/**
* Compiler Error 60.
*
@ -236,87 +242,87 @@ public enum ErrorType {
* Compiler Error 63.
*
* <p>
* unknown attribute reference '<em>attribute</em>' in
* '<em>expression</em>'</p>
* unknown attribute reference <em>attribute</em> in
* <em>expression</em></p>
*/
UNKNOWN_SIMPLE_ATTRIBUTE(63, "unknown attribute reference '<arg>' in '<arg2>'", ErrorSeverity.ERROR),
UNKNOWN_SIMPLE_ATTRIBUTE(63, "unknown attribute reference <arg> in <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 64.
*
* <p>
* parameter '<em>parameter</em>' of rule '<em>rule</em>' is not accessible
* parameter <em>parameter</em> of rule <em>rule</em> is not accessible
* in this scope: <em>expression</em></p>
*/
INVALID_RULE_PARAMETER_REF(64, "parameter '<arg>' of rule '<arg2>' is not accessible in this scope: <arg3>", ErrorSeverity.ERROR),
INVALID_RULE_PARAMETER_REF(64, "parameter <arg> of rule <arg2> is not accessible in this scope: <arg3>", ErrorSeverity.ERROR),
/**
* Compiler Error 65.
*
* <p>
* unknown attribute '<em>attribute</em>' for rule '<em>rule</em>' in
* '<em>expression</em>'</p>
* unknown attribute <em>attribute</em> for rule <em>rule</em> in
* <em>expression</em></p>
*/
UNKNOWN_RULE_ATTRIBUTE(65, "unknown attribute '<arg>' for rule '<arg2>' in '<arg3>'", ErrorSeverity.ERROR),
UNKNOWN_RULE_ATTRIBUTE(65, "unknown attribute <arg> for rule <arg2> in <arg3>", ErrorSeverity.ERROR),
/**
* Compiler Error 66.
*
* <p>
* attribute '<em>attribute</em>' isn't a valid property in
* '<em>expression</em>'</p>
* attribute <em>attribute</em> isn't a valid property in
* <em>expression</em></p>
*/
UNKNOWN_ATTRIBUTE_IN_SCOPE(66, "attribute '<arg>' isn't a valid property in '<arg2>'", ErrorSeverity.ERROR),
UNKNOWN_ATTRIBUTE_IN_SCOPE(66, "attribute <arg> isn't a valid property in <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 67.
*
* <p>
* missing attribute access on rule reference '<em>rule</em>' in
* '<em>expression</em>'</p>
* missing attribute access on rule reference <em>rule</em> in
* <em>expression</em></p>
*/
ISOLATED_RULE_REF(67, "missing attribute access on rule reference '<arg>' in '<arg2>'", ErrorSeverity.ERROR),
ISOLATED_RULE_REF(67, "missing attribute access on rule reference <arg> in <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 69.
*
* <p>label '<em>label</em>' conflicts with rule with same name</p>
* <p>label <em>label</em> conflicts with rule with same name</p>
*/
LABEL_CONFLICTS_WITH_RULE(69, "label '<arg>' conflicts with rule with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_RULE(69, "label <arg> conflicts with rule with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 70.
*
* <p>label '<em>label</em>' conflicts with token with same name</p>
* <p>label <em>label</em> conflicts with token with same name</p>
*/
LABEL_CONFLICTS_WITH_TOKEN(70, "label '<arg>' conflicts with token with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_TOKEN(70, "label <arg> conflicts with token with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 72.
*
* <p>label '<em>label</em>' conflicts with parameter with same name</p>
* <p>label <em>label</em> conflicts with parameter with same name</p>
*/
LABEL_CONFLICTS_WITH_ARG(72, "label '<arg>' conflicts with parameter with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_ARG(72, "label <arg> conflicts with parameter with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 73.
*
* <p>label '<em>label</em>' conflicts with return value with same name</p>
* <p>label <em>label</em> conflicts with return value with same name</p>
*/
LABEL_CONFLICTS_WITH_RETVAL(73, "label '<arg>' conflicts with return value with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_RETVAL(73, "label <arg> conflicts with return value with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 74.
*
* <p>label '<em>label</em>' conflicts with local with same name</p>
* <p>label <em>label</em> conflicts with local with same name</p>
*/
LABEL_CONFLICTS_WITH_LOCAL(74, "label '<arg>' conflicts with local with same name", ErrorSeverity.ERROR),
LABEL_CONFLICTS_WITH_LOCAL(74, "label <arg> conflicts with local with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 75.
*
* <p>
* label '<em>label</em>' type mismatch with previous definition:
* label <em>label</em> type mismatch with previous definition:
* <em>message</em></p>
*/
LABEL_TYPE_CONFLICT(75, "label '<arg>' type mismatch with previous definition: <arg2>", ErrorSeverity.ERROR),
LABEL_TYPE_CONFLICT(75, "label <arg> type mismatch with previous definition: <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Error 76.
*
* <p>
* return value '<em>name</em>' conflicts with parameter with same name</p>
* return value <em>name</em> conflicts with parameter with same name</p>
*/
RETVAL_CONFLICTS_WITH_ARG(76, "return value '<arg>' conflicts with parameter with same name", ErrorSeverity.ERROR),
RETVAL_CONFLICTS_WITH_ARG(76, "return value <arg> conflicts with parameter with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 79.
*
@ -326,38 +332,38 @@ public enum ErrorType {
/**
* Compiler Error 80.
*
* <p>rule '<em>rule</em>' has no defined parameters</p>
* <p>rule <em>rule</em> has no defined parameters</p>
*/
RULE_HAS_NO_ARGS(80, "rule '<arg>' has no defined parameters", ErrorSeverity.ERROR),
RULE_HAS_NO_ARGS(80, "rule <arg> has no defined parameters", ErrorSeverity.ERROR),
/**
* Compiler Warning 83.
*
* <p>unsupported option '<em>option</em>'</p>
* <p>unsupported option <em>option</em></p>
*/
ILLEGAL_OPTION(83, "unsupported option '<arg>'", ErrorSeverity.WARNING),
ILLEGAL_OPTION(83, "unsupported option <arg>", ErrorSeverity.WARNING),
/**
* Compiler Warning 84.
*
* <p>unsupported option value '<em>name</em>=<em>value</em>'</p>
* <p>unsupported option value <em>name</em>=<em>value</em></p>
*/
ILLEGAL_OPTION_VALUE(84, "unsupported option value '<arg>=<arg2>'", ErrorSeverity.WARNING),
ILLEGAL_OPTION_VALUE(84, "unsupported option value <arg>=<arg2>", ErrorSeverity.WARNING),
/**
* Compiler Error 94.
*
* <p>redefinition of '<em>action</em>' action</p>
* <p>redefinition of <em>action</em> action</p>
*/
ACTION_REDEFINITION(94, "redefinition of '<arg>' action", ErrorSeverity.ERROR),
ACTION_REDEFINITION(94, "redefinition of <arg> action", ErrorSeverity.ERROR),
/**
* Compiler Error 99.
*
* <p>This error may take any of the following forms.</p>
*
* <ul>
* <li>grammar '<em>grammar</em>' has no rules</li>
* <li>implicitly generated grammar '<em>grammar</em>' has no rules</li>
* <li>grammar <em>grammar</em> has no rules</li>
* <li>implicitly generated grammar <em>grammar</em> has no rules</li>
* </ul>
*/
NO_RULES(99, "<if(arg2.implicitLexerOwner)>implicitly generated <endif>grammar '<arg>' has no rules", ErrorSeverity.ERROR),
NO_RULES(99, "<if(arg2.implicitLexerOwner)>implicitly generated <endif>grammar <arg> has no rules", ErrorSeverity.ERROR),
/**
* Compiler Error 105.
*
@ -369,54 +375,60 @@ public enum ErrorType {
/**
* Compiler Error 106.
*
* <p>rule '<em>rule</em>' is not defined in grammar '<em>grammar</em>'</p>
* <p>rule <em>rule</em> is not defined in grammar <em>grammar</em></p>
*/
NO_SUCH_RULE_IN_SCOPE(106, "rule '<arg2>' is not defined in grammar '<arg>'", ErrorSeverity.ERROR),
NO_SUCH_RULE_IN_SCOPE(106, "rule <arg2> is not defined in grammar <arg>", ErrorSeverity.ERROR),
/**
* Compiler Warning 108.
*
* <p>token name '<em>Token</em>' is already defined</p>
* <p>token name <em>Token</em> is already defined</p>
*/
TOKEN_NAME_REASSIGNMENT(108, "token name '<arg>' is already defined", ErrorSeverity.WARNING),
TOKEN_NAME_REASSIGNMENT(108, "token name <arg> is already defined", ErrorSeverity.WARNING),
/**
* Compiler Warning 109.
*
* <p>options ignored in imported grammar '<em>grammar</em>'</p>
* <p>options ignored in imported grammar <em>grammar</em></p>
*/
OPTIONS_IN_DELEGATE(109, "options ignored in imported grammar '<arg>'", ErrorSeverity.WARNING),
OPTIONS_IN_DELEGATE(109, "options ignored in imported grammar <arg>", ErrorSeverity.WARNING),
/**
* Compiler Error 110.
*
* <p>
* can't find or load grammar '<em>grammar</em>' from
* '<em>filename</em>'</p>
* can't find or load grammar <em>grammar</em> from
* <em>filename</em></p>
*/
CANNOT_FIND_IMPORTED_GRAMMAR(110, "can't find or load grammar '<arg>' from '<arg2>'", ErrorSeverity.ERROR),
CANNOT_FIND_IMPORTED_GRAMMAR(110, "can't find or load grammar <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 111.
*
* <p>
* <em>grammartype</em> grammar '<em>grammar1</em>' cannot import
* <em>grammartype</em> grammar '<em>grammar2</em>'</p>
* <em>grammartype</em> grammar <em>grammar1</em> cannot import
* <em>grammartype</em> grammar <em>grammar2</em></p>
*/
INVALID_IMPORT(111, "<arg.typeString> grammar '<arg.name>' cannot import <arg2.typeString> grammar '<arg2.name>'", ErrorSeverity.ERROR),
INVALID_IMPORT(111, "<arg.typeString> grammar <arg.name> cannot import <arg2.typeString> grammar <arg2.name>", ErrorSeverity.ERROR),
/**
* Compiler Error 113.
*
* <p>
* <em>grammartype</em> grammar '<em>grammar1</em>' and imported
* <em>grammartype</em> grammar '<em>grammar2</em>' both generate
* '<em>recognizer</em>'</p>
* <em>grammartype</em> grammar <em>grammar1</em> and imported
* <em>grammartype</em> grammar <em>grammar2</em> both generate
* <em>recognizer</em></p>
*/
IMPORT_NAME_CLASH(113, "<arg.typeString> grammar '<arg.name>' and imported <arg2.typeString> grammar '<arg2.name>' both generate '<arg2.recognizerName>'", ErrorSeverity.ERROR),
IMPORT_NAME_CLASH(113, "<arg.typeString> grammar <arg.name> and imported <arg2.typeString> grammar <arg2.name> both generate <arg2.recognizerName>", ErrorSeverity.ERROR),
/**
* Compiler Error 160.
*
* <p>cannot find tokens file <em>filename</em></p>
*/
CANNOT_FIND_TOKENS_FILE_REFD_IN_GRAMMAR(160, "cannot find tokens file <arg>", ErrorSeverity.ERROR),
/**
* Compiler Warning 118.
*
* <p>
* all operators of alt '<em>alt</em>' of left-recursive rule must have same
* all operators of alt <em>alt</em> of left-recursive rule must have same
* associativity</p>
*/
ALL_OPS_NEED_SAME_ASSOC(118, "all operators of alt '<arg>' of left-recursive rule must have same associativity", ErrorSeverity.WARNING),
ALL_OPS_NEED_SAME_ASSOC(118, "all operators of alt <arg> of left-recursive rule must have same associativity", ErrorSeverity.WARNING),
/**
* Compiler Error 119.
*
@ -440,30 +452,30 @@ public enum ErrorType {
/**
* Compiler Error 122.
*
* <p>rule '<em>rule</em>': must label all alternatives or none</p>
* <p>rule <em>rule</em>: must label all alternatives or none</p>
*/
RULE_WITH_TOO_FEW_ALT_LABELS(122, "rule '<arg>': must label all alternatives or none", ErrorSeverity.ERROR),
RULE_WITH_TOO_FEW_ALT_LABELS(122, "rule <arg>: must label all alternatives or none", ErrorSeverity.ERROR),
/**
* Compiler Error 123.
*
* <p>
* rule alt label '<em>label</em>' redefined in rule '<em>rule1</em>',
* originally in rule '<em>rule2</em>'</p>
* rule alt label <em>label</em> redefined in rule <em>rule1</em>,
* originally in rule <em>rule2</em></p>
*/
ALT_LABEL_REDEF(123, "rule alt label '<arg>' redefined in rule '<arg2>', originally in rule '<arg3>'", ErrorSeverity.ERROR),
ALT_LABEL_REDEF(123, "rule alt label <arg> redefined in rule <arg2>, originally in rule <arg3>", ErrorSeverity.ERROR),
/**
* Compiler Error 124.
*
* <p>
* rule alt label '<em>label</em>' conflicts with rule '<em>rule</em>'</p>
* rule alt label <em>label</em> conflicts with rule <em>rule</em></p>
*/
ALT_LABEL_CONFLICTS_WITH_RULE(124, "rule alt label '<arg>' conflicts with rule '<arg2>'", ErrorSeverity.ERROR),
ALT_LABEL_CONFLICTS_WITH_RULE(124, "rule alt label <arg> conflicts with rule <arg2>", ErrorSeverity.ERROR),
/**
* Compiler Warning 125.
*
* <p>implicit definition of token '<em>Token</em>' in parser</p>
* <p>implicit definition of token <em>Token</em> in parser</p>
*/
IMPLICIT_TOKEN_DEFINITION(125, "implicit definition of token '<arg>' in parser", ErrorSeverity.WARNING),
IMPLICIT_TOKEN_DEFINITION(125, "implicit definition of token <arg> in parser", ErrorSeverity.WARNING),
/**
* Compiler Error 126.
*
@ -483,9 +495,9 @@ public enum ErrorType {
/**
* Compiler Error 130.
*
* <p>label '<em>label</em>' assigned to a block which is not a set</p>
* <p>label <em>label</em> assigned to a block which is not a set</p>
*/
LABEL_BLOCK_NOT_A_SET(130, "label '<arg>' assigned to a block which is not a set", ErrorSeverity.ERROR),
LABEL_BLOCK_NOT_A_SET(130, "label <arg> assigned to a block which is not a set", ErrorSeverity.ERROR),
/**
* Compiler Warning 131.
*
@ -501,97 +513,97 @@ public enum ErrorType {
* Compiler Error 132.
*
* <p>
* action in lexer rule '<em>rule</em>' must be last element of single
* action in lexer rule <em>rule</em> must be last element of single
* outermost alt</p>
*
* @deprecated This error is no longer issued by ANTLR 4.2.
*/
@Deprecated
LEXER_ACTION_PLACEMENT_ISSUE(132, "action in lexer rule '<arg>' must be last element of single outermost alt", ErrorSeverity.ERROR),
LEXER_ACTION_PLACEMENT_ISSUE(132, "action in lexer rule <arg> must be last element of single outermost alt", ErrorSeverity.ERROR),
/**
* Compiler Error 133.
*
* <p>
* {@code ->command} in lexer rule '<em>rule</em>' must be last element of
* {@code ->command} in lexer rule <em>rule</em> must be last element of
* single outermost alt</p>
*/
LEXER_COMMAND_PLACEMENT_ISSUE(133, "->command in lexer rule '<arg>' must be last element of single outermost alt", ErrorSeverity.ERROR),
LEXER_COMMAND_PLACEMENT_ISSUE(133, "->command in lexer rule <arg> must be last element of single outermost alt", ErrorSeverity.ERROR),
/**
* Compiler Error 134.
*
* <p>
* symbol '<em>symbol</em>' conflicts with generated code in target language
* symbol <em>symbol</em> conflicts with generated code in target language
* or runtime</p>
*
* <p>
* Note: This error has the same number as the unrelated error
* {@link #UNSUPPORTED_REFERENCE_IN_LEXER_SET}.</p>
*/
USE_OF_BAD_WORD(134, "symbol '<arg>' conflicts with generated code in target language or runtime", ErrorSeverity.ERROR),
USE_OF_BAD_WORD(134, "symbol <arg> conflicts with generated code in target language or runtime", ErrorSeverity.ERROR),
/**
* Compiler Error 134.
*
* <p>rule reference '<em>rule</em>' is not currently supported in a set</p>
* <p>rule reference <em>rule</em> is not currently supported in a set</p>
*
* <p>
* Note: This error has the same number as the unrelated error
* {@link #USE_OF_BAD_WORD}.</p>
*/
UNSUPPORTED_REFERENCE_IN_LEXER_SET(134, "rule reference '<arg>' is not currently supported in a set", ErrorSeverity.ERROR),
UNSUPPORTED_REFERENCE_IN_LEXER_SET(134, "rule reference <arg> is not currently supported in a set", ErrorSeverity.ERROR),
/**
* Compiler Error 135.
*
* <p>cannot assign a value to list label '<em>label</em>'</p>
* <p>cannot assign a value to list label <em>label</em></p>
*/
ASSIGNMENT_TO_LIST_LABEL(135, "cannot assign a value to list label '<arg>'", ErrorSeverity.ERROR),
ASSIGNMENT_TO_LIST_LABEL(135, "cannot assign a value to list label <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 136.
*
* <p>return value '<em>name</em>' conflicts with rule with same name</p>
* <p>return value <em>name</em> conflicts with rule with same name</p>
*/
RETVAL_CONFLICTS_WITH_RULE(136, "return value '<arg>' conflicts with rule with same name", ErrorSeverity.ERROR),
RETVAL_CONFLICTS_WITH_RULE(136, "return value <arg> conflicts with rule with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 137.
*
* <p>return value '<em>name</em>' conflicts with token with same name</p>
* <p>return value <em>name</em> conflicts with token with same name</p>
*/
RETVAL_CONFLICTS_WITH_TOKEN(137, "return value '<arg>' conflicts with token with same name", ErrorSeverity.ERROR),
RETVAL_CONFLICTS_WITH_TOKEN(137, "return value <arg> conflicts with token with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 138.
*
* <p>parameter '<em>parameter</em>' conflicts with rule with same name</p>
* <p>parameter <em>parameter</em> conflicts with rule with same name</p>
*/
ARG_CONFLICTS_WITH_RULE(138, "parameter '<arg>' conflicts with rule with same name", ErrorSeverity.ERROR),
ARG_CONFLICTS_WITH_RULE(138, "parameter <arg> conflicts with rule with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 139.
*
* <p>parameter '<em>parameter</em>' conflicts with token with same name</p>
* <p>parameter <em>parameter</em> conflicts with token with same name</p>
*/
ARG_CONFLICTS_WITH_TOKEN(139, "parameter '<arg>' conflicts with token with same name", ErrorSeverity.ERROR),
ARG_CONFLICTS_WITH_TOKEN(139, "parameter <arg> conflicts with token with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 140.
*
* <p>local '<em>local</em>' conflicts with rule with same name</p>
* <p>local <em>local</em> conflicts with rule with same name</p>
*/
LOCAL_CONFLICTS_WITH_RULE(140, "local '<arg>' conflicts with rule with same name", ErrorSeverity.ERROR),
LOCAL_CONFLICTS_WITH_RULE(140, "local <arg> conflicts with rule with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 141.
*
* <p>local '<em>local</em>' conflicts with rule token same name</p>
* <p>local <em>local</em> conflicts with rule token same name</p>
*/
LOCAL_CONFLICTS_WITH_TOKEN(141, "local '<arg>' conflicts with rule token same name", ErrorSeverity.ERROR),
LOCAL_CONFLICTS_WITH_TOKEN(141, "local <arg> conflicts with rule token same name", ErrorSeverity.ERROR),
/**
* Compiler Error 142.
*
* <p>local '<em>local</em>' conflicts with parameter with same name</p>
* <p>local <em>local</em> conflicts with parameter with same name</p>
*/
LOCAL_CONFLICTS_WITH_ARG(142, "local '<arg>' conflicts with parameter with same name", ErrorSeverity.ERROR),
LOCAL_CONFLICTS_WITH_ARG(142, "local <arg> conflicts with parameter with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 143.
*
* <p>local '<em>local</em>' conflicts with return value with same name</p>
* <p>local <em>local</em> conflicts with return value with same name</p>
*/
LOCAL_CONFLICTS_WITH_RETVAL(143, "local '<arg>' conflicts with return value with same name", ErrorSeverity.ERROR),
LOCAL_CONFLICTS_WITH_RETVAL(143, "local <arg> conflicts with return value with same name", ErrorSeverity.ERROR),
/**
* Compiler Error 144.
*
@ -604,18 +616,18 @@ public enum ErrorType {
* Compiler Error 145.
*
* <p>
* lexer mode '<em>mode</em>' must contain at least one non-fragment
* lexer mode <em>mode</em> must contain at least one non-fragment
* rule</p>
*
* <p>
* Every lexer mode must contain at least one rule which is not declared
* with the {@code fragment} modifier.</p>
*/
MODE_WITHOUT_RULES(145, "lexer mode '<arg>' must contain at least one non-fragment rule", ErrorSeverity.ERROR),
MODE_WITHOUT_RULES(145, "lexer mode <arg> must contain at least one non-fragment rule", ErrorSeverity.ERROR),
/**
* Compiler Warning 146.
*
* <p>non-fragment lexer rule '<em>rule</em>' can match the empty string</p>
* <p>non-fragment lexer rule <em>rule</em> can match the empty string</p>
*
* <p>All non-fragment lexer rules must match at least one character.</p>
*
@ -630,12 +642,12 @@ public enum ErrorType {
* Whitespace : [ \t]*; // error 146
* </pre>
*/
EPSILON_TOKEN(146, "non-fragment lexer rule '<arg>' can match the empty string", ErrorSeverity.WARNING),
EPSILON_TOKEN(146, "non-fragment lexer rule <arg> can match the empty string", ErrorSeverity.WARNING),
/**
* Compiler Error 147.
*
* <p>
* left recursive rule '<em>rule</em>' must contain an alternative which is
* left recursive rule <em>rule</em> must contain an alternative which is
* not left recursive</p>
*
* <p>Left-recursive rules must contain at least one alternative which is not
@ -650,12 +662,12 @@ public enum ErrorType {
* ;
* </pre>
*/
NO_NON_LR_ALTS(147, "left recursive rule '<arg>' must contain an alternative which is not left recursive", ErrorSeverity.ERROR),
NO_NON_LR_ALTS(147, "left recursive rule <arg> must contain an alternative which is not left recursive", ErrorSeverity.ERROR),
/**
* Compiler Error 148.
*
* <p>
* left recursive rule '<em>rule</em>' contains a left recursive alternative
* left recursive rule <em>rule</em> contains a left recursive alternative
* which can be followed by the empty string</p>
*
* <p>In left-recursive rules, all left-recursive alternatives must match at
@ -670,12 +682,12 @@ public enum ErrorType {
* ;
* </pre>
*/
EPSILON_LR_FOLLOW(148, "left recursive rule '<arg>' contains a left recursive alternative which can be followed by the empty string", ErrorSeverity.ERROR),
EPSILON_LR_FOLLOW(148, "left recursive rule <arg> contains a left recursive alternative which can be followed by the empty string", ErrorSeverity.ERROR),
/**
* Compiler Error 149.
*
* <p>
* lexer command '<em>command</em>' does not exist or is not supported by
* lexer command <em>command</em> does not exist or is not supported by
* the current target</p>
*
* <p>Each lexer command requires an explicit implementation in the target
@ -685,34 +697,34 @@ public enum ErrorType {
* <p>The following rule produces this error.</p>
*
* <pre>
* X : 'foo' -> type(Foo); // ok
* Y : 'foo' -> token(Foo); // error 149 (token is not a supported lexer command)
* X : foo -> type(Foo); // ok
* Y : foo -> token(Foo); // error 149 (token is not a supported lexer command)
* </pre>
*
* @since 4.1
*/
INVALID_LEXER_COMMAND(149, "lexer command '<arg>' does not exist or is not supported by the current target", ErrorSeverity.ERROR),
INVALID_LEXER_COMMAND(149, "lexer command <arg> does not exist or is not supported by the current target", ErrorSeverity.ERROR),
/**
* Compiler Error 150.
*
* <p>missing argument for lexer command '<em>command</em>'</p>
* <p>missing argument for lexer command <em>command</em></p>
*
* <p>Some lexer commands require an argument.</p>
*
* <p>The following rule produces this error.</p>
*
* <pre>
* X : 'foo' -> type(Foo); // ok
* Y : 'foo' -> type; // error 150 (the type command requires an argument)
* X : foo -> type(Foo); // ok
* Y : foo -> type; // error 150 (the type command requires an argument)
* </pre>
*
* @since 4.1
*/
MISSING_LEXER_COMMAND_ARGUMENT(150, "missing argument for lexer command '<arg>'", ErrorSeverity.ERROR),
MISSING_LEXER_COMMAND_ARGUMENT(150, "missing argument for lexer command <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 151.
*
* <p>lexer command '<em>command</em>' does not take any arguments</p>
* <p>lexer command <em>command</em> does not take any arguments</p>
*
* <p>A lexer command which does not take parameters was invoked with an
* argument.</p>
@ -720,13 +732,13 @@ public enum ErrorType {
* <p>The following rule produces this error.</p>
*
* <pre>
* X : 'foo' -> popMode; // ok
* Y : 'foo' -> popMode(A); // error 151 (the popMode command does not take an argument)
* X : foo -> popMode; // ok
* Y : foo -> popMode(A); // error 151 (the popMode command does not take an argument)
* </pre>
*
* @since 4.1
*/
UNWANTED_LEXER_COMMAND_ARGUMENT(151, "lexer command '<arg>' does not take any arguments", ErrorSeverity.ERROR),
UNWANTED_LEXER_COMMAND_ARGUMENT(151, "lexer command <arg> does not take any arguments", ErrorSeverity.ERROR),
/**
* Compiler Error 152.
*
@ -737,8 +749,8 @@ public enum ErrorType {
* <p>The following rule produces this error.</p>
*
* <pre>
* x : 'x'; // ok
* y : 'y; // error 152
* x : x; // ok
* y : y; // error 152
* </pre>
*
* @since 4.1
@ -748,7 +760,7 @@ public enum ErrorType {
* Compiler Error 153.
*
* <p>
* rule '<em>rule</em>' contains a closure with at least one alternative
* rule <em>rule</em> contains a closure with at least one alternative
* that can match an empty string</p>
*
* <p>A rule contains a closure ({@code (...)*}) or positive closure
@ -759,18 +771,18 @@ public enum ErrorType {
* <pre>
* x : ;
* y : x+; // error 153
* z1 : ('foo' | 'bar'? 'bar2'?)*; // error 153
* z2 : ('foo' | 'bar' 'bar2'? | 'bar2')*; // ok
* z1 : (foo | bar? bar2?)*; // error 153
* z2 : (foo | bar bar2? | bar2)*; // ok
* </pre>
*
* @since 4.1
*/
EPSILON_CLOSURE(153, "rule '<arg>' contains a closure with at least one alternative that can match an empty string", ErrorSeverity.ERROR),
EPSILON_CLOSURE(153, "rule <arg> contains a closure with at least one alternative that can match an empty string", ErrorSeverity.ERROR),
/**
* Compiler Warning 154.
*
* <p>
* rule '<em>rule</em>' contains an optional block with at least one
* rule <em>rule</em> contains an optional block with at least one
* alternative that can match an empty string</p>
*
* <p>A rule contains an optional block ({@code (...)?}) around an empty
@ -781,18 +793,18 @@ public enum ErrorType {
* <pre>
* x : ;
* y : x?; // warning 154
* z1 : ('foo' | 'bar'? 'bar2'?)?; // warning 154
* z2 : ('foo' | 'bar' 'bar2'? | 'bar2')?; // ok
* z1 : (foo | bar? bar2?)?; // warning 154
* z2 : (foo | bar bar2? | bar2)?; // ok
* </pre>
*
* @since 4.1
*/
EPSILON_OPTIONAL(154, "rule '<arg>' contains an optional block with at least one alternative that can match an empty string", ErrorSeverity.WARNING),
EPSILON_OPTIONAL(154, "rule <arg> contains an optional block with at least one alternative that can match an empty string", ErrorSeverity.WARNING),
/**
* Compiler Warning 155.
*
* <p>
* rule '<em>rule</em>' contains a lexer command with an unrecognized
* rule <em>rule</em> contains a lexer command with an unrecognized
* constant value; lexer interpreters may produce incorrect output</p>
*
* <p>A lexer rule contains a standard lexer command, but the constant value
@ -808,13 +820,13 @@ public enum ErrorType {
* public static final int CUSTOM = HIDDEN + 1;
* }
*
* X : 'foo' -> channel(HIDDEN); // ok
* Y : 'bar' -> channel(CUSTOM); // warning 155
* X : foo -> channel(HIDDEN); // ok
* Y : bar -> channel(CUSTOM); // warning 155
* </pre>
*
* @since 4.2
*/
UNKNOWN_LEXER_CONSTANT(155, "rule '<arg>' contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output", ErrorSeverity.WARNING),
UNKNOWN_LEXER_CONSTANT(155, "rule <arg> contains a lexer command with an unrecognized constant value; lexer interpreters may produce incorrect output", ErrorSeverity.WARNING),
/**
* Compiler Error 156.
*
@ -825,8 +837,8 @@ public enum ErrorType {
* <p>The following rule produces this error.</p>
*
* <pre>
* x : 'x'; // ok
* y : '\u005Cu'; // error 156
* x : x; // ok
* y : \u005Cu; // error 156
* </pre>
*
* @since 4.2.1
@ -835,7 +847,7 @@ public enum ErrorType {
/**
* Compiler Warning 157.
*
* <p>rule '<em>rule</em>' contains an 'assoc' element option in an
* <p>rule <em>rule</em> contains an assoc element option in an
* unrecognized location</p>
*
* <p>
@ -849,19 +861,19 @@ public enum ErrorType {
* <p>The following rule produces this warning.</p>
*
* <pre>
* x : 'x'
* | x '+'&lt;assoc=right&gt; x // warning 157
* |&lt;assoc=right&gt; x '*' x // ok
* x : x
* | x +&lt;assoc=right&gt; x // warning 157
* |&lt;assoc=right&gt; x * x // ok
* ;
* </pre>
*
* @since 4.2.1
*/
UNRECOGNIZED_ASSOC_OPTION(157, "rule '<arg>' contains an 'assoc' terminal option in an unrecognized location", ErrorSeverity.WARNING),
UNRECOGNIZED_ASSOC_OPTION(157, "rule <arg> contains an assoc terminal option in an unrecognized location", ErrorSeverity.WARNING),
/**
* Compiler Warning 158.
*
* <p>fragment rule '<em>rule</em>' contains an action or command which can
* <p>fragment rule <em>rule</em> contains an action or command which can
* never be executed</p>
*
* <p>A lexer rule which is marked with the {@code fragment} modifier
@ -874,38 +886,38 @@ public enum ErrorType {
* <p>The following rule produces this warning.</p>
*
* <pre>
* X1 : 'x' -> more // ok
* X1 : x -> more // ok
* ;
* Y1 : 'x' {more();} // ok
* Y1 : x {more();} // ok
* ;
* fragment
* X2 : 'x' -> more // warning 158
* X2 : x -> more // warning 158
* ;
* fragment
* Y2 : 'x' {more();} // warning 158
* Y2 : x {more();} // warning 158
* ;
* </pre>
*
* @since 4.2.1
*/
FRAGMENT_ACTION_IGNORED(158, "fragment rule '<arg>' contains an action or command which can never be executed", ErrorSeverity.WARNING),
FRAGMENT_ACTION_IGNORED(158, "fragment rule <arg> contains an action or command which can never be executed", ErrorSeverity.WARNING),
/**
* Compiler Error 159.
*
* <p>cannot declare a rule with reserved name '<em>rule</em>'</p>
* <p>cannot declare a rule with reserved name <em>rule</em></p>
*
* <p>A rule was declared with a reserved name.</p>
*
* <p>The following rule produces this error.</p>
*
* <pre>
* EOF : ' ' // error 159 (EOF is a reserved name)
* EOF : // error 159 (EOF is a reserved name)
* ;
* </pre>
*
* @since 4.2.1
*/
RESERVED_RULE_NAME(159, "cannot declare a rule with reserved name '<arg>'", ErrorSeverity.ERROR),
RESERVED_RULE_NAME(159, "cannot declare a rule with reserved name <arg>", ErrorSeverity.ERROR),
/*
* Backward incompatibility errors
@ -944,7 +956,7 @@ public enum ErrorType {
* Compiler Warning 202.
*
* <p>
* '{@code tokens {A; B;}}' syntax is now '{@code tokens {A, B}}' in ANTLR
* {@code tokens {A; B;}} syntax is now {@code tokens {A, B}} in ANTLR
* 4</p>
*
* <p>
@ -956,13 +968,13 @@ public enum ErrorType {
* <strong>NOTE:</strong> ANTLR 4 does not allow a trailing comma to appear following the
* last token declared in the {@code tokens{}} block.</p>
*/
V3_TOKENS_SYNTAX(202, "'tokens {A; B;}' syntax is now 'tokens {A, B}' in ANTLR 4", ErrorSeverity.WARNING),
V3_TOKENS_SYNTAX(202, "tokens {A; B;} syntax is now tokens {A, B} in ANTLR 4", ErrorSeverity.WARNING),
/**
* Compiler Error 203.
*
* <p>
* assignments in {@code tokens{}} are not supported in ANTLR 4; use lexical
* rule '<em>TokenName</em> : <em>LiteralValue</em>;' instead</p>
* rule <em>TokenName</em> : <em>LiteralValue</em>; instead</p>
*
* <p>
* ANTLR 3 allowed literal tokens to be declared and assigned a value within
@ -971,7 +983,7 @@ public enum ErrorType {
* value declared in the {@code tokens{}} block should be converted to
* standard lexer rules.</p>
*/
V3_ASSIGN_IN_TOKENS(203, "assignments in tokens{} are not supported in ANTLR 4; use lexical rule '<arg> : <arg2>;' instead", ErrorSeverity.ERROR),
V3_ASSIGN_IN_TOKENS(203, "assignments in tokens{} are not supported in ANTLR 4; use lexical rule <arg> : <arg2>; instead", ErrorSeverity.ERROR),
/**
* Compiler Warning 204.
*
@ -993,7 +1005,7 @@ public enum ErrorType {
* <p>{@code (...)=>} syntactic predicates are not supported in ANTLR 4</p>
*
* <p>
* ANTLR 4's improved lookahead algorithms do not require the use of
* ANTLR 4s improved lookahead algorithms do not require the use of
* syntactic predicates to disambiguate long lookahead sequences. The
* syntactic predicates should be removed when migrating a grammar from
* ANTLR 3 to ANTLR 4.</p>

View File

@ -30,6 +30,7 @@
package org.antlr.v4.tool;
import org.antlr.runtime.tree.Tree;
import org.antlr.v4.Tool;
import org.antlr.v4.analysis.LeftRecursiveRuleTransformer;
import org.antlr.v4.misc.CharSupport;
@ -355,7 +356,8 @@ public class Grammar implements AttributeResolver {
GrammarAST t = (GrammarAST)c;
String importedGrammarName = null;
if ( t.getType()==ANTLRParser.ASSIGN ) {
importedGrammarName = t.getChild(1).getText();
t = (GrammarAST)t.getChild(1);
importedGrammarName = t.getText();
tool.log("grammar", "import "+ importedGrammarName);
}
else if ( t.getType()==ANTLRParser.ID ) {
@ -364,11 +366,14 @@ public class Grammar implements AttributeResolver {
}
Grammar g;
try {
g = tool.loadImportedGrammar(this, importedGrammarName);
g = tool.loadImportedGrammar(this, t);
}
catch (IOException ioe) {
tool.errMgr.toolError(ErrorType.CANNOT_FIND_IMPORTED_GRAMMAR, ioe,
importedGrammarName);
tool.errMgr.grammarError(ErrorType.ERROR_READING_IMPORTED_GRAMMAR,
importedGrammarName,
t.getToken(),
importedGrammarName,
name);
continue;
}
// did it come back as error node or missing?
@ -811,7 +816,7 @@ public class Grammar implements AttributeResolver {
public void importTokensFromTokensFile() {
String vocab = getOptionString("tokenVocab");
if ( vocab!=null ) {
TokenVocabParser vparser = new TokenVocabParser(tool, vocab);
TokenVocabParser vparser = new TokenVocabParser(this);
Map<String,Integer> tokens = vparser.load();
tool.log("grammar", "tokens=" + tokens);
for (String t : tokens.keySet()) {

View File

@ -33,40 +33,17 @@ package org.antlr.v4.tool;
import org.antlr.runtime.Token;
/** A problem with the symbols and/or meaning of a grammar such as rule
* redefinition.
* redefinition. Any msg where we can point to a location in the grammar.
*/
public class GrammarSemanticsMessage extends ANTLRMessage {
public Grammar g;
/** Most of the time, we'll have a token such as an undefined rule ref
* and so this will be set.
*/
public Token offendingToken;
/*
public GrammarSemanticsMessage(ErrorType etype,
Grammar g,
Token offendingToken,
Object... args)
{
super(etype,args);
this.g = g;
if ( g!=null ) fileName = g.fileName;
this.offendingToken = offendingToken;
if ( offendingToken!=null ) {
line = offendingToken.getLine();
charPosition = offendingToken.getCharPositionInLine();
}
}
*/
public GrammarSemanticsMessage(ErrorType etype,
String fileName,
Token offendingToken,
Object... args)
{
super(etype,args);
super(etype,offendingToken,args);
this.fileName = fileName;
this.offendingToken = offendingToken;
if ( offendingToken!=null ) {
if ( offendingToken!=null ) {
line = offendingToken.getLine();
charPosition = offendingToken.getCharPositionInLine();
}

View File

@ -37,17 +37,13 @@ import org.antlr.runtime.Token;
* "The '{' came as a complete surprise to me at this point in your program"
*/
public class GrammarSyntaxMessage extends ANTLRMessage {
public Grammar g;
/** Most of the time, we'll have a token and so this will be set. */
public Token offendingToken;
public GrammarSyntaxMessage(ErrorType etype,
String fileName,
Token offendingToken,
RecognitionException antlrException,
Object... args)
{
super(etype, antlrException, args);
super(etype, antlrException, offendingToken, args);
this.fileName = fileName;
this.offendingToken = offendingToken;
if ( offendingToken!=null ) {

View File

@ -30,14 +30,13 @@
package org.antlr.v4.tool;
import org.antlr.runtime.Token;
import java.util.Collection;
public class LeftRecursionCyclesMessage extends ANTLRMessage {
public Collection<? extends Collection<Rule>> cycles;
public LeftRecursionCyclesMessage(String fileName, Collection<? extends Collection<Rule>> cycles) {
super(ErrorType.LEFT_RECURSION_CYCLES, cycles);
this.cycles = cycles;
public LeftRecursionCyclesMessage(String fileName, Token startTokenOfFirstRuleInCycle, Collection<? extends Collection<Rule>> cycles) {
super(ErrorType.LEFT_RECURSION_CYCLES, startTokenOfFirstRuleInCycle, cycles);
this.fileName = fileName;
}
}

View File

@ -30,6 +30,8 @@
package org.antlr.v4.tool;
import org.antlr.runtime.Token;
/** A generic message from the tool such as "file not found" type errors; there
* is no reason to create a special object for each error unlike the grammar
* errors, which may be rather complex.
@ -43,9 +45,9 @@ public class ToolMessage extends ANTLRMessage {
super(errorType);
}
public ToolMessage(ErrorType errorType, Object... args) {
super(errorType, null, args);
super(errorType, null, Token.INVALID_TOKEN, args);
}
public ToolMessage(ErrorType errorType, Throwable e, Object... args) {
super(errorType, e, args);
super(errorType, e, Token.INVALID_TOKEN, args);
}
}

View File

@ -16,7 +16,7 @@
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
@ -55,8 +55,8 @@ public class TestAttributeChecks extends BaseTest {
"c : ;\n";
String[] membersChecks = {
"$a", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:2:11: unknown attribute reference 'a' in '$a'\n",
"$a.y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:2:11: unknown attribute reference 'a' in '$a.y'\n",
"$a", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:2:11: unknown attribute reference a in $a\n",
"$a.y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:2:11: unknown attribute reference a in $a.y\n",
};
String[] initChecks = {
@ -68,8 +68,8 @@ public class TestAttributeChecks extends BaseTest {
"$ids", "",
"$labs", "",
"$c", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:5:8: unknown attribute reference 'c' in '$c'\n",
"$a.q", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:5:10: unknown attribute 'q' for rule 'a' in '$a.q'\n",
"$c", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:5:8: unknown attribute reference c in $c\n",
"$a.q", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:5:10: unknown attribute q for rule a in $a.q\n",
};
String[] inlineChecks = {
@ -92,21 +92,21 @@ public class TestAttributeChecks extends BaseTest {
};
String[] bad_inlineChecks = {
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:7:4: missing attribute access on rule reference 'lab' in '$lab'\n",
"$q", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'q' in '$q'\n",
"$q.y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'q' in '$q.y'\n",
"$q = 3", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'q' in '$q'\n",
"$q = 3;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'q' in '$q = 3;'\n",
"$q.y = 3;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'q' in '$q.y'\n",
"$q = $blort;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'q' in '$q = $blort;'\n" +
"error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:9: unknown attribute reference 'blort' in '$blort'\n",
"$a.ick", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:7:6: unknown attribute 'ick' for rule 'a' in '$a.ick'\n",
"$a.ick = 3;", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:7:6: unknown attribute 'ick' for rule 'a' in '$a.ick'\n",
"$b.d", "error(" + ErrorType.INVALID_RULE_PARAMETER_REF.code + "): A.g4:7:6: parameter 'd' of rule 'b' is not accessible in this scope: $b.d\n", // can't see rule ref's arg
"$d.text", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'd' in '$d.text'\n", // valid rule, but no ref
"$lab.d", "error(" + ErrorType.INVALID_RULE_PARAMETER_REF.code + "): A.g4:7:8: parameter 'd' of rule 'b' is not accessible in this scope: $lab.d\n",
"$ids = null;", "error(" + ErrorType.ASSIGNMENT_TO_LIST_LABEL.code + "): A.g4:7:4: cannot assign a value to list label 'ids'\n",
"$labs = null;","error(" + ErrorType.ASSIGNMENT_TO_LIST_LABEL.code + "): A.g4:7:4: cannot assign a value to list label 'labs'\n",
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:7:4: missing attribute access on rule reference lab in $lab\n",
"$q", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference q in $q\n",
"$q.y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference q in $q.y\n",
"$q = 3", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference q in $q\n",
"$q = 3;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference q in $q = 3;\n",
"$q.y = 3;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference q in $q.y\n",
"$q = $blort;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference q in $q = $blort;\n" +
"error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:9: unknown attribute reference blort in $blort\n",
"$a.ick", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:7:6: unknown attribute ick for rule a in $a.ick\n",
"$a.ick = 3;", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:7:6: unknown attribute ick for rule a in $a.ick\n",
"$b.d", "error(" + ErrorType.INVALID_RULE_PARAMETER_REF.code + "): A.g4:7:6: parameter d of rule b is not accessible in this scope: $b.d\n", // cant see rule refs arg
"$d.text", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference d in $d.text\n", // valid rule, but no ref
"$lab.d", "error(" + ErrorType.INVALID_RULE_PARAMETER_REF.code + "): A.g4:7:8: parameter d of rule b is not accessible in this scope: $lab.d\n",
"$ids = null;", "error(" + ErrorType.ASSIGNMENT_TO_LIST_LABEL.code + "): A.g4:7:4: cannot assign a value to list label ids\n",
"$labs = null;","error(" + ErrorType.ASSIGNMENT_TO_LIST_LABEL.code + "): A.g4:7:4: cannot assign a value to list label labs\n",
};
String[] finallyChecks = {
@ -121,97 +121,97 @@ public class TestAttributeChecks extends BaseTest {
"$ids", "",
"$labs", "",
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:10:14: missing attribute access on rule reference 'lab' in '$lab'\n",
"$q", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'q' in '$q'\n",
"$q.y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'q' in '$q.y'\n",
"$q = 3", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'q' in '$q'\n",
"$q = 3;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'q' in '$q = 3;'\n",
"$q.y = 3;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'q' in '$q.y'\n",
"$q = $blort;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'q' in '$q = $blort;'\n" +
"error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:19: unknown attribute reference 'blort' in '$blort'\n",
"$a.ick", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:10:16: unknown attribute 'ick' for rule 'a' in '$a.ick'\n",
"$a.ick = 3;", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:10:16: unknown attribute 'ick' for rule 'a' in '$a.ick'\n",
"$b.e", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'b' in '$b.e'\n", // can't see rule refs outside alts
"$b.d", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'b' in '$b.d'\n",
"$c.text", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'c' in '$c.text'\n",
"$lab.d", "error(" + ErrorType.INVALID_RULE_PARAMETER_REF.code + "): A.g4:10:18: parameter 'd' of rule 'b' is not accessible in this scope: $lab.d\n",
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:10:14: missing attribute access on rule reference lab in $lab\n",
"$q", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference q in $q\n",
"$q.y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference q in $q.y\n",
"$q = 3", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference q in $q\n",
"$q = 3;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference q in $q = 3;\n",
"$q.y = 3;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference q in $q.y\n",
"$q = $blort;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference q in $q = $blort;\n" +
"error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:19: unknown attribute reference blort in $blort\n",
"$a.ick", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:10:16: unknown attribute ick for rule a in $a.ick\n",
"$a.ick = 3;", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:10:16: unknown attribute ick for rule a in $a.ick\n",
"$b.e", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference b in $b.e\n", // cant see rule refs outside alts
"$b.d", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference b in $b.d\n",
"$c.text", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference c in $c.text\n",
"$lab.d", "error(" + ErrorType.INVALID_RULE_PARAMETER_REF.code + "): A.g4:10:18: parameter d of rule b is not accessible in this scope: $lab.d\n",
};
String[] dynMembersChecks = {
"$S", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:2:11: unknown attribute reference 'S' in '$S'\n",
"$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule 'S' in non-local ref '$S::i'\n",
"$S::i=$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule 'S' in non-local ref '$S::i'\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:17: reference to undefined rule 'S' in non-local ref '$S::i'\n",
"$S", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:2:11: unknown attribute reference S in $S\n",
"$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule S in non-local ref $S::i\n",
"$S::i=$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule S in non-local ref $S::i\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:17: reference to undefined rule S in non-local ref $S::i\n",
"$b::f", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:2:14: unknown attribute 'f' for rule 'b' in '$b::f'\n",
"$S::j", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule 'S' in non-local ref '$S::j'\n",
"$S::j = 3;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule 'S' in non-local ref '$S::j = 3;'\n",
"$S::j = $S::k;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule 'S' in non-local ref '$S::j = $S::k;'\n",
"$b::f", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:2:14: unknown attribute f for rule b in $b::f\n",
"$S::j", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule S in non-local ref $S::j\n",
"$S::j = 3;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule S in non-local ref $S::j = 3;\n",
"$S::j = $S::k;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:2:11: reference to undefined rule S in non-local ref $S::j = $S::k;\n",
};
String[] dynInitChecks = {
"$a", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:5:8: missing attribute access on rule reference 'a' in '$a'\n",
"$b", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:5:8: unknown attribute reference 'b' in '$b'\n",
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:5:8: missing attribute access on rule reference 'lab' in '$lab'\n",
"$b::f", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:5:11: unknown attribute 'f' for rule 'b' in '$b::f'\n",
"$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule 'S' in non-local ref '$S::i'\n",
"$S::i=$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule 'S' in non-local ref '$S::i'\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:14: reference to undefined rule 'S' in non-local ref '$S::i'\n",
"$a::z", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:5:11: unknown attribute 'z' for rule 'a' in '$a::z'\n",
"$S", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:5:8: unknown attribute reference 'S' in '$S'\n",
"$a", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:5:8: missing attribute access on rule reference a in $a\n",
"$b", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:5:8: unknown attribute reference b in $b\n",
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:5:8: missing attribute access on rule reference lab in $lab\n",
"$b::f", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:5:11: unknown attribute f for rule b in $b::f\n",
"$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule S in non-local ref $S::i\n",
"$S::i=$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule S in non-local ref $S::i\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:14: reference to undefined rule S in non-local ref $S::i\n",
"$a::z", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:5:11: unknown attribute z for rule a in $a::z\n",
"$S", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:5:8: unknown attribute reference S in $S\n",
"$S::j", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule 'S' in non-local ref '$S::j'\n",
"$S::j = 3;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule 'S' in non-local ref '$S::j = 3;'\n",
"$S::j = $S::k;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule 'S' in non-local ref '$S::j = $S::k;'\n",
"$S::j", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule S in non-local ref $S::j\n",
"$S::j = 3;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule S in non-local ref $S::j = 3;\n",
"$S::j = $S::k;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:5:8: reference to undefined rule S in non-local ref $S::j = $S::k;\n",
};
String[] dynInlineChecks = {
"$a", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:7:4: missing attribute access on rule reference 'a' in '$a'\n",
"$b", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:7:4: missing attribute access on rule reference 'b' in '$b'\n",
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:7:4: missing attribute access on rule reference 'lab' in '$lab'\n",
"$b::f", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:7:7: unknown attribute 'f' for rule 'b' in '$b::f'\n",
"$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule 'S' in non-local ref '$S::i'\n",
"$S::i=$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule 'S' in non-local ref '$S::i'\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:10: reference to undefined rule 'S' in non-local ref '$S::i'\n",
"$a::z", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:7:7: unknown attribute 'z' for rule 'a' in '$a::z'\n",
"$a", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:7:4: missing attribute access on rule reference a in $a\n",
"$b", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:7:4: missing attribute access on rule reference b in $b\n",
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:7:4: missing attribute access on rule reference lab in $lab\n",
"$b::f", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:7:7: unknown attribute f for rule b in $b::f\n",
"$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule S in non-local ref $S::i\n",
"$S::i=$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule S in non-local ref $S::i\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:10: reference to undefined rule S in non-local ref $S::i\n",
"$a::z", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:7:7: unknown attribute z for rule a in $a::z\n",
"$S::j", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule 'S' in non-local ref '$S::j'\n",
"$S::j = 3;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule 'S' in non-local ref '$S::j = 3;'\n",
"$S::j = $S::k;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule 'S' in non-local ref '$S::j = $S::k;'\n",
"$Q[-1]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'Q' in '$Q'\n",
"$Q[-i]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'Q' in '$Q'\n",
"$Q[i]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'Q' in '$Q'\n",
"$Q[0]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'Q' in '$Q'\n",
"$Q[-1]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'Q' in '$Q'\n",
"$Q[-i]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'Q' in '$Q'\n",
"$Q[i]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'Q' in '$Q'\n",
"$Q[0]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'Q' in '$Q'\n",
"$S[-1]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'S' in '$S'\n",
"$S[-i]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'S' in '$S'\n",
"$S[i]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'S' in '$S'\n",
"$S[0]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'S' in '$S'\n",
"$S[-1]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'S' in '$S'\n",
"$S[-i]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'S' in '$S'\n",
"$S[i]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'S' in '$S'\n",
"$S[0]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'S' in '$S'\n",
"$S[$S::y]::i", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference 'S' in '$S'\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:7: reference to undefined rule 'S' in non-local ref '$S::y'\n"
"$S::j", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule S in non-local ref $S::j\n",
"$S::j = 3;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule S in non-local ref $S::j = 3;\n",
"$S::j = $S::k;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:4: reference to undefined rule S in non-local ref $S::j = $S::k;\n",
"$Q[-1]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference Q in $Q\n",
"$Q[-i]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference Q in $Q\n",
"$Q[i]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference Q in $Q\n",
"$Q[0]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference Q in $Q\n",
"$Q[-1]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference Q in $Q\n",
"$Q[-i]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference Q in $Q\n",
"$Q[i]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference Q in $Q\n",
"$Q[0]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference Q in $Q\n",
"$S[-1]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference S in $S\n",
"$S[-i]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference S in $S\n",
"$S[i]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference S in $S\n",
"$S[0]::y", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference S in $S\n",
"$S[-1]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference S in $S\n",
"$S[-i]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference S in $S\n",
"$S[i]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference S in $S\n",
"$S[0]::y = 23;", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference S in $S\n",
"$S[$S::y]::i", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:7:4: unknown attribute reference S in $S\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:7:7: reference to undefined rule S in non-local ref $S::y\n"
};
String[] dynFinallyChecks = {
"$a", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:10:14: missing attribute access on rule reference 'a' in '$a'\n",
"$b", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'b' in '$b'\n",
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:10:14: missing attribute access on rule reference 'lab' in '$lab'\n",
"$b::f", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:10:17: unknown attribute 'f' for rule 'b' in '$b::f'\n",
"$S", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference 'S' in '$S'\n",
"$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule 'S' in non-local ref '$S::i'\n",
"$S::i=$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule 'S' in non-local ref '$S::i'\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:20: reference to undefined rule 'S' in non-local ref '$S::i'\n",
"$a::z", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:10:17: unknown attribute 'z' for rule 'a' in '$a::z'\n",
"$a", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:10:14: missing attribute access on rule reference a in $a\n",
"$b", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference b in $b\n",
"$lab", "error(" + ErrorType.ISOLATED_RULE_REF.code + "): A.g4:10:14: missing attribute access on rule reference lab in $lab\n",
"$b::f", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:10:17: unknown attribute f for rule b in $b::f\n",
"$S", "error(" + ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE.code + "): A.g4:10:14: unknown attribute reference S in $S\n",
"$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule S in non-local ref $S::i\n",
"$S::i=$S::i", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule S in non-local ref $S::i\n" +
"error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:20: reference to undefined rule S in non-local ref $S::i\n",
"$a::z", "error(" + ErrorType.UNKNOWN_RULE_ATTRIBUTE.code + "): A.g4:10:17: unknown attribute z for rule a in $a::z\n",
"$S::j", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule 'S' in non-local ref '$S::j'\n",
"$S::j = 3;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule 'S' in non-local ref '$S::j = 3;'\n",
"$S::j = $S::k;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule 'S' in non-local ref '$S::j = $S::k;'\n",
"$S::j", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule S in non-local ref $S::j\n",
"$S::j = 3;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule S in non-local ref $S::j = 3;\n",
"$S::j = $S::k;", "error(" + ErrorType.UNDEFINED_RULE_IN_NONLOCAL_REF.code + "): A.g4:10:14: reference to undefined rule S in non-local ref $S::j = $S::k;\n",
};
@Test public void testMembersActions() throws RecognitionException {

View File

@ -54,17 +54,17 @@ public class TestBasicSemanticErrors extends BaseTest {
"b : ( options { ick=bar; greedy=true; } : ID )+ ;\n" +
"c : ID<blue> ID<x=y> ;",
// YIELDS
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:2:10: unsupported option 'foo'\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:2:19: unsupported option 'k'\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:2:10: unsupported option foo\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:2:19: unsupported option k\n" +
"error(" + ErrorType.TOKEN_NAMES_MUST_START_UPPER.code + "): U.g4:5:8: token names must start with an uppercase letter: f\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:9:10: unsupported option 'x'\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:9:10: unsupported option x\n" +
"error(" + ErrorType.REPEATED_PREQUEL.code + "): U.g4:9:0: repeated grammar prequel spec (options, tokens, or import); please merge\n" +
"error(" + ErrorType.REPEATED_PREQUEL.code + "): U.g4:8:0: repeated grammar prequel spec (options, tokens, or import); please merge\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:12:10: unsupported option 'blech'\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:12:21: unsupported option 'greedy'\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:15:16: unsupported option 'ick'\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:15:25: unsupported option 'greedy'\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:16:16: unsupported option 'x'\n",
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:12:10: unsupported option blech\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:12:21: unsupported option greedy\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:15:16: unsupported option ick\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:15:25: unsupported option greedy\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): U.g4:16:16: unsupported option x\n",
};
@Test public void testU() { super.testErrors(U, false); }
@ -82,7 +82,7 @@ public class TestBasicSemanticErrors extends BaseTest {
"";
String expected =
"error(" + ErrorType.LABEL_BLOCK_NOT_A_SET.code + "): T.g4:2:5: label 'op' assigned to a block which is not a set\n";
"error(" + ErrorType.LABEL_BLOCK_NOT_A_SET.code + "): T.g4:2:5: label op assigned to a block which is not a set\n";
testErrors(new String[] { grammar, expected }, false);
}
@ -97,16 +97,16 @@ public class TestBasicSemanticErrors extends BaseTest {
"expr : '=';\n";
String expected =
"error(" + ErrorType.ARG_CONFLICTS_WITH_RULE.code + "): T.g4:2:7: parameter 'expr' conflicts with rule with same name\n" +
"error(" + ErrorType.RETVAL_CONFLICTS_WITH_RULE.code + "): T.g4:2:26: return value 'expr' conflicts with rule with same name\n" +
"error(" + ErrorType.LOCAL_CONFLICTS_WITH_RULE.code + "): T.g4:3:12: local 'expr' conflicts with rule with same name\n" +
"error(" + ErrorType.RETVAL_CONFLICTS_WITH_ARG.code + "): T.g4:2:26: return value 'expr' conflicts with parameter with same name\n" +
"error(" + ErrorType.LOCAL_CONFLICTS_WITH_ARG.code + "): T.g4:3:12: local 'expr' conflicts with parameter with same name\n" +
"error(" + ErrorType.LOCAL_CONFLICTS_WITH_RETVAL.code + "): T.g4:3:12: local 'expr' conflicts with return value with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_RULE.code + "): T.g4:4:4: label 'expr' conflicts with rule with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_ARG.code + "): T.g4:4:4: label 'expr' conflicts with parameter with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_RETVAL.code + "): T.g4:4:4: label 'expr' conflicts with return value with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_LOCAL.code + "): T.g4:4:4: label 'expr' conflicts with local with same name\n";
"error(" + ErrorType.ARG_CONFLICTS_WITH_RULE.code + "): T.g4:2:7: parameter expr conflicts with rule with same name\n" +
"error(" + ErrorType.RETVAL_CONFLICTS_WITH_RULE.code + "): T.g4:2:26: return value expr conflicts with rule with same name\n" +
"error(" + ErrorType.LOCAL_CONFLICTS_WITH_RULE.code + "): T.g4:3:12: local expr conflicts with rule with same name\n" +
"error(" + ErrorType.RETVAL_CONFLICTS_WITH_ARG.code + "): T.g4:2:26: return value expr conflicts with parameter with same name\n" +
"error(" + ErrorType.LOCAL_CONFLICTS_WITH_ARG.code + "): T.g4:3:12: local expr conflicts with parameter with same name\n" +
"error(" + ErrorType.LOCAL_CONFLICTS_WITH_RETVAL.code + "): T.g4:3:12: local expr conflicts with return value with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_RULE.code + "): T.g4:4:4: label expr conflicts with rule with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_ARG.code + "): T.g4:4:4: label expr conflicts with parameter with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_RETVAL.code + "): T.g4:4:4: label expr conflicts with return value with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_LOCAL.code + "): T.g4:4:4: label expr conflicts with local with same name\n";
ST grammarST = new ST(grammarTemplate);
grammarST.add("args", "int expr");
grammarST.add("retvals", "int expr");

View File

@ -491,7 +491,7 @@ public class TestLeftRecursion extends BaseTest {
"ID : 'a'..'z'+ ;\n" +
"WS : (' '|'\\n') -> skip ;\n";
String expected =
"error(" + ErrorType.NO_NON_LR_ALTS.code + "): T.g4:3:0: left recursive rule 'a' must contain an alternative which is not left recursive\n";
"error(" + ErrorType.NO_NON_LR_ALTS.code + "): T.g4:3:0: left recursive rule a must contain an alternative which is not left recursive\n";
testErrors(new String[] { grammar, expected }, false);
}
@ -505,7 +505,7 @@ public class TestLeftRecursion extends BaseTest {
"ID : 'a'..'z'+ ;\n" +
"WS : (' '|'\\n') -> skip ;\n";
String expected =
"error(" + ErrorType.EPSILON_LR_FOLLOW.code + "): T.g4:3:0: left recursive rule 'a' contains a left recursive alternative which can be followed by the empty string\n";
"error(" + ErrorType.EPSILON_LR_FOLLOW.code + "): T.g4:3:0: left recursive rule a contains a left recursive alternative which can be followed by the empty string\n";
testErrors(new String[] { grammar, expected }, false);
}

View File

@ -32,6 +32,7 @@ package org.antlr.v4.test;
import org.antlr.v4.parse.ScopeParser;
import org.antlr.v4.tool.ErrorManager;
import org.antlr.v4.tool.Grammar;
import org.junit.Test;
import static org.junit.Assert.*;
@ -55,11 +56,12 @@ public class TestScopeParsing extends BaseTest {
"i,j, k", "{i=null i, j=null j, k=null k}",
};
@Test public void testArgs() {
@Test public void testArgs() throws Exception {
for (int i = 0; i < argPairs.length; i+=2) {
String input = argPairs[i];
String expected = argPairs[i+1];
String actual = ScopeParser.parseTypedArgList(null, input, new ErrorManager(null)).attributes.toString();
Grammar dummy = new Grammar("grammar T; a:'a';");
String actual = ScopeParser.parseTypedArgList(null, input, dummy).attributes.toString();
assertEquals(expected, actual);
}
}

View File

@ -238,7 +238,7 @@ public class TestSets extends BaseTest {
"a : A {System.out.println($A.text);} ;\n" +
"A : ~('a'|B) ;\n" +
"B : 'b' ;\n",
"error(" + ErrorType.UNSUPPORTED_REFERENCE_IN_LEXER_SET.code + "): T.g4:3:10: rule reference 'B' is not currently supported in a set\n"
"error(" + ErrorType.UNSUPPORTED_REFERENCE_IN_LEXER_SET.code + "): T.g4:3:10: rule reference B is not currently supported in a set\n"
};
super.testErrors(pair, true);
}

View File

@ -54,15 +54,15 @@ public class TestSymbolIssues extends BaseTest {
"\n" +
"ID : 'a'..'z'+ ID ;",
// YIELDS
"error(" + ErrorType.ACTION_REDEFINITION.code + "): A.g4:5:1: redefinition of 'members' action\n" +
"error(" + ErrorType.ACTION_REDEFINITION.code + "): A.g4:7:1: redefinition of 'header' action\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): A.g4:2:10: unsupported option 'opt'\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): A.g4:2:21: unsupported option 'k'\n" +
"error(" + ErrorType.ACTION_REDEFINITION.code + "): A.g4:5:1: redefinition of 'members' action\n" +
"warning(" + ErrorType.IMPLICIT_TOKEN_DEFINITION.code + "): A.g4:9:27: implicit definition of token 'X' in parser\n" +
"warning(" + ErrorType.IMPLICIT_TOKEN_DEFINITION.code + "): A.g4:10:20: implicit definition of token 'Y' in parser\n" +
"warning(" + ErrorType.IMPLICIT_TOKEN_DEFINITION.code + "): A.g4:11:4: implicit definition of token 'FJKD' in parser\n" +
"error(" + ErrorType.RULE_HAS_NO_ARGS.code + "): A.g4:9:37: rule 'b' has no defined parameters\n" +
"error(" + ErrorType.ACTION_REDEFINITION.code + "): A.g4:5:1: redefinition of members action\n" +
"error(" + ErrorType.ACTION_REDEFINITION.code + "): A.g4:7:1: redefinition of header action\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): A.g4:2:10: unsupported option opt\n" +
"warning(" + ErrorType.ILLEGAL_OPTION.code + "): A.g4:2:21: unsupported option k\n" +
"error(" + ErrorType.ACTION_REDEFINITION.code + "): A.g4:5:1: redefinition of members action\n" +
"warning(" + ErrorType.IMPLICIT_TOKEN_DEFINITION.code + "): A.g4:9:27: implicit definition of token X in parser\n" +
"warning(" + ErrorType.IMPLICIT_TOKEN_DEFINITION.code + "): A.g4:10:20: implicit definition of token Y in parser\n" +
"warning(" + ErrorType.IMPLICIT_TOKEN_DEFINITION.code + "): A.g4:11:4: implicit definition of token FJKD in parser\n" +
"error(" + ErrorType.RULE_HAS_NO_ARGS.code + "): A.g4:9:37: rule b has no defined parameters\n" +
"error(" + ErrorType.MISSING_RULE_ARGS.code + "): A.g4:10:31: missing arguments(s) on rule reference: a\n"
};
@ -77,10 +77,10 @@ public class TestSymbolIssues extends BaseTest {
"\n" +
"s : FOO ;",
// YIELDS
"error(" + ErrorType.LABEL_CONFLICTS_WITH_RULE.code + "): B.g4:4:4: label 's' conflicts with rule with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_RULE.code + "): B.g4:4:9: label 'b' conflicts with rule with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_TOKEN.code + "): B.g4:4:15: label 'X' conflicts with token with same name\n" +
"error(" + ErrorType.LABEL_TYPE_CONFLICT.code + "): B.g4:6:9: label 'x' type mismatch with previous definition: TOKEN_LIST_LABEL!=TOKEN_LABEL\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_RULE.code + "): B.g4:4:4: label s conflicts with rule with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_RULE.code + "): B.g4:4:9: label b conflicts with rule with same name\n" +
"error(" + ErrorType.LABEL_CONFLICTS_WITH_TOKEN.code + "): B.g4:4:15: label X conflicts with token with same name\n" +
"error(" + ErrorType.LABEL_TYPE_CONFLICT.code + "): B.g4:6:9: label x type mismatch with previous definition: TOKEN_LIST_LABEL!=TOKEN_LABEL\n" +
"error(" + ErrorType.IMPLICIT_STRING_DEFINITION.code + "): B.g4:4:20: cannot create implicit token for string literal in non-combined grammar: '.'\n"
};
@ -97,8 +97,8 @@ public class TestSymbolIssues extends BaseTest {
" : ID ;",
// YIELDS
"error(" + ErrorType.LABEL_CONFLICTS_WITH_ARG.code + "): D.g4:4:21: label 'j' conflicts with parameter with same name\n" +
"error(" + ErrorType.RETVAL_CONFLICTS_WITH_ARG.code + "): D.g4:6:22: return value 'i' conflicts with parameter with same name\n"
"error(" + ErrorType.LABEL_CONFLICTS_WITH_ARG.code + "): D.g4:4:21: label j conflicts with parameter with same name\n" +
"error(" + ErrorType.RETVAL_CONFLICTS_WITH_ARG.code + "): D.g4:6:22: return value i conflicts with parameter with same name\n"
};
static String[] E = {
@ -112,7 +112,7 @@ public class TestSymbolIssues extends BaseTest {
"a : A ;\n",
// YIELDS
"warning(" + ErrorType.TOKEN_NAME_REASSIGNMENT.code + "): E.g4:3:4: token name 'A' is already defined\n"
"warning(" + ErrorType.TOKEN_NAME_REASSIGNMENT.code + "): E.g4:3:4: token name A is already defined\n"
};
@Test public void testA() { super.testErrors(A, false); }
@ -147,7 +147,7 @@ public class TestSymbolIssues extends BaseTest {
"mode X;\n" +
"fragment B : 'b';",
"error(" + ErrorType.MODE_WITHOUT_RULES.code + "): L.g4:3:5: lexer mode 'X' must contain at least one non-fragment rule\n"
"error(" + ErrorType.MODE_WITHOUT_RULES.code + "): L.g4:3:5: lexer mode X must contain at least one non-fragment rule\n"
};
testErrors(test, false);
@ -162,8 +162,8 @@ public class TestSymbolIssues extends BaseTest {
" B : C;\n" +
" fragment C : A | (A C)?;",
"warning(" + ErrorType.EPSILON_TOKEN.code + "): L.g4:3:0: non-fragment lexer rule 'WS' can match the empty string\n" +
"warning(" + ErrorType.EPSILON_TOKEN.code + "): L.g4:5:2: non-fragment lexer rule 'B' can match the empty string\n"
"warning(" + ErrorType.EPSILON_TOKEN.code + "): L.g4:3:0: non-fragment lexer rule WS can match the empty string\n" +
"warning(" + ErrorType.EPSILON_TOKEN.code + "): L.g4:5:2: non-fragment lexer rule B can match the empty string\n"
};
testErrors(test, false);

View File

@ -39,7 +39,7 @@ public class TestToolSyntaxErrors extends BaseTest {
"grammar A;\n" +
"",
// YIELDS
"error(" + ErrorType.NO_RULES.code + "): A.g4::: grammar 'A' has no rules\n",
"error(" + ErrorType.NO_RULES.code + "): A.g4::: grammar A has no rules\n",
"A;",
"error(" + ErrorType.SYNTAX_ERROR.code + "): A.g4:1:0: syntax error: 'A' came as a complete surprise to me\n",
@ -273,8 +273,8 @@ public class TestToolSyntaxErrors extends BaseTest {
"X : 'foo' -> popmode;\n" + // "meant" to use -> popMode
"Y : 'foo' -> token(Foo);", // "meant" to use -> type(Foo)
"error(" + ErrorType.INVALID_LEXER_COMMAND.code + "): A.g4:4:13: lexer command 'popmode' does not exist or is not supported by the current target\n" +
"error(" + ErrorType.INVALID_LEXER_COMMAND.code + "): A.g4:5:13: lexer command 'token' does not exist or is not supported by the current target\n"
"error(" + ErrorType.INVALID_LEXER_COMMAND.code + "): A.g4:4:13: lexer command popmode does not exist or is not supported by the current target\n" +
"error(" + ErrorType.INVALID_LEXER_COMMAND.code + "): A.g4:5:13: lexer command token does not exist or is not supported by the current target\n"
};
super.testErrors(pair, true);
}
@ -287,8 +287,8 @@ public class TestToolSyntaxErrors extends BaseTest {
"X : 'foo' -> popMode(Foo);\n" + // "meant" to use -> popMode
"Y : 'foo' -> type;", // "meant" to use -> type(Foo)
"error(" + ErrorType.UNWANTED_LEXER_COMMAND_ARGUMENT.code + "): A.g4:4:13: lexer command 'popMode' does not take any arguments\n" +
"error(" + ErrorType.MISSING_LEXER_COMMAND_ARGUMENT.code + "): A.g4:5:13: missing argument for lexer command 'type'\n"
"error(" + ErrorType.UNWANTED_LEXER_COMMAND_ARGUMENT.code + "): A.g4:4:13: lexer command popMode does not take any arguments\n" +
"error(" + ErrorType.MISSING_LEXER_COMMAND_ARGUMENT.code + "): A.g4:5:13: missing argument for lexer command type\n"
};
super.testErrors(pair, true);
}
@ -303,7 +303,7 @@ public class TestToolSyntaxErrors extends BaseTest {
"A : 'a' ;\n" +
"B : 'b' ;\n",
"error(" + ErrorType.RULE_REDEFINITION.code + "): Oops.g4:4:0: rule 'ret_ty' redefinition; previous at line 3\n"
"error(" + ErrorType.RULE_REDEFINITION.code + "): Oops.g4:4:0: rule ret_ty redefinition; previous at line 3\n"
};
super.testErrors(pair, true);
}
@ -317,15 +317,15 @@ public class TestToolSyntaxErrors extends BaseTest {
+ "z1 : ('foo' | 'bar'? 'bar2'?)*;\n"
+ "z2 : ('foo' | 'bar' 'bar2'? | 'bar2')*;\n";
String expected =
"error(" + ErrorType.EPSILON_CLOSURE.code + "): A.g4:3:0: rule 'y1' contains a closure with at least one alternative that can match an empty string\n" +
"error(" + ErrorType.EPSILON_CLOSURE.code + "): A.g4:4:0: rule 'y2' contains a closure with at least one alternative that can match an empty string\n" +
"error(" + ErrorType.EPSILON_CLOSURE.code + "): A.g4:5:0: rule 'z1' contains a closure with at least one alternative that can match an empty string\n";
"error(" + ErrorType.EPSILON_CLOSURE.code + "): A.g4:3:0: rule y1 contains a closure with at least one alternative that can match an empty string\n" +
"error(" + ErrorType.EPSILON_CLOSURE.code + "): A.g4:4:0: rule y2 contains a closure with at least one alternative that can match an empty string\n" +
"error(" + ErrorType.EPSILON_CLOSURE.code + "): A.g4:5:0: rule z1 contains a closure with at least one alternative that can match an empty string\n";
String[] pair = new String[] {
grammar,
expected
};
super.testErrors(pair, true);
}
@ -337,8 +337,8 @@ public class TestToolSyntaxErrors extends BaseTest {
+ "z1 : ('foo' | 'bar'? 'bar2'?)?;\n"
+ "z2 : ('foo' | 'bar' 'bar2'? | 'bar2')?;\n";
String expected =
"warning(" + ErrorType.EPSILON_OPTIONAL.code + "): A.g4:3:0: rule 'y' contains an optional block with at least one alternative that can match an empty string\n" +
"warning(" + ErrorType.EPSILON_OPTIONAL.code + "): A.g4:4:0: rule 'z1' contains an optional block with at least one alternative that can match an empty string\n";
"warning(" + ErrorType.EPSILON_OPTIONAL.code + "): A.g4:3:0: rule y contains an optional block with at least one alternative that can match an empty string\n" +
"warning(" + ErrorType.EPSILON_OPTIONAL.code + "): A.g4:4:0: rule z1 contains an optional block with at least one alternative that can match an empty string\n";
String[] pair = new String[] {
grammar,
@ -373,7 +373,7 @@ public class TestToolSyntaxErrors extends BaseTest {
"WS : [ \\r\\t\\n]+ -> skip ;\n";
String expected =
"";
String[] pair = new String[] { grammar, expected };
super.testErrors(pair, true);
}
@ -464,7 +464,7 @@ public class TestToolSyntaxErrors extends BaseTest {
" |<assoc=right> x '*' x // ok\n" +
" ;\n";
String expected =
"warning(" + ErrorType.UNRECOGNIZED_ASSOC_OPTION.code + "): A.g4:3:10: rule 'x' contains an 'assoc' terminal option in an unrecognized location\n";
"warning(" + ErrorType.UNRECOGNIZED_ASSOC_OPTION.code + "): A.g4:3:10: rule x contains an assoc terminal option in an unrecognized location\n";
String[] pair = new String[] {
grammar,
@ -492,8 +492,8 @@ public class TestToolSyntaxErrors extends BaseTest {
"Y2 : 'x' {more();} // warning 158\n" +
" ;\n";
String expected =
"warning(" + ErrorType.FRAGMENT_ACTION_IGNORED.code + "): A.g4:7:12: fragment rule 'X2' contains an action or command which can never be executed\n" +
"warning(" + ErrorType.FRAGMENT_ACTION_IGNORED.code + "): A.g4:10:9: fragment rule 'Y2' contains an action or command which can never be executed\n";
"warning(" + ErrorType.FRAGMENT_ACTION_IGNORED.code + "): A.g4:7:12: fragment rule X2 contains an action or command which can never be executed\n" +
"warning(" + ErrorType.FRAGMENT_ACTION_IGNORED.code + "): A.g4:10:9: fragment rule Y2 contains an action or command which can never be executed\n";
String[] pair = new String[] {
grammar,
@ -514,7 +514,7 @@ public class TestToolSyntaxErrors extends BaseTest {
"WS : ' ';\n" +
" EOF : 'a';\n";
String expected =
"error(" + ErrorType.RESERVED_RULE_NAME.code + "): A.g4:3:1: cannot declare a rule with reserved name 'EOF'\n";
"error(" + ErrorType.RESERVED_RULE_NAME.code + "): A.g4:3:1: cannot declare a rule with reserved name EOF\n";
String[] pair = new String[] {
grammar,