Started working on '+' operator
This commit is contained in:
6
main.go
6
main.go
@@ -11,7 +11,7 @@ import (
|
||||
const CONCAT rune = '~'
|
||||
|
||||
func isOperator(c rune) bool {
|
||||
if c == '*' || c == '|' || c == CONCAT {
|
||||
if c == '+' || c == '*' || c == '|' || c == CONCAT {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -19,7 +19,7 @@ func isOperator(c rune) bool {
|
||||
|
||||
/* priority returns the priority of the given operator */
|
||||
func priority(op rune) int {
|
||||
precedence := []rune{'|', CONCAT, '*'}
|
||||
precedence := []rune{'|', CONCAT, '+', '*'}
|
||||
return slices.Index(precedence, op)
|
||||
}
|
||||
|
||||
@@ -138,6 +138,8 @@ func thompson(re string) *State {
|
||||
}
|
||||
stateToAdd.transitions[s1.content] = append(stateToAdd.transitions[s1.content], s1)
|
||||
nfa = append(nfa, stateToAdd)
|
||||
case '+':
|
||||
|
||||
case '|':
|
||||
s1 := pop(&nfa)
|
||||
s2 := pop(&nfa)
|
||||
|
||||
Reference in New Issue
Block a user