Enhanced C#
Language of your choice: library documentation
Public static fields | Properties | Public Member Functions | List of all members
Loyc.Syntax.LNodeFactory Class Reference

Contains helper methods for creating LNodes. An LNodeFactory holds a reference to the current source file (File) so that it does not need to be repeated every time you create a node. More...


Source file:

Remarks

Contains helper methods for creating LNodes. An LNodeFactory holds a reference to the current source file (File) so that it does not need to be repeated every time you create a node.

Public static fields

static readonly LNode Missing_ = new StdIdNode(S.Missing, new SourceRange(EmptySourceFile.Unknown))
 

Properties

LNode Missing [get]
 
ISourceFile File [get, set]
 
IMessageSink< LNode >?? ErrorSink [get, set]
 Where errors should be sent if there is an error parsing a literal. More...
 
LNode true [get]
 
LNode false [get]
 
LNode null [get]
 
LNode void [get]
 
LNode int_0 [get]
 
LNode int_1 [get]
 
LNode string_empty [get]
 

Public Member Functions

 LNodeFactory (ISourceFile file, IMessageSink sink=null)
 
LNode?? this[0, Missing_]. IsIdNamed (S.TriviaNewline)) return node
 
LNode Id (string name, int startIndex=-1, int endIndex=-1)
 
LNode Id (Symbol name, int startIndex=-1, int endIndex=-1)
 
LNode Id (Symbol name, Token t)
 
LNode Id (Token t)
 
LiteralNode Literal< V > (V value, int startIndex=-1, int endIndex=-1)
 
LiteralNode Literal (object value, string typeMarker, int startIndex=-1, int endIndex=-1)
 
LiteralNode Literal (object value, Symbol typeMarker, int startIndex=-1, int endIndex=-1)
 
LiteralNode Literal (Token t)
 Creates a literal from a Token. If the token style is NodeStyle.UninterpretedLiteral, this method uses StandardLiteralHandlers.Value to parse the literal's value; otherwise LiteralFromValueOf(Token) is called to create the literal based on the Token.Value. More...
 
LiteralNode Literal (Token t, ILiteralParser parser)
 Creates a literal from a Token. If it's an "ordinary" token, this function simply calls LiteralFromValueOf(Token). If it is an "uninterpreted literal" (type marker with text), this function uses the parser provided to interpret the literal, or, parser is null, calls UninterpretedLiteral(Token) to create the node without parsing it. More...
 
LiteralNode LiteralFromValueOf (Token t)
 Creates a literal whose LNode.Value is the same as the value of t. More...
 
LiteralNode UninterpretedLiteral (Token t)
 This method produces a literal by assuming that the provided token is an uninterpreted literal (see NodeStyle.UninterpretedLiteral) in the current file and that it does not need to be parsed. Therefore, t.Value becomes the LNode.TypeMarker, t.TextValue(_file.Text) becomes the LNode.TextValue, and the LNode.Value will be a boxed copy of TextValue. More...
 
LNode Trivia (string suffix, object value)
 Creates a trivia node named "%" + suffix with the specified Value attached. More...
 
LNode Trivia (Symbol name, object value, int startIndex=-1, int endIndex=-1)
 Creates a trivia node with the specified Value attached. More...
 
LNode Call (LNode target, IEnumerable< LNode > args, int startIndex=-1, int endIndex=-1)
 
LNode Call (LNode target, LNodeList args, int startIndex=-1, int endIndex=-1)
 
LNode Call (LNode target, int startIndex=-1, int endIndex=-1)
 
LNode Call (LNode target, LNode _1, int startIndex=-1, int endIndex=-1)
 
LNode Call (LNode target, LNode _1, LNode _2, int startIndex=-1, int endIndex=-1)
 
LNode Call (LNode target, LNode _1, LNode _2, LNode _3, int startIndex=-1, int endIndex=-1)
 
LNode Call (LNode target, LNode _1, LNode _2, LNode _3, LNode _4, int startIndex=-1, int endIndex=-1)
 
LNode Call (LNode target, params LNode[] list)
 
LNode Call (LNode target, LNode[] list, int startIndex=-1, int endIndex=-1)
 
LNode Call (Symbol target, IEnumerable< LNode > args, int startIndex=-1, int endIndex=-1)
 
LNode Call (Symbol target, LNodeList args, int startIndex=-1, int endIndex=-1)
 
LNode Call (Symbol target, LNodeList args, int startIndex, int endIndex, int targetStart, int targetEnd, NodeStyle style=NodeStyle.Default)
 
LNode Call (Symbol target, int startIndex=-1, int endIndex=-1)
 
LNode Call (Symbol target, LNode _1, int startIndex=-1, int endIndex=-1)
 
LNode Call (Symbol target, LNode _1, LNode _2, int startIndex=-1, int endIndex=-1)
 
