bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] dfa: drop ORTOP


From: Paolo Bonzini
Subject: [PATCH] dfa: drop ORTOP
Date: Sat, 17 Apr 2010 04:05:46 +0200

* src/dfa.c (token, prtok, addtok_mb, nsubtoks, dfaanalyze, dfamust):
Remove ORTOP.
(regexp): Remove parameter, always add OR at the end, adjust callers.
(atom): Adjust caller.
(dfaparse): Adjust caller.  Always add OR at the end.
---
 src/dfa.c |   23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 0ff2ee3..6306f30 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -207,9 +207,6 @@ typedef enum
   OR,                          /* OR is an operator of two arguments that
                                    matches either of its arguments. */
 
-  ORTOP,                       /* OR at the toplevel in the parse tree.
-                                   This is used for a boyer-moore heuristic. */
-
   LPAREN,                      /* LPAREN never appears in the parse tree,
                                    it is only a lexeme. */
 
@@ -402,7 +399,7 @@ struct dfa
                        prevn, currn, prevl, currl)
 
 static void dfamust (struct dfa *dfa);
-static void regexp (int toplevel);
+static void regexp (void);
 
 #define CALLOC(p, t, n) ((p) = xcalloc((size_t)(n), sizeof (t)))
 #define MALLOC(p, t, n) ((p) = xmalloc((n) * sizeof (t)))
@@ -447,7 +444,6 @@ prtok (token t)
         case PLUS: s = "PLUS"; break;
         case CAT: s = "CAT"; break;
         case OR: s = "OR"; break;
-        case ORTOP: s = "ORTOP"; break;
         case LPAREN: s = "LPAREN"; break;
         case RPAREN: s = "RPAREN"; break;
 #if MBS_SUPPORT
@@ -1418,7 +1414,6 @@ addtok_mb (token t, int mbprop)
 
     case CAT:
     case OR:
-    case ORTOP:
       --depth;
       break;
 
@@ -1581,7 +1576,7 @@ atom (void)
   else if (tok == LPAREN)
     {
       tok = lex();
-      regexp(0);
+      regexp();
       if (tok != RPAREN)
         dfaerror(_("unbalanced ("));
       tok = lex();
@@ -1606,7 +1601,6 @@ nsubtoks (int tindex)
       return 1 + nsubtoks(tindex - 1);
     case CAT:
     case OR:
-    case ORTOP:
       ntoks1 = nsubtoks(tindex - 1);
       return 1 + ntoks1 + nsubtoks(tindex - 1 - ntoks1);
     }
@@ -1682,17 +1676,14 @@ branch (void)
 }
 
 static void
-regexp (int toplevel)
+regexp (void)
 {
   branch();
   while (tok == OR)
     {
       tok = lex();
       branch();
-      if (toplevel)
-        addtok(ORTOP);
-      else
-        addtok(OR);
+      addtok(OR);
     }
 }
 
@@ -1725,7 +1716,7 @@ dfaparse (char const *s, size_t len, struct dfa *d)
   tok = lex();
   depth = d->depth;
 
-  regexp(1);
+  regexp();
 
   if (tok != END)
     dfaerror(_("unbalanced )"));
@@ -1734,7 +1725,7 @@ dfaparse (char const *s, size_t len, struct dfa *d)
   addtok(CAT);
 
   if (d->nregexps)
-    addtok(ORTOP);
+    addtok(OR);
 
   ++d->nregexps;
 }
@@ -2130,7 +2121,6 @@ dfaanalyze (struct dfa *d, int searchflag)
         break;
 
       case OR:
-      case ORTOP:
         /* The firstpos is the union of the firstpos of each argument. */
         nfirstpos[-2] += nfirstpos[-1];
         --nfirstpos;
@@ -3765,7 +3755,6 @@ dfamust (struct dfa *d)
           resetmust(mp);
           break;
         case OR:
-        case ORTOP:
           assert (&musts[2] <= mp);
           {
             char **new;
-- 
1.6.6.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]