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
Namespaces | Classes | Enumerations | Functions
Package Loyc.Syntax

Loyc.Syntax.dll: contains Loyc trees (Loyc.Syntax.LNode), lexing stuff, LLLPG base classes (BaseParser{T} and BaseLexer), the LES parser and printer, data types related to source code management (e.g. ISourceFile, SourceRange) and other general-purpose code related to the manipulation of syntax. More...

Namespaces

package  Les
 Contains classes related to Loyc Expression Syntax (LES), including the parser and printer (reachable through Loyc.Syntax.Les.LesLanguageService).
 
package  Lexing
 Contains classes related to lexical analysis, such as the universal token type (Loyc.Syntax.Lexing.Token) and Loyc.Syntax.Lexing.TokensToTree.
 

Classes

class  BaseParser< Token >
 An base class designed for parsers that use LLLPG (Loyc LL(k) Parser Generator). Note: this is the old (harder to use) base class. You should use BaseParserForList{Token, LaType} instead. This class is now an alias for BaseParser{Token,int}. More...
 
class  BaseParser< Token, MatchType >
 An base class designed for parsers that use LLLPG (Loyc LL(k) Parser Generator). Note: this is the old (harder to use) base class design. You should use BaseParserForList{Token,MatchType} instead. More...
 
class  BaseParserForList< Token, MatchType >
 An base class designed for parsers that use LLLPG (Loyc LL(k) Parser Generator) and receive tokens from any IEnumerator{Token}. More...
 
class  BaseParserForList< Token, MatchType, List >
 An base class designed for parsers that use LLLPG (Loyc LL(k) Parser Generator) and receive tokens from any IEnumerator{Token}. (Potentially also useful for parsers written by hand.) More...
 
class  BaseParserNoBacktracking< Token >
 An base class designed for parsers that use LLLPG (Loyc LL(k) Parser Generator) and receive tokens from an IEnumerator{Token}. More...
 
class  BaseParserNoBacktracking< Token, Enumerator >
 An base class designed for parsers that use LLLPG (Loyc LL(k) Parser Generator) and receive tokens from any IEnumerator{Token}. More...
 
class  CallNode
 Base class of all nodes that represent calls such as f(x), operator calls such as x + y, braced blocks, and all other things that are not simple symbols and literals. More...
 
class  CharIndexPositionMapperTests
 
class  CodeSymbols
 A list of common symbols that have special meaning somewhere in Loyc or EC#: operators, built-in data types, keywords, trivia, etc. More...
 
struct  DescendantsFrame
 Helper class used to enumerate LNode.Descendants(). More...
 
class  EmptySourceFile
 A dummy implementation of ISourceFile that has only a filename, no source text. Used as the source file of synthetic syntax nodes. More...
 
