diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-05 10:09:56 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-05 10:09:56 +0000 |
commit | 1bbc983105406a22a22a8fa1aa8fdbcc964d2678 (patch) | |
tree | 79664ddc9b0ba53bcbb38c74d0161e65912f0466 /gcc/ada/g-regpat.ads | |
parent | bc42cc1afb2286e57b4a1e742d5f1251614fc0ee (diff) | |
download | gcc-1bbc983105406a22a22a8fa1aa8fdbcc964d2678.tar.gz |
2004-05-05 Emmanuel Briot <briot@act-europe.fr>
* g-os_lib.ads (Invalid_Time): New constant
* adaint.h, adaint.c (__gnat_file_time_name, __gnat_file_time_fd): Now
return OS_Time instead of time_t to match what is imported by Ada.
Now return -1 if the file doesn't exist, instead of a random value
2004-05-05 Robert Dewar <dewar@gnat.com>
* usage.adb: Add line for -gnatR?s switch
* sem_ch13.adb, exp_ch2.adb: Minor reformatting
* g-regpat.ads, g-regpat.adb: Add documentation on handling of Size
and for Match (Data_First, Data_last)
* lib-writ.adb (Write_With_Lines): Ensure that correct index number is
written when we are dealing with multi-unit files.
2004-05-05 Jerome Guitton <guitton@act-europe.fr>
* Makefile.in: Remove unused targets and variables.
2004-05-05 Vincent Celier <celier@gnat.com>
* switch-m.adb: New gnatmake switch -eI
* vms_data.ads: Add VMS equivalents of new gnatclean swith -innn and
of new gnatmake switch -eInnn.
* makegpr.adb: Take into account new parameters Index and Src_Index in
Prj.Util.
* clean.adb: Implement support for multi-unit sources, including new
switch -i.
* gnatcmd.adb (GNATCmd): Call Prj.Util.Value_Of with new parameter
Src_Index.
* make.ads, make.adb (Insert_Q): New parameter Index, defaulted to 0
(Extract_From_Q): New out parameter Index
(Mark, Is_Marked): Subprograms moved to Makeutl
(Switches_Of): New parameter Source_Index
(Add_Switch): New parameter Index
(Check): New parameter Source_Index
(Collect_Arguments): New parameter Source_Index
(Collect_Arguments_And_Compile): New parameter Source_Index
(Compile): New parameter Source_Index
Put subprograms in alphabetical order
Add support for multi-source sources, including in project files.
* makeutl.ads, makeutl.adb (Unit_Index_Of): New function
(Mark, Is_Marked, Delete_All_Marks): New subprograms, moved from
Make.
* makeusg.adb: New gnatmake switch -eInnn
* mlib-prj.adb (Build_Library): Add new parameter Src_Index to call to
Prj.Util.Value_Of.
* opt.ads (Main_Index): New variable, defaulted to 0.
* osint.ads, osinte.adb (Add_File): New parameter Index
(Current_Source_Index): New function
* prj.adb: Take into account new components Index and Src_Index
* prj.ads (String_Element): New component Index
(Variable_Value): New component Index
(Array_Element): New component Src_Index
* prj-attr.adb: Indicate that optional index may be specified for
attributes Main, Executable, Spec, Body and some of Switches.
* prj-attr.ads (Attribute_Kind): New values for optional indexes
(Attribute_Record): New component Optional_Index
* prj-com.ads (File_Name_Data): New component Index
* prj-dect.adb (Parse_Attribute_Declaration): Process optional index
* prj-env.adb (Put): Output optional index
* prj-makr.adb: Put indexes for multi-unit sources in SFN pragmas and
attributes Spec and Body.
* prj-nmsc.adb: Process optional indexes
* prj-pp.adb: Ouput "at" for optional indexes
* prj-proc.adb: Take into account optional indexes
* prj-strt.ads, prj-strt.adb (Terms): New Boolean parameter
Optional_Index. For string literal,
process optional index when Optional_Index is True.
(Parse_Expresion): New Boolean parameter Optional_Index
* prj-tree.ads, prj-tree.adb (Source_Index_Of): New function
(Set_Source_Index_Of): New procedure
* prj-util.adb (Executable_Of, Value_Of): Take into account optional
index.
* prj-util.ads (Executable_Of): New parameter Index
(Value_Of (Name_Id, Array_Element_Id) returning Variable_Value):
New parameter Src_Index, defaulted to 0.
2004-05-05 Ed Schonberg <schonberg@gnat.com>
PR ada/15257
* sem_ch3.adb (Access_Definition): If this is an access parameter
whose designated type is imported through a limited_with clause, do
not add the enclosing subprogram to the list of private dependents of
the type.
2004-05-05 Ed Schonberg <schonberg@gnat.com>
PR ada/15258
* sem_ch6.adb (Base_Types_Match): True if one type is imported through
a limited_with clause, and the other is its non-limited view.
2004-05-05 Thomas Quinot <quinot@act-europe.fr>
* cstand.adb (Create_Standard): Initialize Stand.Boolean_Literals.
* exp_attr.adb, exp_ch5.adb, exp_ch9.adb, exp_disp.adb,
exp_fixd.adb, sem_attr.adb, sem_dist.adb, sem_util.adb: Use
Stand.Boolean_Literals to produce references to entities
Standard_False and Standard_True from compile-time computed boolean
values.
* stand.ads (Boolean_Literals): New variable, provides the entity
values for False and True, for use by the expander.
2004-05-05 Doug Rupp <rupp@gnat.com>
* 5vinmaop.adb, 5[vx]system.ads: Add Short_Address subtype
5vinmaop.adb: Unchecked convert Short_Address vice Address
* adaint.c, raise.c: Caste CRTL function return value
to avoid gcc error on 32/64 bit IVMS.
* Makefile.in [VMS]: Use iar archiver if host = Alpha/VMS and
target = IA64/VMS.
* init.c[VMS]: Only call Alpha specific __gnat_error_prehandler IN_RTS.
* 5qsystem.ads (Address): Declare as Long_Integer
(Short_Address): Declare as 32 bit subtype of Address
Declare abstract address operations to avoid gratuitous ambiguities.
2004-05-05 Jose Ruiz <ruiz@act-europe.fr>
* gnat_rm.texi: Use the new restriction Simple_Barriers (AI-249)
instead of the old Boolean_Entry_Barriers.
Ditto for No_Task_Attributes_Package instead of No_Task_Attributes.
2004-05-05 GNAT Script <nobody@gnat.com>
* Make-lang.in: Makefile automatically updated
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@81519 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-regpat.ads')
-rw-r--r-- | gcc/ada/g-regpat.ads | 208 |
1 files changed, 128 insertions, 80 deletions
diff --git a/gcc/ada/g-regpat.ads b/gcc/ada/g-regpat.ads index 57bc076717a..82bab7f5bda 100644 --- a/gcc/ada/g-regpat.ads +++ b/gcc/ada/g-regpat.ads @@ -7,7 +7,7 @@ -- S p e c -- -- -- -- Copyright (C) 1986 by University of Toronto. -- --- Copyright (C) 1996-2003 Ada Core Technologies, Inc. -- +-- Copyright (C) 1996-2004 Ada Core Technologies, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -300,19 +300,32 @@ pragma Preelaborate (Regpat); -- This is limited by the size of a Character, as found in the -- byte-compiled version of regular expressions. - Max_Program_Size : constant := 2**15 - 1; - -- Maximum size that can be allocated for a program - Max_Curly_Repeat : constant := 32767; -- Maximum number of repetition for the curly operator. -- The digits in the {n}, {n,} and {n,m } operators can not be higher -- than this constant, since they have to fit on two characters in the -- byte-compiled version of regular expressions. + Max_Program_Size : constant := 2**15 - 1; + -- Maximum size that can be allocated for a program + type Program_Size is range 0 .. Max_Program_Size; for Program_Size'Size use 16; -- Number of bytes allocated for the byte-compiled version of a regular - -- expression. + -- expression. The size required depends on the complexity of the regular + -- expression in a complex manner that is undocumented (other than in the + -- body of the Compile procedure). Normally the size is automatically set + -- and the programmer need not be concerned about it. There are two + -- exceptions to this. First in the calls to Match, it is possible to + -- specify a non-zero size that is known to be large enough. This can + -- slightly increase the efficiency by avoiding a copy. Second, in the + -- case of calling compile, it is possible using the procedural form + -- of Compile to use a single Pattern_Matcher variable for several + -- different expressions by setting its size sufficiently large. + + Auto_Size : constant := 0; + -- Used in calls to Match to indicate that the Size should be set to + -- a value appropriate to the expression being used automatically. type Regexp_Flags is mod 256; for Regexp_Flags'Size use 8; @@ -368,9 +381,14 @@ pragma Preelaborate (Regpat); -- matching a null string at position 1, which uses (1, 0) -- and no match at all. - ------------------------------ - -- Pattern_Matcher Creation -- - ------------------------------ + --------------------------------- + -- Pattern_Matcher Compilation -- + --------------------------------- + + -- The subprograms here are used to precompile regular expressions + -- for use in subsequent Match calls. Precompilation improves + -- efficiency if the same regular expression is to be used in + -- more than one Match call. type Pattern_Matcher (Size : Program_Size) is private; -- Type used to represent a regular expression compiled into byte code @@ -381,14 +399,18 @@ pragma Preelaborate (Regpat); function Compile (Expression : String; Flags : Regexp_Flags := No_Flags) return Pattern_Matcher; - -- Compile a regular expression into internal code. - -- Raises Expression_Error if Expression is not a legal regular expression. - -- The appropriate size is calculated automatically, but this means that - -- the regular expression has to be compiled twice (the first time to - -- calculate the size, the second time to actually generate the byte code). + -- Compile a regular expression into internal code -- - -- Flags is the default value to use to set properties for Expression (case - -- sensitivity,...). + -- Raises Expression_Error if Expression is not a legal regular expression + -- + -- The appropriate size is calculated automatically to correspond to the + -- provided expression. This is the normal default method of compilation. + -- Note that it is generally not possible to assign the result of two + -- different calls to this Compile function to the same Pattern_Matcher + -- variable, since the sizes will differ. + -- + -- Flags is the default value to use to set properties for Expression + -- (e.g. case sensitivity,...). procedure Compile (Matcher : out Pattern_Matcher; @@ -396,11 +418,28 @@ pragma Preelaborate (Regpat); Final_Code_Size : out Program_Size; Flags : Regexp_Flags := No_Flags); -- Compile a regular expression into into internal code - -- This procedure is significantly faster than the function - -- Compile, as there is a known maximum size for the matcher. - -- This function raises Storage_Error if Matcher is too small - -- to hold the resulting code, or Expression_Error is Expression - -- is not a legal regular expression. + + -- This procedure is significantly faster than the Compile function + -- since it avoids the extra step of precomputing the required size. + -- + -- However, it requires the user to provide a Pattern_Matcher variable + -- whose size is preset to a large enough value. One advantage of this + -- approach, in addition to the improved efficiency, is that the same + -- Pattern_Matcher variable can be used to hold the compiled code for + -- several different regular expressions by setting a size that is + -- large enough to accomodate all possibilities. + -- + -- In this version of the procedure call, the actual required code + -- size is returned. Also if Matcher.Size is zero on entry, then the + -- resulting code is not stored. A call with Matcher.Size set to Auto_Size + -- can thus be used to determine the space required for compiling the + -- given regular expression. + -- + -- This function raises Storage_Error if Matcher is too small to hold + -- the resulting code (i.e. Matcher.Size has too small a value). + -- + -- Expression_Error is raised if the string Expression does not contain + -- a valid regular expression. -- -- Flags is the default value to use to set properties for Expression (case -- sensitivity,...). @@ -410,7 +449,7 @@ pragma Preelaborate (Regpat); Expression : String; Flags : Regexp_Flags := No_Flags); -- Same procedure as above, expect it does not return the final - -- program size. + -- program size, and Matcher.Size cannot be Auto_Size. function Paren_Count (Regexp : Pattern_Matcher) return Match_Count; pragma Inline (Paren_Count); @@ -442,83 +481,96 @@ pragma Preelaborate (Regpat); -- Matching -- -------------- - procedure Match - (Expression : String; - Data : String; - Matches : out Match_Array; - Size : Program_Size := 0; - Data_First : Integer := -1; - Data_Last : Positive := Positive'Last); - -- Match Expression against Data (Data_First .. Data_Last) and store - -- result in Matches. - -- - -- Data_First defaults to Data'First if unspecified (that is the - -- dummy value of -1 is interpreted to mean Data'First). - -- - -- Data_Last defaults to Data'Last if unspecified (that is the - -- dummy value of Positive'Last is interpreted to mean Data'Last) - -- - -- It is important that Data contains the whole string (or file) you - -- want to matched against, even if you start in the middle, since - -- otherwise regular expressions starting with "^" or ending with "$" will - -- be improperly processed. + -- The Match subprograms are given a regular expression in string + -- form, and perform the corresponding match. The following parameters + -- are present in all forms of the Match call. + + -- Expression contains the regular expression to be matched as a string + + -- Data contains the string to be matched + + -- Data_First is the lower bound for the match, i.e. Data (Data_First) + -- will be the first character to be examined. If Data_First is set to + -- the special value of -1 (the default), then the first character to + -- be examined is Data (Data_First). However, the regular expression + -- character ^ (start of string) still refers to the first character + -- of the full string (Data (Data'First)), which is why there is a + -- separate mechanism for specifying Data_First. + + -- Data_Last is the upper bound for the match, i.e. Data (Data_Last) + -- will be the last character to be examined. If Data_Last is set to + -- the special value of Positive'Last (the default), then the last + -- character to be examined is Data (Data_Last). However, the regular + -- expression character $ (end of string) still refers to the last + -- character of the full string (Data (Data'Last)), which is why there + -- is a separate mechanism for specifying Data_Last. + + -- Note: the use of Data_First and Data_Last is not equivalent to + -- simply passing a slice as Expression because of the handling of + -- regular expression characters ^ and $. + + -- Size is the size allocated for the compiled byte code. Normally + -- this is defaulted to Auto_Size which means that the appropriate + -- size is allocated automatically. It is possible to specify an + -- explicit size, which must be sufficiently large. This slightly + -- increases the efficiency by avoiding the extra step of computing + -- the appropriate size. + + -- The following exceptions can be raised in calls to Match -- - -- Function raises Storage_Error if Size is too small for Expression, - -- or Expression_Error if Expression is not a legal regular expression. - -- If Size is 0, then the appropriate size is automatically calculated - -- by this package, but this is slightly slower. + -- Storage_Error is raised if a non-zero value is given for Size + -- and it is too small to hold the compiled byte code. -- + -- Expression_Error is raised if the given expression is not a legal + -- regular expression. + + + procedure Match + (Expression : String; + Data : String; + Matches : out Match_Array; + Size : Program_Size := Auto_Size; + Data_First : Integer := -1; + Data_Last : Positive := Positive'Last); + -- This version returns the result of the match stored in Match_Array. -- At most Matches'Length parenthesis are returned. - function Match + function Match (Expression : String; Data : String; - Size : Program_Size := 0; - Data_First : Integer := -1; - Data_Last : Positive := Positive'Last) return Natural; - -- Return the position where Data matches, or (Data'First - 1) if - -- there is no match. - -- - -- Function raises Storage_Error if Size is too small for Expression - -- or Expression_Error if Expression is not a legal regular expression - -- - -- If Size is 0, then the appropriate size is automatically calculated - -- by this package, but this is slightly slower. - -- See description of Data_First and Data_Last above. + Size : Program_Size := Auto_Size; + Data_First : Integer := -1; + Data_Last : Positive := Positive'Last) return Natural; + -- This version returns the position where Data matches, or if there is + -- no match, then the value Data'First - 1. function Match (Expression : String; Data : String; - Size : Program_Size := 0; - Data_First : Integer := -1; - Data_Last : Positive := Positive'Last) return Boolean; - -- Return True if Data matches Expression. Match raises Storage_Error - -- if Size is too small for Expression, or Expression_Error if Expression - -- is not a legal regular expression. - -- - -- If Size is 0, then the appropriate size is automatically calculated - -- by this package, but this is slightly slower. - -- - -- See description of Data_First and Data_Last above. + Size : Program_Size := Auto_Size; + Data_First : Integer := -1; + Data_Last : Positive := Positive'Last) return Boolean; + -- This version returns True if the match succeeds, False otherwise ------------------------------------------------ - -- Matching a pre-compiled regular expression -- + -- Matching a Pre-Compiled Regular Expression -- ------------------------------------------------ -- The following functions are significantly faster if you need to reuse -- the same regular expression multiple times, since you only have to - -- compile it once. + -- compile it once. For these functions you must first compile the + -- expression with a call to Compile as previously described. + + -- The parameters Data, Data_First and Data_Last are as described + -- in the previous section. function Match (Self : Pattern_Matcher; Data : String; Data_First : Integer := -1; Data_Last : Positive := Positive'Last) return Natural; - -- Match Data using the given pattern matcher. - -- Return the position where Data matches, or (Data'First - 1) if there is - -- no match. - -- - -- See description of Data_First and Data_Last above. + -- Match Data using the given pattern matcher. Returns the position + -- where Data matches, or (Data'First - 1) if there is no match. function Match (Self : Pattern_Matcher; @@ -526,8 +578,6 @@ pragma Preelaborate (Regpat); Data_First : Integer := -1; Data_Last : Positive := Positive'Last) return Boolean; -- Return True if Data matches using the given pattern matcher. - -- - -- See description of Data_First and Data_Last above. pragma Inline (Match); -- All except the last one below @@ -542,8 +592,6 @@ pragma Preelaborate (Regpat); -- The expression matches if Matches (0) /= No_Match. -- -- At most Matches'Length parenthesis are returned. - -- - -- See description of Data_First and Data_Last above. ----------- -- Debug -- |