Skip to content

Commit

Permalink
found simpler fix
Browse files Browse the repository at this point in the history
  • Loading branch information
knudtty committed Aug 3, 2024
1 parent e36bcf0 commit efe4e5f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions parser/v2/goexpression/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func Expression(src string) (start, end int, err error) {
errorHandler := func(pos token.Position, msg string) {
err = fmt.Errorf("error parsing expression: %v", msg)
}
s.Init(file, []byte(src), errorHandler, scanner.ScanComments)
s.Init(file, []byte(src), errorHandler, 0)

// Read chains of identifiers and constants up until RBRACE, e.g.:
// true
Expand Down Expand Up @@ -176,6 +176,7 @@ loop:
braceDepth--
if braceDepth < 0 {
// We've hit the end of the expression.
end = int(pos)-1
break loop
}
end = int(pos)
Expand All @@ -185,12 +186,13 @@ loop:
continue
case token.ILLEGAL:
return 0, 0, fmt.Errorf("illegal token: %v", lit)
case token.COMMENT:
end = int(pos) + len(lit) - 1
default:
end = int(pos) + len(tok.String()) - 1
}
fmt.Println("pos: ", int(pos))
}
fmt.Println("OUT")
fmt.Println(src[start:end])
return start, end, nil
}

Expand Down

0 comments on commit efe4e5f

Please sign in to comment.