コード例 #1
0
        public UnitExpressionParserTests()
        {
            var unitRegistry = new UnitRegistry();

            this.lexicalAnalyzer = A.Fake <ILexicalAnalyzer>();
            this.testee          = new UnitExpressionParser(unitRegistry, this.lexicalAnalyzer);
        }
コード例 #2
0
        /// <summary>
        /// Creates the parser.
        /// </summary>
        /// <param name="unitRegistry">The unit registry.</param>
        /// <returns>
        /// A new <see cref="IExpressionParser" />.
        /// </returns>
        public IExpressionParser CreateParser(IUnitRegistry unitRegistry)
        {
            var tokenMatcherBuilder  = new TokenMatcherBuilder();
            var prefixTokenMatchers  = tokenMatcherBuilder.Build(unitRegistry.GetPrefixNotations(), true);
            var unitTokenMatchers    = tokenMatcherBuilder.Build(unitRegistry.GetUnitNotations(), false);
            var unitExpressionParser = new UnitExpressionParser(
                unitRegistry,
                new LexicalAnalyzer(new[] { prefixTokenMatchers, unitTokenMatchers }));

            return(new ExpressionParser(unitExpressionParser));
        }