Class Printer
- Direct Known Subclasses:
Printer,Printer.WithLines,Solver_z3_4_3.Translator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceFunctional interface for the argument-printing lambda passed toprintCommand(org.smtlib.ICommand, org.smtlib.sexpr.Printer.PrintArgs).static classNested classes/interfaces inherited from interface org.smtlib.IVisitor
IVisitor.TreeVisitor<T>, IVisitor.VisitorException -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPrinter(SMT.Configuration smtConfig, Writer w) Creates a printer object that follows the given Configuration's rules. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAppends a string to the writer, converting any IOException to VisitorException.Utility function to print error messages in this printer's formatUtility function to create an exception using the message from the first argument and the position from the second, if it is IPosable.protected voidflush()Flushes the writer, converting any IOException to VisitorException.newPrinter(Writer w) Creates a new printer of the same type as the receiver, writing to the given Writer.<T extends INode>
voidprint(T expr) Prints the argument to the receiverprotected VoidPrints a no-argument command:(commandName()).protected VoidprintCommand(ICommand e, Printer.PrintArgs args) Prints(commandName() args)— the space between name and args is emitted here, so theargslambda should not prepend one.toString(T expr) Returns the argument as a String using a Printer of the same type as the receiver, but does not modify the receiver.Fallback for extension command types not covered by a specific visit method; uses reflection to invokewrite(Printer)on the command object.A comment is never "(commandName args)" S-expression syntax to begin with, so this doesn't go throughprintCommand()like every other command here -- instead it's printed directly, now that Comment is a real, typed command rather than going through the genericvisit(ICommand)fallback's reflection-basedwrite()lookup (see issue #115; this logic used to live in awrite()override onC_commentitself, invoked only via that reflection call -- moved here instead, so printing for every command, including this one, lives in exactly one place: Printer's own typedvisit()methods).visit(IExpr.IAttribute<? extends IAttributeValue> e) visit(IExpr.ILet e) Visits the value of a programmatically built:patternattribute; by default does nothing.Prints the proof s-expression compactly; a proof that is a list of lists (e.g.visit(ISexpr.ISeq e) visit(ISexpr.IToken<?> e) static <T extends INode>
voidwrite(SMT.Configuration smtConfig, PrintStream w, T e) Writes the given expression to the given stream, following the given Configuration's rules.static <T extends INode>
voidwrite(SMT.Configuration smtConfig, Writer w, T e) Writes the given expression to the given writer, following the given Configuration's rules.write(SMT.Configuration smtConfig, T e) Writes the given expression and outputs as a String, following the given Configuration's rules (e.g.writer()The writer to write text to
-
Field Details
-
smtConfig
The Configuration whose rules (e.g. string-literal quoting -- seevisit(IStringLiteral)-- which is version-dependent) this Printer instance follows. Issue #22: used to be a single static field shared by every Printer instance process-wide, so constructing a second Configuration anywhere in the process silently repointed every other Printer's quoting rules at the new instance's settings. Now set once per instance, at construction, like the writer itself. -
w
The writer to write text to -
eol
The system-dependent line termination
-
-
Constructor Details
-
Printer
Creates a printer object that follows the given Configuration's rules.
-
-
Method Details
-
writer
The writer to write text to -
append
Appends a string to the writer, converting any IOException to VisitorException.- Throws:
IVisitor.VisitorException
-
flush
Flushes the writer, converting any IOException to VisitorException.- Throws:
IVisitor.VisitorException
-
newPrinter
Description copied from interface:IPrinterCreates a new printer of the same type as the receiver, writing to the given Writer.- Specified by:
newPrinterin interfaceIPrinter
-
print
Prints the argument to the receiver- Specified by:
printin interfaceIPrinter- Throws:
IVisitor.VisitorException
-
toString
Returns the argument as a String using a Printer of the same type as the receiver, but does not modify the receiver. -
write
Writes the given expression and outputs as a String, following the given Configuration's rules (e.g. string-literal quoting). -
write
public static <T extends INode> void write(SMT.Configuration smtConfig, Writer w, T e) throws IVisitor.VisitorException Writes the given expression to the given writer, following the given Configuration's rules.- Throws:
IVisitor.VisitorException
-
write
public static <T extends INode> void write(SMT.Configuration smtConfig, PrintStream w, T e) throws IVisitor.VisitorException Writes the given expression to the given stream, following the given Configuration's rules.- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
Description copied from interface:IVisitorVisits the value of a programmatically built:patternattribute; by default does nothing.- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
printCommand
Prints(commandName() args)— the space between name and args is emitted here, so theargslambda should not prepend one. Subclasses may override to change the overall command format.- Throws:
IVisitor.VisitorException
-
printCommand
Prints a no-argument command:(commandName()). Subclasses may override to change format.- Throws:
IVisitor.VisitorException
-
visit
Fallback for extension command types not covered by a specific visit method; uses reflection to invokewrite(Printer)on the command object.- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
A comment is never "(commandName args)" S-expression syntax to begin with, so this doesn't go throughprintCommand()like every other command here -- instead it's printed directly, now that Comment is a real, typed command rather than going through the genericvisit(ICommand)fallback's reflection-basedwrite()lookup (see issue #115; this logic used to live in awrite()override onC_commentitself, invoked only via that reflection call -- moved here instead, so printing for every command, including this one, lives in exactly one place: Printer's own typedvisit()methods).Text parsed from a real script is always already well-formed this way (every line, including a multi-line block's continuation lines, already carries its own leading
;in the source, so it prints back out verbatim, byte for byte) -- but text supplied directly via the public API might have an embedded newline with no;on the continuation line, which would silently end the comment there and let the continuation be re-parsed as code. So each line is checked, and given its own;if it doesn't already have one and isn't just blank. A comment parsed immediately before a real command always already ends with a newline in the captured source text (a;comment can't share a line with whatever follows it, so there's necessarily at least one newline swept into the capture) -- but a trailing comment at true end-of-file, or text supplied directly via the public API, might not. Printing without a final newline would risk whatever gets printed right after landing on the same line and being silently swallowed by this comment (since;consumes to end of line), so one is always guaranteed here regardless.- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
exc
Utility function to create an exception using the message from the first argument and the position from the second, if it is IPosable. -
error
Utility function to print error messages in this printer's format -
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
Prints the proof s-expression compactly; a proof that is a list of lists (e.g. cvc5's steps, z3's (set-logic) and (proof)) gets one element per line, as get-assertions does.- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-
visit
- Specified by:
visitin interfaceIVisitor<Void>- Throws:
IVisitor.VisitorException
-