New, more flexible, parser context datatype that includes and extends

the previous flags allowForest and allowVarRef.
Added binary operator (work in progress).
Better implementation of +=,-=,*=, and /= (new) operators.
This commit is contained in:
2024-12-19 14:48:27 +01:00
parent 5c44532790
commit 6ee21e10af
16 changed files with 537 additions and 140 deletions
+10 -1
View File
@@ -93,6 +93,15 @@ func (tk *Token) Error() (err error) {
return
}
func (tk *Token) ErrorText() (err string) {
if tk.Sym == SymError {
if msg, ok := tk.Value.(error); ok {
err = msg.Error()
}
}
return
}
func (tk *Token) Errors(msg string) (err error) {
err = fmt.Errorf("[%d:%d] %v", tk.row, tk.col, msg)
return
@@ -108,6 +117,6 @@ func (tk *Token) ErrorExpectedGotString(symbol, got string) (err error) {
}
func (tk *Token) ErrorExpectedGotStringWithPrefix(prefix, symbol, got string) (err error) {
err = fmt.Errorf("[%d:%d] %s `%s`, got `%s`", tk.row, tk.col, prefix, symbol, got)
err = fmt.Errorf("[%d:%d] %s %s, got `%s`", tk.row, tk.col, prefix, symbol, got)
return
}