LNode Call (Symbol target, LNode _1, LNode _2, LNode _3, int startIndex=-1, int endIndex=-1)
 
LNode Call (Symbol target, LNode _1, LNode _2, LNode _3, LNode _4, int startIndex=-1, int endIndex=-1)
 
LNode Call (Symbol target, int startIndex, int endIndex, int targetStart, int targetEnd, NodeStyle style=NodeStyle.Default)
 
LNode Call (Symbol target, LNode _1, int startIndex, int endIndex, int targetStart, int targetEnd, NodeStyle style=NodeStyle.Default)
 
LNode Call (Symbol target, LNode _1, LNode _2, int startIndex, int endIndex, int targetStart, int targetEnd, NodeStyle style=NodeStyle.Default)
 
LNode Call (Symbol target, params LNode[] args)
 
LNode Call (Symbol target, LNode[] args, int startIndex=-1, int endIndex=-1)
 
LNode Call (string target, IEnumerable< LNode > args, int startIndex=-1, int endIndex=-1)
 
LNode Call (string target, LNodeList args, int startIndex=-1, int endIndex=-1)
 
LNode Call (string target, int startIndex=-1, int endIndex=-1)
 
LNode Call (string target, LNode _1, int startIndex=-1, int endIndex=-1)
 
LNode Call (string target, LNode _1, LNode _2, int startIndex=-1, int endIndex=-1)
 
LNode Call (string target, LNode _1, LNode _2, LNode _3, int startIndex=-1, int endIndex=-1)
 
LNode Call (string target, LNode _1, LNode _2, LNode _3, LNode _4, int startIndex=-1, int endIndex=-1)
 
LNode Call (string target, params LNode[] args)
 
LNode Call (string target, LNode[] args, int startIndex=-1, int endIndex=-1)
 
LNode Call (Token target, IEnumerable< LNode > args, int startIndex=-1, int endIndex=-1, NodeStyle style=NodeStyle.Default)
 
LNode Call (Token target, LNodeList args, int startIndex=-1, int endIndex=-1, NodeStyle style=NodeStyle.Default)
 
LNode Call (Token target, int startIndex=-1, int endIndex=-1, NodeStyle style=NodeStyle.Default)
 
LNode Call (Token target, LNode _1, int startIndex=-1, int endIndex=-1, NodeStyle style=NodeStyle.Default)
 
LNode Call (Token target, LNode _1, LNode _2, int startIndex=-1, int endIndex=-1, NodeStyle style=NodeStyle.Default)
 
LNode Dot (Symbol prefix, Symbol symbol)
 
LNode Dot (params string[] symbols)
 
LNode Dot (params Symbol[] symbols)
 
LNode Dot (params LNode[] parts)
 
LNode Dot (LNode prefix, Symbol symbol, int startIndex=-1, int endIndex=-1)
 
LNode Dot (LNode prefix, LNode symbol, int startIndex=-1, int endIndex=-1)
 
LNode Dot (LNode prefix, LNode symbol, int startIndex, int endIndex, int dotStart, int dotEnd, NodeStyle style=NodeStyle.Default)
 
LNode Of (params Symbol[] list)
 
LNode Of (params LNode[] list)
 
LNode Of (LNode stem, LNode T1, int startIndex=-1, int endIndex=-1)
 
LNode Of (Symbol stem, LNode T1, int startIndex=-1, int endIndex=-1)
 
LNode Of (LNode stem, IEnumerable< LNode > typeParams, int startIndex=-1, int endIndex=-1)
 
LNode Of (Symbol stem, IEnumerable< LNode > typeParams, int startIndex=-1, int endIndex=-1)
 
LNode Braces (params LNode[] contents)
 
LNode Braces (LNodeList contents, int startIndex=-1, int endIndex=-1)
 
LNode Braces (LNode[] contents, int startIndex=-1, int endIndex=-1)
 
LNode Braces (IEnumerable< LNode > contents, int startIndex=-1, int endIndex=-1)
 
LNode List ()
 
LNode List (params LNode[] contents)
 
LNode List (LNode[] contents, int startIndex=-1, int endIndex=-1)
 
LNode List (LNodeList contents, int startIndex=-1, int endIndex=-1)
 
LNode List (IEnumerable< LNode > contents, int startIndex=-1, int endIndex=-1)
 
LNode Splice ()
 
LNode Splice (params LNode[] contents)
 
LNode Splice (LNode[] contents, int startIndex=-1, int endIndex=-1)
 
LNode Splice (LNodeList contents, int startIndex=-1, int endIndex=-1)
 
LNode Splice (IEnumerable< LNode > contents, int startIndex=-1, int endIndex=-1)
 
LNode Tuple ()
 
LNode Tuple (params LNode[] contents)
 
LNode Tuple (LNode[] contents, int startIndex=-1, int endIndex=-1)
 
LNode Tuple (LNodeList contents, int startIndex=-1, int endIndex=-1)
 
