DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ B T ┃
Length: 18841 (0x4999) Types: TextFile Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11 └─ ⟦129cab021⟧ »DATA« └─⟦this⟧ └─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04 └─ ⟦d65440be7⟧ »DATA« └─⟦this⟧
with Misc_Defs, Misc, Command_Line_Interface, Dfa, Ecs, Gen, Text_Io, Parser; with Main_Body, Tstring, Parse_Tokens, Skeleton_Manager, External_File_Manager; with External_File_Manager, Int_Io; use Misc_Defs, Command_Line_Interface, Tstring, External_File_Manager; package body Main_Body is Outfile_Created : Boolean := False; Aflex_Version : constant String := "1.1d"; Starttime, Endtime : Vstring; -- aflexend - terminate aflex -- -- note -- This routine does not return. procedure Aflexend (Status : in Integer) is use Text_Io; Tblsiz : Integer; begin Termination_Status := Status; -- we'll return this value of the OS. if (Is_Open (Skelfile)) then Close (Skelfile); end if; if (Is_Open (Temp_Action_File)) then Delete (Temp_Action_File); end if; if (Is_Open (Def_File)) then Delete (Def_File); end if; if (Backtrack_Report) then if (Num_Backtracking = 0) then Text_Io.Put_Line (Backtrack_File, "No backtracking."); else if (Fulltbl) then Int_Io.Put (Backtrack_File, Num_Backtracking, 0); Text_Io.Put_Line (Backtrack_File, " backtracking (non-accepting) states."); else Text_Io.Put_Line (Backtrack_File, "Compressed tables always backtrack."); end if; end if; Close (Backtrack_File); end if; if (Printstats) then Endtime := Misc.Aflex_Gettime; Text_Io.Put_Line (Standard_Error, "aflex version " & Aflex_Version & " usage statistics:"); Tstring.Put_Line (Standard_Error, " started at " & Starttime & ", finished at " & Endtime); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Lastnfa, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Current_Mns, 0); Text_Io.Put_Line (Standard_Error, " NFA states"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Lastdfa, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Current_Max_Dfas, 0); Text_Io.Put (Standard_Error, " DFA states ("); Int_Io.Put (Standard_Error, Totnst, 0); Text_Io.Put (Standard_Error, " words)"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Num_Rules - 1, 0); -- - 1 for def. rule Text_Io.Put_Line (Standard_Error, " rules"); if (Num_Backtracking = 0) then Text_Io.Put_Line (Standard_Error, " No backtracking"); else if (Fulltbl) then Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Num_Backtracking, 0); Text_Io.Put_Line (Standard_Error, " backtracking (non-accepting) states"); else Text_Io.Put_Line (Standard_Error, " compressed tables always backtrack"); end if; end if; if (Bol_Needed) then Text_Io.Put_Line (Standard_Error, " Beginning-of-line patterns used"); end if; Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Lastsc, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Current_Max_Scs, 0); Text_Io.Put_Line (Standard_Error, " start conditions"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Numeps, 0); Text_Io.Put (Standard_Error, " epsilon states, "); Int_Io.Put (Standard_Error, Eps2, 0); Text_Io.Put_Line (Standard_Error, " double epsilon states"); if (Lastccl = 0) then Text_Io.Put_Line (Standard_Error, " no character classes"); else Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Lastccl, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Current_Maxccls, 0); Text_Io.Put (Standard_Error, " character classes needed "); Int_Io.Put (Standard_Error, Cclmap (Lastccl) + Ccllen (Lastccl), 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Current_Max_Ccl_Tbl_Size, 0); Text_Io.Put (Standard_Error, " words of storage, "); Int_Io.Put (Standard_Error, Cclreuse, 0); Text_Io.Put_Line (Standard_Error, "reused"); end if; Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Numsnpairs, 0); Text_Io.Put_Line (Standard_Error, " state/nextstate pairs created"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Numuniq, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Numdup, 0); Text_Io.Put_Line (Standard_Error, " unique/duplicate transitions"); if (Fulltbl) then Tblsiz := Lastdfa * Numecs; Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Tblsiz, 0); Text_Io.Put_Line (Standard_Error, " table entries"); else Tblsiz := 2 * (Lastdfa + Numtemps) + 2 * Tblend; Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Lastdfa + Numtemps, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Current_Max_Dfas, 0); Text_Io.Put_Line (Standard_Error, " base-def entries created"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Tblend, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Current_Max_Xpairs, 0); Text_Io.Put (Standard_Error, " (peak "); Int_Io.Put (Standard_Error, Peakpairs, 0); Text_Io.Put_Line (Standard_Error, ") nxt-chk entries created"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Numtemps * Nummecs, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Current_Max_Template_Xpairs, 0); Text_Io.Put (Standard_Error, " (peak "); Int_Io.Put (Standard_Error, Numtemps * Numecs, 0); Text_Io.Put_Line (Standard_Error, ") template nxt-chk entries created"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Nummt, 0); Text_Io.Put_Line (Standard_Error, " empty table entries"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Numprots, 0); Text_Io.Put_Line (Standard_Error, " protos created"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Numtemps, 0); Text_Io.Put (Standard_Error, " templates created, "); Int_Io.Put (Standard_Error, Tmpuses, 0); Text_Io.Put_Line (Standard_Error, "uses"); end if; if (Useecs) then Tblsiz := Tblsiz + Csize; Text_Io.Put_Line (Standard_Error, " "); Int_Io.Put (Standard_Error, Numecs, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Csize, 0); Text_Io.Put_Line (Standard_Error, " equivalence classes created"); end if; if (Usemecs) then Tblsiz := Tblsiz + Numecs; Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Nummecs, 0); Text_Io.Put (Standard_Error, '/'); Int_Io.Put (Standard_Error, Csize, 0); Text_Io.Put_Line (Standard_Error, " meta-equivalence classes created"); end if; Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Hshcol, 0); Text_Io.Put (Standard_Error, " ("); Int_Io.Put (Standard_Error, Hshsave, 0); Text_Io.Put_Line (Standard_Error, " saved) hash collisions, "); Int_Io.Put (Standard_Error, Dfaeql, 0); Text_Io.Put_Line (Standard_Error, " DFAs equal"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Num_Reallocs, 0); Text_Io.Put_Line (Standard_Error, " sets of reallocations needed"); Text_Io.Put (Standard_Error, " "); Int_Io.Put (Standard_Error, Tblsiz, 0); Text_Io.Put_Line (Standard_Error, " total table entries needed"); end if; if (Status /= 0) then raise Aflex_Terminate; end if; end Aflexend; -- aflexinit - initialize aflex procedure Aflexinit (Backtrack_Report : Boolean := False; Ddebug : Boolean := False; Useecs : Boolean := True; Usemecs : Boolean := True; Fulltbl : Boolean := False; Interactive : Boolean := False; Caseins : Boolean := False; Gen_Line_Dirs : Boolean := True; Performance_Report : Boolean := False; Spprdflt : Boolean := False; Use_Stdout : Boolean := False; Trace : Boolean := False; Printstats : Boolean := False) is use Text_Io, Tstring; Sawcmpflag, Use_Stdout : Boolean; Output_File : File_Type; Input_File : File_Type; I : Integer; Arg_Cnt : Integer; Flag_Pos : Integer; Arg : Vstring; Skelname : Vstring; Skelname_Used : Boolean := False; begin Syntaxerror := False; Continued_Action := False; Sawcmpflag := False; -- read flags Command_Line_Interface.Initialize_Command_Line; -- load up argv External_File_Manager.Initialize_Files; -- do external files setup if (Fulltbl and Usemecs) then Misc.Aflexerror ("full table and -cm don't make sense together"); end if; if (Fulltbl and Interactive) then Misc.Aflexerror ("full table and -I are (currently) incompatible"); end if; if (Arg_Cnt < Argc) then begin if (Arg_Cnt - Argc > 1) then Misc.Aflexerror ("extraneous argument(s) given"); end if; -- Tell aflex where to read input from. Infilename := Argv (Arg_Cnt); Open (Input_File, In_File, Str (Argv (Arg_Cnt))); Set_Input (Input_File); exception when Name_Error => Misc.Aflexfatal ("can't open " & Infilename); end; end if; if (not Use_Stdout) then External_File_Manager.Get_Scanner_File (Output_File); Outfile_Created := True; end if; if (Backtrack_Report) then External_File_Manager.Get_Backtrack_File (Backtrack_File); end if; Lastccl := 0; Lastsc := 0; --initialize the statistics Starttime := Misc.Aflex_Gettime; begin -- open the skeleton file if (Skelname_Used) then Open (Skelfile, In_File, Str (Skelname)); Skeleton_Manager.Set_External_Skeleton; end if; exception when Use_Error | Name_Error => Misc.Aflexfatal ("couldn't open skeleton file " & Skelname); end; -- without a third argument create make an anonymous temp file. begin Create (Temp_Action_File, Out_File); Create (Def_File, Out_File); exception when Use_Error | Name_Error => Misc.Aflexfatal ("can't create temporary file"); end; Lastdfa := 0; Lastnfa := 0; Num_Rules := 0; Numas := 0; Numsnpairs := 0; Tmpuses := 0; Numecs := 0; Numeps := 0; Eps2 := 0; Num_Reallocs := 0; Hshcol := 0; Dfaeql := 0; Totnst := 0; Numuniq := 0; Numdup := 0; Hshsave := 0; Eofseen := False; Datapos := 0; Dataline := 0; Num_Backtracking := 0; Onesp := 0; Numprots := 0; Variable_Trailing_Context_Rules := False; Bol_Needed := False; Linenum := 1; Sectnum := 1; Firstprot := Nil; -- used in mkprot() so that the first proto goes in slot 1 -- of the proto queue Lastprot := 1; if (Useecs) then -- set up doubly-linked equivalence classes Ecgroup (1) := Nil; for Cnt in 2 .. Csize loop Ecgroup (Cnt) := Cnt - 1; Nextecm (Cnt - 1) := Cnt; end loop; Nextecm (Csize) := Nil; else -- put everything in its own equivalence class for Cnt in 1 .. Csize loop Ecgroup (Cnt) := Cnt; Nextecm (Cnt) := Bad_Subscript; -- to catch errors end loop; end if; Set_Up_Initial_Allocations; end Aflexinit; -- readin - read in the rules section of the input file(s) procedure Readin is begin Skeleton_Manager.Skelout; Text_Io.Put ("with " & Tstring.Str (Misc.Basename) & "_dfa" & "; "); Text_Io.Put_Line ("use " & Tstring.Str (Misc.Basename) & "_dfa" & "; "); Text_Io.Put ("with " & Tstring.Str (Misc.Basename) & "_io" & "; "); Text_Io.Put_Line ("use " & Tstring.Str (Misc.Basename) & "_io" & "; "); Misc.Line_Directive_Out; Parser.Yyparse; if (Useecs) then Ecs.Cre8ecs (Nextecm, Ecgroup, Csize, Numecs); Ecs.Ccl2ecl; else Numecs := Csize; end if; exception when Parse_Tokens.Syntax_Error => Misc.Aflexerror ("fatal parse error at line " & Integer'Image (Linenum)); Main_Body.Aflexend (1); end Readin; -- set_up_initial_allocations - allocate memory for internal tables procedure Set_Up_Initial_Allocations is begin Current_Mns := Initial_Mns; Firstst := Allocate_Integer_Array (Current_Mns); Lastst := Allocate_Integer_Array (Current_Mns); Finalst := Allocate_Integer_Array (Current_Mns); Transchar := Allocate_Integer_Array (Current_Mns); Trans1 := Allocate_Integer_Array (Current_Mns); Trans2 := Allocate_Integer_Array (Current_Mns); Accptnum := Allocate_Integer_Array (Current_Mns); Assoc_Rule := Allocate_Integer_Array (Current_Mns); State_Type := Allocate_State_Enum_Array (Current_Mns); Current_Max_Rules := Initial_Max_Rules; Rule_Type := Allocate_Rule_Enum_Array (Current_Max_Rules); Rule_Linenum := Allocate_Integer_Array (Current_Max_Rules); Current_Max_Scs := Initial_Max_Scs; Scset := Allocate_Integer_Array (Current_Max_Scs); Scbol := Allocate_Integer_Array (Current_Max_Scs); Scxclu := Allocate_Boolean_Array (Current_Max_Scs); Sceof := Allocate_Boolean_Array (Current_Max_Scs); Scname := Allocate_Vstring_Array (Current_Max_Scs); Actvsc := Allocate_Integer_Array (Current_Max_Scs); Current_Maxccls := Initial_Max_Ccls; Cclmap := Allocate_Integer_Array (Current_Maxccls); Ccllen := Allocate_Integer_Array (Current_Maxccls); Cclng := Allocate_Integer_Array (Current_Maxccls); Current_Max_Ccl_Tbl_Size := Initial_Max_Ccl_Tbl_Size; Ccltbl := Allocate_Character_Array (Current_Max_Ccl_Tbl_Size); Current_Max_Dfa_Size := Initial_Max_Dfa_Size; Current_Max_Xpairs := Initial_Max_Xpairs; Nxt := Allocate_Integer_Array (Current_Max_Xpairs); Chk := Allocate_Integer_Array (Current_Max_Xpairs); Current_Max_Template_Xpairs := Initial_Max_Template_Xpairs; Tnxt := Allocate_Integer_Array (Current_Max_Template_Xpairs); Current_Max_Dfas := Initial_Max_Dfas; Base := Allocate_Integer_Array (Current_Max_Dfas); Def := Allocate_Integer_Array (Current_Max_Dfas); Dfasiz := Allocate_Integer_Array (Current_Max_Dfas); Accsiz := Allocate_Integer_Array (Current_Max_Dfas); Dhash := Allocate_Integer_Array (Current_Max_Dfas); Dss := Allocate_Int_Ptr_Array (Current_Max_Dfas); Dfaacc := Allocate_Dfaacc_Union (Current_Max_Dfas); end Set_Up_Initial_Allocations; end Main_Body; -- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- This software was developed by John Self of the Arcadia project -- at the University of California, Irvine. -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- TITLE main body -- AUTHOR: John Self (UCI) -- DESCRIPTION driver routines for aflex. Calls drivers for all -- high level routines from other packages. -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/mainS.a,v 1.5 90/01/12 15:20:14 self Exp Locker: self $ -- aflex - tool to generate fast lexical analyzers