Package org.openrefine.grel
Class Parser
- java.lang.Object
-
- org.openrefine.grel.Parser
-
public class Parser extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected String
_languagePrefix
protected GrelExpr
_root
protected Scanner
_scanner
protected Scanner.Token
_token
static LanguageSpecificParser
grelParser
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Evaluable
getExpression()
protected GrelExpr[]
makeArray(List<GrelExpr> l)
protected ParsingException
makeException(String desc)
protected void
next(boolean regexPossible)
protected GrelExpr
parseExpression()
<expression> := <sub-expression> | <expression> [ "<" "<=" ">" ">=" "==" "!=" ] <sub-expression>
protected List<GrelExpr>
parseExpressionList(String closingDelimiter)
<expression-list> := <empty> | <expression> ( "," <expression> )*
protected GrelExpr
parseFactor()
<term> := <term-start> ( <path-segment> )* <term-start> := <string> | <number> | - <number> | <regex> | <identifier> | <identifier> ( <expression-list> )
<path-segment> := "[" <expression-list> "]" | "." <identifier> | "." <identifier> "(" <expression-list> ")"
protected GrelExpr
parseSubExpression()
<sub-expression> := <term> | <sub-expression> [ "+" "-" ] <term>
protected GrelExpr
parseTerm()
<term> := <factor> | <term> [ "*" "/" "%" ] <factor>
-
-
-
Field Detail
-
grelParser
public static LanguageSpecificParser grelParser
-
_scanner
protected Scanner _scanner
-
_token
protected Scanner.Token _token
-
_root
protected GrelExpr _root
-
_languagePrefix
protected String _languagePrefix
-
-
Constructor Detail
-
Parser
public Parser(String s, String languagePrefix) throws ParsingException
- Throws:
ParsingException
-
Parser
public Parser(String s, String languagePrefix, int from, int to) throws ParsingException
- Throws:
ParsingException
-
-
Method Detail
-
getExpression
public Evaluable getExpression()
-
next
protected void next(boolean regexPossible)
-
makeException
protected ParsingException makeException(String desc)
-
parseExpression
protected GrelExpr parseExpression() throws ParsingException
<expression> := <sub-expression> | <expression> [ "<" "<=" ">" ">=" "==" "!=" ] <sub-expression>
- Throws:
ParsingException
-
parseSubExpression
protected GrelExpr parseSubExpression() throws ParsingException
<sub-expression> := <term> | <sub-expression> [ "+" "-" ] <term>
- Throws:
ParsingException
-
parseTerm
protected GrelExpr parseTerm() throws ParsingException
<term> := <factor> | <term> [ "*" "/" "%" ] <factor>
- Throws:
ParsingException
-
parseFactor
protected GrelExpr parseFactor() throws ParsingException
<term> := <term-start> ( <path-segment> )* <term-start> := <string> | <number> | - <number> | <regex> | <identifier> | <identifier> ( <expression-list> )
<path-segment> := "[" <expression-list> "]" | "." <identifier> | "." <identifier> "(" <expression-list> ")"
- Throws:
ParsingException
-
parseExpressionList
protected List<GrelExpr> parseExpressionList(String closingDelimiter) throws ParsingException
<expression-list> := <empty> | <expression> ( "," <expression> )*
- Throws:
ParsingException
-
-