public DssInstructions Parse(SourceCodeInfo sourceInfo) { var instructions = new DssInstructions(); ParseInto(instructions, sourceInfo); return(instructions); }
public Stylesheet Compile(DssInstructions dssInstructions) { var context = new DssCompilerContext() { Instructions = dssInstructions, Stylesheet = new Stylesheet(), }; foreach (var instruction in dssInstructions) { if (instruction is RulesetInstruction rulesetInstruction) { ProcessRulesetInstruction(context, rulesetInstruction); } } return(context.Stylesheet); }
public void ParseInto(DssInstructions dssInstructions, SourceCodeInfo sourceInfo) { if (sourceInfo == null) { throw new ArgumentNullException(nameof(sourceInfo)); } Internal.DssLexer lexer; using (var stream = sourceInfo.GetStream()) lexer = new Internal.DssLexer(new AntlrInputStream(stream)); var tokens = new CommonTokenStream(lexer); var parser = new Internal.DssParser(tokens); var errorListener = new ErrorListener(sourceInfo.SourceName); //parser.RemoveErrorListeners(); parser.AddErrorListener(errorListener); var listener = new StylesheetListener(sourceInfo.SourceName, dssInstructions); listener.EnterStylesheet(parser.stylesheet()); }