コード例 #1
0
ファイル: Parser.cs プロジェクト: FreeApophis/SortingHat
        public static Parser Create()
        {
            // Create the object tree without DI Framework
            var expressionParser = new ExpressionParser();
            var factorParser     = new FactorParser(expressionParser);
            var termParser       = new TermParser(factorParser);

            expressionParser.TermParser = termParser;
            var lexerRules = new LexerRules();

            ILinePositionCalculator NewLinePositionCalculator(List <Lexem> lexems) => new LinePositionCalculator(lexems);
            ILexerReader NewLexerReader(string expression) => new LexerReader(expression);

            var tokenizer = new Tokenizer(lexerRules, NewLexerReader, NewLinePositionCalculator);

            IToken NewEpsilonToken() => new EpsilonToken();

            var tokenWalker = new TokenWalker(tokenizer, NewEpsilonToken, NewLinePositionCalculator);

            return(new Parser(tokenWalker, expressionParser));
        }
コード例 #2
0
 public TermParser(FactorParser factorParser)
 {
     _factorParser = factorParser;
 }