Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public Types | Public fields | Public static fields | Properties | Public Member Functions | Static Public Member Functions | Protected fields | List of all members
Loyc.Syntax.Les.LesNodePrinter Class Reference

Prints a Loyc tree in LES (Loyc Expression Syntax) format. More...


Source file:

Remarks

Prints a Loyc tree in LES (Loyc Expression Syntax) format.

Unless otherwise noted, the default value of all options is false.

Public Types

enum  Mode { Mode.Wsa = 8, Mode.InParens = 24 }
 TODO: these modes no longer apply, remove them More...
 

Public fields

int SpaceAroundInfixStopPrecedence = LesPrecedence.Power.Lo
 
int SpaceAfterPrefixStopPrecedence = LesPrecedence.Prefix.Lo
 

Public static fields

static readonly LNodePrinter Printer = Print
 
static readonly Precedence StartStmt = Precedence.MinValue
 Context: beginning of main expression (potential superexpression) More...
 

Properties

INodePrinterWriter Writer [get, set]
 
IMessageSink Errors [get, set]
 
bool AllowExtraParenthesis [get, set]
 Introduces extra parenthesis to express precedence, without using an empty attribute list [] to allow perfect round-tripping. More...
 
bool OmitMissingArguments [get, set]
 When an argument to a method or macro has the value @``, it will be omitted completely if this flag is set. More...
 
bool OmitSpaceTrivia [get, set]
 When this flag is set, space trivia attributes are ignored (e.g. CodeSymbols.TriviaSpaceAfter). More...
 
bool OmitComments [get, set]
 When this flag is set, comment trivia attributes are ignored (e.g. CodeSymbols.TriviaSLCommentAfter). More...
 
bool QuoteUnprintableLiterals [get, set]
 When the printer encounters an unprintable literal, it calls Value.ToString(). When this flag is set, the string is placed in double quotes; when this flag is clear, it is printed as raw text. More...
 
bool OmitUnknownTrivia [get, set]
 Causes unknown trivia (other than comments, spaces and raw text) to be dropped from the output. More...
 
bool PrintExplicitTrivia [get, set]
 Causes comments and spaces to be printed as attributes in order to ensure faithful round-trip parsing. By default, only "raw text" and unrecognized trivia is printed this way. Note: #trivia_inParens is always printed as parentheses. More...
 
bool ObeyRawText [get, set]
 Causes raw text to be printed verbatim, as the EC# printer does. When this option is false, raw text trivia is printed as a normal attribute. More...
 

Public Member Functions

 LesNodePrinter (INodePrinterWriter target, IMessageSink errors=null)
 
void Print (LNode node)
 
void Print (LNode node, Mode mode, Precedence context, string terminator=null)
 

Static Public Member Functions

static LesNodePrinter New (StringBuilder target, string indentString="\t", string lineSeparator="\n", IMessageSink sink=null)
 
static LesNodePrinter New (TextWriter target, string indentString="\t", string lineSeparator="\n", IMessageSink sink=null)
 
static void Print (LNode node, StringBuilder target, IMessageSink errors, object mode, string indentString, string lineSeparator)
 
static string PrintId (Symbol name)
 
static string PrintLiteral (object value, NodeStyle style=0)
 
static string PrintString (string text, char quoteType, bool tripleQuoted)
 
static bool IsNormalIdentifier (Symbol name)
 Returns true if the given symbol can be printed as a normal identifier, without an "@" prefix. Note: identifiers starting with "#" still count as normal; call LNode.HasSpecialName to detect this. More...
 

Protected fields

LesPrecedenceMap _prec = LesPrecedenceMap.Default
 

Member Enumeration Documentation

TODO: these modes no longer apply, remove them

Enumerator
Wsa 

Whitespace agnostic mode. ':' cannot be used to begin a python-style code block.

InParens 

Inside parenthesis (implies Wsa, and additionally allows ':' as an operator).

Member Function Documentation

static bool Loyc.Syntax.Les.LesNodePrinter.IsNormalIdentifier ( Symbol  name)
inlinestatic

Returns true if the given symbol can be printed as a normal identifier, without an "@" prefix. Note: identifiers starting with "#" still count as normal; call LNode.HasSpecialName to detect this.

Member Data Documentation

readonly Precedence Loyc.Syntax.Les.LesNodePrinter.StartStmt = Precedence.MinValue
static

Context: beginning of main expression (potential superexpression)

Property Documentation

bool Loyc.Syntax.Les.LesNodePrinter.AllowExtraParenthesis
getset

Introduces extra parenthesis to express precedence, without using an empty attribute list [] to allow perfect round-tripping.

For example, the Loyc tree x * @+(a, b) will be printed x * (a + b), which is a slightly different tree (the parenthesis add the trivia attribute #trivia_inParens.)

bool Loyc.Syntax.Les.LesNodePrinter.ObeyRawText
getset

Causes raw text to be printed verbatim, as the EC# printer does. When this option is false, raw text trivia is printed as a normal attribute.

bool Loyc.Syntax.Les.LesNodePrinter.OmitComments
getset

When this flag is set, comment trivia attributes are ignored (e.g. CodeSymbols.TriviaSLCommentAfter).

bool Loyc.Syntax.Les.LesNodePrinter.OmitMissingArguments
getset

When an argument to a method or macro has the value @``, it will be omitted completely if this flag is set.

bool Loyc.Syntax.Les.LesNodePrinter.OmitSpaceTrivia
getset

When this flag is set, space trivia attributes are ignored (e.g. CodeSymbols.TriviaSpaceAfter).

bool Loyc.Syntax.Les.LesNodePrinter.OmitUnknownTrivia
getset

Causes unknown trivia (other than comments, spaces and raw text) to be dropped from the output.

bool Loyc.Syntax.Les.LesNodePrinter.PrintExplicitTrivia
getset

Causes comments and spaces to be printed as attributes in order to ensure faithful round-trip parsing. By default, only "raw text" and unrecognized trivia is printed this way. Note: #trivia_inParens is always printed as parentheses.

bool Loyc.Syntax.Les.LesNodePrinter.QuoteUnprintableLiterals
getset

When the printer encounters an unprintable literal, it calls Value.ToString(). When this flag is set, the string is placed in double quotes; when this flag is clear, it is printed as raw text.