Enhanced C#
Language of your choice: library documentation
|
An interface that encapsulates the lexer and parser of a programming language, or a non-programming language that can be represented by Loyc trees. More...
An interface that encapsulates the lexer and parser of a programming language, or a non-programming language that can be represented by Loyc trees.
The simplest way to parse code is with the extension method Parse(string, IMessageSink msgs = null, Symbol inputType = null)
. The simplest way to print is with Print(LNode, IMessageSink)
The ToString() method should return a string that indicates the programming language represented by this object, e.g. "Enhanced C#".
Properties | |
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... | |
bool | CanPreserveComments [get] |
Returns true if the parser supports preserving comments. More... | |
Public Member Functions | |
ILexer< Token > | Tokenize (ICharSource text, string fileName, IMessageSink msgs, IParsingOptions options) |
Returns a lexer that is configured to begin reading the specified file. More... | |
IListSource< LNode > | Parse (ICharSource text, string fileName, IMessageSink msgs, IParsingOptions options) |
Parses a source file into one or more Loyc trees. More... | |
IListSource< LNode > | Parse (ILexer< Token > input, IMessageSink msgs, IParsingOptions options) |
If HasTokenizer is true, this method accepts a lexer returned by Tokenize() and begins parsing. More... | |
IListSource< LNode > | Parse (IListSource< Token > tokens, ISourceFile file, IMessageSink msgs, IParsingOptions options) |
Parses a token tree, such as one that came from a token literal. More... | |
IListSource<LNode> Loyc.Syntax.IParsingService.Parse | ( | ICharSource | text, |
string | fileName, | ||
IMessageSink | msgs, | ||
IParsingOptions | options | ||
) |
Parses a source file into one or more Loyc trees.
text | input file or string. |
fileName | A file name to associate with errors, warnings, and output nodes. |
msgs | Error and warning messages are sent to this object. If this parameter is null, messages should be sent to MessageSink.Default. |
options | Parsing options. |
Implemented in Loyc.Ecs.EcsLanguageService, Loyc.Syntax.Les.Les2LanguageService, and Loyc.Syntax.Les.Les3LanguageService.
Referenced by Loyc.Syntax.ParsingService.Parse(), and Loyc.Syntax.ParsingService.ParseSingle().
IListSource<LNode> Loyc.Syntax.IParsingService.Parse | ( | ILexer< Token > | input, |
IMessageSink | msgs, | ||
IParsingOptions | options | ||
) |
If HasTokenizer is true, this method accepts a lexer returned by Tokenize() and begins parsing.
input | A source of tokens. |
msgs | Error and warning messages are sent to this object. If this parameter is null, messages should be sent to MessageSink.Default. |
NotSupportedException | HasTokenizer 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.
Implemented in Loyc.Ecs.EcsLanguageService, Loyc.Syntax.Les.Les2LanguageService, and Loyc.Syntax.Les.Les3LanguageService.
IListSource<LNode> Loyc.Syntax.IParsingService.Parse | ( | IListSource< Token > | tokens, |
ISourceFile | file, | ||
IMessageSink | msgs, | ||
IParsingOptions | options | ||
) |
Parses a token tree, such as one that came from a token literal.
tokens | List of tokens |
file | A source file to associate with errors, warnings, and output nodes. |
msgs | Error and warning messages are sent to this object. If this parameter is null, messages should be sent to MessageSink.Default. |
options | Indicates how the input should be parsed. |
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.
NotSupportedException | This feature is not supported by this parsing service. |
Implemented in Loyc.Ecs.EcsLanguageService, Loyc.Syntax.Les.Les2LanguageService, and Loyc.Syntax.Les.Les3LanguageService.
ILexer<Token> Loyc.Syntax.IParsingService.Tokenize | ( | ICharSource | text, |
string | fileName, | ||
IMessageSink | msgs, | ||
IParsingOptions | options | ||
) |
Returns a lexer that is configured to begin reading the specified file.
text | Text to be tokenized (e.g. UString) |
fileName | File name to be associated with any errors that occur. |
msgs | Error 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.
It is recommended that the implementation of this method filter out spaces (for best performance) but not comments or newlines. If there is a preprocessor, it should not run. If ParsingOptions.PreserveComments is false, it is not this method's responsibility to filter them out.
Implemented in Loyc.Ecs.EcsLanguageService, Loyc.Syntax.Les.Les3LanguageService, and Loyc.Syntax.Les.Les2LanguageService.
Referenced by Loyc.Syntax.ParsingService.Tokenize().
|
get |
Returns true if the parser supports preserving comments.
|
get |
Standard file extensions for this language, without leading dots, with the first one being the most common.
Referenced by Loyc.Syntax.ParsingService.Unregister().
|
get |
Returns true if the Tokenize method is available.