C# Class xFunc.Maths.Lexer

The lexer for mathematical expressions.
Inheritance: ILexer
显示文件 Open project: sys27/xFunc Class Usage Examples

Public Methods

Method Description
Lexer ( ) : System

Initializes a new instance of the Lexer class.

Tokenize ( string function ) : IEnumerable

Converts the string into a sequence of tokens.

Private Methods

Method Description
CountParams ( List tokens ) : IEnumerable

Calculates the number of parametes of functions.

CreateConst ( string match, IList tokens ) : void

Creates the constant token from matched string.

CreateFunction ( string match, IList tokens ) : void

Creates the function token from matched string.

CreateOperations ( string match, IList tokens ) : void

Creates the operation token from matched string.

CreateSymbol ( string match, IList tokens ) : void

Creates the symbol token from matched string.

IsBalanced ( string str ) : bool

Determines whether brackets in the specified string is balanced.

_CountParams ( List tokens, int index ) : int

Method Details

Lexer() public method

Initializes a new instance of the Lexer class.
public Lexer ( ) : System
return System

Tokenize() public method

Converts the string into a sequence of tokens.
Throws when the parameter is null or empty. Throws when has the not supported symbol.
public Tokenize ( string function ) : IEnumerable
function string The string that contains the functions and operators.
return IEnumerable