new Expression(grammar) → {Expression}
Parameters:
Name | Type | Description |
---|---|---|
grammar |
Grammar |
- Source:
Returns:
- Type
- Expression
Methods
applyRule(symbolPos, rule)
Replaces symbol in string according to given rule and adds new node in the syntax tree
Parameters:
Name | Type | Description |
---|---|---|
symbolPos |
number | |
rule |
Rule |
- Source:
applyRules(iter)
Builds expression by picking a random symbol and chosing a matching rule
Parameters:
Name | Type | Description |
---|---|---|
iter |
numbers | How many times a symbol will be substited |
- Source:
createFromString(str)
Creates syntax tree basing on given string
Parameters:
Name | Type | Description |
---|---|---|
str |
string |
- Source:
expressionProbability()
Computes and prints out the probablility of apperance for symbols and operators
- Source:
figureOpOrder(noPosShift) → {Array|Expression.prototype.figureOpOrder.nArr}
Figures out the order of operators
Parameters:
Name | Type | Description |
---|---|---|
noPosShift |
type |
- Source:
- To Do:
-
- rewrite it
Returns:
- Type
- Array | Expression.prototype.figureOpOrder.nArr
findOperator(symbol) → {Expression.grammar.operators}
Returns an 'Operator' object with given symbol
Parameters:
Name | Type | Description |
---|---|---|
symbol |
type |
- Source:
Returns:
- Type
- Expression.grammar.operators
findRule(operatorSymbol) → {Expression.grammar.rules}
Returns an 'Rule' object with given operator sybol
Parameters:
Name | Type | Description |
---|---|---|
operatorSymbol |
type | Character representing operator in the string |
- Source:
Returns:
- Type
- Expression.grammar.rules
findSymbols(string, symbols, terminal) → {Array|Expression.prototype.findSymbols.result}
Returns symbols in the expression's string
Parameters:
Name | Type | Description |
---|---|---|
string |
string | Expression's string |
symbols |
type | |
terminal |
boolean |
- Source:
Returns:
- Type
- Array | Expression.prototype.findSymbols.result
finish()
Replaces terminal symbols with operators so there is no symbols left
- Source:
generateExpression()
Generates expression
- Source:
nonTerminalSymbols(string, symbols) → {Array|Expression.prototype.findSymbols.result}
Returns nonterminal symbols in the expression's string
Parameters:
Name | Type | Description |
---|---|---|
string |
type | |
symbols |
type |
- Source:
Returns:
- Type
- Array | Expression.prototype.findSymbols.result
pickRule(rules) → {String|Expression.prototype.pickRule.rules}
Picks randomly a rule from the set
Parameters:
Name | Type | Description |
---|---|---|
rules |
Array |
- Source:
Returns:
- Type
- String | Expression.prototype.pickRule.rules
ridNonterminals()
Replaces all nonterminal symbols with matching rules
- Source:
terminalSymbols(string, symbols) → {Array|Expression.prototype.findSymbols.result}
Returns terminal symbols in the expression's string
Parameters:
Name | Type | Description |
---|---|---|
string |
type | |
symbols |
type |
- Source:
Returns:
- Type
- Array | Expression.prototype.findSymbols.result