bug-grep
[Top][All Lists]
Advanced

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

[PATCH 11/11] dfa: introduce BEGBUF/ENDBUF


From: Paolo Bonzini
Subject: [PATCH 11/11] dfa: introduce BEGBUF/ENDBUF
Date: Wed, 4 Jan 2012 11:59:52 +0100

* src/dfa.c (BEGLINE, ENDLINE): Adjust comments.
(BEGBUF, ENDBUF): New.
(prtol): Print them.
(lex): Map \` and \' to them.
(atom, epsclosure, dfamust): Handle BEGBUF and ENDBUF.
---
 src/dfa.c |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index d94b408..f477c82 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -190,12 +190,20 @@ typedef enum
                                    a backtracking matcher. */
 
   BEGLINE,                     /* BEGLINE is a terminal symbol that matches
-                                   the empty string if it is at the beginning
-                                   of a line. */
+                                   the empty string if it is after a newline
+                                   or buffer delimiter. */
 
   ENDLINE,                     /* ENDLINE is a terminal symbol that matches
-                                   the empty string if it is at the end of
-                                   a line. */
+                                   the empty string if it is before a newline
+                                   or buffer delimiter. */
+
+  BEGBUF,                      /* BEGBUF is a terminal symbol that matches
+                                   the empty string if it is after a buffer
+                                   delimiter. */
+
+  ENDBUF,                      /* ENDBUF is a terminal symbol that matches
+                                   the empty string if it is before a buffer
+                                   delimiter. */
 
   BEGWORD,                     /* BEGWORD is a terminal symbol that matches
                                    the empty string if it is at the beginning
@@ -483,6 +491,8 @@ prtok (token t)
         case BACKREF: s = "BACKREF"; break;
         case BEGLINE: s = "BEGLINE"; break;
         case ENDLINE: s = "ENDLINE"; break;
+        case BEGBUF: s = "BEGBUF"; break;
+        case ENDBUF: s = "ENDBUF"; break;
         case BEGWORD: s = "BEGWORD"; break;
         case ENDWORD: s = "ENDWORD"; break;
         case LIMWORD: s = "LIMWORD"; break;
@@ -1244,12 +1254,12 @@ lex (void)
 
         case '`':
           if (backslash && !(syntax_bits & RE_NO_GNU_OPS))
-            return lasttok = BEGLINE;  /* FIXME: should be beginning of string 
*/
+           return lasttok = BEGBUF;
           goto normal_char;
 
         case '\'':
           if (backslash && !(syntax_bits & RE_NO_GNU_OPS))
-            return lasttok = ENDLINE;  /* FIXME: should be end of string */
+           return lasttok = ENDBUF;
           goto normal_char;
 
         case '<':
@@ -1738,11 +1748,13 @@ atom (void)
       tok = lex();
     }
   else if ((tok >= 0 && tok < NOTCHAR) || tok >= CSET || tok == BACKREF
-           || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD
 #if MBS_SUPPORT
            || tok == ANYCHAR || tok == MBCSET
 #endif /* MBS_SUPPORT */
-           || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD)
+           || tok == BEGLINE || tok == ENDLINE
+           || tok == BEGBUF || tok == ENDBUF
+           || tok == BEGWORD || tok == ENDWORD
+           || tok == LIMWORD || tok == NOTLIMWORD)
     {
       addtok(tok);
       tok = lex();
@@ -2097,6 +2109,12 @@ epsclosure (position_set *s, struct dfa const *d)
           case ENDLINE:
             p.constraint &= ENDLINE_CONSTRAINT;
             break;
+          case BEGBUF:
+            p.constraint &= BEGBUF_CONSTRAINT;
+            break;
+          case ENDBUF:
+            p.constraint &= ENDBUF_CONSTRAINT;
+            break;
           case BEGWORD:
             p.constraint &= BEGWORD_CONSTRAINT;
             break;
@@ -3917,6 +3935,8 @@ dfamust (struct dfa *d)
         case EMPTY:
         case BEGLINE:
         case ENDLINE:
+        case BEGBUF:
+        case ENDBUF:
         case BEGWORD:
         case ENDWORD:
         case LIMWORD:
-- 
1.7.7.1




reply via email to

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