Annotation of researchv10no/cmd/sml/lib/mlyacc/sample.grm, revision 1.1.1.1

1.1       root        1: type Lineno = int
                      2: val lineno = ref 1
                      3: fun error s l = output std_out 
                      4:        ("line " ^ makestring (l:int) ^ ":" ^ s ^ "\n")
                      5: fun lookup s = ordof(s,0) - ord("a")+1
                      6: %%
                      7: %structure Calc
                      8: %eof   EOF
                      9: %start START
                     10: 
                     11: %left SUB PLUS
                     12: %left TIMES DIV
                     13: 
                     14: %right CARAT
                     15: 
                     16: %term ID of string | NUM of int | PLUS | TIMES | PRINT | EOS | EOF |
                     17:        CARAT | DIV | SUB
                     18: %nonterm EXP of int | START | STMT | STMT_LIST
                     19: 
                     20: %%
                     21:   START : STMT_LIST    ()
                     22:   STMT_LIST : STMT_LIST STMT EOS ()
                     23:   STMT_LIST : ()
                     24:   STMT : PRINT EXP     (print EXP; print "\n"; flush_out std_out)
                     25:   STMT : EXP           ()
                     26:   EXP : NUM            (NUM)
                     27:       | ID             (lookup ID)
                     28:       | EXP PLUS EXP   (EXP1+EXP2)
                     29:       | EXP TIMES EXP  (EXP1*EXP2)
                     30:       | EXP DIV EXP    (EXP1 div EXP2)
                     31:       | EXP SUB EXP    (EXP1-EXP2)
                     32:       | EXP CARAT EXP   (let fun e (m,0) = 1
                     33:                                | e (m,i) = m*e(m,i-1)
                     34:                         in e (EXP1,EXP2)       
                     35:                         end)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.