mirror of
https://github.com/golang/go.git
synced 2025-05-18 05:44:35 +00: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:
parent
8f2bf201d3
commit
fc90fb8c81
@ -10,3 +10,8 @@ GOFILES=\
|
|||||||
|
|
||||||
include $(GOROOT)/src/Make.cmd
|
include $(GOROOT)/src/Make.cmd
|
||||||
|
|
||||||
|
units: goyacc units.y
|
||||||
|
goyacc units.y
|
||||||
|
$(GC) y.go
|
||||||
|
$(LD) -o units y.$O
|
||||||
|
|
||||||
|
@ -1313,18 +1313,18 @@ cpyact(curprod []int, max int)
|
|||||||
putrune(ftable, c);
|
putrune(ftable, c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '{':
|
case '{':
|
||||||
if brac == 0 {
|
if brac == 0 {
|
||||||
}
|
}
|
||||||
putrune(ftable, '\t');
|
putrune(ftable, '\t');
|
||||||
brac++;
|
brac++;
|
||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
s := 1;
|
s := 1;
|
||||||
tok := -1;
|
tok := -1;
|
||||||
c = getrune(finput);
|
c = getrune(finput);
|
||||||
|
|
||||||
// type description
|
// type description
|
||||||
if c == '<' {
|
if c == '<' {
|
||||||
ungetrune(finput, c);
|
ungetrune(finput, c);
|
||||||
@ -1336,7 +1336,7 @@ cpyact(curprod []int, max int)
|
|||||||
}
|
}
|
||||||
if c == '$' {
|
if c == '$' {
|
||||||
fmt.Fprintf(ftable, "YYVAL");
|
fmt.Fprintf(ftable, "YYVAL");
|
||||||
|
|
||||||
// put out the proper tag...
|
// put out the proper tag...
|
||||||
if ntypes != 0 {
|
if ntypes != 0 {
|
||||||
if tok < 0 {
|
if tok < 0 {
|
||||||
@ -1398,7 +1398,7 @@ cpyact(curprod []int, max int)
|
|||||||
continue loop;
|
continue loop;
|
||||||
}
|
}
|
||||||
fmt.Fprintf(ftable, "YYS[yypt-%v]", max-j-1);
|
fmt.Fprintf(ftable, "YYS[yypt-%v]", max-j-1);
|
||||||
|
|
||||||
// put out the proper tag
|
// put out the proper tag
|
||||||
if ntypes != 0 {
|
if ntypes != 0 {
|
||||||
if j <= 0 && tok < 0 {
|
if j <= 0 && tok < 0 {
|
||||||
@ -1899,7 +1899,7 @@ closure(i int)
|
|||||||
}
|
}
|
||||||
pi := wsets[v].pitem.prod;
|
pi := wsets[v].pitem.prod;
|
||||||
ipi := wsets[v].pitem.off + 1;
|
ipi := wsets[v].pitem.off + 1;
|
||||||
|
|
||||||
wsets[v].flag = 0;
|
wsets[v].flag = 0;
|
||||||
if nolook != 0 {
|
if nolook != 0 {
|
||||||
continue;
|
continue;
|
||||||
@ -2284,7 +2284,7 @@ output()
|
|||||||
} else
|
} else
|
||||||
if temp1[k] < 0 { // reduce/reduce conflict
|
if temp1[k] < 0 { // reduce/reduce conflict
|
||||||
if foutput != nil {
|
if foutput != nil {
|
||||||
fmt.Fprintf(foutput,
|
fmt.Fprintf(foutput,
|
||||||
"\n %v: reduce/reduce conflict (red'ns "
|
"\n %v: reduce/reduce conflict (red'ns "
|
||||||
"%v and %v) on %v",
|
"%v and %v) on %v",
|
||||||
i, -temp1[k], lastred, symnam(k));
|
i, -temp1[k], lastred, symnam(k));
|
||||||
@ -2324,7 +2324,7 @@ precftn(r, t, s int)
|
|||||||
if PLEVEL(lt) == 0 || PLEVEL(lp) == 0 {
|
if PLEVEL(lt) == 0 || PLEVEL(lp) == 0 {
|
||||||
// conflict
|
// conflict
|
||||||
if foutput != nil {
|
if foutput != nil {
|
||||||
fmt.Fprintf(foutput,
|
fmt.Fprintf(foutput,
|
||||||
"\n%v: shift/reduce conflict (shift %v(%v), red'n %v(%v)) on %v",
|
"\n%v: shift/reduce conflict (shift %v(%v), red'n %v(%v)) on %v",
|
||||||
s, temp1[t], PLEVEL(lt), r, PLEVEL(lp), symnam(t));
|
s, temp1[t], PLEVEL(lt), r, PLEVEL(lp), symnam(t));
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,12 @@
|
|||||||
// ./6.out $GOROOT/src/cmd/goyacc/units
|
// ./6.out $GOROOT/src/cmd/goyacc/units
|
||||||
// you have: c
|
// you have: c
|
||||||
// you want: furlongs/fortnight
|
// you want: furlongs/fortnight
|
||||||
// * 1.8026178e+12
|
// * 1.8026178e+12
|
||||||
// / 5.5474878e-13
|
// / 5.5474878e-13
|
||||||
// you have:
|
// you have:
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
import
|
import
|
||||||
(
|
(
|
||||||
"flag";
|
"flag";
|
||||||
@ -294,7 +296,7 @@ main()
|
|||||||
|
|
||||||
flag.Parse();
|
flag.Parse();
|
||||||
|
|
||||||
file = "units";
|
file = "units.txt";
|
||||||
if flag.NArg() > 0 {
|
if flag.NArg() > 0 {
|
||||||
file = flag.Arg(0);
|
file = flag.Arg(0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user