C# Class ComponentFactory.Quicksilver.Binding.Arithmetic

Accept and evaluate simple arithmetic expressions.
Top down predictive parser using an LL(1) BNF expression ::= term expression2 expression2 ::= '+' term expression2 | '-' term expression2 | {empty} term ::= factor term2 term2 ::= '*' factor term2 | '/' factor term2 | {empty} factor ::= '+' factor | '-' factor | primary primary ::= integer-literal | real-literal '(' expression ')'
Show file Open project: ComponentFactory/Quicksilver

Private Properties

Property Type Description

Public Methods

Method Description
Arithmetic ( ) : System

Initialize a new instance of the Arithmetic class.

Arithmetic ( System.Language language ) : System

Initialize a new instance of the Arithmetic class.

Arithmetic ( string input ) : System

Initialize a new instance of the Arithmetic class.

Arithmetic ( string input, System.Language language ) : System

Initialize a new instance of the Arithmetic class.

Evaluate ( ) : EvalResult

Evaluate and return result.

Evaluate ( object thisObject ) : EvalResult

Evaluate and return result.

Parse ( string input ) : void

Parse the provided input string.

ToString ( ) : string

Human readable version of the parsed input.

Protected Methods

Method Description
ParseExpression ( ) : EvalNode

Parse the 'expression' rule.

expression ::= term expression2

ParseExpression2 ( ) : EvalNode

Parse the 'expression2' rule.

expression2 ::= '+' term expression2 | '-' term expression2 | {empty}

ParseFactor ( ) : EvalNode

Parse the 'factor' rule.

factor ::= '+' factor | '-' factor | primary

ParsePrimary ( ) : EvalNode

Parse the 'primary' rule.

primary ::= integer-literal | real-literal '(' expression ')'

ParseTerm ( ) : EvalNode

Parse the 'term' rule.

term ::= factor term2

ParseTerm2 ( ) : EvalNode

Process the term2 rule.

term2 ::= '*' factor term2 | '/' factor term2 | {empty}

Method Details

Arithmetic() public method

Initialize a new instance of the Arithmetic class.
public Arithmetic ( ) : System
return System

Arithmetic() public method

Initialize a new instance of the Arithmetic class.
public Arithmetic ( System.Language language ) : System
language System.Language Language used for parsing.
return System

Arithmetic() public method

Initialize a new instance of the Arithmetic class.
public Arithmetic ( string input ) : System
input string Input string to parse.
return System

Arithmetic() public method

Initialize a new instance of the Arithmetic class.
public Arithmetic ( string input, System.Language language ) : System
input string Input string to parse.
language System.Language Language used for parsing.
return System

Evaluate() public method

Evaluate and return result.
public Evaluate ( ) : EvalResult
return EvalResult

Evaluate() public method

Evaluate and return result.
public Evaluate ( object thisObject ) : EvalResult
thisObject object Reference to object that is exposed as 'this'.
return EvalResult

Parse() public method

Parse the provided input string.
public Parse ( string input ) : void
input string Input text.
return void

ParseExpression() protected method

Parse the 'expression' rule.
expression ::= term expression2
protected ParseExpression ( ) : EvalNode
return EvalNode

ParseExpression2() protected method

Parse the 'expression2' rule.
expression2 ::= '+' term expression2 | '-' term expression2 | {empty}
protected ParseExpression2 ( ) : EvalNode
return EvalNode

ParseFactor() protected method

Parse the 'factor' rule.
factor ::= '+' factor | '-' factor | primary
protected ParseFactor ( ) : EvalNode
return EvalNode

ParsePrimary() protected method

Parse the 'primary' rule.
primary ::= integer-literal | real-literal '(' expression ')'
protected ParsePrimary ( ) : EvalNode
return EvalNode

ParseTerm() protected method

Parse the 'term' rule.
term ::= factor term2
protected ParseTerm ( ) : EvalNode
return EvalNode

ParseTerm2() protected method

Process the term2 rule.
term2 ::= '*' factor term2 | '/' factor term2 | {empty}
protected ParseTerm2 ( ) : EvalNode
return EvalNode

ToString() public method

Human readable version of the parsed input.
public ToString ( ) : string
return string