|
|
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 - metrics - downloadIndex: B T
Length: 13013 (0x32d5)
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, Text_Io, File_String;
package body Skeleton_Manager is
use File_String; -- to save having to type FILE_STRING 177 times
Use_External_Skeleton : Boolean := False;
-- are we using an external skelfile?
Current_Line : Integer := 1;
type File_Array is array (Positive range <>) of File_String.Vstring;
Skel_Template : File_Array (1 .. 177) :=
(
-- START OF SKELETON
-- START OF S1
Vstr ("-- A lexical scanner generated by aflex"),
Vstr ("with text_io; use text_io;"),
Vstr ("%% user's code up to the double pound goes right here"),
-- BEGIN S2
Vstr ("function YYLex return Token is"),
Vstr ("subtype short is integer range -32768..32767;"),
Vstr (" yy_act : integer;"), Vstr (" yy_c : short;"),
Vstr (""), Vstr ("-- returned upon end-of-file"),
Vstr ("YY_END_TOK : constant integer := 0;"),
Vstr ("%% tables get generated here."),
-- BEGIN S3
Vstr (""),
Vstr ("-- copy whatever the last rule matched to the standard output"),
Vstr (""),
Vstr ("procedure ECHO is"),
Vstr ("begin"),
Vstr (" text_io.put( yytext );"),
Vstr ("end ECHO;"),
Vstr (""),
Vstr ("-- enter a start condition."),
Vstr
("-- Using procedure requires a () after the ENTER, but makes everything"),
Vstr ("-- much neater."), Vstr (""),
Vstr ("procedure ENTER( state : integer ) is"), Vstr ("begin"),
Vstr (" yy_start := 1 + 2 * state;"),
Vstr ("end ENTER;"), Vstr (""),
Vstr ("-- action number for EOF rule of a given start state"),
Vstr ("function YY_STATE_EOF(state : integer) return integer is"),
Vstr ("begin"), Vstr (" return YY_END_OF_BUFFER + state + 1;"),
Vstr ("end YY_STATE_EOF;"), Vstr (""),
Vstr
("-- return all but the first 'n' matched characters back to the input stream"),
Vstr ("procedure yyless(n : integer) is"), Vstr ("begin"),
Vstr
(" yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext"),
Vstr (" yy_cp := yy_bp + n;"),
Vstr (" yy_c_buf_p := yy_cp;"),
Vstr (" YY_DO_BEFORE_ACTION; -- set up yytext again"),
Vstr ("end yyless;"), Vstr (""),
Vstr ("-- redefine this if you have something you want each time."),
Vstr ("procedure YY_USER_ACTION is"), Vstr ("begin"),
Vstr (" null;"), Vstr ("end;"), Vstr (""),
Vstr
("-- yy_get_previous_state - get the state just before the EOB char was reached"),
Vstr (""),
Vstr ("function yy_get_previous_state return yy_state_type is"),
Vstr (" yy_current_state : yy_state_type;"),
Vstr (" yy_c : short;"),
Vstr ("%% a local declaration of yy_bp goes here if bol_needed"),
Vstr ("begin"),
Vstr ("%% code to get the start state into yy_current_state goes here"),
-- BEGIN S3A
Vstr (""), Vstr (" for yy_cp in yytext_ptr..yy_c_buf_p - 1 loop"),
Vstr ("%% code to find the next state goes here"),
-- BEGIN S4
Vstr (" end loop;"), Vstr (""),
Vstr (" return yy_current_state;"),
Vstr ("end yy_get_previous_state;"), Vstr (""),
Vstr ("procedure yyrestart( input_file : file_type ) is"),
Vstr ("begin"), Vstr (" set_input(input_file);"),
Vstr (" yy_init := true;"), Vstr ("end yyrestart;"), Vstr (""),
Vstr ("begin -- of YYLex"), Vstr ("<<new_file>>"),
Vstr
(" -- this is where we enter upon encountering an end-of-file and"),
Vstr
(" -- yywrap() indicating that we should continue processing"),
Vstr (""), Vstr (" if ( yy_init ) then"),
Vstr (" if ( yy_start = 0 ) then"),
Vstr (" yy_start := 1; -- first start state"),
Vstr (" end if;"), Vstr (""),
Vstr
(" -- we put in the '\n' and start reading from [1] so that an"),
Vstr (" -- initial match-at-newline will be true."),
Vstr (""), Vstr (" yy_ch_buf(0) := ASCII.LF;"),
Vstr (" yy_n_chars := 1;"), Vstr (""),
Vstr
(" -- we always need two end-of-buffer characters. The first causes"),
Vstr
(" -- a transition to the end-of-buffer state. The second causes"),
Vstr (" -- a jam in that state."), Vstr (""),
Vstr (" yy_ch_buf(yy_n_chars) := YY_END_OF_BUFFER_CHAR;"),
Vstr (" yy_ch_buf(yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR;"),
Vstr (""), Vstr (" yy_eof_has_been_seen := false;"),
Vstr (""), Vstr (" yytext_ptr := 1;"),
Vstr (" yy_c_buf_p := yytext_ptr;"),
Vstr (" yy_hold_char := yy_ch_buf(yy_c_buf_p);"),
Vstr (" yy_init := false;"),
Vstr (" end if; -- yy_init"), Vstr (""),
Vstr (" loop -- loops until end-of-file is reached"),
Vstr (" yy_cp := yy_c_buf_p;"), Vstr (""),
Vstr (" -- support of yytext"),
Vstr (" yy_ch_buf(yy_cp) := yy_hold_char;"), Vstr (""),
Vstr
(" -- yy_bp points to the position in yy_ch_buf of the start of the"),
Vstr (" -- current run."), Vstr ("%%"),
-- BEGIN S5
Vstr (""), Vstr ("<<next_action>>"),
Vstr ("%% call to gen_find_action goes here"),
-- BEGIN S6
Vstr (" YY_DO_BEFORE_ACTION;"),
Vstr (" YY_USER_ACTION;"), Vstr (""),
Vstr
(" if aflex_debug then -- output acceptance info. for (-d) debug mode"),
Vstr
(" text_io.put( Standard_Error, ""--accepting rule #"" );"),
Vstr
(" text_io.put( Standard_Error, INTEGER'IMAGE(yy_act) );"),
Vstr
(" text_io.put_line( Standard_Error, ""("""""" & yytext & """""")"");"),
Vstr (" end if;"), Vstr (""),
Vstr
("<<do_action>> -- this label is used only to access EOF actions"),
Vstr (" case yy_act is"), Vstr ("%% actions go here"),
-- BEGIN S7
Vstr (" when YY_END_OF_BUFFER =>"),
Vstr (" -- undo the effects of YY_DO_BEFORE_ACTION"),
Vstr (" yy_ch_buf(yy_cp) := yy_hold_char;"),
Vstr (""), Vstr (" yytext_ptr := yy_bp;"),
Vstr (""), Vstr (" case yy_get_next_buffer is"),
Vstr (" when EOB_ACT_END_OF_FILE =>"),
Vstr (" begin"),
Vstr (" if ( yywrap ) then"),
Vstr
(" -- note: because we've taken care in"),
Vstr
(" -- yy_get_next_buffer() to have set up yytext,"),
Vstr
(" -- we can now set up yy_c_buf_p so that if some"),
Vstr
(" -- total hoser (like aflex itself) wants"),
Vstr
(" -- to call the scanner after we return the"),
Vstr
(" -- End_Of_Input, it'll still work - another"),
Vstr
(" -- End_Of_Input will get returned."),
Vstr (""),
Vstr (" yy_c_buf_p := yytext_ptr;"),
Vstr (""),
Vstr
(" yy_act := YY_STATE_EOF((yy_start - 1) / 2);"),
Vstr (""), Vstr (" goto do_action;"),
Vstr (" else"),
Vstr
(" -- start processing a new file"),
Vstr (" yy_init := true;"),
Vstr (" goto new_file;"),
Vstr (" end if;"),
Vstr (" end;"),
Vstr (" when EOB_ACT_RESTART_SCAN =>"),
Vstr (" yy_c_buf_p := yytext_ptr;"),
Vstr
(" yy_hold_char := yy_ch_buf(yy_c_buf_p);"),
Vstr (" when EOB_ACT_LAST_MATCH =>"),
Vstr (" yy_c_buf_p := yy_n_chars;"),
Vstr
(" yy_current_state := yy_get_previous_state;"),
Vstr (""), Vstr (" yy_cp := yy_c_buf_p;"),
Vstr (" yy_bp := yytext_ptr;"),
Vstr (" goto next_action;"),
Vstr (" when others => null;"),
Vstr (" end case; -- case yy_get_next_buffer()"),
Vstr (" when others =>"),
Vstr (" text_io.put( ""action # "" );"),
Vstr (" text_io.put( INTEGER'IMAGE(yy_act) );"),
Vstr (" text_io.new_line;"),
Vstr (" raise AFLEX_INTERNAL_ERROR;"),
Vstr (" end case; -- case (yy_act)"),
Vstr (" end loop; -- end of loop waiting for end of file"),
Vstr ("end YYLex;"), Vstr ("%%"),
Vstr ("ERROR tried to output beyond end of skeleton file")
-- END OF SKELETON
);
-- set_external_skeleton
--
-- DESCRIPTION
-- sets flag so we know to use an external skelfile
procedure Set_External_Skeleton is
begin
Use_External_Skeleton := True;
end Set_External_Skeleton;
procedure Get_Internal (Buffer : in out File_String.Vstring) is
begin
Buffer := Skel_Template (Current_Line);
Current_Line := Current_Line + 1;
end Get_Internal;
procedure Get_External (Buffer : in out File_String.Vstring) is
begin
File_String.Get_Line (Misc_Defs.Skelfile, Buffer);
end Get_External;
-- end_of_skeleton
--
-- DESCRIPTION
-- returns true if there are no more lines left to output in the skeleton
function End_Of_Skeleton return Boolean is
begin
if (Use_External_Skeleton) then
-- we're using an external skelfile
return Text_Io.End_Of_File (Misc_Defs.Skelfile);
else
-- internal skeleton
return Current_Line > Skel_Template'Last;
end if;
end End_Of_Skeleton;
procedure Get_File_Line (Buffer : in out File_String.Vstring) is
begin
if (Use_External_Skeleton) then
Get_External (Buffer);
else
Get_Internal (Buffer);
end if;
end Get_File_Line;
-- skelout - write out one section of the skeleton file
--
-- DESCRIPTION
-- Either outputs internal skeleton, or from a file with "%%" dividers
-- if a skeleton file is specified by the user.
-- Copies from skelfile to stdout until a line beginning with "%%" or
-- EOF is found.
procedure Skelout is
Buf : File_String.Vstring;
Line_Len : Integer;
begin
while (not End_Of_Skeleton) loop
Get_File_Line (Buf);
if ((File_String.Len (Buf) >= 2) and then
((File_String.Char (Buf, 1) = '%') and
(File_String.Char (Buf, 2) = '%'))) then
exit;
else
File_String.Put_Line (Buf);
end if;
end loop;
end Skelout;
end Skeleton_Manager;
-- 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 skeleton manager
-- AUTHOR: John Self (UCI)
-- DESCRIPTION outputs skeleton sections when called by gen.
-- NOTES allows use of internal or external skeleton
-- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/skeleton_managerS.a,v 1.3 90/01/12 15:20:38 self Exp Locker: self $