public IXenonASTElement Compile(Lexer Lexer, XenonErrorLogger Logger) { XenonASTElementCollection liturgys = new XenonASTElementCollection(); // assume all tokens inside braces are litrugy commands // only excpetions are we will gobble all leading whitespace in braces, and will remove the last // character of whitespace before last brace Lexer.GobbleWhitespace(); // optional params if (Lexer.Inspect("(")) { var args = Lexer.ConsumeArgList(false, "startnewline"); if (args["startnewline"] == "true") { ForceSpeakerStartOnNewline = true; } Lexer.GobbleWhitespace(); } Lexer.GobbleandLog("{", "Expected opening brace at start of liturgy."); Lexer.GobbleWhitespace(); XenonASTLiturgy liturgy = CompileSubContent(Lexer, Logger); liturgys.Elements.Add(liturgy); while (!Lexer.Inspect("}")) { Lexer.GobbleandLog("#", "Only '#break' command recognized in '#liturgy' block"); if (Lexer.Inspect("break")) { Lexer.GobbleandLog("break"); Lexer.GobbleWhitespace(); } else { Logger.Log(new XenonCompilerMessage() { ErrorMessage = "Expected Command 'break'", ErrorName = "Unrecognized Command", Generator = "Compiler - XenonASTLiturgy", Inner = "", Level = XenonCompilerMessageType.Error, Token = Lexer.CurrentToken }); } liturgy = CompileSubContent(Lexer, Logger); liturgys.Elements.Add(liturgy); } Lexer.GobbleandLog("}", "Missing closing brace for liturgy."); return(liturgys); }
public IXenonASTElement Compile(Lexer Lexer, XenonErrorLogger Logger) { XenonASTElementCollection litverses = new XenonASTElementCollection(); // assume all tokens inside braces are litrugy commands // only excpetions are we will gobble all leading whitespace in braces, and will remove the last // character of whitespace before last brace Lexer.GobbleWhitespace(); var args = Lexer.ConsumeArgList(true, "title", "reference"); Title = args["title"]; Reference = args["reference"]; Lexer.GobbleWhitespace(); Lexer.GobbleandLog("{", "Expected opening brace at start of litverse."); Lexer.GobbleWhitespace(); XenonASTLiturgyVerse litverse = CompileSubContent(Lexer, Logger); litverses.Elements.Add(litverse); while (!Lexer.Inspect("}")) { Lexer.GobbleandLog("#", "Only '#break' command recognized in '#litverse' block"); if (Lexer.Inspect("break")) { Lexer.GobbleandLog("break"); Lexer.GobbleWhitespace(); } else { Logger.Log(new XenonCompilerMessage() { ErrorMessage = "Expected Command 'break'", ErrorName = "Unrecognized Command", Generator = "Compiler - XenonASTLitVerse", Inner = "", Level = XenonCompilerMessageType.Error, Token = Lexer.CurrentToken }); } litverse = CompileSubContent(Lexer, Logger); litverses.Elements.Add(litverse); } Lexer.GobbleandLog("}", "Missing closing brace for litverse."); return(litverses); }