Enhanced C#
Language of your choice: library documentation
Public Member Functions | Protected Member Functions | List of all members
Loyc.Ecs.Parser.EcsTriviaInjector Class Reference

Trivia injector customized for Enhanced C#. More...


Source file:
Inheritance diagram for Loyc.Ecs.Parser.EcsTriviaInjector:
Loyc.Syntax.StandardTriviaInjector Loyc.Syntax.AbstractTriviaInjector< Token >

Remarks

Trivia injector customized for Enhanced C#.

How newline trivia works in EC# (mostly this is the same as StandardTriviaInjector):

Public Member Functions

 EcsTriviaInjector (IListSource< Token > sortedTrivia, ISourceFile sourceFile, int newlineTypeInt, string mlCommentPrefix, string mlCommentSuffix, string slCommentPrefix, bool topLevelIsBlock)
 
- Public Member Functions inherited from Loyc.Syntax.StandardTriviaInjector
 StandardTriviaInjector (IListSource< Token > sortedTrivia, ISourceFile sourceFile, int newlineTypeInt, string mlCommentPrefix, string mlCommentSuffix, string slCommentPrefix, bool topLevelIsBlock=true)
 Initializes StandardTriviaInjector. More...
 
- Public Member Functions inherited from Loyc.Syntax.AbstractTriviaInjector< Token >
 AbstractTriviaInjector (IListSource< Trivia > sortedTrivia)
 Initializes the SortedTrivia property. More...
 
IEnumerator< LNodeRun (IEnumerator< LNode > nodes)
 Attaches trivia to the input nodes provided. More...
 

Protected Member Functions

override LNodeList GetTriviaToAttach (LNode node, IListSource< Token > trivia, TriviaLocation loc, LNode parent, int indexInParent)
 
override LNode MakeTriviaAttribute (Token t)
 Called to transform a trivia token into a trivia attribute. More...
 
override LNode DoneAttaching (LNode node, LNode parent, int indexInParent)
 This method is called after a node has been processed and any applicable trivia was attached. More...
 
- Protected Member Functions inherited from Loyc.Syntax.StandardTriviaInjector
override LNodeList GetTriviaToAttach (LNode node, IListSource< Token > trivia, TriviaLocation loc, LNode parent, int indexInParent)
 
virtual bool HasImplicitLeadingNewline (LNode child, LNode parent, int indexInParent)
 Called to find out if a newline is to be added implicitly before the current child of the specified node. More...
 
override bool IsNewline (Token trivia)
 
override SourceRange GetRange (Token trivia)
 
- Protected Member Functions inherited from Loyc.Syntax.AbstractTriviaInjector< Token >
abstract LNodeList GetTriviaToAttach (LNode node, IListSource< Trivia > trivia, TriviaLocation loc, LNode parent, int indexInParent)
 Derived class translates a list of trivia (tokens) into appropriate trivia attributes. This will be called for leading trivia before trailing trivia. More...
 
virtual void ProcessChildrenOfOneLiner (ref LNode node)
 This method is called when a node has no newlines or comments within it (although the node may still have a leading or trailing comment). The method should add appendStatement trivia inside blocks in the node, if necessary. More...
 
abstract SourceRange GetRange (Trivia trivia)
 Gets the SourceRange for an element of trivia. More...
 
abstract bool IsNewline (Trivia trivia)
 Returns true if the trivia represents a newline, false otherwise. More...
 
virtual LNode GetEmptyResultSet ()
 A method called to create a virtual node, in order to apply trivia to a source file that is completely empty except for trivia. More...
 
IEnumerator< Pair< LNode, int > > RunCore (IEnumerator< Pair< LNode, int >> nodes, LNode parent)
 Core trivia associaton algorithm. More...
 

Additional Inherited Members

- Properties inherited from Loyc.Syntax.StandardTriviaInjector
ISourceFile SourceFile [get, set]
 
int NewlineTypeInt [get, set]
 
string SLCommentPrefix [get, set]
 
string SLCommentSuffix [get, set]
 
string MLCommentPrefix [get, set]
 
string MLCommentSuffix [get, set]
 
bool TopLevelIsBlock [get, set]
 
- Properties inherited from Loyc.Syntax.AbstractTriviaInjector< Token >
IListSource< Trivia > SortedTrivia [get, set]
 List of trivia to be injected by Run. Must be sorted. More...
 
int NextIndex [get, set]
 Index of next trivia to be injected. More...
 
- Static Protected Member Functions inherited from Loyc.Syntax.AbstractTriviaInjector< Token >
static IEnumerator< Pair< T, int > > WithIndexes< T > (IEnumerator< T > e)
 

Member Function Documentation

◆ DoneAttaching()

override LNode Loyc.Ecs.Parser.EcsTriviaInjector.DoneAttaching ( LNode  node,
LNode  parent,
int  indexInParent 
)
inlineprotectedvirtual

This method is called after a node has been processed and any applicable trivia was attached.

Parameters
nodeNode (after trivia attached)
parentParent of node (old version, before changes to children are applied)
indexInParentIndex of node within parent.
Returns
Should return node or an altered version of node.

This method gives the derived class one final chance to rearrange or alter the interpretation of the attached trivia. Note that this method may be called on some nodes to which trivia was not attached, when siblings of the same parent had trivia attached.

Reimplemented from Loyc.Syntax.AbstractTriviaInjector< Token >.

References Loyc.Syntax.LNode.Args, Loyc.Syntax.CodeSymbols.Braces, Loyc.Syntax.LNode.Calls(), Loyc.Syntax.LNode.CallsMin(), Loyc.Syntax.LNode.Range, and Loyc.Syntax.LNode.Target.

◆ MakeTriviaAttribute()

override LNode Loyc.Ecs.Parser.EcsTriviaInjector.MakeTriviaAttribute ( Token  t)
inlineprotectedvirtual

Called to transform a trivia token into a trivia attribute.

If a trivia token is not recognized, null is returned to ignore the trivia.

Reimplemented from Loyc.Syntax.StandardTriviaInjector.

References Loyc.Syntax.Lexing.Token.Range(), and Loyc.Syntax.Lexing.Token.Value.