LNode Tuple (IEnumerable< LNode > contents, int startIndex=-1, int endIndex=-1)
 
LNode Fn (LNode retType, Symbol name, LNode argList, LNode body=null, int startIndex=-1, int endIndex=-1)
 
LNode Fn (LNode retType, LNode name, LNode argList, LNode body=null, int startIndex=-1, int endIndex=-1)
 
LNode Property (LNode type, LNode name, LNode body=null, int startIndex=-1, int endIndex=-1)
 
LNode Property (LNode type, LNode name, LNode argList, LNode body, LNode initializer=null, int startIndex=-1, int endIndex=-1)
 
LNode Var (LNode type, string name, LNode initValue=null, int startIndex=-1, int endIndex=-1)
 
LNode Var (LNode type, Symbol name, LNode initValue=null, int startIndex=-1, int endIndex=-1)
 
LNode Var (LNode type, LNode name, LNode initValue=null, int startIndex=-1, int endIndex=-1)
 
LNode Var (LNode type, LNode name)
 
LNode Vars (LNode type, params Symbol[] names)
 
LNode Vars (LNode type, params LNode[] namesWithValues)
 
LNode InParens (LNode inner)
 
LNode InParens (LNode inner, int startIndex, int endIndex)
 
LNode Result (LNode expr)
 
LNode Attr (LNode attr, LNode node)
 
LNode Attr (params LNode[] attrsAndNode)
 
LNode Assign (Symbol lhs, LNode rhs, int startIndex=-1, int endIndex=-1)
 
LNode Assign (LNode lhs, LNode rhs, int startIndex=-1, int endIndex=-1)
 

Member Function Documentation

◆ Literal() [1/2]

LiteralNode Loyc.Syntax.LNodeFactory.Literal ( Token  t)

Creates a literal from a Token. If the token style is NodeStyle.UninterpretedLiteral, this method uses StandardLiteralHandlers.Value to parse the literal's value; otherwise LiteralFromValueOf(Token) is called to create the literal based on the Token.Value.

Parameters
tToken to be converted

◆ Literal() [2/2]

LiteralNode Loyc.Syntax.LNodeFactory.Literal ( Token  t,
ILiteralParser  parser 
)
inline

Creates a literal from a Token. If it's an "ordinary" token, this function simply calls LiteralFromValueOf(Token). If it is an "uninterpreted literal" (type marker with text), this function uses the parser provided to interpret the literal, or, parser is null, calls UninterpretedLiteral(Token) to create the node without parsing it.

Parameters
tToken to be converted
parserUsed to obtain a value from an uninterpreted literal, which becomes the LNode.Value property.

References Loyc.Syntax.LNodeFactory.ErrorSink, Loyc.Syntax.LNodeFactory.LiteralFromValueOf(), Loyc.Syntax.Lexing.Token.TextValue(), Loyc.Syntax.ILiteralParser.TryParse(), Loyc.Syntax.Lexing.Token.TypeMarker, and Loyc.Syntax.LNodeFactory.UninterpretedLiteral().

◆ LiteralFromValueOf()

LiteralNode Loyc.Syntax.LNodeFactory.LiteralFromValueOf ( Token  t)
inline

◆ Trivia() [1/2]

LNode Loyc.Syntax.LNodeFactory.Trivia ( string  suffix,
object  value 
)
inline

Creates a trivia node named "%" + suffix with the specified Value attached.

This method only adds the prefix % if it is not already present in the 'suffix' argument.

◆ Trivia() [2/2]

LNode Loyc.Syntax.LNodeFactory.Trivia ( Symbol  name,
object  value,
int  startIndex = -1,
int  endIndex = -1 
)
inline

Creates a trivia node with the specified Value attached.

See also
LNode.Trivia(Symbol, object, LNode)

◆ UninterpretedLiteral()

LiteralNode Loyc.Syntax.LNodeFactory.UninterpretedLiteral ( Token  t)
inline

This method produces a literal by assuming that the provided token is an uninterpreted literal (see NodeStyle.UninterpretedLiteral) in the current file and that it does not need to be parsed. Therefore, t.Value becomes the LNode.TypeMarker, t.TextValue(_file.Text) becomes the LNode.TextValue, and the LNode.Value will be a boxed copy of TextValue.

References Loyc.Syntax.Lexing.Token.Range(), Loyc.Syntax.Lexing.Token.TextValue(), and Loyc.Syntax.Lexing.Token.TypeMarker.

Referenced by Loyc.Syntax.LNodeFactory.Literal().

Property Documentation

◆ ErrorSink

IMessageSink<LNode>?? Loyc.Syntax.LNodeFactory.ErrorSink
getset

Where errors should be sent if there is an error parsing a literal.

Attempting to set this to null makes the getter return MessageSink.Default.

Referenced by Loyc.Syntax.LNodeFactory.Literal().