Fix issues in newly generated code

This commit is contained in:
Sam Harwell 2014-03-25 14:47:19 -05:00
parent 53f2c8f1a6
commit a14b197714
2 changed files with 5 additions and 6 deletions

View File

@ -1379,7 +1379,7 @@ namespace Antlr4.Runtime.Atn
[return: NotNull] [return: NotNull]
protected internal virtual ATNConfigSet ApplyPrecedenceFilter(ATNConfigSet configs, ParserRuleContext globalContext, PredictionContextCache contextCache) protected internal virtual ATNConfigSet ApplyPrecedenceFilter(ATNConfigSet configs, ParserRuleContext globalContext, PredictionContextCache contextCache)
{ {
IDictionary<int, PredictionContext> statesFromAlt1 = new Dictionary<int, PredictionContext>(); Dictionary<int, PredictionContext> statesFromAlt1 = new Dictionary<int, PredictionContext>();
ATNConfigSet configSet = new ATNConfigSet(); ATNConfigSet configSet = new ATNConfigSet();
foreach (ATNConfig config in configs) foreach (ATNConfig config in configs)
{ {
@ -1394,7 +1394,7 @@ namespace Antlr4.Runtime.Atn
// the configuration was eliminated // the configuration was eliminated
continue; continue;
} }
statesFromAlt1.Put(config.State.stateNumber, config.Context); statesFromAlt1[config.State.stateNumber] = config.Context;
if (updatedContext != config.SemanticContext) if (updatedContext != config.SemanticContext)
{ {
configSet.Add(config.Transform(config.State, updatedContext, false), contextCache); configSet.Add(config.Transform(config.State, updatedContext, false), contextCache);
@ -1411,8 +1411,8 @@ namespace Antlr4.Runtime.Atn
// already handled // already handled
continue; continue;
} }
PredictionContext context = statesFromAlt1.Get(config_1.State.stateNumber); PredictionContext context;
if (context != null && context.Equals(config_1.Context)) if (statesFromAlt1.TryGetValue(config_1.State.stateNumber, out context) && context.Equals(config_1.Context))
{ {
// eliminated // eliminated
continue; continue;

View File

@ -229,8 +229,7 @@ namespace Antlr4.Runtime
/// your token objects because you don't have to go modify your lexer /// your token objects because you don't have to go modify your lexer
/// so that it creates a new Java type. /// so that it creates a new Java type.
/// </remarks> /// </remarks>
[Obsolete] [ObsoleteAttribute(@"This method is not called by the ANTLR 4 Runtime. Specific implementations of IAntlrErrorStrategy may provide a similar feature when necessary. For example, see DefaultErrorStrategy.GetTokenErrorDisplay(IToken).")]
[System.ObsoleteAttribute(@"This method is not called by the ANTLR 4 Runtime. Specific implementations of IAntlrErrorStrategy may provide a similar feature when necessary. For example, seeDefaultErrorStrategy.GetTokenErrorDisplay(IToken) .")]
public virtual string GetTokenErrorDisplay(IToken t) public virtual string GetTokenErrorDisplay(IToken t)
{ {
if (t == null) if (t == null)