* scanner object to class

This commit is contained in:
peter 2001-04-13 18:08:36 +00:00
parent 22db4256ce
commit fdeadeed22
6 changed files with 67 additions and 40 deletions

View File

@ -162,7 +162,7 @@ begin
if CompilerInitedAfterArgs then
begin
CompilerInitedAfterArgs:=false;
doneparser;
DoneParser;
DoneImport;
DoneExport;
DoneLinker;
@ -204,7 +204,7 @@ begin
{ read the arguments }
read_arguments(cmd);
{ inits which depend on arguments }
initparser;
InitParser;
InitImport;
InitExport;
InitLinker;
@ -323,7 +323,10 @@ end;
end.
{
$Log$
Revision 1.17 2001-04-13 01:22:06 peter
Revision 1.18 2001-04-13 18:08:36 peter
* scanner object to class
Revision 1.17 2001/04/13 01:22:06 peter
* symtable change to classes
* range check generation and errors fixed, make cycle DEBUG=1 works
* memory leaks fixed

View File

@ -611,7 +611,7 @@ uses
pm : tdependent_unit;
begin
if assigned(scanner) then
pscannerfile(scanner)^.invalid:=true;
tscannerfile(scanner).invalid:=true;
if assigned(globalsymtable) then
begin
globalsymtable.free;
@ -785,7 +785,7 @@ uses
externals.free;
externals:=nil;
if assigned(scanner) then
pscannerfile(scanner)^.invalid:=true;
tscannerfile(scanner).invalid:=true;
used_units.free;
dependent_units.free;
resourcefiles.Free;
@ -878,7 +878,10 @@ uses
end.
{
$Log$
Revision 1.11 2001-04-13 01:22:07 peter
Revision 1.12 2001-04-13 18:08:37 peter
* scanner object to class
Revision 1.11 2001/04/13 01:22:07 peter
* symtable change to classes
* range check generation and errors fixed, make cycle DEBUG=1 works
* memory leaks fixed

View File

@ -50,7 +50,9 @@ implementation
{$ifdef GDB}
gdb,
{$endif GDB}
comphook,scanner,pbase,ptype,pmodules,cresstr;
comphook,
scanner,scandir,
pbase,ptype,pmodules,cresstr;
procedure initparser;
@ -77,6 +79,10 @@ implementation
{ global switches }
aktglobalswitches:=initglobalswitches;
{ initialize scanner }
InitScanner;
InitScannerDirectives;
{ scanner }
c:=#0;
pattern:='';
@ -112,10 +118,13 @@ implementation
still assinged }
if assigned(current_scanner) then
begin
dispose(current_scanner,done);
current_scanner.free;
current_scanner:=nil;
end;
{ close scanner }
DoneScanner;
{ close ppas,deffile }
asmres.free;
deffile.free;
@ -133,13 +142,13 @@ implementation
hp:=tstringlistitem(initdefines.first);
while assigned(hp) do
begin
current_scanner^.def_macro(hp.str);
current_scanner.def_macro(hp.str);
hp:=tstringlistitem(hp.next);
end;
{ set macros for version checking }
current_scanner^.set_macro('FPC_VERSION',version_nr);
current_scanner^.set_macro('FPC_RELEASE',release_nr);
current_scanner^.set_macro('FPC_PATCH',patch_nr);
current_scanner.set_macro('FPC_VERSION',version_nr);
current_scanner.set_macro('FPC_RELEASE',release_nr);
current_scanner.set_macro('FPC_PATCH',patch_nr);
end;
@ -226,7 +235,7 @@ implementation
oldorgpattern : string;
old_block_type : tblock_type;
oldcurrent_scanner,prev_scanner,
scanner : pscannerfile;
scanner : tscannerfile;
{ symtable }
oldrefsymtable,
olddefaultsymtablestack,
@ -362,9 +371,9 @@ implementation
if assigned(current_module) then
begin
{current_module.reset this is wrong !! }
scanner:=current_module.scanner;
scanner:=tscannerfile(current_module.scanner);
current_module.reset;
current_module.scanner:=scanner;
tscannerfile(current_module.scanner):=scanner;
end
else
begin
@ -400,12 +409,12 @@ implementation
aktmoduleswitches:=aktmoduleswitches+[cs_compilesystem];
{ startup scanner, and save in current_module }
current_scanner:=new(pscannerfile,Init(filename));
current_scanner:=tscannerfile.Create(filename);
{ macros }
default_macros;
{ read the first token }
current_scanner^.readtoken;
prev_scanner:=current_module.scanner;
current_scanner.readtoken;
prev_scanner:=tscannerfile(current_module.scanner);
current_module.scanner:=current_scanner;
{ init code generator for a new module }
@ -473,12 +482,12 @@ implementation
current_module.ppufile:=nil;
end;
{ free scanner }
dispose(current_scanner,done);
current_scanner.free;
current_scanner:=nil;
{ restore previous scanner !! }
current_module.scanner:=prev_scanner;
if assigned(prev_scanner) then
prev_scanner^.invalid:=true;
prev_scanner.invalid:=true;
if (compile_level>1) then
begin
@ -603,7 +612,10 @@ implementation
end.
{
$Log$
Revision 1.14 2001-04-13 01:22:10 peter
Revision 1.15 2001-04-13 18:08:37 peter
* scanner object to class
Revision 1.14 2001/04/13 01:22:10 peter
* symtable change to classes
* range check generation and errors fixed, make cycle DEBUG=1 works
* memory leaks fixed

View File

@ -203,7 +203,7 @@ implementation
begin
if token=_END then
last_endtoken_filepos:=akttokenpos;
current_scanner^.readtoken;
current_scanner.readtoken;
end;
end;
@ -217,7 +217,7 @@ implementation
try_to_consume:=true;
if token=_END then
last_endtoken_filepos:=akttokenpos;
current_scanner^.readtoken;
current_scanner.readtoken;
end;
end;
@ -322,7 +322,10 @@ end.
{
$Log$
Revision 1.10 2001-04-13 01:22:11 peter
Revision 1.11 2001-04-13 18:08:37 peter
* scanner object to class
Revision 1.10 2001/04/13 01:22:11 peter
* symtable change to classes
* range check generation and errors fixed, make cycle DEBUG=1 works
* memory leaks fixed

View File

@ -465,7 +465,7 @@ implementation
old_current_ppu : pppufile;
old_current_module,hp,hp2 : tmodule;
name : string;{ necessary because current_module.mainsource^ is reset in compile !! }
scanner : pscannerfile;
scanner : tscannerfile;
procedure loadppufile;
begin
@ -508,14 +508,14 @@ implementation
current_module.in_second_compile:=true;
Message1(parser_d_compiling_second_time,current_module.modulename^);
end;
current_scanner^.tempcloseinputfile;
current_scanner.tempcloseinputfile;
name:=current_module.mainsource^;
if assigned(scanner) then
scanner^.invalid:=true;
scanner.invalid:=true;
compile(name,compile_system);
current_module.in_second_compile:=false;
if (not current_scanner^.invalid) then
current_scanner^.tempopeninputfile;
if (not current_scanner.invalid) then
current_scanner.tempopeninputfile;
end;
end
else
@ -595,7 +595,7 @@ implementation
begin
{ remove the old unit }
loaded_units.remove(hp);
scanner:=hp.scanner;
scanner:=tscannerfile(hp.scanner);
hp.reset;
hp.scanner:=scanner;
{ try to reopen ppu }
@ -924,16 +924,16 @@ implementation
{ define a symbol in delphi,objfpc,tp,gpc mode }
if (m_delphi in aktmodeswitches) then
current_scanner^.def_macro('FPC_DELPHI')
current_scanner.def_macro('FPC_DELPHI')
else
if (m_tp in aktmodeswitches) then
current_scanner^.def_macro('FPC_TP')
current_scanner.def_macro('FPC_TP')
else
if (m_objfpc in aktmodeswitches) then
current_scanner^.def_macro('FPC_OBJFPC')
current_scanner.def_macro('FPC_OBJFPC')
else
if (m_gpc in aktmodeswitches) then
current_scanner^.def_macro('FPC_GPC');
current_scanner.def_macro('FPC_GPC');
end;
@ -1005,7 +1005,7 @@ implementation
if token=_ID then
begin
{ create filenames and unit name }
main_file := current_scanner^.inputfile;
main_file := current_scanner.inputfile;
while assigned(main_file.next) do
main_file := main_file.next;
@ -1424,7 +1424,7 @@ implementation
end;
{ get correct output names }
main_file := current_scanner^.inputfile;
main_file := current_scanner.inputfile;
while assigned(main_file.next) do
main_file := main_file.next;
@ -1639,7 +1639,10 @@ implementation
end.
{
$Log$
Revision 1.27 2001-04-13 01:22:12 peter
Revision 1.28 2001-04-13 18:08:37 peter
* scanner object to class
Revision 1.27 2001/04/13 01:22:12 peter
* symtable change to classes
* range check generation and errors fixed, make cycle DEBUG=1 works
* memory leaks fixed

View File

@ -1181,7 +1181,7 @@ implementation
hs:=current_ppu^.getstring;
was_defined_at_startup:=boolean(current_ppu^.getbyte);
was_used:=boolean(current_ppu^.getbyte);
mac:=tmacro(current_scanner^.macros.search(hs));
mac:=tmacro(current_scanner.macros.search(hs));
if assigned(mac) then
begin
{$ifndef EXTDEBUG}
@ -2117,7 +2117,7 @@ implementation
procedure tglobalsymtable.writeusedmacros;
begin
current_ppu^.do_crc:=false;
current_scanner^.macros.foreach({$ifdef FPCPROCVAR}@{$endif}writeusedmacro);
current_scanner.macros.foreach({$ifdef FPCPROCVAR}@{$endif}writeusedmacro);
current_ppu^.writeentry(ibusedmacros);
current_ppu^.do_crc:=true;
end;
@ -2587,7 +2587,10 @@ implementation
end.
{
$Log$
Revision 1.31 2001-04-13 01:22:16 peter
Revision 1.32 2001-04-13 18:08:37 peter
* scanner object to class
Revision 1.31 2001/04/13 01:22:16 peter
* symtable change to classes
* range check generation and errors fixed, make cycle DEBUG=1 works
* memory leaks fixed