Ejemplo n.º 1
0
        private Expression ParseRightSide()
        {
            var left = ParseExpression();

            AdvanceWhile(e => e.Current.Type == TokenType.Whitespace);
            if (!_enumerator.Moved || _enumerator.Current.Value.In(",", "]", ";", ")"))
            {
                return(left);
            }
            if (_enumerator.Current.Value == "+")
            {
                Advance();
                AdvanceWhile(e => e.Current.Type == TokenType.Whitespace);
                var right  = ParseRightSide();
                var result = CustomExpression.Concat(left, right);
                return(result);
            }
            throw new RecipeCompilerException(_enumerator.Current.Position, $"Unexpected token '{_enumerator.Current.Value}'");
        }
Ejemplo n.º 2
0
        private Expression ParseLeftSide()
        {
            if (!_enumerator.Current.LooksLikeFilePath())
            {
                throw new RecipeCompilerException(_enumerator.Current.Position, $"Output cannot start with '{_enumerator.Current.Value}'");
            }

            var value = ReadWhile(e => e.Current.Type.In(TokenType.String) || e.Current.Value == ".");

            var left = _variables.ContainsKey(value) ? (Expression)_variables[value] : Expression.Constant(value);

            AdvanceWhile(e => e.Current.Type == TokenType.Whitespace);
            if (_enumerator.Current.Value == "+")
            {
                Advance();
                AdvanceWhile(e => e.Current.Type == TokenType.Whitespace);
                return(CustomExpression.Concat(left, ParseLeftSide()));
            }
            return(left);
        }