M2000 Compiler Task: Difference between revisions

Content added Content deleted
Line 15: Line 15:
<lang M2000 Interpreter>
<lang M2000 Interpreter>
Module CompilerExample {
Module CompilerExample {
Set Fast !
Module lexical_analyzer (a$){
Module lexical_analyzer (a$){
lim=Len(a$)
lim=Len(a$)
Line 674: Line 675:
Append func, ne_:=lambda->{Return stack_, sp+1:=uint(if(eval(stack_, sp+1)<>eval(stack_, sp)->-1, 0)):sp++}
Append func, ne_:=lambda->{Return stack_, sp+1:=uint(if(eval(stack_, sp+1)<>eval(stack_, sp)->-1, 0)):sp++}
Append func, eq_:=lambda->{Return stack_, sp+1:=uint(if(eval(stack_, sp+1)=eval(stack_, sp)->-1, 0)):sp++}
Append func, eq_:=lambda->{Return stack_, sp+1:=uint(if(eval(stack_, sp+1)=eval(stack_, sp)->-1, 0)):sp++}
Append func, prts_:=lambda->{Print #-2, string$(eval(stack_,sp));:sp++}
Append func, prts_:=lambda->{Print #-2, string$(eval(stack_,sp));: Refresh:sp++}
Append func, prti_:=lambda->{Print #-2, str$(sint(eval(stack_,sp)),0);:sp++}
Append func, prti_:=lambda->{Print #-2, str$(sint(eval(stack_,sp)),0);: Refresh:sp++}
Append func, prtc_:=lambda->{Print #-2, chrcode$(eval(stack_,sp));:sp++}
Append func, prtc_:=lambda->{Print #-2, chrcode$(eval(stack_,sp));: Refresh:sp++}
Rem : Form 120, 60 ' change console width X height to run Ascii Mandlebrot example
Rem : Form 120, 60 ' change console width X height to run Ascii Mandlebrot example
\\ change Report with Print #-2, (report stop when scrolling 3/4 of height of console, waiting key or mouse key to continue)
\\ change Report with Print #-2, (report stop when scrolling 3/4 of height of console, waiting key or mouse key to continue)
Line 793: Line 794:
CodeGenerator
CodeGenerator
Virtual_Machine_Interpreter
Virtual_Machine_Interpreter
Set Fast 'restore speed setting
}
}
CompilerExample
CompilerExample