1
0
mirror of https://github.com/golang/go synced 2024-11-22 08:14:40 -07:00

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
This commit is contained in:
Russ Cox 2009-09-10 14:47:10 -07:00
parent 8f2bf201d3
commit fc90fb8c81
4 changed files with 18 additions and 11 deletions

View File

@ -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

View File

@ -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));
}

View File

@ -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);
}