예제 #1
0
 public LanguageData(Grammar grammar)
 {
     Grammar     = grammar;
     GrammarData = new GrammarData(this);
     ParserData  = new ParserData(this);
     ScannerData = new ScannerData(this);
     ConstructAll();
 }
예제 #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();
     }
 }
예제 #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;
        }