]> Cypherpunks repositories - gostls13.git/commitdiff
rename units -> units.txt.
authorRuss Cox <rsc@golang.org>
Thu, 10 Sep 2009 21:47:10 +0000 (14:47 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 10 Sep 2009 21:47:10 +0000 (14:47 -0700)
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
src/cmd/goyacc/goyacc.go
src/cmd/goyacc/units.txt [moved from src/cmd/goyacc/units with 100% similarity]
src/cmd/goyacc/units.y

index cca46c3e8b8806ab7f057c557038b974e6e835ac..0fb6198042419226c9596f3af7781b0f7f279495 100644 (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
+
index 480d34e4b4414373cf37a3cbe6db4e9596def8dc..3304f31dede5d63430c026b1eab7a4ce2575244f 100644 (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));
                }
index a5510fbca6a85adc9443ac0540bb9223b9cdaffc..fcb37dd6799ecd6141bb4d96a177924ed2c58f63 100644 (file)
 //     ./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);
        }