Class ScriptPrinter
Script — or one Statement — back as .relix text.
The statement-level counterpart of PrettyPrinter, which does the same for
a relational expression and which this delegates to for every RelNode and
Operand it reaches.
The property this exists for
Printing is only useful if the text reads back as the same script:
parse(print(s)) must equal s, modulo source locations. That is what
makes a script a thing a program can hold, transform and hand back — and it is the
same promise PrettyPrinter already carries for an expression, where it is
load-bearing enough that AstEquivalence compares two nodes through it.
Without this, a session assembled by building an AST has no text form at all: the
REPL's :save works only because it replays the source it captured, which a
script that was never parsed does not have.
Formatting is not part of the promise
The output is normalised, not preserved: one statement per line, a canonical spelling of each keyword, and comments dropped — a comment is not in the AST, so no printer can return one. What is promised is that the text parses back to an equal script, never that it matches the text someone originally wrote.
-
Method Summary
-
Method Details
-
print
Renders a whole script, namespace first, one statement per line.- Parameters:
script- the script to render; must not be null- Returns:
- the
.relixtext
-
print
Renders one statement, including its trailing semicolon.- Parameters:
statement- the statement to render; must not be null- Returns:
- the
.relixtext for that statement
-