• Russ Cox's avatar
    cmd/yacc: adjust expansion of $n to be more useful in errors · 2e78447b
    Russ Cox authored
    When the compiler echoes back an expression, it shows the
    generated yacc expression. Change the generated code to
    use a slice so that $3 shows up as yyDollar[3] in such messages.
    
    Consider changing testdata/expr/expr.y to say:
    
    	$$.Sub(float64($1), $3)
    
    (The float64 conversion is incorrect.)
    
    Before:
    expr.y:70[expr.go:486]: cannot convert exprS[exprpt - 2].num (type *big.Rat) to type float64
    
    After:
    expr.y:70[expr.go:492]: cannot convert exprDollar[1].num (type *big.Rat) to type float64
    
    Change-Id: I74e494069df588e62299d1fccb282f3658d8f8f4
    Reviewed-on: https://go-review.googlesource.com/4630Reviewed-by: default avatarRob Pike <r@golang.org>
    2e78447b
yacc.go 65.6 KB