Exemplo n.º 1
0
        public CgParser([NotNull] ILexer <int> originalLexer, CommonIdentifierIntern intern)
        {
            myOriginalLexer = originalLexer;
            myIntern        = intern;

            SetLexer(myOriginalLexer);

            myPreProcessor = new CgPreProcessor();
            myPreProcessor.Run(myOriginalLexer, this, new SeldomInterruptChecker());

            SetLexer(new CgFilteringLexer(myOriginalLexer, myPreProcessor));
        }
Exemplo n.º 2
0
        public static void Run(TreeElement node, ILexer lexer, ITokenOffsetProvider offsetProvider, CgPreProcessor preProcessor, SeldomInterruptChecker interruptChecker, ITokenIntern intern)
        {
            Assertion.Assert(node.parent == null, "node.parent == null");

            var root = node as CompositeElement;

            if (root == null)
            {
                return;
            }

            // Append an EOF token so we insert filtered tokens right up to
            // the end of the file
            var eof = new EofToken(lexer.Buffer.Length);

            root.AppendNewChild(eof);

            var inserter = new CgMissingTokensInserter(lexer, offsetProvider, preProcessor, interruptChecker, intern);

            // Reset the lexer, walk the tree and call ProcessLeafElement on each leaf element
            lexer.Start();
            inserter.Run(root);

            root.DeleteChildRange(eof, eof);
        }
Exemplo n.º 3
0
 private CgMissingTokensInserter(ILexer lexer, ITokenOffsetProvider offsetProvider, CgPreProcessor preProcessor, SeldomInterruptChecker interruptChecker, ITokenIntern intern)
     : base(offsetProvider, interruptChecker, intern)
 {
     myLexer        = lexer;
     myPreProcessor = preProcessor;
 }
Exemplo n.º 4
0
 public CgFilteringLexer([NotNull] ILexer lexer, [CanBeNull] CgPreProcessor preProcessor)
     : base(lexer)
 {
     myPreProcessor = preProcessor;
 }