From fc90fb8c814bcaaa6bb107da9f3e4430da3b48da Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 10 Sep 2009 14:47:10 -0700 Subject: [PATCH] rename units -> units.txt. add makefile rules to build a binary named units as a demo. R=r DELTA=1257 (659 added, 597 deleted, 1 changed) OCL=34528 CL=34530 --- src/cmd/goyacc/Makefile | 5 +++++ src/cmd/goyacc/goyacc.go | 16 ++++++++-------- src/cmd/goyacc/{units => units.txt} | 0 src/cmd/goyacc/units.y | 8 +++++--- 4 files changed, 18 insertions(+), 11 deletions(-) rename src/cmd/goyacc/{units => units.txt} (100%) diff --git a/src/cmd/goyacc/Makefile b/src/cmd/goyacc/Makefile index cca46c3e8b8..0fb61980424 100644 --- a/src/cmd/goyacc/Makefile +++ b/src/cmd/goyacc/Makefile @@ -10,3 +10,8 @@ GOFILES=\ include $(GOROOT)/src/Make.cmd +units: goyacc units.y + goyacc units.y + $(GC) y.go + $(LD) -o units y.$O + diff --git a/src/cmd/goyacc/goyacc.go b/src/cmd/goyacc/goyacc.go index 480d34e4b44..3304f31dede 100644 --- a/src/cmd/goyacc/goyacc.go +++ b/src/cmd/goyacc/goyacc.go @@ -1313,18 +1313,18 @@ cpyact(curprod []int, max int) putrune(ftable, c); return; } - + case '{': if brac == 0 { } putrune(ftable, '\t'); brac++; - + case '$': s := 1; tok := -1; c = getrune(finput); - + // type description if c == '<' { ungetrune(finput, c); @@ -1336,7 +1336,7 @@ cpyact(curprod []int, max int) } if c == '$' { fmt.Fprintf(ftable, "YYVAL"); - + // put out the proper tag... if ntypes != 0 { if tok < 0 { @@ -1398,7 +1398,7 @@ cpyact(curprod []int, max int) continue loop; } fmt.Fprintf(ftable, "YYS[yypt-%v]", max-j-1); - + // put out the proper tag if ntypes != 0 { if j <= 0 && tok < 0 { @@ -1899,7 +1899,7 @@ closure(i int) } pi := wsets[v].pitem.prod; ipi := wsets[v].pitem.off + 1; - + wsets[v].flag = 0; if nolook != 0 { continue; @@ -2284,7 +2284,7 @@ output() } else if temp1[k] < 0 { // reduce/reduce conflict if foutput != nil { - fmt.Fprintf(foutput, + fmt.Fprintf(foutput, "\n %v: reduce/reduce conflict (red'ns " "%v and %v) on %v", i, -temp1[k], lastred, symnam(k)); @@ -2324,7 +2324,7 @@ precftn(r, t, s int) if PLEVEL(lt) == 0 || PLEVEL(lp) == 0 { // conflict if foutput != nil { - fmt.Fprintf(foutput, + fmt.Fprintf(foutput, "\n%v: shift/reduce conflict (shift %v(%v), red'n %v(%v)) on %v", s, temp1[t], PLEVEL(lt), r, PLEVEL(lp), symnam(t)); } diff --git a/src/cmd/goyacc/units b/src/cmd/goyacc/units.txt similarity index 100% rename from src/cmd/goyacc/units rename to src/cmd/goyacc/units.txt diff --git a/src/cmd/goyacc/units.y b/src/cmd/goyacc/units.y index a5510fbca6a..fcb37dd6799 100644 --- a/src/cmd/goyacc/units.y +++ b/src/cmd/goyacc/units.y @@ -17,10 +17,12 @@ // ./6.out $GOROOT/src/cmd/goyacc/units // you have: c // you want: furlongs/fortnight -// * 1.8026178e+12 -// / 5.5474878e-13 +// * 1.8026178e+12 +// / 5.5474878e-13 // you have: +package main + import ( "flag"; @@ -294,7 +296,7 @@ main() flag.Parse(); - file = "units"; + file = "units.txt"; if flag.NArg() > 0 { file = flag.Arg(0); }