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 static fields | Properties | Public Member Functions | List of all members
Loyc.Ecs.EcsLanguageService Class Reference

The Value property provides easy access to the lexer, parser and printer for Enhanced C#. More...


Source file:
Inheritance diagram for Loyc.Ecs.EcsLanguageService:
Loyc.Syntax.IParsingService

Remarks

The Value property provides easy access to the lexer, parser and printer for Enhanced C#.

EC# overview: https://sourceforge.net/apps/mediawiki/loyc/index.php?title=Ecs

Public static fields

static readonly EcsLanguageService Value = new EcsLanguageService(false)
 
static readonly EcsLanguageService WithPlainCSharpPrinter = new EcsLanguageService(true)
 

Properties

IEnumerable< string > FileExtensions [get]
 
LNodePrinter Printer [get]
 
bool HasTokenizer [get]
 
- Properties inherited from Loyc.Syntax.IParsingService
IEnumerable< string > FileExtensions [get]
 Standard file extensions for this language, without leading dots, with the first one being the most common. More...
 
bool HasTokenizer [get]
 Returns true if the Tokenize() method is available. More...
 
LNodePrinter Printer [get]
 Gets a printer delegate that you can use with LNode.Printer and LNode.PushPrinter, or null if there is no corresponding printer available for the parser reresented by this object. More...
 

Public Member Functions

override string ToString ()
 
string Print (LNode node, IMessageSink msgs=null, object mode=null, string indentString="\t", string lineSeparator="\n")
 Converts the specified syntax tree to a string. More...
 
ILexer< TokenTokenize (ICharSource text, string fileName, IMessageSink msgs)
 Returns a lexer that is configured to begin reading the specified file. More...
 
IListSource< LNodeParse (ICharSource text, string fileName, IMessageSink msgs, Symbol inputType=null)
 Parses a source file into one or more Loyc trees. More...
 
IListSource< LNodeParse (ILexer< Token > input, IMessageSink msgs, Symbol inputType=null)
 If HasTokenizer is true, this method accepts a lexer returned by Tokenize() and begins parsing. More...
 
IListSource< LNodeParse (IListSource< Token > input, ISourceFile file, IMessageSink msgs, Symbol inputType=null)
 Parses a token tree, such as one that came from a token literal. More...
 

Member Function Documentation

IListSource<LNode> Loyc.Ecs.EcsLanguageService.Parse ( ICharSource  file,
string  fileName,
IMessageSink  msgs,
Symbol  inputType = null 
)
inline

Parses a source file into one or more Loyc trees.

Parameters
fileinput file or string.
msgsoutput sink for error and warning messages.
inputTypeIndicates the kind of input: Exprs (one or more expressions, typically seprated by commas but this is language- defined), Stmts (a series of statements), or File (an entire source file). null is a synonym for File.

Implements Loyc.Syntax.IParsingService.

IListSource<LNode> Loyc.Ecs.EcsLanguageService.Parse ( ILexer< Token input,
IMessageSink  msgs,
Symbol  inputType = null 
)
inline

If HasTokenizer is true, this method accepts a lexer returned by Tokenize() and begins parsing.

Parameters
msgsoutput sink for error and warning messages.
inputTypeIndicates how the input should be interpreted: ParsingService.File, ParsingService.Exprs or ParsingService.Stmts. The default input type should be File.
Exceptions
NotSupportedExceptionHasTokenizer is false.

This method adds any preprocessing steps to the lexer (tree-ification or token preprocessing) that are required by this language before it sends the results to the parser. If possible, the output is computed lazily.

Implements Loyc.Syntax.IParsingService.

IListSource<LNode> Loyc.Ecs.EcsLanguageService.Parse ( IListSource< Token tokens,
ISourceFile  file,
IMessageSink  msgs,
Symbol  inputType = null 
)
inline

Parses a token tree, such as one that came from a token literal.

Some languages may offer token literals, which are stored as token trees that can be processed by "macros" or compiler plugins. A macro may wish to parse some of the token literal using the host language's parser (e.g. LLLPG needs to do this), so this method is provided for that purpose.

Exceptions
NotSupportedExceptionThis feature is not supported by this parsing service.

Implements Loyc.Syntax.IParsingService.

References Loyc.Syntax.ParsingService.Exprs, and Loyc.Collections.IListSource< out T >.TryGet().

string Loyc.Ecs.EcsLanguageService.Print ( LNode  node,
IMessageSink  msgs = null,
object  mode = null,
string  indentString = "\t",
string  lineSeparator = "\n" 
)
inline

Converts the specified syntax tree to a string.

Parameters
nodeA syntax tree to print.
msgsIf errors or warnings occur during printing, they are sent here. If this is null, messages shall be sent to MessageSink.Current.
modeLanguage-defined configuration. It is suggested that the printing service should accept ParsingService.Exprs, ParsingService.Stmts and ParsingService.File as possible printing modes.
indentStringIndent character for multi-line nodes
lineSeparatorNewline string for multi-line nodes

Implements Loyc.Syntax.IParsingService.

ILexer<Token> Loyc.Ecs.EcsLanguageService.Tokenize ( ICharSource  file,
string  fileName,
IMessageSink  msgs 
)
inline

Returns a lexer that is configured to begin reading the specified file.

Parameters
fileText to be tokenized (e.g. UString)
fileNameFile name to be associated with any errors that occur.
msgsError messages are sent to this object.

The returned lexer should be a "simple" tokenizer. If the language uses tree lexing (in which tokens are grouped by parentheses and braces), the returned lexer should NOT include the grouping process, and it should not remove comments, although it may skip spaces and perhaps newlines. If there is a preprocessor, it should not run.

Implements Loyc.Syntax.IParsingService.