From: Ulya Trofimovich Date: Wed, 11 Nov 2015 11:46:52 +0000 (+0000) Subject: Added [-Wempty-character-class] description. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a70cd26b647f3c45d6a41960e3d6e9998987779d;p=re2c Added [-Wempty-character-class] description. --- 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 index 00000000..465b358b --- /dev/null +++ b/src/manual/warnings/empty_character_class/wempty_character_class.rst @@ -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] + + diff --git a/src/manual/warnings/warnings.rst b/src/manual/warnings/warnings.rst index 70a21cab..0e77c0f7 100644 --- a/src/manual/warnings/warnings.rst +++ b/src/manual/warnings/warnings.rst @@ -11,7 +11,7 @@ Warnings * `[-Wcondition-order] `_ * `[-Wuseless-escape] `_ * `[-Wswapped-range] `_ -* `[-Wempty-character-class] `_ +* `[-Wempty-character-class] `_ * `[-Wmatch-empty-string] `_ .. 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 index 69e08896..00000000 --- a/src/manual/warnings/wempty_character_class.rst +++ /dev/null @@ -1,5 +0,0 @@ -[-Wempty-character-class] --------------------------- - -.. include:: home.rst -