Class SourceCodeUtils
Provides static methods that assist in working with source code
Inheritance
Inherited Members
Namespace: CilTools.SourceCode.Common
Assembly: CilTools.SourceCode.dll
Syntax
public static class SourceCodeUtils
Methods
GetFactory(SourceLanguage)
Gets a syntax factory that creates tokens for the specified language
Declaration
public static SourceTokenFactory GetFactory(SourceLanguage lang)
Parameters
Type | Name | Description |
---|---|---|
SourceLanguage | lang |
Returns
Type | Description |
---|---|
SourceTokenFactory |
GetFactory(String)
Gets a syntax factory that creates tokens for the specified language (defined by source file extension)
Declaration
public static SourceTokenFactory GetFactory(string ext)
Parameters
Type | Name | Description |
---|---|---|
System.String | ext | Source file extension with a leading dot (for example, |
Returns
Type | Description |
---|---|
SourceTokenFactory |
GetTokenDefinitions(String)
Gets a collection of token definitions that can be used to tokenize a source file with the specified extension
Declaration
public static IEnumerable<SyntaxTokenDefinition> GetTokenDefinitions(string ext)
Parameters
Type | Name | Description |
---|---|---|
System.String | ext | Source file extension with a leading dot (for example, |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SyntaxTokenDefinition> |
ReadAllTokens(String, IEnumerable<SyntaxTokenDefinition>, SourceTokenFactory)
Reads all tokens from the specified string using the specified collection of token definitions and syntax factory
Declaration
public static SourceToken[] ReadAllTokens(string src, IEnumerable<SyntaxTokenDefinition> definitions, SourceTokenFactory factory)
Parameters
Type | Name | Description |
---|---|---|
System.String | src | Input string |
System.Collections.Generic.IEnumerable<SyntaxTokenDefinition> | definitions | Collection of token definitions that will be used to split the input string into a sequence of tokens |
SourceTokenFactory | factory | Syntax factory object that will be used to create new SyntaxNode instances |
Returns
Type | Description |
---|---|
SourceToken[] | Array of syntax nodes that contain tokens |