Mercurial > hg > Members > kono > TL1bt
changeset 6:1896f63eedc1
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 04 Nov 2020 17:38:45 +0900 |
parents | 91e08ff0630d |
children | c95d28c5aaf2 |
files | tl1trans/tl1token.tl1 tl1trans/tl1trans.pl |
diffstat | 2 files changed, 110 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/tl1trans/tl1token.tl1 Wed Oct 28 14:16:09 2020 +0900 +++ b/tl1trans/tl1token.tl1 Wed Nov 04 17:38:45 2020 +0900 @@ -1,3 +1,78 @@ +% +% +% +% +PROC RESERVE +BEGIN + WRITE(3:$30,"PPROC"); + WRRIE(3:$31,"FUNC"); + WRITE(3:$32,"VAR"); + WRITE(3:$33,:ARRAY"); + WRITE(3:$34,"BEGIN"); + WRITE(3:$35,";"); + WRITE(3:$36,"["); + WRITE(3:$37,"("); + WRITE(3:$38,"END"); + WRITE(3:$39,"=" ); + WRITE(3:$3A,"]"); + WRITE(3:$3B,")"); + WRITE(3:$3C,","); + WRITE(3:$3D,":"); + WRITE(3:$3E,";"); + WRITE(3:$50,"STOP" ); + WRITE(3:$51,"RETURN"); + WRITE(3:$55,"IF"); + WRITE(3:$65,"THEN"); + WRITE(3:$53,"FOR" ); + WRITE(3:$61,"TO"); + WRITE(3:$52,"REPEAT"); + WRITE(3:$60,"UNTIL"); + WRITE(3:$54,"WHILE"); + WRITE(3:$64,"DO"); + WRITE(3:$56,"CASE"); + WRITE(3:$66,"OF" ); + WRITE(3:$67,"ELSE"); + WRITE(3:$57,"WRITE"); + WRITE(3:$69,"ASCII" ); + WRITE(3:$6A,"SPACE"); + WRITE(3:$68,"CRLF" ); + WRITE(3:$6C,"\""); + WRITE(3:$8B,"+"); + WRITE(3:$80,"-"); + WRITE(3:$8E,"*" ); + WRITE(3:$8F,"/"); + WRITE(3:$82,".SBC."); + WRITE(3:$84,".AND."); + WRITE(3:$88,".EOR."); + WRITE(3:$89,".ADC."); + WRITE(3:$8A,".OR."); + WRITE(3:$22,">" ); + WRITE(3:$25,"<"); + WRITE(3:$26,"#"); + WRITE(3:$27,"=" ); + WRITE(3:$2D,".LT."); + WRITE(3:$2E,".GT."); + WRITE(3:$40,"NEG"); + WRITE(3:$43,"NOT"); + WRITE(3:$43,"COM"); + WRITE(3:$44,"LSR"); + WRITE(3:$46,"ROR"); + WRITE(3:$47,"ASR"); + WRITE(3:$48,"ASL"); + WRITE(3:$49,"ROL"); + WRITE(3:$06,"MEM"); + WRITE(3:$A0,"TRUE"); + WRITE(3:$A1,"FALSE"); + WRITE(3:$16,"MHIGH"); + WRITE(3:$17,"MOD"); + WRITE(3:$70,"RND"); + WRITE(3:$71,"GET"); + WRITE(3:$72,"READ"); + WRITE(3:$73 "RETRUN"); + WRITE(3:$74 "OTHERWISE"); + WRITE(3:$FF ""); % delimitor +END + FUNC TOKEN VAR C,KIND,VALUE BEGIN @@ -10,22 +85,44 @@ FUNC TOKEN() VAR D +ARRAY W(8) BEGIN - WHILE (C<'%'+1) DO { % comment - DO { + WHILE (C<'%'+1) DO BEGIN % comment + DO BEGIN C:=GET(0) - } WHILE(C # 0) + END WHILE(C # 0) C:=GET(0) - } + END IF('0'<C+1 && C<'9'+1) { % Decimal VALUE := C-'0'; DO { C:=GET(0) - IF(('0'<C+1).AND.(c<='9')) THEN + IF(('0'<C+1).AND.(C<='9')) THEN VALUE := VALUE*10 + (C - '0') } WHILE(C # 0) RETURN '0' - } ELSE IF (('A'<C+1).AND.(c<'Z'+1)) { /* name */ + } ELSE IF ('$'=C) { % hex * + } ELSE IF ('\''=C) { % ascii char * + } ELSE IF ('"'=C) { % string * + } ELSE IF (('A'<C+1).AND.(c<'Z'+1)) { % name + FOR I:=0 TO 8 DO { + IF (('A'<C+1).AND.(c<'Z'+1)) { + W[I] := C ; I:=I+1; + } + } + W[I]:=0; + SEEK(3:0); + IF (FIND(3:W)) THEN { + } ELSE { + WRITE(3:IDTOP,W); % register new id + IDTOP:=IDTOP+1; + } + + % reserved word + % proc + % func + % scalar var + % array var RETURN 'V' } ELSE { D:=C ; C:=GET(0)
--- a/tl1trans/tl1trans.pl Wed Oct 28 14:16:09 2020 +0900 +++ b/tl1trans/tl1trans.pl Wed Nov 04 17:38:45 2020 +0900 @@ -1,5 +1,6 @@ -#!/usr/bin/perl -w -use strict; +#!/usr/bin/perl + +use strict; # % ** SPRITE TEST PROGRAM ** # PROC WAIT,TIME @@ -224,14 +225,14 @@ &output("}"); $nest--; last statement if ($nest==0) ; - } elsif (s/^(\w+)//) { - &output(" $1"); - } elsif (s/^RETURN\s*(\w*)\s*//) { - &output("return $1;"); + } elsif (s/^RETURN\s*//) { + &output("return"); } elsif (s/^:=\s*//) { &output("="); } elsif (s/^=\s*//) { &output("=="); + } elsif (s/^(\w+)//) { + &output(" $1"); } elsif (s/^.//) { &output($&); }