[PATCH] Restructure intrinsic operator parsing
Roger Sayle
roger@eyesopen.com
Thu Aug 23 09:51:00 GMT 2007
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
--
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070823/f07ed101/attachment.txt>
More information about the Fortran
mailing list