Пример #1
0
        public DssInstructions Parse(SourceCodeInfo sourceInfo)
        {
            var instructions = new DssInstructions();

            ParseInto(instructions, sourceInfo);
            return(instructions);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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());
        }