private static void CheckVersion(CommandFileReader reader, int[] supportedVersions) { string line = null; CommandFileLine lastChecked = null; while (!reader.IsDone) { line = reader.NextLine(); if (line.StartsWith("#ver")) { if (lastChecked != null) { throw new MultipleDeclarationException(lastChecked, reader.GetLineObject()); } lastChecked = reader.GetLineObject(); if (int.TryParse(line.Substring("#ver".Length), out int version)) { if (!supportedVersions.Contains(version)) { throw new WrongVersionException(supportedVersions, version); } } else { throw new PositionException(lastChecked, new MalformedCodeException(CreateVersionRegex(supportedVersions))); } } } }
public CommandFileLine GetRelativeLine(CommandFileLine line, int direction) { return(lines[Array.IndexOf(lines, line) + direction]); }
public void FlagsPosition(CommandFileLine position) { Flags = position; }