2024-10-03 22:12:40 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
var hadError = false
|
2024-10-04 15:24:01 +03:00
|
|
|
var hadRuntimeError = false
|
2024-10-03 22:12:40 +03:00
|
|
|
|
|
|
|
func printError(token Token, message string) {
|
|
|
|
if token.typ == EOF {
|
|
|
|
report(token.line, " at and", message)
|
|
|
|
} else {
|
|
|
|
report(token.line, fmt.Sprintf(" at '%s'", token.lexeme), message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func report(line int, where string, message string) {
|
|
|
|
log.Printf("[%d] Error %s: %s", line, where, message)
|
|
|
|
hadError = true
|
|
|
|
}
|
2024-10-04 15:24:01 +03:00
|
|
|
|
|
|
|
func reportRuntimeError(token Token, message string) {
|
|
|
|
log.Printf("[%d] Error: %s", token.line, message)
|
|
|
|
hadRuntimeError = true
|
|
|
|
}
|