@ -480,6 +480,9 @@ func shuntingYard(re string, flags ...ReFlag) ([]postfixNode, error) {
if ( c == '*' && outQueueFinalElement . nodetype == KLEENE ) || ( c == '+' && outQueueFinalElement . nodetype == PLUS ) { // You cannot apply a quantifier to a quantifier in this way
return nil , fmt . Errorf ( "illegal use of token '%c'" , c )
}
if c == '?' && slices . Contains ( [ ] NodeType { KLEENE , PLUS , QUESTION } , outQueueFinalElement . nodetype ) {
return nil , fmt . Errorf ( "non-greedy operators not supported" )
}
opStack = append ( opStack , c )
}
}
@ -1001,6 +1004,9 @@ func thompson(re []postfixNode) (Reg, error) {
if err != nil {
return Reg { } , fmt . Errorf ( "error applying kleene star" )
}
if s1 . isEmpty && s1 . assert != NONE {
return Reg { } , fmt . Errorf ( "previous token is not quantifiable" )
}
stateToAdd := kleene ( * s1 )
nfa = append ( nfa , stateToAdd )
case PLUS : // a+ is equivalent to aa*