@ 260915.5

190509.4 · 979a179c196ac7f5439a523e70cdfbc049d185d5

More patterns added

reading declarations

README.md

@@ -26,9 +26,16 @@ only, `-n` shows line numbers in the output, `-o` for multi-line matches (for example, `mainly` won't be matched), the `-f` options specify two pre-defined patterns to match and ignore strings and comments in the input. -**ugrep** offers options that are compatible with the-[GNU grep](https://www.gnu.org/software/grep/manual/grep.html) and BSD grep-utilities, and can be used as a more powerful replacement of these.+**ugrep** searches source code files by file name extension and other criteria+using option `-t` so specify the type of files to search recursively in a+directory tree with option `-r`, e.g. `-r -t c++`.++**ugrep** includes a growing database of+[patterns](https://github.com/Genivia/ugrep/tree/master/patterns) with common+search patterns to use with option `-f`.  So you don't need to memorize complex+regex patterns for common search criteria.  Environment variable `GREP_PATH`+can be set to point to your own directory with patterns that option `-f` uses+to find files.  **ugrep** matches Unicode patterns.  The regular expression syntax is POSIX ERE compliant, extended with Unicode character classes, lazy quantifiers, and@@ -41,6 +48,10 @@ and ASCII and UTF-8 when no UTF BOM is present.  Option `--file-format` permits many other file formats to be searched, such as ISO-8859-1, EBCDIC, and code pages 437, 850, 858, 1250 to 1258. +**ugrep** offers options that are compatible with the+[GNU grep](https://www.gnu.org/software/grep/manual/grep.html) and BSD grep+utilities, and can be used as a more powerful replacement of these.+ **ugrep** regex patterns are converted to [DFAs](https://en.wikipedia.org/wiki/Deterministic_finite_automaton) for fast matching.  Rare and pathelogical cases are known to exist that may increase the

patterns/README.md

@@ -2,6 +2,10 @@ This directory contains a collection of patterns that are helpful to search source code files.  Use ugrep option `-f` to specify one or more pattern files for searching. +Many patterns require option `-o` to match the pattern across multiple lines.+Otherwise you may miss out on finding matches.  For example, strings and+comments may span multiple lines, such as Python docstrings.+ For example, to display C/C++ comments and strings in a file      ugrep -o -f patterns/c/comments -f patterns/c/strings file.cpp

patterns/c/directives

new file mode 100644@@ -0,0 +1 @@+^\h*#\h*\w+(.|\\\n)*

patterns/c/function_defs

@@ -1 +1 @@-^(\h*[[:word:]:*&]+)+\h+[[:word:]]+\h*\([^;\n]+$+^(\h*[\w:*&]+)+\h+\w+\h*\([^)\n]+\)\h*$

patterns/c/names

new file mode 100644@@ -0,0 +1 @@+\p{UnicodeIdentifierStart}\p{UnicodeIdentifierPart}*

patterns/c/zap_directives

@@ -1 +1 @@-(?^^\h*#\h*[[:word:]]+.*)+(?^^\h*#\h*\w+(.|\\\n)*)

patterns/java/names

new file mode 100644@@ -0,0 +1 @@+\p{JavaIdentifierStart}\p{JavaIdentifierPart}*

patterns/python/comments

new file mode 100644@@ -0,0 +1 @@+#.*

patterns/python/defs

new file mode 100644@@ -0,0 +1 @@+\<def\h+\p{PythonIdentifierStart}\p{PythonIdentifierPart}*

patterns/python/imports

new file mode 100644@@ -0,0 +1,3 @@+\<import\h+.*+\<from\h+.*import\h+.*+

patterns/python/names

new file mode 100644@@ -0,0 +1 @@+\p{PythonIdentifierStart}\p{PythonIdentifierPart}*

patterns/python/strings

new file mode 100644@@ -0,0 +1,4 @@+'([^\\\n']|\\.)*'+"([^\\\n"]|\\.)*"+'''('{0,2}[^\\']|\\.)*'''+"""("{0,2}[^\\"]|\\.)*"""

patterns/python/zap_comments

new file mode 100644@@ -0,0 +1 @@+(?^#.*)

patterns/python/zap_strings

new file mode 100644@@ -0,0 +1,4 @@+(?^'([^\\\n']|\\.)*')+(?^"([^\\\n"]|\\.)*")+(?^'''('{0,2}[^\\']|\\.)*''')+(?^"""("{0,2}[^\\"]|\\.)*""")

patterns/ruby/classes

new file mode 100644@@ -0,0 +1 @@+\<class\h+.*

patterns/ruby/comments

new file mode 100644@@ -0,0 +1,2 @@+#.*+^=begin(.|\n[^=]|\n=e[^n]|\n=en[^d])*\n=end

patterns/ruby/defs

new file mode 100644@@ -0,0 +1 @@+\<def\h+.*

patterns/ruby/modules

new file mode 100644@@ -0,0 +1 @@+\<module\h+.*

patterns/ruby/names

new file mode 100644@@ -0,0 +1 @@+\p{UnicodeIdentifierStart}\p{UnicodeIdentifierPart}*

patterns/ruby/strings

new file mode 100644@@ -0,0 +1,6 @@+'([^'\\]*|\\(.|\n))*'+"([^"\\]*|\\(.|\n))*"+%q/[^/]*/+%Q/[^/]*/+%q([^)]*)+%Q([^)]*)

patterns/ruby/zap_comments

new file mode 100644@@ -0,0 +1,2 @@+(?^#.*)+(?^^=begin(.|\n[^=]|\n=e[^n]|\n=en[^d])*\n=end)