include lexi.e
constant ident={"ABCDEFGHIJKLNMOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLNMOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"}
constant num ={"0123456789","0123456789"}
constant punctuation = {"?/()#$*-+:=<>&{}[]@!,;'.^\"",{}}
constant terminals_read={ident,num,punctuation,"\n"}
function readf()
sequence result={}, dec
L_in(terminals_read)
while L_result[L_INDEX]!=4 do
if L_result[L_INDEX]=1 then result=append(result,L_result[L_SEARCH])
elsif L_result[L_INDEX]=2 then dec =value(L_result[L_SEARCH])
result=append(result,dec[2])
elsif L_result[L_INDEX]=3 then result=append(result,L_result[L_SEARCH])
elsif L_result[L_INDEX]<0 then result = -1 exit
else L_error("Onbekend teken")
end if
L_in(terminals_read)
end while
return result
end function
sequence file=open("d:/menno/basic/syntax/peu.sct","r")
sequence num_term
sequence termtab={},partab={},result
if not L_init(file) then puts(1,"File not there\n") abort(1) end if
L_any(" ")
num_term=readf()
printf(1,"Terminal Table (length=%i)\n",num_term)
for i=1 to num_term[1] do
result=readf()
termtab=append(termtab,result[1])
end for
for i=1 to length(termtab) do
puts(1,termtab[i]&'\n')
end for
puts(1,"Program code ")
result=readf()
while sequence(result) do
partab&=result[1..2]
result=readf()
end while
printf(1,"(length=%i)\n",{length(partab)})
?partab
if L_end()
then puts(1,"End failed , stil work to do\n")
else puts(1,"End successfull\n")
end if
close(file)