Treat source as runes to allow for unicode characters (e.g. greek, japanese)
This commit is contained in:
parent
74bf43d387
commit
402644d219
2 changed files with 4 additions and 4 deletions
|
|
@ -14,7 +14,7 @@ type ParsingError struct {
|
|||
}
|
||||
|
||||
// Print a rich and informative error
|
||||
func (p *ParsingError) Format(src string) string {
|
||||
func (p *ParsingError) Format(src []rune) string {
|
||||
builder := strings.Builder{}
|
||||
|
||||
lineNumber := 1
|
||||
|
|
@ -38,7 +38,7 @@ func (p *ParsingError) Format(src string) string {
|
|||
builder.WriteString(p.Description)
|
||||
builder.WriteRune('\n')
|
||||
|
||||
builder.WriteString(fmt.Sprintf(" %d:%d\t | %s", lineNumber, int(p.Causer.Start)-lineBeginning+1, src[lineBeginning:lineEnd]))
|
||||
builder.WriteString(fmt.Sprintf(" %d:%d\t | %s", lineNumber, int(p.Causer.Start)-lineBeginning+1, string(src[lineBeginning:lineEnd])))
|
||||
|
||||
builder.WriteString("\n\t ^")
|
||||
for i := lineBeginning; i <= int(p.Causer.Start); i++ {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue