// parser Som-som generated from parse-grammar.txt 22 Sept 2009
// global: Nlv, tok, tokvalue, nenum

to top = {
case tok {
tkTO: {
lex
commit fundef
1 break }
tkCOLON: {
lex
commit macro
1 break }
else: {
if ex {
1 break }
}
}
0
}

to fundef = {
if tok == tkIDEN {
ypush tokvalue
lex
commit args
setfname tyFUNC
expect tkEQ "missing tkEQ"
lex
commit ex
dofun tkTO
1 break }
0
}

to macro = {
if tok == tkIDEN {
ypush tokvalue
lex
commit args
setfname tyMAC
expect tkEQ "missing tkEQ"
lex
commit ex
dofun tkCOLON
1 break }
0
}

to args = {
while tok == tkIDEN {
enterLocal tokvalue
lex
}
if tok == tkBAR {
ypush Nlv
lex
commit local
1 break }
ypush Nlv
1
}

to local = {
while tok == tkIDEN {
enterLocal tokvalue
lex
}
1
}

to ex = {
if tok == tkBB {
ypush MARK
lex
commit exs
expect tkBE "missing tkBE"
doblock
lex
1 break }
if ex1 {
1 break }
0
}

to exs = {
while ex1 {
}
1
}

to ex1 = {
case tok {
tkIF: {
lex
commit ex0
commit ex
commit exelse
doif
1 break }
tkWHILE: {
lex
commit ex0
commit ex
dowhile
1 break }
tkFOR: {
lex
expect tkIDEN "missing tkIDEN"
ypush tokvalue
lex
commit ex0
commit ex0
commit ex
dofor
1 break }
tkCASE: {
lex
commit ex0
expect tkBB "missing tkBB"
ypush MARK
lex
commit caselist
expect tkBE "missing tkBE"
docase
lex
1 break }
tkENUM: {
lex
expect tkBB "missing tkBB"
lex
commit elist
expect tkBE "missing tkBE"
ypush NIL
lex
1 break }
tkBREAK: {
ypush list newatom OPER tkBREAK
lex
1 break }
else: {
if exas {
1 break }
}
}
0
}

to exelse = {
if tok == tkELSE {
lex
commit ex
ypush MARK
1 break }
1
}

to elist = {
if tok == tkNUMBER {
nenum = tokvalue
lex
commit elist2
1 break }
if elist2 {
1 break }
0
}

to elist2 = {
while tok == tkIDEN {
doenum
lex
}
1
}

to caselist = {
while label {
expect tkCOLON "missing tkCOLON"
lex
commit ex
}
if tok == tkELSE {
donum #ff
lex
expect tkCOLON "missing tkCOLON"
lex
commit ex
1 break }
1
}

to label = {
if tok == tkNUMBER {
donum tokvalue
lex
1 break }
if tok == tkIDEN {
dolabel
lex
1 break }
0
}

to ex0 = {
if term {
commit terms
1 break }
0
}

to terms = {
while bop {
commit term
dobop
}
1
}

to term | a  = {
case tok {
tkNUMBER: {
donum tokvalue
lex
1 break }
tkSTRING: {
dostring
lex
1 break }
tkIDEN: {
a = tokvalue
lex
doiden a
1 break }
tkNOT: {
lex
commit ex0
douop tkNOT
1 break }
tkARRAY: {
lex
commit aspec
1 break }
tkSYSCALL: {
lex
commit tuple
dosys
1 break }
tkLPAREN: {
lex
commit ex0
expect tkRPAREN "missing tkRPAREN"
lex
1 break }
}
0
}

to aspec | a  = {
if tok == tkBB {
a = array 0
lex
commit alist
expect tkBE "missing tkBE"
ypush newatom ADS a
lex
1 break }
if ex0 {
douop tkARRAY
1 break }
0
}

to alist = {
while aitem {
}
1
}

to aitem = {
case tok {
tkNUMBER: {
M[newdata] = tokvalue
lex
1 break }
tkSTRING: {
akeepStr
lex
1 break }
tkIDEN: {
akeepIden
lex
1 break }
}
0
}

to tuple = {
if tok == tkBB {
lex
expect tkNUMBER "missing tkNUMBER"
ypush MARK donum tokvalue
lex
commit tuples
expect tkBE "missing tkBE"
lex
1 break }
0
}

to tuples = {
while ex0 {
}
1
}

to mod = {
if tok == tkLBRACKET {
lex
commit ex0
expect tkRBRACKET "missing tkRBRACKET"
dovec
lex
1 break }
1
}

to bop = {
case tok {
tkPLUS: {
ypush tok
lex
1 break }
tkMINUS: {
ypush tok
lex
1 break }
tkSTAR: {
ypush tok
lex
1 break }
tkSLASH: {
ypush tok
lex
1 break }
tkAND: {
ypush tok
lex
1 break }
tkBAR: {
ypush tok
lex
1 break }
tkCARET: {
ypush tok
lex
1 break }
tkEQEQ: {
ypush tok
lex
1 break }
tkNE: {
ypush tok
lex
1 break }
tkLT: {
ypush tok
lex
1 break }
tkLE: {
ypush tok
lex
1 break }
tkGE: {
ypush tok
lex
1 break }
tkGT: {
ypush tok
lex
1 break }
tkMOD: {
ypush tok
lex
1 break }
tkGTGT: {
ypush tok
lex
1 break }
tkLTLT: {
ypush tok
lex
1 break }
}
0
}

noi 47148
