Ejemplo n.º 1
0
        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)));
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public CommandFileLine GetRelativeLine(CommandFileLine line, int direction)
 {
     return(lines[Array.IndexOf(lines, line) + direction]);
 }
Ejemplo n.º 3
0
 public void FlagsPosition(CommandFileLine position)
 {
     Flags = position;
 }