include source location when complaining about bad miniyaml indents

This commit is contained in:
Chris Forbes
2012-03-16 18:02:03 +13:00
parent 5b8334b26d
commit 6f688275c5

View File

@@ -112,15 +112,16 @@ namespace OpenRA.FileFormats
if (t.Length == 0 || t[0] == '#') if (t.Length == 0 || t[0] == '#')
continue; continue;
var level = line.Length - t.Length; var level = line.Length - t.Length;
var location = new MiniYamlNode.SourceLocation { Filename = filename, Line = lineNo };
if (levels.Count <= level) if (levels.Count <= level)
throw new YamlException("Bad indent in miniyaml"); throw new YamlException("Bad indent in miniyaml at {0}".F (location));
while (levels.Count > level + 1) while (levels.Count > level + 1)
levels.RemoveAt(levels.Count - 1); levels.RemoveAt(levels.Count - 1);
var d = new List<MiniYamlNode>(); var d = new List<MiniYamlNode>();
var rhs = SplitAtColon( ref t ); var rhs = SplitAtColon( ref t );
levels[ level ].Add( new MiniYamlNode( t, rhs, d, new MiniYamlNode.SourceLocation { Filename = filename, Line = lineNo } ) ); levels[ level ].Add( new MiniYamlNode( t, rhs, d, location ) );
levels.Add(d); levels.Add(d);
} }