Fix examples

This commit is contained in:
Александр Кирюхин 2021-03-06 22:38:08 +03:00
parent 8399e3834b
commit df3a032c52
No known key found for this signature in database
GPG key ID: 8CDA417C9098753B
3 changed files with 15 additions and 10 deletions

View file

@ -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)")

View file

@ -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{}

View file

@ -1,3 +1,5 @@
// +build example
package main
// Simple lexem stack implementation.