This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Restructure intrinsic operator parsing


Hi Tobias,

On Tue, August 21, 2007 11:51 am, Tobias Schlüter wrote:
> Roger Sayle wrote:
>> 2007-08-21  Roger Sayle  <roger@eyesopen.com>
>>
>>         * match.c (intrinsic_operators): Delete.
>>         (gfc_match_intrinsic_op): Rewrite matcher to avoid calling
>>         gfc_match_strings.
>>
>
> Ok, but I would prefer if you rewrote this to use gfc_peek_char(), as in
> the following example:
>> !     case '>':
>> !       best_loc = gfc_current_locus;
>> !       if (gfc_next_char () == '=')
>> ! 	{
>> ! 	  /* Matched ">=".  */
>> ! 	  *result = INTRINSIC_GE;
>> ! 	  return MATCH_YES;
>> ! 	}
>> !       /* Matched ">".  */
>> !       gfc_current_locus = best_loc;
>> !       *result = INTRINSIC_GT;
>> !       return MATCH_YES;
> rewrite as:
>    case '>':
>       if (gfc_peek_char () == '=')
>         {
>            /* Matched ">=".  */
>            gfc_next_char ();
>            *result = INTRINSIC_GE;
>            return MATCH_YES;
>         }
>       /* Matched ">".  */
>       *result = INTRINSIC_GT;
>       return MATCH_YES;

An excellent suggestion.  Here's what I've committed to subversion as
revision 127727, which by using gfc_peek_char as you suggest, completely
removes the need for "best_loc".  Tested by another bootstrap and "make -k
check" on x86_64-unknown-linux-gnu.  Thanks.

2007-08-22  Roger Sayle  <roger@eyesopen.com>
            Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>

        * match.c (intrinsic_operators): Delete.
        (gfc_match_intrinsic_op): Rewrite matcher to avoid calling
        gfc_match_strings.



> Do you have plans to remove the last caller of gfc_match_strings() as
> well?

For completeness, I'll post a patch for that shortly.  Unlike this
intrinsic_operators patch, I don't have an ulterior motive, but its
a nice clean-up and may improve compile-time performance.

Thanks again.

Roger
--

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]