Пример #1
0
 void IASTElementGeneratesDebugXML.GenerateDebugXMLTree(IASTElement parent, StringBuilder output)
 {
     output.Append("<Liturgy>");
     foreach (var line in Lines)
     {
         ((IASTElementGeneratesDebugXML)line).GenerateDebugXMLTree(this, output);
     }
     output.Append("</Liturgy>");
 }
Пример #2
0
 void IASTElementGeneratesDebugXML.GenerateDebugXMLTree(IASTElement parent, StringBuilder output)
 {
     output.Append("<ASTProgram>");
     foreach (var child in Children)
     {
         child.GenerateDebugXMLTree(this, output);
     }
     output.Append("</ASTProgram>");
 }
Пример #3
0
 IASTElement IParsable.Parse(Lexer lexer, IASTElement parent)
 {
     while (!lexer.InspectEOF())
     {
         lexer.GobbleWhitespace();
         // find a valid command
         IASTElement cmd = new ASTCommand();
         Children.Add(cmd.Parse(lexer, this));
         lexer.GobbleWhitespace();
     }
     return(this);
 }
Пример #4
0
 void IASTElementGeneratesDebugXML.GenerateDebugXMLTree(IASTElement parent, StringBuilder output)
 {
     output.Append($"<ASTLiturgyLine Speaker=\"{Speaker}\" SpeakerText=\"{SpeakerText}\">");
     foreach (var word in Words)
     {
         output.Append($"<Word Format=\"{word.Format}\" Value=\"{word.Value}\">");
         foreach (var kvp in word.Attributes)
         {
             output.Append($"<Attribute Name=\"{kvp.Key}\" Value=\"{kvp.Value}\"/>");
         }
         output.Append($"</Word>");
     }
     output.Append("</ASTLiturgyLine>");
 }
Пример #5
0
        IASTElement IParsable.Parse(Lexer lexer, IASTElement parent)
        {
            /*
             *  Figure out what command it is
             *  Parse the actual command
             */

            lexer.GobbleWhitespace();
            CommandName = lexer.Peek();

            if (CommandName.Value == "Liturgy" && !CommandName.IsEscaped)
            {
                Command = new ASTLiturgy_cmd();
                Command.Parse(lexer, this);
                return(this);
            }
            else
            {
                // unrecognized sequence
                throw new MidnightCompilerParseError(lexer.CurrenToken, $"[Compiler Error] Error parsing 'Command'. Unrecognized command {lexer.CurrenToken.Value} at Line: {lexer.CurrenToken.LineNumber} on Col: {lexer.CurrenToken.SColNumber}");
            }
        }
Пример #6
0
        IASTElement IParsable.Parse(Lexer lexer, IASTElement parent)
        {
            if (!lexer.Consume("Liturgy"))
            {
                throw new MidnightCompilerParseError(lexer.CurrenToken, string.Join(Environment.NewLine, lexer.Messages));
            }
            lexer.GobbleWhitespace();
            if (!lexer.Consume("("))
            {
                throw new MidnightCompilerParseError(lexer.CurrenToken, string.Join(Environment.NewLine, lexer.Messages));
            }
            lexer.GobbleWhitespace();
            if (!lexer.Consume(")"))
            {
                throw new MidnightCompilerParseError(lexer.CurrenToken, string.Join(Environment.NewLine, lexer.Messages));
            }
            lexer.GobbleWhitespace();
            if (!lexer.Consume("{"))
            {
                throw new MidnightCompilerParseError(lexer.CurrenToken, string.Join(Environment.NewLine, lexer.Messages));
            }

            Content = lexer.ConsumeUntil("}");

            LiturgySubCompiler liturgySubCompiler = new LiturgySubCompiler();

            Lines = liturgySubCompiler.ParseLiturgyLines(Content);


            if (!lexer.Consume("}"))
            {
                throw new MidnightCompilerParseError(lexer.CurrenToken, string.Join(Environment.NewLine, lexer.Messages));
            }

            return(this);
        }
Пример #7
0
 void IASTElementGeneratesDebugXML.GenerateDebugXMLTree(IASTElement parent, StringBuilder output)
 {
     output.Append($"<ASTCommand CommandName=\"{CommandName.AsText}\">");
     Command.GenerateDebugXMLTree(this, output);
     output.Append("</ASTCommand>");
 }