From 920df48fb1e1b30f5ea86f1a49b599098fa81793 Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Wed, 16 Nov 2011 16:58:02 -0500 Subject: [PATCH] gc: support for building with Plan 9 yacc I've modified Plan 9's yacc to work with the grammar in go.y. These are the only changes necessary on the Go side. R=rsc CC=golang-dev https://golang.org/cl/5375104 --- src/cmd/gc/bisonerrors | 29 +++++++++++++++++++++-------- src/cmd/gc/go.h | 7 ++++++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/cmd/gc/bisonerrors b/src/cmd/gc/bisonerrors index 5110f5350c..0f865d086c 100755 --- a/src/cmd/gc/bisonerrors +++ b/src/cmd/gc/bisonerrors @@ -46,24 +46,36 @@ bison && /^state 0/ { grammar = 0; states = 1 } states && /^state / { state = $2 } states { statetext[state] = statetext[state] $0 "\n" } -states && / shift, and go to state/ { +states && / shift/ { n = nshift[state]++ - shift[state,n] = $7 + if($0 ~ /and go to/) + shift[state,n] = $7 # GNU Bison + else + shift[state,n] = $3 # Plan 9 Yacc shifttoken[state,n] = $1 next } -states && / go to state/ { +states && / (go to|goto)/ { n = nshift[state]++ - shift[state,n] = $5 + if($0 ~ /go to/) + shift[state,n] = $5 # GNU Bison + else + shift[state,n] = $3 # Plan 9 Yacc shifttoken[state,n] = $1 next } -states && / reduce using rule/ { +states && / reduce/ { n = nreduce[state]++ - reduce[state,n] = $5 + if($0 ~ /reduce using rule/) + reduce[state,n] = $5 # GNU Bison + else + reduce[state,n] = $3 # Plan 9 yacc reducetoken[state,n] = $1 next -} +} + +# Skip over the summary information printed by Plan 9 yacc. +/nonterminals$/,/^maximum spread/ { next } # First // comment marks the beginning of the pattern file. /^\/\// { bison = 0; grammar = 0; state = 0 } @@ -96,7 +108,8 @@ $1 == "%" { if(found) continue for(j=0; j