github.com/jflude/taocp@v0.0.0-20240210234939-99f2a91af3c2/mixal/operator.go (about)

     1  package mixal
     2  
     3  import "github.com/jflude/taocp/mix"
     4  
     5  func (a *asmb) matchOperator() bool {
     6  	var i int
     7  	for i = 0; i < 4; i++ {
     8  		if i >= len(a.input) ||
     9  			(!mix.IsLetter(rune(a.input[0])) &&
    10  				!mix.IsDigit(rune(a.input[0]))) {
    11  			break
    12  		}
    13  	}
    14  	op := a.input[:i]
    15  	switch op {
    16  	case "EQU", "ORIG", "CON", "ALF", "END":
    17  	default:
    18  		if _, ok := opcodes[op]; !ok {
    19  			return false
    20  		}
    21  	}
    22  	a.addToken(operator, op)
    23  	a.input = a.input[i:]
    24  	return true
    25  }