private void Preprocess()
		{
			if(TokenStartColumn != 0)
				NotifyErrorListeners("Preprocessor directives must be the first non-whitespace character on the line");

			var directive = Text;
			var stream = new AntlrInputStream(directive);
			var lexer = new PreprocessorLineLexer(stream);
			var tokens = new CommonTokenStream(lexer);
			var parser = new PreprocessorLineParser(tokens) { BuildParseTree = true };
			var tree = parser.preprocessorLine();
			if(preprocessorVisitor == null) preprocessorVisitor = new PreprocessorVisitor(preprocessorState); //annoyingly can't use constructor
			tree.Accept(preprocessorVisitor);
			CurrentMode = preprocessorState.InSkippedSection ? PREPROCESSOR_SKIP : DefaultMode;
		}
Пример #2
0
        private void Preprocess()
        {
            if (TokenStartColumn != 0)
            {
                NotifyErrorListeners("Preprocessor directives must be the first non-whitespace character on the line");
            }

            var directive = Text;
            var stream    = new AntlrInputStream(directive);
            var lexer     = new PreprocessorLineLexer(stream);
            var tokens    = new CommonTokenStream(lexer);
            var parser    = new PreprocessorLineParser(tokens)
            {
                BuildParseTree = true
            };
            var tree = parser.preprocessorLine();

            if (preprocessorVisitor == null)
            {
                preprocessorVisitor = new PreprocessorVisitor(preprocessorState);                                         //annoyingly can't use constructor
            }
            tree.Accept(preprocessorVisitor);
            CurrentMode = preprocessorState.InSkippedSection ? PREPROCESSOR_SKIP : DefaultMode;
        }