From f9ed5776cd68b94b668690d82c9de1c073647c9e Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Sat, 4 May 2024 19:08:02 +0200 Subject: [PATCH] token.go: function IsSymbol() --- token.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/token.go b/token.go index 2fadb27..64a48e8 100644 --- a/token.go +++ b/token.go @@ -63,6 +63,10 @@ func (tk *Token) IsTerm(termSymbols []Symbol) bool { return tk.IsEos() || tk.IsError() || (termSymbols != nil && slices.Index(termSymbols, tk.Sym) >= 0) } +func (tk *Token) IsSymbol(sym Symbol) bool { + return tk.Sym == sym +} + func (self *Token) Errorf(template string, args ...any) (err error) { err = fmt.Errorf(fmt.Sprintf("[%d:%d] ", self.row, self.col)+template, args...) return