token.go: New functions Clone() and IsOneOfA()
This commit is contained in:
parent
c76e1d3c8e
commit
837b887490
8
token.go
8
token.go
@ -51,6 +51,10 @@ func NewErrorToken(row, col int, err error) *Token {
|
||||
return NewValueToken(row, col, SymError, fmt.Sprintf("[%d:%d]", row, col), err)
|
||||
}
|
||||
|
||||
func (tk *Token) Clone() (c *Token) {
|
||||
return NewValueToken(tk.row, tk.col, tk.Sym, tk.source, tk.Value)
|
||||
}
|
||||
|
||||
func (tk *Token) IsEos() bool {
|
||||
return tk.Sym == SymEos
|
||||
}
|
||||
@ -67,6 +71,10 @@ func (tk *Token) IsOneOf(termSymbols []Symbol) bool {
|
||||
return termSymbols != nil && slices.Index(termSymbols, tk.Sym) >= 0
|
||||
}
|
||||
|
||||
func (tk *Token) IsOneOfA(termSymbols ...Symbol) bool {
|
||||
return slices.Index(termSymbols, tk.Sym) >= 0
|
||||
}
|
||||
|
||||
func (tk *Token) IsSymbol(sym Symbol) bool {
|
||||
return tk.Sym == sym
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user