]> gcc.gnu.org Git - gcc.git/commitdiff
primary.c (match_logical_constant_string): New function to match a ".true." or a...
authorRoger Sayle <roger@eyesopen.com>
Sun, 19 Aug 2007 01:52:23 +0000 (01:52 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sun, 19 Aug 2007 01:52:23 +0000 (01:52 +0000)
* 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.

From-SVN: r127620

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

index f7baaa80aba639dd9549a80f525db91b42c74a42..0a27333bdf9d897f70a6cec42b76559d995a981c 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 199cc598734f605f21d712c56b5bf23c45864df4..2be27d7df4106045d23e1009a88f8f3d34cf62d1 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;
 
This page took 0.072884 seconds and 5 git commands to generate.