diff --git a/token.go b/token.go index 2d7c12c..f0fc464 100644 --- a/token.go +++ b/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 }