コード例 #1
0
        private static Expression Prefix(Lexemes lexemes, IUnitRegistry unitRegistry)
        {
            IUnit unit;
            Prefix prefix;
            if (lexemes.AcceptTokenFrom(unitRegistry, out prefix))
            {
                if (lexemes.AcceptTokenFrom(unitRegistry, out unit))
                {
                    return Unit(prefix, unit);
                }

                lexemes.MoveToPrevious();
            }

            if (lexemes.AcceptTokenFrom(unitRegistry, out unit))
            {
                return Unit(null, unit);
            }

            string variable;
            if (lexemes.AcceptTokenFrom(VariableRegex, out variable))
            {
                return new VariableExpression(variable);
            }

            throw CreateParseException(UnitError.PrefixUnitOrUnitOrVariableNotFound, lexemes.Current);
        }
コード例 #2
0
        private static Expression Prefix(Lexemes lexemes, IUnitRegistry unitRegistry)
        {
            IUnit  unit;
            Prefix prefix;

            if (lexemes.AcceptTokenFrom(unitRegistry, out prefix))
            {
                if (lexemes.AcceptTokenFrom(unitRegistry, out unit))
                {
                    return(Unit(prefix, unit));
                }

                lexemes.MoveToPrevious();
            }

            if (lexemes.AcceptTokenFrom(unitRegistry, out unit))
            {
                return(Unit(null, unit));
            }

            string variable;

            if (lexemes.AcceptTokenFrom(VariableRegex, out variable))
            {
                return(new VariableExpression(variable));
            }

            throw CreateParseException(UnitError.PrefixUnitOrUnitOrVariableNotFound, lexemes.Current);
        }