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]

[PATCH] Rewrite match_attr_spec, eliminate gfc_match_strings



My first attempts at posting this (with a new mail client) didn't make it through, so I'm trying again...


The following patch restructures the gfortran front-end's match_attr_spec parser to use effiicient in-line pattern matching rather than call the large hammer gfc_match_strings. This being the last remaining caller of gfc_match_strings, allows it to be deleted.

The implementation follows the same idiom as used to replace the two previous callers of gfc_match_strings. One minor difference/implementation choice is the decision to perform the matching in the body of decl.c's match_attr_spec. This both avoids exposing the function local "enum decl_types" outside this function, and allows better integration with the new "BIND(C)" parsing code which was previously a separate processing step performed when the initial table-based declaration parsing failed. Another minor benefit is that we can now avoid the enumerated value DECL_COLON (returned by matching "::") which was used as a terminator value purely to indicate that we should break out of the loop. The new inline code is now able to "break;" directly and so we no longer need this sentinel. Finally, the one small remaining inefficiency/backtracking is in the code to parse the attribute list following "intent", either "(in)", "(out)" or "(inout)". The current patch simply uses gfc_match, duplicating identical code in match_intent_spec. I'll propose a follow-up patch to improve match_intent_spec, and re-use it from here in match_attr_spec, but that change is independent, and may potentially affect the diagnostics we choose to generate for "intent (foo)". I've marked the relevant spot with a "TODO" comment.

The following patch has been tested on x86_64-unknown-linux-gnu with a full "make bootstrap", including gfortran, and regression tested with a top-level "make -k check" with no new failures. Ok for mainline?


2007-08-30 Roger Sayle <roger@eyesopen.com>


* decl.c (match_string_p): New helper function to explicitly match
a string of characters.
(match_attr_spec): Remove no longer needed DECL_COLON from decl_types.
Delete decls array and peek_char. Rewrite decl attribute parser to
avoid calling gfc_match_strings.
* match.c (gfc_match_strings): Delete unused function.
* match.h (gfc_match_strings): Delete prototype.



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]