Merge pull request #44 from sharwell/fix-40

Fix string.Format syntax (fixes #40)
This commit is contained in:
Sam Harwell 2014-04-28 06:54:59 -05:00
commit 3194fa037a
9 changed files with 25 additions and 25 deletions

View File

@ -151,14 +151,14 @@ namespace Antlr4.Runtime.Atn
int version = ToInt(data[p++]);
if (version != SerializedVersion)
{
string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with version %d (expected %d).", version, SerializedVersion);
string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with version {0} (expected {1}).", version, SerializedVersion);
throw new NotSupportedException(reason);
}
Guid uuid = ToUUID(data, p);
p += 8;
if (!SupportedUuids.Contains(uuid))
{
string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with UUID %s (expected %s or a legacy UUID).", uuid, SerializedUuid);
string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with UUID {0} (expected {1} or a legacy UUID).", uuid, SerializedUuid);
throw new NotSupportedException(reason);
}
bool supportsLexerActions = IsFeatureSupported(AddedLexerActions, uuid);
@ -1263,7 +1263,7 @@ nextState_break: ;
default:
{
string message = string.Format(CultureInfo.CurrentCulture, "The specified state type %d is not valid.", type);
string message = string.Format(CultureInfo.CurrentCulture, "The specified state type {0} is not valid.", type);
throw new ArgumentException(message);
}
}
@ -1317,7 +1317,7 @@ nextState_break: ;
default:
{
string message = string.Format(CultureInfo.CurrentCulture, "The specified lexer action type %d is not valid.", type);
string message = string.Format(CultureInfo.CurrentCulture, "The specified lexer action type {0} is not valid.", type);
throw new ArgumentException(message);
}
}

View File

@ -445,7 +445,7 @@ namespace Antlr4.Runtime.Atn
default:
{
string message = string.Format(CultureInfo.CurrentCulture, "The specified lexer action type %s is not valid.", action.GetActionType());
string message = string.Format(CultureInfo.CurrentCulture, "The specified lexer action type {0} is not valid.", action.GetActionType());
throw new ArgumentException(message);
}
}
@ -477,14 +477,14 @@ namespace Antlr4.Runtime.Atn
int version = ATNDeserializer.ToInt(data[p++]);
if (version != ATNDeserializer.SerializedVersion)
{
string reason = string.Format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SerializedVersion);
string reason = string.Format("Could not deserialize ATN with version {0} (expected {1}).", version, ATNDeserializer.SerializedVersion);
throw new NotSupportedException(new InvalidClassException(typeof(ATN).FullName, reason));
}
UUID uuid = ATNDeserializer.ToUUID(data, p);
p += 8;
if (!uuid.Equals(ATNDeserializer.SerializedUuid))
{
string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with UUID %s (expected %s).", uuid, ATNDeserializer.SerializedUuid);
string reason = string.Format(CultureInfo.CurrentCulture, "Could not deserialize ATN with UUID {0} (expected {1}).", uuid, ATNDeserializer.SerializedUuid);
throw new NotSupportedException(new InvalidClassException(typeof(ATN).FullName, reason));
}
p++;

View File

@ -139,7 +139,7 @@ namespace Antlr4.Runtime.Atn
public override string ToString()
{
return string.Format("channel(%d)", channel);
return string.Format("channel({0})", channel);
}
}
}

View File

@ -137,7 +137,7 @@ namespace Antlr4.Runtime.Atn
public override string ToString()
{
return string.Format("mode(%d)", mode);
return string.Format("mode({0})", mode);
}
}
}

View File

@ -136,7 +136,7 @@ namespace Antlr4.Runtime.Atn
public override string ToString()
{
return string.Format("pushMode(%d)", mode);
return string.Format("pushMode({0})", mode);
}
}
}

View File

@ -132,7 +132,7 @@ namespace Antlr4.Runtime.Atn
public override string ToString()
{
return string.Format("type(%d)", type);
return string.Format("type({0})", type);
}
}
}

