示例#1
0
        public LangElement Parse(
            ITokenProvider <SemanticValueType, Span> lexer,
            INodesFactory <LangElement, Span> astFactory,
            LanguageFeatures language,
            IErrorSink <Span> errors = null,
            int positionShift        = 0)
        {
            if (lexer == null)
            {
                throw new ArgumentNullException(nameof(lexer));
            }

            if (astFactory == null)
            {
                throw new ArgumentNullException(nameof(astFactory));
            }

            // initialization:
            _languageFeatures = language;
            _lexer            = new CompliantLexer(lexer);
            _astFactory       = astFactory;
            _errors           = errors ?? new EmptyErrorSink <Span>();
            //InitializeFields();

            _currentScope = new Scope(0);

            base.Scanner = _lexer;
            bool accept = base.Parse();

            LangElement result = _astRoot;

            // clean and let GC collect unused AST and other stuff:
            //ClearFields();

            return(result);
        }
示例#2
0
 public BufferedLexer(CompliantLexer provider)
 {
     _provider = provider;
 }