|
@@ -75,6 +75,14 @@ unit scan;
|
|
{ p contains the operator string
|
|
{ p contains the operator string
|
|
p1 contains the left expr
|
|
p1 contains the left expr
|
|
p2 contains the right expr }
|
|
p2 contains the right expr }
|
|
|
|
+ t_arrayop,
|
|
|
|
+ {
|
|
|
|
+ p1 contains the array expr
|
|
|
|
+ p2 contains the index expressions }
|
|
|
|
+ t_callop,
|
|
|
|
+ {
|
|
|
|
+ p1 contains the proc expr
|
|
|
|
+ p2 contains the index expressions }
|
|
t_arg,
|
|
t_arg,
|
|
{
|
|
{
|
|
p1 contain the typedef
|
|
p1 contain the typedef
|
|
@@ -110,12 +118,14 @@ unit scan;
|
|
p : pchar;
|
|
p : pchar;
|
|
next : presobject;
|
|
next : presobject;
|
|
p1,p2,p3 : presobject;
|
|
p1,p2,p3 : presobject;
|
|
- { dtyp : tdtyp; }
|
|
|
|
|
|
+ { name of int/real, then no T prefix is required }
|
|
|
|
+ intname : boolean;
|
|
constructor init_no(t : ttyp);
|
|
constructor init_no(t : ttyp);
|
|
constructor init_one(t : ttyp;_p1 : presobject);
|
|
constructor init_one(t : ttyp;_p1 : presobject);
|
|
constructor init_two(t : ttyp;_p1,_p2 : presobject);
|
|
constructor init_two(t : ttyp;_p1,_p2 : presobject);
|
|
constructor init_three(t : ttyp;_p1,_p2,_p3 : presobject);
|
|
constructor init_three(t : ttyp;_p1,_p2,_p3 : presobject);
|
|
constructor init_id(const s : string);
|
|
constructor init_id(const s : string);
|
|
|
|
+ constructor init_intid(const s : string);
|
|
constructor init_bop(const s : string;_p1,_p2 : presobject);
|
|
constructor init_bop(const s : string;_p1,_p2 : presobject);
|
|
constructor init_preop(const s : string;_p1 : presobject);
|
|
constructor init_preop(const s : string;_p1 : presobject);
|
|
procedure setstr(const s:string);
|
|
procedure setstr(const s:string);
|
|
@@ -208,6 +218,7 @@ unit scan;
|
|
p2:=nil;
|
|
p2:=nil;
|
|
p3:=nil;
|
|
p3:=nil;
|
|
next:=nil;
|
|
next:=nil;
|
|
|
|
+ intname:=false;
|
|
end;
|
|
end;
|
|
|
|
|
|
constructor tresobject.init_bop(const s : string;_p1,_p2 : presobject);
|
|
constructor tresobject.init_bop(const s : string;_p1,_p2 : presobject);
|
|
@@ -218,6 +229,7 @@ unit scan;
|
|
p2:=_p2;
|
|
p2:=_p2;
|
|
p3:=nil;
|
|
p3:=nil;
|
|
next:=nil;
|
|
next:=nil;
|
|
|
|
+ intname:=false;
|
|
end;
|
|
end;
|
|
|
|
|
|
constructor tresobject.init_id(const s : string);
|
|
constructor tresobject.init_id(const s : string);
|
|
@@ -228,6 +240,18 @@ unit scan;
|
|
p2:=nil;
|
|
p2:=nil;
|
|
p3:=nil;
|
|
p3:=nil;
|
|
next:=nil;
|
|
next:=nil;
|
|
|
|
+ intname:=false;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ constructor tresobject.init_intid(const s : string);
|
|
|
|
+ begin
|
|
|
|
+ typ:=t_id;
|
|
|
|
+ p:=strpnew(s);
|
|
|
|
+ p1:=nil;
|
|
|
|
+ p2:=nil;
|
|
|
|
+ p3:=nil;
|
|
|
|
+ next:=nil;
|
|
|
|
+ intname:=true;
|
|
end;
|
|
end;
|
|
|
|
|
|
constructor tresobject.init_two(t : ttyp;_p1,_p2 : presobject);
|
|
constructor tresobject.init_two(t : ttyp;_p1,_p2 : presobject);
|
|
@@ -238,6 +262,7 @@ unit scan;
|
|
p3:=nil;
|
|
p3:=nil;
|
|
p:=nil;
|
|
p:=nil;
|
|
next:=nil;
|
|
next:=nil;
|
|
|
|
+ intname:=false;
|
|
end;
|
|
end;
|
|
|
|
|
|
constructor tresobject.init_three(t : ttyp;_p1,_p2,_p3 : presobject);
|
|
constructor tresobject.init_three(t : ttyp;_p1,_p2,_p3 : presobject);
|
|
@@ -248,6 +273,7 @@ unit scan;
|
|
p3:=_p3;
|
|
p3:=_p3;
|
|
p:=nil;
|
|
p:=nil;
|
|
next:=nil;
|
|
next:=nil;
|
|
|
|
+ intname:=false;
|
|
end;
|
|
end;
|
|
|
|
|
|
constructor tresobject.init_one(t : ttyp;_p1 : presobject);
|
|
constructor tresobject.init_one(t : ttyp;_p1 : presobject);
|
|
@@ -258,6 +284,7 @@ unit scan;
|
|
p3:=nil;
|
|
p3:=nil;
|
|
next:=nil;
|
|
next:=nil;
|
|
p:=nil;
|
|
p:=nil;
|
|
|
|
+ intname:=false;
|
|
end;
|
|
end;
|
|
|
|
|
|
constructor tresobject.init_no(t : ttyp);
|
|
constructor tresobject.init_no(t : ttyp);
|
|
@@ -268,6 +295,7 @@ unit scan;
|
|
p2:=nil;
|
|
p2:=nil;
|
|
p3:=nil;
|
|
p3:=nil;
|
|
next:=nil;
|
|
next:=nil;
|
|
|
|
+ intname:=false;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure tresobject.setstr(const s : string);
|
|
procedure tresobject.setstr(const s : string);
|
|
@@ -310,6 +338,7 @@ unit scan;
|
|
newres : presobject;
|
|
newres : presobject;
|
|
begin
|
|
begin
|
|
newres:=new(presobject,init_no(typ));
|
|
newres:=new(presobject,init_no(typ));
|
|
|
|
+ newres^.intname:=intname;
|
|
if assigned(p) then
|
|
if assigned(p) then
|
|
newres^.p:=strnew(p);
|
|
newres^.p:=strnew(p);
|
|
if assigned(p1) then
|
|
if assigned(p1) then
|
|
@@ -415,10 +444,8 @@ D [0-9]
|
|
else
|
|
else
|
|
return(256);
|
|
return(256);
|
|
{D}*[U]?[L]? begin
|
|
{D}*[U]?[L]? begin
|
|
- if yytext[length(yytext)]='L' then
|
|
|
|
- dec(byte(yytext[0]));
|
|
|
|
- if yytext[length(yytext)]='U' then
|
|
|
|
- dec(byte(yytext[0]));
|
|
|
|
|
|
+ if yytext[length(yytext)] in ['L','U'] then
|
|
|
|
+ Delete(yytext,length(yytext),1);
|
|
return(NUMBER);
|
|
return(NUMBER);
|
|
end;
|
|
end;
|
|
"0x"[0-9A-Fa-f]*[U]?[L]?
|
|
"0x"[0-9A-Fa-f]*[U]?[L]?
|
|
@@ -429,10 +456,8 @@ D [0-9]
|
|
delete(yytext,1,2);
|
|
delete(yytext,1,2);
|
|
yytext:='$'+yytext;
|
|
yytext:='$'+yytext;
|
|
end;
|
|
end;
|
|
- if yytext[length(yytext)]='L' then
|
|
|
|
- dec(byte(yytext[0]));
|
|
|
|
- if yytext[length(yytext)]='U' then
|
|
|
|
- dec(byte(yytext[0]));
|
|
|
|
|
|
+ if yytext[length(yytext)] in ['L','U'] then
|
|
|
|
+ Delete(yytext,length(yytext),1);
|
|
return(NUMBER);
|
|
return(NUMBER);
|
|
end;
|
|
end;
|
|
{D}+(\.{D}+)?([Ee][+-]?{D}+)?
|
|
{D}+(\.{D}+)?([Ee][+-]?{D}+)?
|
|
@@ -455,6 +480,7 @@ D [0-9]
|
|
"<" return(LT);
|
|
"<" return(LT);
|
|
"|" return(_OR);
|
|
"|" return(_OR);
|
|
"&" return(_AND);
|
|
"&" return(_AND);
|
|
|
|
+"~" return(_NOT); (* inverse, but handled as not operation *)
|
|
"!" return(_NOT);
|
|
"!" return(_NOT);
|
|
"/" return(_SLASH);
|
|
"/" return(_SLASH);
|
|
"+" return(_PLUS);
|
|
"+" return(_PLUS);
|
|
@@ -527,17 +553,17 @@ D [0-9]
|
|
if not stripinfo then
|
|
if not stripinfo then
|
|
writeln(outfile,'{ C++ end of extern C conditionnal removed }');
|
|
writeln(outfile,'{ C++ end of extern C conditionnal removed }');
|
|
end;
|
|
end;
|
|
-"#else" begin
|
|
|
|
|
|
+"#"[ \t]*"else" begin
|
|
writeln(outfile,'{$else}');
|
|
writeln(outfile,'{$else}');
|
|
block_type:=bt_no;
|
|
block_type:=bt_no;
|
|
flush(outfile);
|
|
flush(outfile);
|
|
end;
|
|
end;
|
|
-"#endif" begin
|
|
|
|
|
|
+"#"[ \t]*"endif" begin
|
|
writeln(outfile,'{$endif}');
|
|
writeln(outfile,'{$endif}');
|
|
block_type:=bt_no;
|
|
block_type:=bt_no;
|
|
flush(outfile);
|
|
flush(outfile);
|
|
end;
|
|
end;
|
|
-"#elif" begin
|
|
|
|
|
|
+"#"[ \t]*"elif" begin
|
|
if not stripinfo then
|
|
if not stripinfo then
|
|
write(outfile,'(*** was #elif ****)');
|
|
write(outfile,'(*** was #elif ****)');
|
|
write(outfile,'{$else');
|
|
write(outfile,'{$else');
|
|
@@ -546,33 +572,48 @@ D [0-9]
|
|
block_type:=bt_no;
|
|
block_type:=bt_no;
|
|
flush(outfile);
|
|
flush(outfile);
|
|
end;
|
|
end;
|
|
-"#undef" begin
|
|
|
|
|
|
+"#"[ \t]*"undef" begin
|
|
write(outfile,'{$undef');
|
|
write(outfile,'{$undef');
|
|
copy_until_eol;
|
|
copy_until_eol;
|
|
writeln(outfile,'}');
|
|
writeln(outfile,'}');
|
|
flush(outfile);
|
|
flush(outfile);
|
|
end;
|
|
end;
|
|
-"#error" begin
|
|
|
|
|
|
+"#"[ \t]*"error" begin
|
|
write(outfile,'{$error');
|
|
write(outfile,'{$error');
|
|
copy_until_eol;
|
|
copy_until_eol;
|
|
writeln(outfile,'}');
|
|
writeln(outfile,'}');
|
|
flush(outfile);
|
|
flush(outfile);
|
|
end;
|
|
end;
|
|
-"#include" begin
|
|
|
|
|
|
+"#"[ \t]*"include" begin
|
|
write(outfile,'{$include');
|
|
write(outfile,'{$include');
|
|
copy_until_eol;
|
|
copy_until_eol;
|
|
writeln(outfile,'}');
|
|
writeln(outfile,'}');
|
|
flush(outfile);
|
|
flush(outfile);
|
|
block_type:=bt_no;
|
|
block_type:=bt_no;
|
|
end;
|
|
end;
|
|
-"#if" begin
|
|
|
|
|
|
+"#"[ \t]*"if" begin
|
|
write(outfile,'{$if');
|
|
write(outfile,'{$if');
|
|
copy_until_eol;
|
|
copy_until_eol;
|
|
writeln(outfile,'}');
|
|
writeln(outfile,'}');
|
|
flush(outfile);
|
|
flush(outfile);
|
|
block_type:=bt_no;
|
|
block_type:=bt_no;
|
|
end;
|
|
end;
|
|
-"#pragma" begin
|
|
|
|
|
|
+"# "[0-9]+" " begin
|
|
|
|
+ (* preprocessor line info *)
|
|
|
|
+ repeat
|
|
|
|
+ c:=get_char;
|
|
|
|
+ case c of
|
|
|
|
+ newline :
|
|
|
|
+ begin
|
|
|
|
+ unget_char(c);
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ #0 :
|
|
|
|
+ commenteof;
|
|
|
|
+ end;
|
|
|
|
+ until false;
|
|
|
|
+ end;
|
|
|
|
+"#"[ \t]*"pragma" begin
|
|
if not stripinfo then
|
|
if not stripinfo then
|
|
begin
|
|
begin
|
|
write(outfile,'(** unsupported pragma');
|
|
write(outfile,'(** unsupported pragma');
|
|
@@ -585,7 +626,7 @@ D [0-9]
|
|
skip_until_eol;
|
|
skip_until_eol;
|
|
block_type:=bt_no;
|
|
block_type:=bt_no;
|
|
end;
|
|
end;
|
|
-"#define" begin
|
|
|
|
|
|
+"#"[ \t]*"define" begin
|
|
in_define:=true;
|
|
in_define:=true;
|
|
in_space_define:=1;
|
|
in_space_define:=1;
|
|
return(DEFINE);
|
|
return(DEFINE);
|
|
@@ -600,6 +641,7 @@ D [0-9]
|
|
"int" return(INT);
|
|
"int" return(INT);
|
|
"short" return(SHORT);
|
|
"short" return(SHORT);
|
|
"long" return(LONG);
|
|
"long" return(LONG);
|
|
|
|
+"signed" return(SIGNED);
|
|
"unsigned" return(UNSIGNED);
|
|
"unsigned" return(UNSIGNED);
|
|
"float" return(REAL);
|
|
"float" return(REAL);
|
|
"const" return(_CONST);
|
|
"const" return(_CONST);
|