Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Meyhem/go-simple-expression-eval
/ functions
Functions
60 in github.com/Meyhem/go-simple-expression-eval
⨍
Functions
60
◇
Types & classes
11
↓ 8 callers
Method
emit
Emits lexer item to output channel
lexer.go:165
↓ 7 callers
Method
Len
()
stack.go:35
↓ 7 callers
Function
Parse
Parse parses given infix expression and produces Abstract syntax tree
parser.go:189
↓ 7 callers
Method
Pop
()
stack.go:17
↓ 6 callers
Function
NewParserError
NewParserError intantiates new Parser error
errors.go:54
↓ 4 callers
Function
Interpret
Interpret is function that evaluates AST and returns corresponding result
interpreter.go:81
↓ 4 callers
Method
Push
(val interface{})
stack.go:13
↓ 4 callers
Method
Top
()
stack.go:31
↓ 4 callers
Function
runLexing
(expr string)
lexer_test.go:7
↓ 4 callers
Function
traversePreorder
helper debug func
parser.go:156
↓ 3 callers
Function
NewAstNode
(typ AstNodeType, value *string)
ast.go:50
↓ 3 callers
Function
NewInterpreterError
NewInterpreterError intantiates new Interpreter error
errors.go:62
↓ 3 callers
Method
consume
Consume next rune if its one of 'runes' parameter, otherwise no effect
lexer.go:144
↓ 3 callers
Method
next
Move to next ASCII or UTF-8 character/rune
lexer.go:115
↓ 2 callers
Method
Items
Items method gets channel of lex items
lexer.go:255
↓ 2 callers
Function
Lex
Lex is constructor for lexer
lexer.go:272
↓ 2 callers
Function
NewStack
()
stack.go:7
↓ 2 callers
Method
Run
Run method will is the core part of this lexer It fires off the state machine, starting with lexFn and takes return function as next state once some f
lexer.go:262
↓ 2 callers
Method
backup
Go back one character/rune
lexer.go:130
↓ 2 callers
Method
consumeAll
Consume all following runes that are one of 'runes'
lexer.go:153
↓ 2 callers
Method
errorf
Helper func that emits error item IERR with message
lexer.go:175
↓ 2 callers
Function
precedence
Determines precedence of operator given
parser.go:9
↓ 1 callers
Function
NewLexerError
NewLexerError intantiates new Lexer error
errors.go:46
↓ 1 callers
Function
constructAst
Takes list of postfix formed lexer items and builds binary expression tree
parser.go:111
↓ 1 callers
Method
ignore
Ignores all un-emitted characters (moves start to current pos)
lexer.go:159
↓ 1 callers
Method
peek
Check what rune is next in input
lexer.go:137
↓ 1 callers
Function
postOrderTraversal
Recursive post order traversal that evaluates AST 1. Visit left 2. Visit right 3. Visit self
interpreter.go:37
↓ 1 callers
Function
toPostfix
Converts infix output form of Lexer to postfix form
parser.go:27
↓ 1 callers
Function
translateLexToAstType
helper method that translates Lexer item types to AST node types
parser.go:95
Method
String
()
ast.go:15
Method
String
()
ast.go:40
Method
String
()
errors.go:19
Method
String
()
errors.go:41
Method
String
()
lexer.go:12
Method
String
Debug stringify lex item
lexer.go:88
Function
TestEmptyExprItems
(t *testing.T)
lexer_test.go:63
Function
TestInterpreter
(t *testing.T)
interpreter_test.go:7
Function
TestInvalidRune
(t *testing.T)
lexer_test.go:79
Function
TestOperator
(t *testing.T)
interpreter_test.go:35
Function
TestParserAst
(t *testing.T)
parser_test.go:7
Function
TestParserEmptyExpr
(t *testing.T)
parser_test.go:43
Function
TestParserEmptyParenExpr
(t *testing.T)
parser_test.go:55
Function
TestParserPrecedence
(t *testing.T)
parser_test.go:67
Function
TestSimpleExprItems
(t *testing.T)
lexer_test.go:31
Function
TestSimpleExprLen
(t *testing.T)
lexer_test.go:20
Function
TestSingleValue
(t *testing.T)
interpreter_test.go:21
Function
add
Implementation of ADD operation
interpreter.go:8
Function
div
Implementation of DIVIDE operation
interpreter.go:23
Method
dumpState
()
lexer.go:110
Function
lexFn
Starting state of state machine, peeks forward and decides what lexing function should be used
lexer.go:185
Function
lexLpar
Lexes left parenthesis
lexer.go:227
Function
lexNumber
lexes numbers
lexer.go:241
Function
lexOperator
Lexes operators
lexer.go:208
Function
lexRpar
Lexes right parenthesis
lexer.go:234
Function
lexWhite
Lexes whitespaces and thrashes them (no emitting)
lexer.go:248
Function
main
()
main.go:8
Function
mul
Implementation of MULTIPLY operation
interpreter.go:18
Function
sub
Implementation of SUBTRACT operation
interpreter.go:13
Function
traverseInorder
helper debug func
parser.go:167
Function
traversePostorder
helper debug func
parser.go:178