Mercurial > hg > Members > kono > TL1bt
changeset 4:e66321b51bb5
tokenizer start
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 21 Oct 2020 17:31:44 +0900 |
parents | 8f05bcf2f4ef |
children | 91e08ff0630d |
files | tl1trans/tl1token.tl1 tl1trans/tl1trans.pl |
diffstat | 2 files changed, 38 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tl1trans/tl1token.tl1 Wed Oct 21 17:31:44 2020 +0900 @@ -0,0 +1,35 @@ +FUNC TOKEN +VAR C,KIND,VALUE +BEGIN + C:=GET(0) + DO { + TOKEN() + } WHILE(C=255) +END + +FUNC +TOKEN() +VAR D +BEGIN + WHILE (C<'%'+1) DO { % comment + DO { + C:=GET(0) + } WHILE(C # 0) + C:=GET(0) + } + IF('0'<C+1 && C<'9'+1) { % Decimal + VALUE := C-'0'; + DO { + C:=GET(0) + 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 */ + RETURN 'V' + } ELSE { + D:=C ; C:=GET(0) + RETURN D + } +END +
--- a/tl1trans/tl1trans.pl Wed Oct 14 23:44:23 2020 +0900 +++ b/tl1trans/tl1trans.pl Wed Oct 21 17:31:44 2020 +0900 @@ -114,6 +114,7 @@ $array; int main(int ac, char *av[]) { + { EOFEOF $nest = 1 ; &statement(0); print <<"EOFEOF"; @@ -249,12 +250,13 @@ print <<"EOFEOF"; $type$proc($args) { $lvar; +{ EOFEOF } elsif (/^BEGIN/) { $nest = 1; &statement(0); print <<"EOFEOF"; -\n} // end $proc +}\n // end $proc EOFEOF } elsif (/^(\w+)\([\w,]+\)/) { $proc = $1;