Beispiel #1
0
 public LanguageData(Grammar grammar)
 {
     Grammar     = grammar;
     GrammarData = new GrammarData(this);
     ParserData  = new ParserData(this);
     ScannerData = new ScannerData(this);
     ConstructAll();
 }
Beispiel #2
0
 public LanguageData(Grammar grammar, bool construct = true)
 {
     Grammar     = grammar;
     GrammarData = new GrammarData(this);
     ParserData  = new ParserData(this);
     ScannerData = new ScannerData(this);
     if (construct)
     {
         ConstructAll();
     }
 }
Beispiel #3
0
        public Scanner(Parser parser)
        {
            Parser   = parser;
            Data     = parser.Language.ScannerData;
            _grammar = parser.Language.Grammar;
            //create token streams
            var tokenStream = GetUnfilteredTokens();

            //chain all token filters
            Context.TokenFilters.Clear();
            _grammar.CreateTokenFilters(Data.Language, Context.TokenFilters);
            foreach (TokenFilter filter in Context.TokenFilters)
            {
                tokenStream = filter.BeginFiltering(Context, tokenStream);
            }
            Context.FilteredTokens = tokenStream.GetEnumerator();
        }
        private int _nextNewLinePosition = -1; //private field to cache position of next \n character

        public SourceStream(ScannerData scannerData, int tabWidth)
        {
            _scannerData = scannerData;
            TabWidth     = tabWidth;
        }