View File

@ -80,7 +80,7 @@ namespace Antlr4.Runtime.Misc
}
foreach (KeyValuePair<ITypeMirror, IList<Tuple<RuleDependency, IElement>>> entry in recognizerDependencies.EntrySet())
{
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Note, string.Format("ANTLR 4: Validating %d dependencies on rules in %s.", entry.Value.Count, entry.Key.ToString()));
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Note, string.Format("ANTLR 4: Validating {0} dependencies on rules in {1}.", entry.Value.Count, entry.Key.ToString()));
CheckDependencies(entry.Value, entry.Key);
}
return true;
@ -100,7 +100,7 @@ namespace Antlr4.Runtime.Misc
Args.NotNull("clazz", clazz);
if (!className.Equals(clazz.GetCanonicalName()))
{
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, string.Format("Unable to process rule dependencies due to class name mismatch: %s != %s", className, clazz.GetCanonicalName()));
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, string.Format("Unable to process rule dependencies due to class name mismatch: {0} != {1}", className, clazz.GetCanonicalName()));
return false;
}
return true;
@ -111,7 +111,7 @@ namespace Antlr4.Runtime.Misc
try
{
dependency.Recognizer();
string message = string.Format("Expected %s to get the %s.", typeof(MirroredTypeException).Name, typeof(ITypeMirror).Name);
string message = string.Format("Expected {0} to get the {1}.", typeof(MirroredTypeException).Name, typeof(ITypeMirror).Name);
throw new NotSupportedException(message);
}
catch (MirroredTypeException ex)
@ -138,7 +138,7 @@ namespace Antlr4.Runtime.Misc
if (effectiveRule < 0 || effectiveRule >= ruleVersions.Length)
{
Tuple<IAnnotationMirror, IAnnotationValue> ruleReferenceElement = FindRuleDependencyProperty(dependency, RuleDependencyProcessor.RuleDependencyProperty.Rule);
string message = string.Format("Rule dependency on unknown rule %d@%d in %s", dependency.Item1.Rule(), dependency.Item1.Version(), GetRecognizerType(dependency.Item1).ToString());
string message = string.Format("Rule dependency on unknown rule {0}@{1} in {2}", dependency.Item1.Rule(), dependency.Item1.Version(), GetRecognizerType(dependency.Item1).ToString());
if (ruleReferenceElement != null)
{
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, dependency.Item2, ruleReferenceElement.Item1, ruleReferenceElement.Item2);
@ -213,7 +213,7 @@ namespace Antlr4.Runtime.Misc
if (declaredVersion > highestRequiredDependency)
{
Tuple<IAnnotationMirror, IAnnotationValue> versionElement = FindRuleDependencyProperty(dependency, RuleDependencyProcessor.RuleDependencyProperty.Version);
string message = string.Format("Rule dependency version mismatch: %s has maximum dependency version %d (expected %d) in %s", ruleNames[dependency.Item1.Rule()], highestRequiredDependency, declaredVersion, GetRecognizerType(dependency.Item1).ToString());
string message = string.Format("Rule dependency version mismatch: {0} has maximum dependency version {1} (expected {2}) in {3}", ruleNames[dependency.Item1.Rule()], highestRequiredDependency, declaredVersion, GetRecognizerType(dependency.Item1).ToString());
if (versionElement != null)
{
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, dependency.Item2, versionElement.Item1, versionElement.Item2);
@ -226,7 +226,7 @@ namespace Antlr4.Runtime.Misc
}
catch (AnnotationTypeMismatchException)
{
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, string.Format("Could not validate rule dependencies for element %s", dependency.Item2.ToString()), dependency.Item2);
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, string.Format("Could not validate rule dependencies for element {0}", dependency.Item2.ToString()), dependency.Item2);
}
}
}
@ -244,7 +244,7 @@ namespace Antlr4.Runtime.Misc
{
dependentsElement = FindRuleDependencyProperty(dependency, RuleDependencyProcessor.RuleDependencyProperty.Rule);
}
string message = string.Format("Cannot validate the following dependents of rule %d: %s", dependency.Item1.Rule(), unimplemented);
string message = string.Format("Cannot validate the following dependents of rule {0}: {1}", dependency.Item1.Rule(), unimplemented);
if (dependentsElement != null)
{
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, message, dependency.Item2, dependentsElement.Item1, dependentsElement.Item2);
@ -267,14 +267,14 @@ namespace Antlr4.Runtime.Misc
else
{
string mismatchedRuleName = ruleNames[relatedRule];
path = string.Format("rule %s (%s of %s)", mismatchedRuleName, relation, ruleName);
path = string.Format("rule {0} ({1} of {2})", mismatchedRuleName, relation, ruleName);
}
int declaredVersion = dependency.Item1.Version();
int actualVersion = ruleVersions[relatedRule];
if (actualVersion > declaredVersion)
{
Tuple<IAnnotationMirror, IAnnotationValue> versionElement = FindRuleDependencyProperty(dependency, RuleDependencyProcessor.RuleDependencyProperty.Version);
string message = string.Format("Rule dependency version mismatch: %s has version %d (expected <= %d) in %s", path, actualVersion, declaredVersion, GetRecognizerType(dependency.Item1).ToString());
string message = string.Format("Rule dependency version mismatch: {0} has version {1} (expected <= {2}) in {3}", path, actualVersion, declaredVersion, GetRecognizerType(dependency.Item1).ToString());
if (versionElement != null)
{
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, dependency.Item2, versionElement.Item1, versionElement.Item2);
@ -314,7 +314,7 @@ namespace Antlr4.Runtime.Misc
int index = (int)constantValue;
if (index < 0 || index >= versions.Length)
{
string message = string.Format("Rule index %d for rule '%s' out of bounds for recognizer %s.", index, name, recognizerClass.ToString());
string message = string.Format("Rule index {0} for rule '{1}' out of bounds for recognizer {2}.", index, name, recognizerClass.ToString());
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, element);
continue;
}
@ -326,7 +326,7 @@ namespace Antlr4.Runtime.Misc
IExecutableElement ruleMethod = GetRuleMethod(recognizerClass, name);
if (ruleMethod == null)
{
string message = string.Format("Could not find rule method for rule '%s' in recognizer %s.", name, recognizerClass.ToString());
string message = string.Format("Could not find rule method for rule '{0}' in recognizer {1}.", name, recognizerClass.ToString());
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, message, element);
continue;
}
@ -507,7 +507,7 @@ namespace Antlr4.Runtime.Misc
}
else
{
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, string.Format("Unexpected annotation property %s.", value.Key.ToString()), dependency.Item2, annotationMirror, value.Value);
processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, string.Format("Unexpected annotation property {0}.", value.Key.ToString()), dependency.Item2, annotationMirror, value.Value);
}
}
}

View File

@ -277,7 +277,7 @@ namespace Antlr4.Runtime
{
if (!Precpred(_ctx, ((PrecedencePredicateTransition)transition).precedence))
{
throw new FailedPredicateException(this, string.Format("precpred(_ctx, %d)", ((PrecedencePredicateTransition)transition).precedence));
throw new FailedPredicateException(this, string.Format("precpred(_ctx, {0})", ((PrecedencePredicateTransition)transition).precedence));
}
break;
}

View File

@ -298,7 +298,7 @@ namespace Antlr4.Runtime.Tree.Pattern
/// <summary><inheritDoc></inheritDoc></summary>
public override string ToString()
{
return string.Format("Match %s; found %d labels", Succeeded() ? "succeeded" : "failed", GetLabels().Count);
return string.Format("Match {0}; found {1} labels", Succeeded() ? "succeeded" : "failed", GetLabels().Count);
}
}
}