Beispiel #1
0
        public static bool TryScan(CodeReader reader, out Import import)
        {
            import = null;
            bool result = Import.TryScan(reader, out IScanable scanned);

            if (result)
            {
                import = (Import)scanned;
            }
            return(result);
        }
Beispiel #2
0
        public static Presentation Parse(CodeReader reader)
        {
            CodeReader           r            = reader.Copy();
            Presentation         presentation = new Presentation();
            DefinitionCollection dc           = DefinitionCollection.Create(r);

            r = dc.CreateReader(r);
            while (!r.Done)
            {
                var line = r.NextLine();

                if (Import.TryScan(r.Copy(), out Import import))
                {
                    presentation.AddImport(import);
                    r.Skip(import.LineLength - 1);
                }
                else if (Style.TryScan(r.Copy(), out Style style))
                {
                    presentation.AddStyle(style);
                    r.Skip(style.LineLength - 1);
                }
                else if (Interactive.TryScan(r.Copy(), out Interactive interactive))
                {
                    presentation.AddInteractive(interactive);
                    r.Skip(interactive.LineLength - 1);
                }
                else if (Pattern.TryScan(r.Copy(), out Pattern pattern))
                {
                    presentation.AddPattern(pattern);
                    r.Skip(pattern.LineLength - 1);
                }
                else if (Slide.TryScan(r.Copy(), presentation, out Slide slide))
                {
                    presentation.AddSlide(slide);
                    r.Skip(slide.LineLength - 1);
                }
                else
                {
                    throw new Exception("Unknown Command in Line " + r.CurrentLine + ": " + r.PeekLine());
                }

                Console.WriteLine(line);
            }
            return(presentation);
        }