	&stlimit = 1000000
	lines = 0
	nest = 0
	in_proc = 0

	OUTPUT(.outfile,12,2048,"gram.dbg.txt")


loop	line = trim(input)  :f(end)
	lines = lines + 1
	line "procedure" :f(skip1)
	save = line
	in_proc = 1
skip1	work = line
loop2   work fence break("{") "{" = ""  :f(skip2)
	work fence '"' = "" :s(loop2)
	work fence "'" = ""  :s(loop2)
	nest = nest + 1 :(loop2)
skip2   work = line
loop3   work fence break("}") "}" = ""    :f(skip3)
	work fence '"' = "" :s(loop3)
	work fence "'" = "" :s(loop3)
	nest = nest - 1 :(loop3)
skip3   work = line
	ne(in_proc,1)        :s(skip4)
	work break("e") "end" rpos(0) :f(skip4)
	le(nest,0) :s(skip4)	
	outfile = "line " lines " in " save " added }"
	output =  "}"
	nest = 0
	in_proc = 0
skip4   output = line	:(loop)
end