class  IdNode
 Base class of all nodes that represent simple identifiers (including special symbols such as #foo). More...
 
interface  IIndexPositionMapper
 This interface is for classes that can convert indexes to SourcePos structures and back. More...
 
interface  IIndexToLine
 Contains IndexToLine method. More...
 
interface  ILNodeVisitor
 Interface for people that want to implement the visitor pattern with LNode. If your visitor does not need a base class, use LNodeVisitor as the base class. More...
 
class  IndexPositionMapper
 Synonym for IndexPositionMapper<IListSource<char>>. More...
 
class  IndexPositionMapper< CharSource >
 Helper class for mapping from indexes to SourcePos and back. More...
 
interface  IParsingService
 An interface that encapsulates the lexer, parser, and printer of a programming language, or a non-programming language that can be represented by Loyc trees. More...
 
interface  ISourceFile
 Represents a text file with a file name and its textual content, plus the data necessary to convert between line-column positions and 0-based integer indexes. More...
 
class  LineAndCol
 Holds a line number (Line) and a position in the line (PosInLine). This class isn't really needed in Loyc but is separated from SourcePos in case anyone might want position without a filename. More...
 
class  LineRemapper
 A small helper class for languages such as C# and C++ that permit the locations reported by error messages to be remapped. This class stores and applies such commands (#line in C#/C++) More...
 
class  LiteralNode
 Base class of all nodes that represent literal values such as 123 and "foo". More...
 
class  LNode
 All nodes in a Loyc syntax tree share this base class. More...
 
class  LNodeExt
 Standard extension methods for LNode. More...
 
class  LNodeFactory
 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...
 
class  LNodeTests
 
class  LNodeVisitor
 Base class for people that want to implement the visitor pattern with LNode. More...
 
class  ParserSource< Token >
 Alias for ParserSource{Token, int, IList{Token}}. More...
 
class  ParserSource< Token, MatchType >
 Alias for ParserSource{Token, int, IList{Token}}. More...
 
class  ParserSource< Token, MatchType, List >
 An implementation of the LLLPG Parser API, used with the LLLPG options inputSource and inputClass. More...
 
class  ParsingService
 Extension methods for IParsingService. More...
 
struct  Precedence
 A four-byte tuple that represents the precedence and miscibility of an operator. More...
 
class  SourceFile
 
class  SourceFile< CharSource >
 A default implementation of ISourceFile based on IndexPositionMapper. More...
 
class  SourceFileWithLineRemaps
 An wrapper around ISourceFile that applies line remapping information (if the source file uses it). More...
 
class  SourcePos
 Holds a filename (FileName), a line number (Line) and a position in the line (PosInLine), representing a position in a source code file. More...
 
class  SourcePosAndIndex
 A SourcePos that also includes the original index from which the Line and PosInLine were derived. More...
 
struct  SourceRange
 Holds a reference to a source file (ISourceFile<char>) and the beginning and end indices of a range in that file. More...
 
class  StreamCharSource
 Exposes a stream as an ICharSource, as though it were an array of characters. The stream must support seeking, and if a text decoder is specified, it must meet certain constraints. More...
 

Enumerations

enum  NodeScanMode {
  YieldSelf = 1, YieldLocalAttrs = 2, YieldLocalHead = 4,
  YieldLocalArgsOnly = 8, YieldLocalNonAttrs = YieldLocalArgsOnly | YieldLocalHead, YieldLocal = YieldLocalAttrs | YieldLocalNonAttrs,
  YieldDeepAttrs = 16, YieldDeepHeads = 32, YieldDeepArgsOnly = 64,
  YieldDeepNonAttrs = YieldDeepArgsOnly | YieldDeepHeads, YieldDeep = YieldDeepAttrs | YieldDeepNonAttrs, YieldAttrs = YieldLocalAttrs | YieldDeepAttrs,
  YieldHeads = YieldLocalHead | YieldDeepHeads, YieldArgsOnly = YieldLocalArgsOnly | YieldDeepArgsOnly, YieldNonAttrs = YieldLocalNonAttrs | YieldDeepNonAttrs,
  YieldAllChildren = YieldAttrs | YieldNonAttrs, YieldAll = YieldAllChildren | YieldSelf, ScanAttrs = 128,
  ScanHeads = 256, ScanArgsOnly = 512, ScanNonAttrs = ScanHeads | ScanArgsOnly,
  ScanAll = ScanAttrs | ScanNonAttrs
}
 Specifies which children to enumerate when calling LNode.Descendants(). More...
 
enum  LNodeKind { Id, Literal, Call }
 The three kinds of nodes in a Loyc tree More...
 
enum  NodeStyle : byte {
  NodeStyle.Default = 0, NodeStyle.Operator = 1, NodeStyle.Statement = 2,
  NodeStyle.Special = 3, NodeStyle.PrefixNotation = 4, NodeStyle.Expression = 5,
  NodeStyle.DataType = 6, NodeStyle.OldStyle = 7, NodeStyle.BaseStyleMask = 7,
  NodeStyle.Alternate = 8, NodeStyle.Alternate2 = 16, NodeStyle.Handled = 128
}
 Suggests a printing style when serializing a Loyc tree to text. More...
 
enum  OperatorShape {
  Suffix = -1, Nullary = 0, Prefix = 1,
  Infix = 2, Ternary = 3, Other = 4
}
 An enum of common operator formats. More...
 

Functions

delegate void LNodePrinter (LNode node, StringBuilder target, IMessageSink errors, object mode=null, string indentString="\t", string lineSeparator="\n")
 Signature for a method that serializes a Loyc tree to text. Each programming language will have one (when complete). More...
 

Detailed Description

Loyc.Syntax.dll: contains Loyc trees (Loyc.Syntax.LNode), lexing stuff, LLLPG base classes (BaseParser{T} and BaseLexer), the LES parser and printer, data types related to source code management (e.g. ISourceFile, SourceRange) and other general-purpose code related to the manipulation of syntax.

Enumeration Type Documentation

The three kinds of nodes in a Loyc tree

Specifies which children to enumerate when calling LNode.Descendants().

TODO code review

enum Loyc.Syntax.NodeStyle : byte

Suggests a printing style when serializing a Loyc tree to text.

See LNode.Style.

TODO: review, rethink.

A printer should not throw exceptions unless specifically requested. It should ignore printing styles that it does not allow, rather than throwing.

Styles may be used in different ways by different parsers, different printers and different people. Be careful how you rely on them; they are intended to affect only the appearance of a node when it is printed, not its semantics.

Please note that language-specific printing styles can be denoted by attaching special attributes recognized by the printer for that language. These attributes should have Names starting with the string "#trivia_"; printers are programmed to ignore trivia attributes that they do not understand.

Enumerator
Default 

No style category is specified; the printer should choose a style automatically.

Operator 

The node should be printed with operator notation (infix, prefix, suffix) instead of prefix notation if applicable (can be used to request backquote notation in LES and EC#).

Statement 

The node's immediate children (and/or the node itself) should be printed in statement notation, if possible in the context in which it is located.

Special 

A language-specific special notation should be used for this node. In LES, this marker requests that the arguments to a call be broken out into separate expressions, forming a "superexpression", e.g. in "if c {a();} else {b();}", which actually means "if(c,{a();},else,{b();})", the "if(...)" node will have this style.

PrefixNotation 

The node should be printed in prefix notation, e.g. (X, Y) instead of X.Y.

Expression 

The node(s) should be printed as a normal expression, rather than using a special or statement notation.

DataType 

The node should be printed like a data type, if the type notation is somehow different from expression notation. (Note: in general, one cannot expect data types to have this style).

OldStyle 

Use an older or backward-compatible notation.

BaseStyleMask 

If s is a NodeStyle, (s & NodeStyle.BaseStyleMask) is the base style (Default, Expression, Statement, PrefixNotation, or PurePrefixNotation).

Alternate 

If this node has two common styles in which it is printed, this selects the second (either the less common style, or the EC# style for features of C# with new syntax in EC#). In LES and EC#, alternate style denotes hex numbers. In EC#, it denotes verbatim strings, x(->int) as opposed to (int)x, x (as Y) as opposed to (x as Y). delegate(X) {Y;} is considered to be the alternate style for X => Y, and it forces parens and braces as a side-effect.

Alternate2 

Another alternate style flag. In LES and EC#, this is used for binary-format numbers.

Handled 

Indicates that some part of a compiler has seen the node and done something with it.

The idea behind this flag relates to compilers that allow user-defined attributes for plug-ins that add functionality. For example, internationalization plug-in might notice a language marker:

MessageBox.Show([en] "Hello, World!");

If an attribute is not used by any plug-in, the compiler should print a warning that the attribute is unused. This leads to the question, how can a compiler tell if an attribute was used or not? The Handled flag is one possible mechanism; when any part of the compiler or its plug- ins use an attribute, the Handled flag should be set to disable the compiler warning.

Remember that the same node can theoretically appear in multiple places in a syntax tree, which typically happens when a statement or expression is duplicated by a macro, without being changed. Remember that when a style is changed on such a node, the change is visible at all locations where the same node is used. However, style flags are not synchronized between copies of a node.

An enum of common operator formats.

It is intentional that the absolute value of each OperatorShape (except Other) is the arity of (number of arguments to) that shape.

Function Documentation

delegate void Loyc.Syntax.LNodePrinter ( LNode  node,
StringBuilder  target,
IMessageSink  errors,
object  mode = null,
string  indentString = "\t",
string  lineSeparator = "\n" 
)

Signature for a method that serializes a Loyc tree to text. Each programming language will have one (when complete).

Parameters
nodeNode to print
targetOutput buffer
modeA language-specific way of modifying printer behavior. The printer should ignore the mode object if it does not not understand it.
indentStringA string to print for each level of indentation, such as a tab or four spaces.
lineSeparatorLine separator, typically "\n" or "\r\n".

This delegate only prints to a StringBuilder. Printing directly to a stream requires language-specific facilities.