Package com.darkcollective.relix.parser
Class RelAlgebraParser
java.lang.Object
com.darkcollective.relix.parser.RelAlgebraParser
Recursive-descent parser for relational algebra expressions.
Each public parse method accepts an optional file path that is
embedded into every SourceLocation attached to parsed AST nodes.
When no file path is supplied, SourceLocation.UNKNOWN is used.
-
Method Summary
Modifier and TypeMethodDescriptionstatic RelNodeparse(InputStream input) Parses a relational algebra expression from the given input stream.static RelNodeparse(InputStream input, int startLine, int startColumn) Parses a relational algebra expression from the given input stream, starting from the specified line and column position.static RelNodeParses a relational algebra expression from the given input string.static RelNodeParses a relational algebra expression from the given input string, starting from the specified line and column position.static RelNodeParses a relational algebra expression from the given input string, with a specific file path embedded in every node's source location.static OperandparseOperand(String input, int startLine, int startColumn) Parses a scalar operand expression from the given input string, starting from the specified source position.static OperandparseOperand(String input, String filePath, int startLine, int startColumn) Parses a scalar operand expression from the given input string, starting from the specified source position, with a specific file path embedded in every node's source location.
-
Method Details
-
parse
Parses a relational algebra expression from the given input string.- Parameters:
input- the relational algebra expression to parse- Returns:
- the parsed AST root node
- Throws:
ParseException- if the input contains syntax errors
-
parse
Parses a relational algebra expression from the given input string, starting from the specified line and column position. Useful when the parser is used by another parser that provides only a portion of an input stream.- Parameters:
input- the relational algebra expression to parsestartLine- the line number to start counting from (1-based)startColumn- the column number to start counting from (1-based)- Returns:
- the parsed AST root node
- Throws:
ParseException- if the input contains syntax errorsIllegalArgumentException- if startLine or startColumn is less than 1
-
parse
Parses a relational algebra expression from the given input string, with a specific file path embedded in every node's source location.- Parameters:
input- the relational algebra expression to parsefilePath- the file path to embed in source locationsstartLine- the line number to start counting from (1-based)startColumn- the column number to start counting from (1-based)- Returns:
- the parsed AST root node
- Throws:
ParseException- if the input contains syntax errorsIllegalArgumentException- if startLine or startColumn is less than 1
-
parseOperand
Parses a scalar operand expression from the given input string, starting from the specified source position.Used by the scripting-language parser to parse the bodies of
deffunction declarations, which are operand expressions rather than full relational-algebra expressions.- Parameters:
input- the operand expression to parsestartLine- 1-based source line (used for error reporting)startColumn- 1-based source column (used for error reporting)- Returns:
- the parsed operand
- Throws:
ParseException- if the input contains syntax errors
-
parseOperand
Parses a scalar operand expression from the given input string, starting from the specified source position, with a specific file path embedded in every node's source location.- Parameters:
input- the operand expression to parsefilePath- the file path to embed in source locationsstartLine- 1-based source line (used for error reporting)startColumn- 1-based source column (used for error reporting)- Returns:
- the parsed operand
- Throws:
ParseException- if the input contains syntax errors
-
parse
Parses a relational algebra expression from the given input stream.- Parameters:
input- the input stream containing the relational algebra expression- Returns:
- the parsed AST root node
- Throws:
IOException- if an error occurs reading from the input streamParseException- if the input contains syntax errors
-
parse
Parses a relational algebra expression from the given input stream, starting from the specified line and column position. Useful when the parser is used by another parser that provides only a portion of an input stream.- Parameters:
input- the input stream containing the relational algebra expressionstartLine- the line number to start counting from (1-based)startColumn- the column number to start counting from (1-based)- Returns:
- the parsed AST root node
- Throws:
IOException- if an error occurs reading from the input streamParseException- if the input contains syntax errorsIllegalArgumentException- if startLine or startColumn is less than 1
-