/// <summary> /// Initializes a new instance of the <see cref="Expression"/> class /// by parsing specified expression string. /// </summary> /// <param name="expression">Expression to parse.</param> public static IExpression Parse(string expression) { if (StringUtils.HasText(expression)) { ExpressionLexer lexer = new ExpressionLexer(new StringReader(expression)); ExpressionParser parser = new SpringExpressionParser(lexer); try { parser.expr(); } catch (TokenStreamRecognitionException ex) { throw new SyntaxErrorException(ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), expression); } return((IExpression)parser.getAST()); } else { return(new Expression()); } }
/// <summary> /// Initializes a new instance of the <see cref="Expression"/> class /// by parsing specified expression string. /// </summary> /// <param name="expression">Expression to parse.</param> public static IExpression Parse( string expression ) { if (StringUtils.HasText( expression )) { ExpressionLexer lexer = new ExpressionLexer( new StringReader( expression ) ); ExpressionParser parser = new SpringExpressionParser( lexer ); try { parser.expr(); } catch (TokenStreamRecognitionException ex) { throw new SyntaxErrorException( ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), expression ); } return (IExpression)parser.getAST(); } else { return new Expression(); } }