[Top][All Lists]
[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
- [RFC/RFT PATCH 00/11] Differentiate ^/$ from \` and \' in grep -z mode, Paolo Bonzini, 2012/01/04
- [PATCH 01/11] dfa: fix corner case with anchors, Paolo Bonzini, 2012/01/04
- [PATCH 02/11] dfa: introduce contexts for the values in d->success, Paolo Bonzini, 2012/01/04
- [PATCH 04/11] dfa: refactor common context computations, Paolo Bonzini, 2012/01/04
- [PATCH 03/11] dfa: change newline/letter to a single context value, Paolo Bonzini, 2012/01/04
- [PATCH 05/11] dfa: change meaning of a state context, Paolo Bonzini, 2012/01/04
- [PATCH 06/11] dfa: remove useless check, Paolo Bonzini, 2012/01/04
- [PATCH 07/11] dfa: make repetitive code *really* repetitive, Paolo Bonzini, 2012/01/04
- [PATCH 08/11] dfa: remove redundant line constraints, Paolo Bonzini, 2012/01/04
- [PATCH 11/11] dfa: introduce BEGBUF/ENDBUF,
Paolo Bonzini <=
- [PATCH 09/11] dfa: rename "newline" to "buffer delimiter", Paolo Bonzini, 2012/01/04
- [PATCH 10/11] dfa: introduce bufdelim context, Paolo Bonzini, 2012/01/04
- Re: [RFC/RFT PATCH 00/11] Differentiate ^/$ from \` and \' in grep -z mode, Jim Meyering, 2012/01/04