OSDN Git Service

* primary.c (match_logical_constant_string): New function to match
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 19 Aug 2007 01:52:23 +0000 (01:52 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 19 Aug 2007 01:52:23 +0000 (01:52 +0000)
a ".true." or a ".false.".
(match_logical_constant): Use it instead of gfc_match_strings.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127620 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/primary.c

index f7baaa8..0a27333 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-18  Roger Sayle  <roger@eyesopen.com>
+
+       * primary.c (match_logical_constant_string): New function to match
+       a ".true." or a ".false.".
+       (match_logical_constant): Use it instead of gfc_match_strings.
+
 2007-08-18  Paul Thomas  <pault@gcc.gnu.org>
            Janus Weil  <jaydub66@gmail.com>
 
index 199cc59..2be27d7 100644 (file)
@@ -977,21 +977,50 @@ no_match:
 }
 
 
+/* Match a .true. or .false.  Returns 1 if a .true. was found,
+   0 if a .false. was found, and -1 otherwise.  */
+static int
+match_logical_constant_string (void)
+{
+  locus orig_loc = gfc_current_locus;
+
+  gfc_gobble_whitespace ();
+  if (gfc_next_char () == '.')
+    {
+      int ch = gfc_next_char();
+      if (ch == 'f')
+       {
+         if (gfc_next_char () == 'a'
+             && gfc_next_char () == 'l'
+             && gfc_next_char () == 's'
+             && gfc_next_char () == 'e'
+             && gfc_next_char () == '.')
+           /* Matched ".false.".  */
+           return 0;
+       }
+      else if (ch == 't')
+       {
+         if (gfc_next_char () == 'r'
+             && gfc_next_char () == 'u'
+             && gfc_next_char () == 'e'
+             && gfc_next_char () == '.')
+           /* Matched ".true.".  */
+           return 1;
+       }
+    }
+  gfc_current_locus = orig_loc;
+  return -1;
+}
+
 /* Match a .true. or .false.  */
 
 static match
 match_logical_constant (gfc_expr **result)
 {
-  static mstring logical_ops[] = {
-    minit (".false.", 0),
-    minit (".true.", 1),
-    minit (NULL, -1)
-  };
-
   gfc_expr *e;
   int i, kind;
 
-  i = gfc_match_strings (logical_ops);
+  i = match_logical_constant_string ();
   if (i == -1)
     return MATCH_NO;