Fixed @sharwell remarks: typos and etc.

This commit is contained in:
Ivan Kochurkin 2015-10-28 13:22:21 +03:00
parent 9fbef85c1c
commit d692e1f0d9
5 changed files with 20 additions and 25 deletions

View File

@ -198,9 +198,9 @@ public class TestSymbolIssues extends BaseTest {
"C: 'c';",
"error(" + ErrorType.RESERVED_RULE_NAME.code + "): L.g4:5:0: cannot declare a rule with reserved name MIN_CHAR_VALUE\n" +
"error(" + ErrorType.MODE_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:4:0: can not use or declare mode with reserved name MAX_CHAR_VALUE\n" +
"error(" + ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:2:11: can not use or declare channel with reserved name SKIP\n" +
"error(" + ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:2:17: can not use or declare channel with reserved name HIDDEN\n"
"error(" + ErrorType.MODE_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:4:0: cannot use or declare mode with reserved name MAX_CHAR_VALUE\n" +
"error(" + ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:2:11: cannot use or declare channel with reserved name SKIP\n" +
"error(" + ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:2:17: cannot use or declare channel with reserved name HIDDEN\n"
};
testErrors(test, false);
@ -216,9 +216,9 @@ public class TestSymbolIssues extends BaseTest {
"E: 'e' -> type(EOF);\n" +
"F: 'f' -> pushMode(DEFAULT_MODE);",
"error(" + ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:2:18: can not use or declare channel with reserved name SKIP\n" +
"error(" + ErrorType.TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:3:15: can not use or declare token with reserved name MORE\n" +
"error(" + ErrorType.MODE_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:4:15: can not use or declare mode with reserved name SKIP\n"
"error(" + ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:2:18: cannot use or declare channel with reserved name SKIP\n" +
"error(" + ErrorType.TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:3:15: cannot use or declare token with reserved name MORE\n" +
"error(" + ErrorType.MODE_CONFLICTS_WITH_COMMON_CONSTANTS.code + "): L.g4:4:15: cannot use or declare mode with reserved name SKIP\n"
};
testErrors(test, false);

View File

@ -467,11 +467,11 @@ public class TestToolSyntaxErrors extends BaseTest {
"Error3: '';\n" +
"NotError: ' ';";
String expected =
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:2:8: empty strings not allowed\n" +
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:2:16: empty strings not allowed\n" +
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:3:8: empty strings not allowed\n" +
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:4:15: empty strings not allowed\n" +
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:5:8: empty strings not allowed\n";
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:2:8: string literals cannot be empty\n" +
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:2:16: string literals cannot be empty\n" +
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:3:8: string literals cannot be empty\n" +
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:4:15: string literals cannot be empty\n" +
"error(" + ErrorType.EMPTY_STRINGS_NOT_ALLOWED.code + "): T.g4:5:8: string literals cannot be empty\n";
String[] pair = new String[] {
grammar,

View File

@ -83,7 +83,7 @@ public class LexerATNFactory extends ParserATNFactory {
* actions, but are required during code generation for creating
* {@link LexerAction} instances that are usable by a lexer interpreter.
*/
protected static final Map<String, Integer> COMMON_CONSTANTS = new HashMap<String, Integer>();
public static final Map<String, Integer> COMMON_CONSTANTS = new HashMap<String, Integer>();
static {
COMMON_CONSTANTS.put("HIDDEN", Lexer.HIDDEN);
COMMON_CONSTANTS.put("DEFAULT_TOKEN_CHANNEL", Lexer.DEFAULT_TOKEN_CHANNEL);

View File

@ -69,11 +69,6 @@ import java.util.Set;
* tokens and rules from the imported grammars into a single collection.
*/
public class SemanticPipeline {
protected final Set<String> reservedNames = new HashSet<String>();
{
reservedNames.addAll(LexerATNFactory.getCommonConstants());
}
public Grammar g;
public SemanticPipeline(Grammar g) {
@ -295,7 +290,7 @@ public class SemanticPipeline {
g.tool.errMgr.grammarError(ErrorType.CHANNEL_CONFLICTS_WITH_TOKEN, g.fileName, channel.token, channelName);
}
if (reservedNames.contains(channelName)) {
if (LexerATNFactory.COMMON_CONSTANTS.containsKey(channelName)) {
g.tool.errMgr.grammarError(ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, channel.token, channelName);
}

View File

@ -978,9 +978,9 @@ public enum ErrorType {
*
* <p>Reserved names: HIDDEN, DEFAULT_TOKEN_CHANNEL, SKIP, MORE, MAX_CHAR_VALUE, MIN_CHAR_VALUE.
*
* <p>Can be used but can not be declared: EOF</p>
* <p>Can be used but cannot be declared: EOF</p>
*/
TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS(171, "can not use or declare token with reserved name <arg>", ErrorSeverity.ERROR),
TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS(171, "cannot use or declare token with reserved name <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 172.
*
@ -988,9 +988,9 @@ public enum ErrorType {
*
* <p>Reserved names: DEFAULT_MODE, SKIP, MORE, EOF, MAX_CHAR_VALUE, MIN_CHAR_VALUE.
*
* <p>Can be used but can not be declared: HIDDEN, DEFAULT_TOKEN_CHANNEL</p>
* <p>Can be used but cannot be declared: HIDDEN, DEFAULT_TOKEN_CHANNEL</p>
*/
CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS(172, "can not use or declare channel with reserved name <arg>", ErrorSeverity.ERROR),
CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS(172, "cannot use or declare channel with reserved name <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 173.
*
@ -998,9 +998,9 @@ public enum ErrorType {
*
* <p>Reserved names: HIDDEN, DEFAULT_TOKEN_CHANNEL, SKIP, MORE, MAX_CHAR_VALUE, MIN_CHAR_VALUE.
*
* <p>Can be used and can be declared: DEFAULT_MODE</p>
* <p>Can be used and cannot declared: DEFAULT_MODE</p>
*/
MODE_CONFLICTS_WITH_COMMON_CONSTANTS(173, "can not use or declare mode with reserved name <arg>", ErrorSeverity.ERROR),
MODE_CONFLICTS_WITH_COMMON_CONSTANTS(173, "cannot use or declare mode with reserved name <arg>", ErrorSeverity.ERROR),
/**
* Compiler Error 174.
*
@ -1010,7 +1010,7 @@ public enum ErrorType {
* <pre>B: '';</pre>
* <pre>C: 'test' '';</pre>
*/
EMPTY_STRINGS_NOT_ALLOWED(174, "empty strings not allowed", ErrorSeverity.ERROR),
EMPTY_STRINGS_NOT_ALLOWED(174, "string literals cannot be empty", ErrorSeverity.ERROR),
/*
* Backward incompatibility errors