Table of Contents

Class ExpressionWriter

Namespace
RDCore.SDK.Model.AST.Expressions
Assembly
RDCore.SDK.dll

Writes an expression of the syntax tree back as the VBA code that says it: what a fix or a refactoring writes when it moves an expression, or builds one out of the parts of others (t = c out of If c Then t = True Else t = False).

public static class ExpressionWriter
Inheritance
ExpressionWriter
Inherited Members

Remarks

What the tree keeps of how an expression is written is written as it was: a name's type-declaration character and its square brackets (Left$, x.[My Field]), a literal's spelling (Spelling), and every pair of parentheses. A pair of parentheses is an operation of its own (MS-VBAL §5.6.6): the writer never adds or drops one for precedence's sake, so what it writes parses back to the tree it was written from (ExpressionEquivalence).

What the tree does not keep is written the one way the writer has: one space around a binary operator, none inside parentheses, ", " between arguments, and the keywords as VBA spells them.

Methods

Write(ExpressionNode)

The VBA code that says an expression.

public static string? Write(ExpressionNode expression)

Parameters

expression ExpressionNode

The expression, a node of a syntax tree or one a fix or a refactoring builds.

Returns

string

The code, or null when the expression, or any part of it, is one the writer does not write: an expression the parse could not read (UnbuiltExpressionTriviaNode), a part of a declaration or of a Print statement rather than an expression, or a literal of a value no literal writes (a Byte, a Decimal, a string that holds a line break). It is never a guess.