]> granicus.if.org Git - re2c/commitdiff
Added [-Wempty-character-class] description.
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 11 Nov 2015 11:46:52 +0000 (11:46 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 11 Nov 2015 11:46:52 +0000 (11:46 +0000)
src/manual/warnings/empty_character_class/wempty_character_class.rst [new file with mode: 0644]
src/manual/warnings/warnings.rst
src/manual/warnings/wempty_character_class.rst [deleted file]

diff --git a/src/manual/warnings/empty_character_class/wempty_character_class.rst b/src/manual/warnings/empty_character_class/wempty_character_class.rst
new file mode 100644 (file)
index 0000000..465b358
--- /dev/null
@@ -0,0 +1,56 @@
+[-Wempty-character-class]
+--------------------------
+
+.. include:: ../home.rst
+
+This warning is complementary to ``--empty-class`` option.
+The option expects a single argument, one of the following:
+
+* ``match-empty`` (default): empty character class matches empty string
+  (that is, always matches and consumes no code units).
+  This attitude is strange; however, some real-world programs rely on it.
+
+* ``match-none``: empty character class never matches.
+  This is what logic suggests.
+
+* ``error``: empty character class is an error.
+
+The ``[-Wempty-character-class]`` warning is a reminder for those
+who are not aware of ``--empty-class`` option.
+
+Note that empty character class can be constructed in many ways:
+
+.. code-block:: cpp
+    :number-lines:
+
+    /*!re2c
+        []                        { return 0; }
+        [^\x00-\xFF]              { return 1; }
+        [^] \ [^]                 { return 2; }
+        [abc] \ ("a" | "b" | "c") { return 3; }
+        "a" \ [a-z]               { return 4; }
+    */
+
+Given this code, ```re2c -i -Wempty-character-class``` generates:
+
+.. code-block:: cpp
+    :number-lines:
+
+    /* Generated by re2c 0.14.1.dev on Wed Nov 11 11:42:00 2015*/
+    
+    {
+            YYCTYPE yych;
+            { return 0; }
+    }
+
+And warns:
+
+.. code-block::
+
+    re2c: warning: line 2: empty character class [-Wempty-character-class]
+    re2c: warning: line 3: empty character class [-Wempty-character-class]
+    re2c: warning: line 4: empty character class [-Wempty-character-class]
+    re2c: warning: line 5: empty character class [-Wempty-character-class]
+    re2c: warning: line 6: empty character class [-Wempty-character-class]
+
+
index 70a21cab2b5a0d1c0878e38d2c17c30c71ad9035..0e77c0f74cde8851824a19886ef0fc6ae0786ab8 100644 (file)
@@ -11,7 +11,7 @@ Warnings
 * `[-Wcondition-order]        <condition_order/wcondition_order.html>`_
 * `[-Wuseless-escape]         <useless_escape/wuseless_escape.html>`_
 * `[-Wswapped-range]          <swapped_range/wswapped_range.html>`_
-* `[-Wempty-character-class]  <wempty_character_class.html>`_
+* `[-Wempty-character-class]  <empty_character_class/wempty_character_class.html>`_
 * `[-Wmatch-empty-string]     <wmatch_empty_string.html>`_
 
 .. include:: warnings_general.rst
diff --git a/src/manual/warnings/wempty_character_class.rst b/src/manual/warnings/wempty_character_class.rst
deleted file mode 100644 (file)
index 69e0889..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-[-Wempty-character-class]
---------------------------
-
-.. include:: home.rst
-