]> granicus.if.org Git - flex/commitdiff
Implemented dot-all syntax.
authorJohn Millaway <john43@users.sourceforge.net>
Mon, 27 Mar 2006 22:04:15 +0000 (22:04 +0000)
committerJohn Millaway <john43@users.sourceforge.net>
Mon, 27 Mar 2006 22:04:15 +0000 (22:04 +0000)
Added test for dot-all syntax in test suite.

parse.y
tests/test-ccl/scanner.l
tests/test-ccl/test.input

diff --git a/parse.y b/parse.y
index cecda23c77731934c9fc5e640101417539c0fbc5..e66deb85b1cd63635d0cc318f9dc25cf03609a08 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -105,13 +105,14 @@ char *alloca ();
 /* Bletch, ^^^^ that was ugly! */
 
 
-int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, rulelen;
+int pat, scnum, eps, headcnt, trailcnt, lastchar, i, rulelen;
 int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule;
 
 int *scon_stk;
 int scon_stk_ptr;
 
 static int madeany = false;  /* whether we've made the '.' character class */
+static int ccldot, cclany;
 int previous_continued_action; /* whether the previous rule's action was '|' */
 
 #define format_warn3(fmt, a1, a2) \
@@ -728,21 +729,33 @@ singleton :  singleton '*'
                        if ( ! madeany )
                                {
                                /* Create the '.' character class. */
-                               anyccl = cclinit();
-                               ccladd( anyccl, '\n' );
-                               cclnegate( anyccl );
+                    ccldot = cclinit();
+                    ccladd( ccldot, '\n' );
+                    cclnegate( ccldot );
 
-                               if ( useecs )
-                                       mkeccl( ccltbl + cclmap[anyccl],
-                                               ccllen[anyccl], nextecm,
-                                               ecgroup, csize, csize );
+                    if ( useecs )
+                        mkeccl( ccltbl + cclmap[ccldot],
+                            ccllen[ccldot], nextecm,
+                            ecgroup, csize, csize );
+
+                               /* Create the (?s:'.') character class. */
+                    cclany = cclinit();
+                    cclnegate( cclany );
+
+                    if ( useecs )
+                        mkeccl( ccltbl + cclmap[cclany],
+                            ccllen[cclany], nextecm,
+                            ecgroup, csize, csize );
 
                                madeany = true;
                                }
 
                        ++rulelen;
 
-                       $$ = mkstate( -anyccl );
+            if (sf_dot_all())
+                $$ = mkstate( -cclany );
+            else
+                $$ = mkstate( -ccldot );
                        }
 
                |  fullccl
index 1cc79171fc01263b66ab696071562b1994a33359..204ac390f89db43a1a29df53bbe506077923aca5 100644 (file)
@@ -29,6 +29,7 @@
 /*#include "parser.h" */
 
 #define err_abort() do{printf("ERROR: flex line %d. input line %d.\n", __LINE__, yylineno); abort();} while(0)
+#define a_ok()      do{printf("OK: flex line %d. input line %d.\n", __LINE__, yylineno); return 1;}while(0)
 %}
 
 %option 8bit outfile="scanner.c" prefix="test"
 ^"check-a:"(?i:(?-i:A))@\n               err_abort();
 ^"check-a:"(?i:(?-i:(?i:A)))@\n          printf("OK: %s", yytext); ++yylineno; return 1;
 
+    /* We don't want this one to match. */
+^"dot-all-1:"(?-s:XXX.*)@dot-all-1@\n    err_abort(); 
+^"dot-all-1:"(?s:XXX.*)@dot-all-1@\n    a_ok();
+
 .|\n                       { err_abort(); }
 %%
 
index af3b8401ee6b66621dd1c0b0efd6e68c4c15115c..e8b82a8c75dea8180c7b6c2f249516f22378665b 100644 (file)
@@ -17,3 +17,7 @@ ia:AaAa@ia@
 iabc:ABCabcAbCaBc@iabc@
 ia-c:ABCabcAbCaBc@ia-c@
 check-a:a@
+dot-all-1:XXX junk
+              junk
+              junk
+            @dot-all-1@