Misprints fixed, code style improved (removed unnecessary else).

This commit is contained in:
Ivan Kochurkin 2016-12-04 15:06:07 +03:00
parent cb16e369fe
commit bf3bff16e4
2 changed files with 12 additions and 12 deletions

View File

@ -510,16 +510,16 @@ public class LexerATNFactory extends ParserATNFactory {
if (modeName.equals("DEFAULT_MODE")) {
return Lexer.DEFAULT_MODE;
}
if (COMMON_CONSTANTS.containsKey(modeName)) {
g.tool.errMgr.grammarError(ErrorType.MODE_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
return null;
}
List<String> modeNames = new ArrayList<String>(((LexerGrammar)g).modes.keySet());
int mode = modeNames.indexOf(modeName);
if (mode >= 0) {
return mode;
}
else if (COMMON_CONSTANTS.containsKey(modeName)) {
g.tool.errMgr.grammarError(ErrorType.MODE_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
return null;
}
try {
return Integer.parseInt(modeName);
@ -537,15 +537,15 @@ public class LexerATNFactory extends ParserATNFactory {
if (tokenName.equals("EOF")) {
return Lexer.EOF;
}
if (COMMON_CONSTANTS.containsKey(tokenName)) {
g.tool.errMgr.grammarError(ErrorType.TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
return null;
}
int tokenType = g.getTokenType(tokenName);
if (tokenType != org.antlr.v4.runtime.Token.INVALID_TYPE) {
return tokenType;
}
else if (COMMON_CONSTANTS.containsKey(tokenName)) {
g.tool.errMgr.grammarError(ErrorType.TOKEN_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
return null;
}
try {
return Integer.parseInt(tokenName);
@ -563,10 +563,10 @@ public class LexerATNFactory extends ParserATNFactory {
if (channelName.equals("HIDDEN")) {
return Lexer.HIDDEN;
}
else if (channelName.equals("DEFAULT_TOKEN_CHANNEL")) {
if (channelName.equals("DEFAULT_TOKEN_CHANNEL")) {
return Lexer.DEFAULT_TOKEN_CHANNEL;
}
else if (COMMON_CONSTANTS.containsKey(channelName)) {
if (COMMON_CONSTANTS.containsKey(channelName)) {
g.tool.errMgr.grammarError(ErrorType.CHANNEL_CONFLICTS_WITH_COMMON_CONSTANTS, g.fileName, token, token.getText());
return null;
}

View File

@ -1024,7 +1024,7 @@ public enum ErrorType {
*
* <p><em>name</em>is not a recognized mode name</p>
*
* <pre>TOKEN: 'a' -> channel(MODE1); // error 176</pre>
* <pre>TOKEN: 'a' -> mode(MODE1); // error 176</pre>
*/
CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_MODE_NAME(176, "<arg> is not a recognized mode name", ErrorSeverity.ERROR),
/**
@ -1032,7 +1032,7 @@ public enum ErrorType {
*
* <p><em>name</em> is not a recognized channel name</p>
*
* <pre>TOKEN: 'a' -> mode(TOKEN1); // error 177</pre>
* <pre>TOKEN: 'a' -> channel(TOKEN1); // error 177</pre>
*/
CONSTANT_VALUE_IS_NOT_A_RECOGNIZED_CHANNEL_NAME(177, "<arg> is not a recognized channel name", ErrorSeverity.ERROR),
/*