Fix examples
This commit is contained in:
parent
8399e3834b
commit
df3a032c52
3 changed files with 15 additions and 10 deletions
|
@ -1,3 +1,5 @@
|
|||
// +build example
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -6,16 +8,6 @@ import (
|
|||
"github.com/neonxp/unilex"
|
||||
)
|
||||
|
||||
var output []unilex.Lexem = []unilex.Lexem{}
|
||||
var opPriority = map[string]int{
|
||||
"^": 3,
|
||||
"!": 3,
|
||||
"*": 2,
|
||||
"/": 2,
|
||||
"+": 1,
|
||||
"-": 1,
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
l := unilex.New("10 * (20.0 + 30.0)")
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// +build example
|
||||
|
||||
package main
|
||||
|
||||
// Helper functions to convert infix notation to RPN and calculates expression result.
|
||||
|
@ -10,6 +12,15 @@ import (
|
|||
"github.com/neonxp/unilex"
|
||||
)
|
||||
|
||||
var opPriority = map[string]int{
|
||||
"^": 3,
|
||||
"!": 3,
|
||||
"*": 2,
|
||||
"/": 2,
|
||||
"+": 1,
|
||||
"-": 1,
|
||||
}
|
||||
|
||||
func infixToRPNotation(l *unilex.Lexer) []unilex.Lexem {
|
||||
output := []unilex.Lexem{}
|
||||
stack := lexemStack{}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// +build example
|
||||
|
||||
package main
|
||||
|
||||
// Simple lexem stack implementation.
|
||||
|
|
Loading…
Reference in a new issue