Esempio n. 1
0
        internal static Exception SyntaxError(ODataLexer lexer, string reason, Exception e = null)
        {
            var src   = lexer.Src;
            var token = lexer.Token;

            var lineInfo = token.Column >= src.Length
                ? " Source:" + src + ">>>>EOF<<<<"
                : " Source:" + src.Substring(0, token.Column) + ">>>>" + src.Substring(token.Column, 1) + "<<<<" + src.Substring(token.Column + 1);

            var msg = String.Concat("Syntax error at line ", token.Line, ", char ", token.Column, ". ", reason, lineInfo);

            return(new ODataParserException(msg, token.Line, token.Column, e));
        }
Esempio n. 2
0
        private void parseFilterExpr(string filter)
        {
            this.lexer = new ODataLexer(filter);
            var expr  = this.parseExpr();
            var token = this.lexer.Token;

            if (token != null && token.TokenType != TokenType.EOF)
            {
                throw SyntaxError(String.Concat("Unexpected ", token.TokenType.ToString(), " in $filter: '", token.Value, "'."));
            }
            var final = Expression.Lambda(expr, this.Builder.x);

            this.req.Filter = final;
        }