automate_3.0.0_b83dfb77/src/insrc.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--------------------------------------------------------------------------------
-- NOM DU CSU (spécification)       : InSrc.ads
-- AUTEUR DU CSU                    : P. Pignard
-- VERSION DU CSU                   : 3.0a
-- DATE DE LA DERNIERE MISE A JOUR  : Octobre 2023
-- ROLE DU CSU                      : Unité de gestion des textes sources.
--
--
-- FONCTIONS EXPORTEES DU CSU       :
--
--
-- FONCTIONS LOCALES DU CSU         :
--
--
-- NOTES                            :
--
-- COPYRIGHT                        : (c) Pascal Pignard 2023
-- LICENCE                          : CeCILL V2.1 (https://cecill.info)
-- CONTACT                          : http://blady.pagesperso-orange.fr
--------------------------------------------------------------------------------

with UXStrings; use UXStrings;
with UXStrings.Text_IO;
with UXStrings.Conversions;
with Ada.Containers.Ordered_Maps;

package InSrc is

   -- Objet assurant la gestion du fichier source.
   type TSourceMgr is tagged limited private;
   type PSourceMgr is access TSourceMgr;

   procedure Open (Object : not null access TSourceMgr; Name : UXString);
   procedure Read (Object : not null access TSourceMgr; Ch1, Ch2 : out Wide_Wide_Character);
   procedure Status (Object : not null access TSourceMgr; Name : out UXString; Ligne : out Natural);
   procedure Close (Object : not null access TSourceMgr);

   -- Eléments lexicaux
   type TTokenId is
     (NullId, EotId, NewlineId, ErrorId, UnknownId, CallId, CarId, CommentId, UndefId, AutomId, DefaultId, OutId, ErrId,
      FromId, InitId, EventId, ActionId, VirgId, PlusId, PointpointId, ToId, GosubId, EndId, SameId, ParOuvId,
      ParFermId, DebugId);

   function Image is new UXStrings.Conversions.Scalar_Image (TTokenId);

   -- Contexte de l'élément lexical
   subtype Ttokenstr is UXString;

   -- Lit un ou plusieurs caractères dans le texte source et le ou les transforme en éléments lexicaux.
   procedure ReadToken (TokenId : out TTokenId; Token : out Ttokenstr);

   -- Référence du package assurant la gestion des mots clés
   package IdAutoUnit is new Ada.Containers.Ordered_Maps (UXString, TTokenId);
   IdAuto : IdAutoUnit.Map;

   SrcAuto : PSourceMgr;     -- Référence de l'objet assurant la gestion du texte source de l'automate

private

   subtype Ttextbuff is UXString;

   -- Objet assurant la gestion du fichier source.
   type TSourceMgr is tagged limited record
      FName            : UXString;
      FRef             : UXStrings.Text_IO.File_Type;
      FLen             : UXStrings.Text_IO.Count;
      CptCar, CptLigne : Natural;
      TextBuff         : Ttextbuff;
      ChTemp           : Wide_Wide_Character;
   end record;

end InSrc;