Class RelAlgebraParser

java.lang.Object
com.darkcollective.relix.parser.RelAlgebraParser

public final class RelAlgebraParser extends Object
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 Type
    Method
    Description
    static RelNode
    Parses a relational algebra expression from the given input stream.
    static RelNode
    parse(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 RelNode
    parse(String input)
    Parses a relational algebra expression from the given input string.
    static RelNode
    parse(String input, int startLine, int startColumn)
    Parses a relational algebra expression from the given input string, starting from the specified line and column position.
    static RelNode
    parse(String input, String filePath, int startLine, int startColumn)
    Parses a relational algebra expression from the given input string, with a specific file path embedded in every node's source location.
    static Operand
    parseOperand(String input, int startLine, int startColumn)
    Parses a scalar operand expression from the given input string, starting from the specified source position.
    static Operand
    parseOperand(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parse

      public static RelNode parse(String input)
      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

      public static RelNode parse(String input, int startLine, int startColumn)
      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 parse
      startLine - 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 errors
      IllegalArgumentException - if startLine or startColumn is less than 1
    • parse

      public static RelNode parse(String input, String filePath, int startLine, int startColumn)
      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 parse
      filePath - the file path to embed in source locations
      startLine - 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 errors
      IllegalArgumentException - if startLine or startColumn is less than 1
    • parseOperand

      public static Operand parseOperand(String input, int startLine, int startColumn)
      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 def function declarations, which are operand expressions rather than full relational-algebra expressions.

      Parameters:
      input - the operand expression to parse
      startLine - 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

      public static Operand parseOperand(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.
      Parameters:
      input - the operand expression to parse
      filePath - the file path to embed in source locations
      startLine - 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

      public static RelNode parse(InputStream input) throws IOException
      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 stream
      ParseException - if the input contains syntax errors
    • parse

      public static RelNode parse(InputStream input, int startLine, int startColumn) throws IOException
      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 expression
      startLine - 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 stream
      ParseException - if the input contains syntax errors
      IllegalArgumentException - if startLine or startColumn is less than 1