My working unpac space for OCaml projects in development
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge opam/patches/re

+13864
+6
vendor/opam/re/.github/dependabot.yml
··· 1 + version: 2 2 + updates: 3 + - package-ecosystem: github-actions 4 + directory: / 5 + schedule: 6 + interval: weekly
+54
vendor/opam/re/.github/workflows/gh-pages.yml
··· 1 + name: Deploy odoc to GitHub Pages 2 + 3 + on: 4 + push: 5 + branches: 6 + - master 7 + 8 + permissions: read-all 9 + 10 + concurrency: 11 + group: deploy-odoc 12 + cancel-in-progress: true 13 + 14 + jobs: 15 + deploy-odoc: 16 + name: Deploy odoc to GitHub Pages 17 + 18 + environment: 19 + name: github-pages 20 + url: ${{ steps.deployment.outputs.page_url }} 21 + 22 + permissions: 23 + contents: read 24 + id-token: write 25 + pages: write 26 + 27 + runs-on: ubuntu-latest 28 + 29 + steps: 30 + - name: Checkout tree 31 + uses: actions/checkout@v6 32 + 33 + - name: Set-up OCaml 34 + uses: ocaml/setup-ocaml@v3 35 + with: 36 + ocaml-compiler: "5.2" 37 + 38 + - name: Install dependencies 39 + run: opam install . --deps-only --with-doc 40 + 41 + - name: Build documentation 42 + run: opam exec -- dune build @doc 43 + 44 + - name: Set-up Pages 45 + uses: actions/configure-pages@v5 46 + 47 + - name: Upload artifact 48 + uses: actions/upload-pages-artifact@v4 49 + with: 50 + path: _build/default/_doc/_html 51 + 52 + - name: Deploy odoc to GitHub Pages 53 + id: deployment 54 + uses: actions/deploy-pages@v4
+32
vendor/opam/re/.github/workflows/main.yml
··· 1 + name: build 2 + on: 3 + - push 4 + - pull_request 5 + jobs: 6 + run: 7 + name: Build 8 + strategy: 9 + matrix: 10 + os: 11 + - macos-latest 12 + - ubuntu-latest 13 + # - windows-latest 14 + ocaml-compiler: 15 + - "4.14" 16 + - "5.2" 17 + include: 18 + - os: ubuntu-24.04-arm 19 + ocaml-compiler: "ocaml-variants.5.2.1+options,ocaml-option-tsan" 20 + runs-on: ${{ matrix.os }} 21 + steps: 22 + - uses: actions/checkout@v6 23 + - run: | 24 + sudo apt update 25 + sudo apt install libunwind-dev 26 + if: ${{ matrix.os == 'ubuntu-24.04-arm' }} 27 + - uses: ocaml/setup-ocaml@v3 28 + with: 29 + ocaml-compiler: ${{ matrix.ocaml-compiler }} 30 + - run: opam install . --deps-only --with-test 31 + - run: opam exec -- dune build 32 + - run: opam exec -- dune runtest
+16
vendor/opam/re/.github/workflows/nix.yml
··· 1 + name: Nix 2 + on: 3 + - push 4 + - pull_request 5 + 6 + jobs: 7 + tests: 8 + runs-on: ubuntu-latest 9 + steps: 10 + - uses: actions/checkout@v6 11 + with: 12 + submodules: true 13 + - uses: cachix/install-nix-action@v31 14 + with: 15 + nix_path: nixpkgs=channel:nixos-unstable 16 + - run: nix develop .#test -c dune runtest
+16
vendor/opam/re/.gitignore
··· 1 + .*.swp 2 + _build/ 3 + *.bak 4 + setup.data 5 + setup.log 6 + setup.exe 7 + *.native 8 + *.byte 9 + *.docdir 10 + .merlin 11 + *.install 12 + perf.data 13 + *.old 14 + *.ctf 15 + *.bench.sexp 16 + *.trace
+3
vendor/opam/re/.ocamlformat
··· 1 + version=0.26.2 2 + profile=janestreet 3 + ocaml-version=4.08.0
+15
vendor/opam/re/.travis.yml
··· 1 + language: c 2 + sudo: required 3 + install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh 4 + script: bash -ex .travis-opam.sh 5 + env: 6 + global: 7 + - PACKAGE=re 8 + matrix: 9 + - OCAML_VERSION=4.03 10 + - OCAML_VERSION=4.04 11 + - OCAML_VERSION=4.05 12 + - OCAML_VERSION=4.06 13 + os: 14 + - linux 15 + - osx
+231
vendor/opam/re/CHANGES.md
··· 1 + 1.14.0 (16-Sep-2025) 2 + -------------------- 3 + 4 + * Thread-safety with OCaml 5 (#574). 5 + 6 + * Introduce [Re.Pcre.get_named_substring_opt]. A non raising version of 7 + [Re.Pcre.get_named_substring] (#525) 8 + 9 + * Introduce parsing functions in `Re.{Perl,Pcre,Emacs,Glob}` that return a 10 + result instead of raising. (#542) 11 + 12 + * Introduce experimental streaming API `Re.Stream`. (#456) 13 + 14 + * Make [Re.Str] functions tail recursive (#539) 15 + 16 + * Fix [Re.Pcre.split]. Regression introduced in 1.12 and a previous bug with 17 + [Re.Pcre.split] (#538). 18 + 19 + * Avoid parsing unnecessary patterns supported only by `Re.Emacs` in `Re.Str` 20 + (#563) 21 + 22 + 1.13.1 (30-Sep-2024) 23 + -------------------- 24 + 25 + * Fix re on jsoo (#150) 26 + 27 + 1.13.0 (30-Sep-2024) 28 + -------------------- 29 + 30 + * Add non raising versions of all [Re.Group] functions (#414, fixes #150) 31 + 32 + * Add support for hex and octal of the form: `\o{...}` and `\x{...}` (#403) 33 + 34 + * Add support for octal characters using `\0dd` and `\ddd` (#402) 35 + 36 + * Add support for `\Q...\E` quoted expressions in Pcre and Perl syntax (#401) 37 + 38 + * Re.execp and related function raise [Invalid_argument "$function"] when [pos] 39 + or [len] arguments are out of bounds. In 1.12.0, a regerssion was introduced 40 + that raised [Invalid_argument _] from [String.get]. 41 + 42 + 1.12.0 (29-Aug-2024) 43 + -------------------- 44 + 45 + * Add `Re.split_delim` (#233) 46 + * Fix handling of empty matches in splitting and substitution functions (#233) 47 + * Add support for character classes in `Re.Posix` (#263) 48 + 49 + 1.11.0 (19-Aug-2023) 50 + -------------------- 51 + 52 + * Add `Re.group_count` to get the number of groups in a compiled regex (#218) 53 + * Add `Re.exec_partial_detailed` to allow resuming searches from partial inputs 54 + (#219) 55 + * Re-export `Re.Perl`'s `Parse_error` and `Not_supported` exceptions 56 + in Pcre (#222) 57 + * Add support for `DOTALL` flag in `Re.Pcre.regexp` (#225) 58 + * Add support for named groups (#223) 59 + * Add support for some control characters in `Re.Perl` (#227) 60 + 61 + 1.10.4 (27-Apr-2022) 62 + -------------------- 63 + 64 + * Improve handling of word boundaries (#179) 65 + 66 + 1.10.3 (13-Sep-2021) 67 + -------------------- 68 + 69 + * Glob: change optional argument `?backslash_escapes` to `?match_backslashes`. 70 + The interpretation of backslashes in the glob pattern remains unchanged with 71 + the new option, but forward slashes match backslashes when activated (#199) 72 + 73 + 1.10.2 (09-Sep-2021) 74 + -------------------- 75 + 76 + * Fix missing aliases introduced in 1.10.1 77 + 78 + 1.10.1 (08-Sep-2021) 79 + -------------------- 80 + 81 + * Glob: add optional argument `?backslash_escapes` to control interpretation of 82 + backslashes (useful under Windows) (#197, #198) 83 + 84 + * Restore accidentally deleted `*_seq` deprecated aliases. 85 + 86 + 1.10.0 (25-Aug-2021) 87 + -------------------- 88 + 89 + * Add the `[:alpha:]` character class in `Re.Perl` (#169) 90 + * Double asterisk (`**`) in `Re.Glob` (#172) 91 + Like `*` but also match `/` characters when `pathname` is set. 92 + * Double asterisk should match 0 or more directories unless in trailing 93 + position. (#192, fixes #185) 94 + 95 + 1.9.0 (05-Apr-2019) 96 + ------------------- 97 + 98 + * Fix regression in `Re.exec_partial` (#164) 99 + * Mov gen related functions to `Re.Gen` and deprecate the old names (#167) 100 + * Introduce `Re.View` that exposes the internal representation (#163) 101 + 102 + 1.8.0 (04-Aug-2018) 103 + ------------------- 104 + 105 + * Fix index-out-of-bounds exception in Re.Perl.re (#160) 106 + * Add seq based iterators (#170) 107 + 108 + 1.7.3 (05-Mar-2018) 109 + ------------------- 110 + 111 + * Remove dependency on bytes package (#155) 112 + 113 + 1.7.2 (01-Mar-2018) 114 + ------------------- 115 + 116 + * Deprecate all Re_* modules. Re_x is now available as Re.X 117 + * Deprecate all re.x sub libraries. Those are all available as Re.X 118 + * Make all function in Re.Str tail recursive. 119 + 120 + 1.7.1 (19-Oct-2016) 121 + ------------------- 122 + 123 + * Fix Re_str.global_replace (#132) 124 + 125 + 1.7.0 (18-Sep-2016) 126 + ------------------- 127 + 128 + * Fix stack overflow in Re_str.full_split 129 + * Use correct exceptions in Re_str group functions 130 + * Add experimental Re.witness 131 + * Add experimental Re.Group.nb_groups 132 + 133 + 1.6.1 (20-Jun-2016) 134 + ------------------- 135 + 136 + * Fix Re.pp (#101) 137 + * Add Re.Group.pp (#102) 138 + 139 + 1.6.0 (30-May-2016) 140 + ------------------- 141 + 142 + * Add Re.pp and Re.pp_re (#55) 143 + * Fix ocamldoc syntax (#87) 144 + 145 + 1.5.0 (04-Jan-2016) 146 + ------------------- 147 + 148 + * Add Re.exec_opt. Like exec but doesn't raise 149 + * Add Group module. Old group accessors are deprecated. 150 + * Add Mark module 151 + * Improve docs of Re.repn 152 + * Improve docs of Re_pcre 153 + * Fix doc of Re_pcre.match 154 + * Consolidate variants of Re.glob that takes options to modify its behavior 155 + (?period, ?expand_braces). Old variants are deprecated. 156 + * New option ?pathname added for Re_glob.glob. Controls how the `/` character 157 + is matched 158 + 159 + 1.4.1 (06-Jun-2015) 160 + ------------------- 161 + 162 + * Fix 4.00.1 compatibilty with tests. 163 + 164 + 1.4.0 (12-May-2015) 165 + ------------------- 166 + 167 + * Add Re.{mark,marked,mark_set}. Regexps can now be "marked" to query post 168 + execution if they matched. 169 + 170 + 1.3.2 (14-Apr-2015) 171 + ------------------- 172 + 173 + * Fix replacing 0 length matches (#55) 174 + 175 + 1.3.1 (13-Mar-2015) 176 + ------------------- 177 + 178 + * Rename {Cset, Automata} to {Re_cset, Re_automata} 179 + 180 + 1.3.0 (02-Feb-2015) 181 + ------------------- 182 + 183 + * Add Re.split{,_gen,_token,_full,_full_gen} 184 + * Add Re.replace{,_string} 185 + * Add Re.all{,_gen} 186 + * Add posix classes of the form [:xxx:] 187 + * Add complement suport for posix classes 188 + * Add Multiline and anchored flag to Re_pcre 189 + * Add Re_pcre.full_split 190 + 191 + 1.2.2 (05-May-2014) 192 + ------------------- 193 + 194 + * Add a Re.whole_string convenience function to only match whole strings 195 + * Add a ?anchored parameter to functions in Re_glob to specify whole 196 + string matching 197 + * Document Re_glob module 198 + * Fix compilation of submatches occurring inside a Kleen star 199 + * Fix word boundary matching 200 + * Fix definition of Re.xdigit 201 + * Fix Re.exec_partial function 202 + * Fix compilation of patterns of the shape r1r2|r1r3 203 + * Fixed compilation of re.cmxs (Vincent Bernardoff) 204 + * Improved matching of anchored regular expressions: stop as soon as 205 + we know there cannot possibly be any match. 206 + * Updated to OASIS 0.4.x (Vincent Bernardoff) 207 + * Add the linking exception to the license 208 + 209 + 1.2.1 (07-Apr-2013) 210 + ------------------- 211 + 212 + * Correct OASIS metadata (Christophe Troestler). 213 + * Fix typo in Invalid_arg error message (Jeremy Yallop). 214 + 215 + 1.2.0 (15-Jan-2012) 216 + ------------------- 217 + 218 + * Rename Pcre module to `Re_pcre` to make it more suitable for 219 + upstream packaging (it currently conflicts with the `Pcre` package). 220 + (Mehdi Dogguy). 221 + 222 + 1.1.0 (05-Sep-2012) 223 + ------------------- 224 + 225 + * Add a basic Pcre wrapper around Re_perl for porting applications using that 226 + API (Thomas Gazagnaire). 227 + 228 + 1.0.0 (01-Aug-2012) 229 + ------------------- 230 + 231 + * Initial public release.
+523
vendor/opam/re/LICENSE.md
··· 1 + This Software is distributed under the terms of the GNU Lesser 2 + General Public License version 2.1 (included below), or (at your 3 + option) any later version. 4 + 5 + As a special exception to the GNU Library General Public License, you 6 + may link, statically or dynamically, a "work that uses the Library" 7 + with a publicly distributed version of the Library to produce an 8 + executable file containing portions of the Library, and distribute 9 + that executable file under terms of your choice, without any of the 10 + additional requirements listed in clause 6 of the GNU Library General 11 + Public License. By "a publicly distributed version of the Library", 12 + we mean either the unmodified Library, or a modified version of the 13 + Library that is distributed under the conditions defined in clause 3 14 + of the GNU Library General Public License. This exception does not 15 + however invalidate any other reasons why the executable file might be 16 + covered by the GNU Library General Public License. 17 + 18 + ---------------------------------------------------------------------- 19 + 20 + GNU LESSER GENERAL PUBLIC LICENSE 21 + Version 2.1, February 1999 22 + 23 + Copyright (C) 1991, 1999 Free Software Foundation, Inc. 24 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 + Everyone is permitted to copy and distribute verbatim copies 26 + of this license document, but changing it is not allowed. 27 + 28 + [This is the first released version of the Lesser GPL. It also counts 29 + as the successor of the GNU Library Public License, version 2, hence 30 + the version number 2.1.] 31 + 32 + Preamble 33 + 34 + The licenses for most software are designed to take away your 35 + freedom to share and change it. By contrast, the GNU General Public 36 + Licenses are intended to guarantee your freedom to share and change 37 + free software--to make sure the software is free for all its users. 38 + 39 + This license, the Lesser General Public License, applies to some 40 + specially designated software packages--typically libraries--of the 41 + Free Software Foundation and other authors who decide to use it. You 42 + can use it too, but we suggest you first think carefully about whether 43 + this license or the ordinary General Public License is the better 44 + strategy to use in any particular case, based on the explanations below. 45 + 46 + When we speak of free software, we are referring to freedom of use, 47 + not price. Our General Public Licenses are designed to make sure that 48 + you have the freedom to distribute copies of free software (and charge 49 + for this service if you wish); that you receive source code or can get 50 + it if you want it; that you can change the software and use pieces of 51 + it in new free programs; and that you are informed that you can do 52 + these things. 53 + 54 + To protect your rights, we need to make restrictions that forbid 55 + distributors to deny you these rights or to ask you to surrender these 56 + rights. These restrictions translate to certain responsibilities for 57 + you if you distribute copies of the library or if you modify it. 58 + 59 + For example, if you distribute copies of the library, whether gratis 60 + or for a fee, you must give the recipients all the rights that we gave 61 + you. You must make sure that they, too, receive or can get the source 62 + code. If you link other code with the library, you must provide 63 + complete object files to the recipients, so that they can relink them 64 + with the library after making changes to the library and recompiling 65 + it. And you must show them these terms so they know their rights. 66 + 67 + We protect your rights with a two-step method: (1) we copyright the 68 + library, and (2) we offer you this license, which gives you legal 69 + permission to copy, distribute and/or modify the library. 70 + 71 + To protect each distributor, we want to make it very clear that 72 + there is no warranty for the free library. Also, if the library is 73 + modified by someone else and passed on, the recipients should know 74 + that what they have is not the original version, so that the original 75 + author's reputation will not be affected by problems that might be 76 + introduced by others. 77 + 78 + Finally, software patents pose a constant threat to the existence of 79 + any free program. We wish to make sure that a company cannot 80 + effectively restrict the users of a free program by obtaining a 81 + restrictive license from a patent holder. Therefore, we insist that 82 + any patent license obtained for a version of the library must be 83 + consistent with the full freedom of use specified in this license. 84 + 85 + Most GNU software, including some libraries, is covered by the 86 + ordinary GNU General Public License. This license, the GNU Lesser 87 + General Public License, applies to certain designated libraries, and 88 + is quite different from the ordinary General Public License. We use 89 + this license for certain libraries in order to permit linking those 90 + libraries into non-free programs. 91 + 92 + When a program is linked with a library, whether statically or using 93 + a shared library, the combination of the two is legally speaking a 94 + combined work, a derivative of the original library. The ordinary 95 + General Public License therefore permits such linking only if the 96 + entire combination fits its criteria of freedom. The Lesser General 97 + Public License permits more lax criteria for linking other code with 98 + the library. 99 + 100 + We call this license the "Lesser" General Public License because it 101 + does Less to protect the user's freedom than the ordinary General 102 + Public License. It also provides other free software developers Less 103 + of an advantage over competing non-free programs. These disadvantages 104 + are the reason we use the ordinary General Public License for many 105 + libraries. However, the Lesser license provides advantages in certain 106 + special circumstances. 107 + 108 + For example, on rare occasions, there may be a special need to 109 + encourage the widest possible use of a certain library, so that it becomes 110 + a de-facto standard. To achieve this, non-free programs must be 111 + allowed to use the library. A more frequent case is that a free 112 + library does the same job as widely used non-free libraries. In this 113 + case, there is little to gain by limiting the free library to free 114 + software only, so we use the Lesser General Public License. 115 + 116 + In other cases, permission to use a particular library in non-free 117 + programs enables a greater number of people to use a large body of 118 + free software. For example, permission to use the GNU C Library in 119 + non-free programs enables many more people to use the whole GNU 120 + operating system, as well as its variant, the GNU/Linux operating 121 + system. 122 + 123 + Although the Lesser General Public License is Less protective of the 124 + users' freedom, it does ensure that the user of a program that is 125 + linked with the Library has the freedom and the wherewithal to run 126 + that program using a modified version of the Library. 127 + 128 + The precise terms and conditions for copying, distribution and 129 + modification follow. Pay close attention to the difference between a 130 + "work based on the library" and a "work that uses the library". The 131 + former contains code derived from the library, whereas the latter must 132 + be combined with the library in order to run. 133 + 134 + GNU LESSER GENERAL PUBLIC LICENSE 135 + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 136 + 137 + 0. This License Agreement applies to any software library or other 138 + program which contains a notice placed by the copyright holder or 139 + other authorized party saying it may be distributed under the terms of 140 + this Lesser General Public License (also called "this License"). 141 + Each licensee is addressed as "you". 142 + 143 + A "library" means a collection of software functions and/or data 144 + prepared so as to be conveniently linked with application programs 145 + (which use some of those functions and data) to form executables. 146 + 147 + The "Library", below, refers to any such software library or work 148 + which has been distributed under these terms. A "work based on the 149 + Library" means either the Library or any derivative work under 150 + copyright law: that is to say, a work containing the Library or a 151 + portion of it, either verbatim or with modifications and/or translated 152 + straightforwardly into another language. (Hereinafter, translation is 153 + included without limitation in the term "modification".) 154 + 155 + "Source code" for a work means the preferred form of the work for 156 + making modifications to it. For a library, complete source code means 157 + all the source code for all modules it contains, plus any associated 158 + interface definition files, plus the scripts used to control compilation 159 + and installation of the library. 160 + 161 + Activities other than copying, distribution and modification are not 162 + covered by this License; they are outside its scope. The act of 163 + running a program using the Library is not restricted, and output from 164 + such a program is covered only if its contents constitute a work based 165 + on the Library (independent of the use of the Library in a tool for 166 + writing it). Whether that is true depends on what the Library does 167 + and what the program that uses the Library does. 168 + 169 + 1. You may copy and distribute verbatim copies of the Library's 170 + complete source code as you receive it, in any medium, provided that 171 + you conspicuously and appropriately publish on each copy an 172 + appropriate copyright notice and disclaimer of warranty; keep intact 173 + all the notices that refer to this License and to the absence of any 174 + warranty; and distribute a copy of this License along with the 175 + Library. 176 + 177 + You may charge a fee for the physical act of transferring a copy, 178 + and you may at your option offer warranty protection in exchange for a 179 + fee. 180 + 181 + 2. You may modify your copy or copies of the Library or any portion 182 + of it, thus forming a work based on the Library, and copy and 183 + distribute such modifications or work under the terms of Section 1 184 + above, provided that you also meet all of these conditions: 185 + 186 + a) The modified work must itself be a software library. 187 + 188 + b) You must cause the files modified to carry prominent notices 189 + stating that you changed the files and the date of any change. 190 + 191 + c) You must cause the whole of the work to be licensed at no 192 + charge to all third parties under the terms of this License. 193 + 194 + d) If a facility in the modified Library refers to a function or a 195 + table of data to be supplied by an application program that uses 196 + the facility, other than as an argument passed when the facility 197 + is invoked, then you must make a good faith effort to ensure that, 198 + in the event an application does not supply such function or 199 + table, the facility still operates, and performs whatever part of 200 + its purpose remains meaningful. 201 + 202 + (For example, a function in a library to compute square roots has 203 + a purpose that is entirely well-defined independent of the 204 + application. Therefore, Subsection 2d requires that any 205 + application-supplied function or table used by this function must 206 + be optional: if the application does not supply it, the square 207 + root function must still compute square roots.) 208 + 209 + These requirements apply to the modified work as a whole. If 210 + identifiable sections of that work are not derived from the Library, 211 + and can be reasonably considered independent and separate works in 212 + themselves, then this License, and its terms, do not apply to those 213 + sections when you distribute them as separate works. But when you 214 + distribute the same sections as part of a whole which is a work based 215 + on the Library, the distribution of the whole must be on the terms of 216 + this License, whose permissions for other licensees extend to the 217 + entire whole, and thus to each and every part regardless of who wrote 218 + it. 219 + 220 + Thus, it is not the intent of this section to claim rights or contest 221 + your rights to work written entirely by you; rather, the intent is to 222 + exercise the right to control the distribution of derivative or 223 + collective works based on the Library. 224 + 225 + In addition, mere aggregation of another work not based on the Library 226 + with the Library (or with a work based on the Library) on a volume of 227 + a storage or distribution medium does not bring the other work under 228 + the scope of this License. 229 + 230 + 3. You may opt to apply the terms of the ordinary GNU General Public 231 + License instead of this License to a given copy of the Library. To do 232 + this, you must alter all the notices that refer to this License, so 233 + that they refer to the ordinary GNU General Public License, version 2, 234 + instead of to this License. (If a newer version than version 2 of the 235 + ordinary GNU General Public License has appeared, then you can specify 236 + that version instead if you wish.) Do not make any other change in 237 + these notices. 238 + 239 + Once this change is made in a given copy, it is irreversible for 240 + that copy, so the ordinary GNU General Public License applies to all 241 + subsequent copies and derivative works made from that copy. 242 + 243 + This option is useful when you wish to copy part of the code of 244 + the Library into a program that is not a library. 245 + 246 + 4. You may copy and distribute the Library (or a portion or 247 + derivative of it, under Section 2) in object code or executable form 248 + under the terms of Sections 1 and 2 above provided that you accompany 249 + it with the complete corresponding machine-readable source code, which 250 + must be distributed under the terms of Sections 1 and 2 above on a 251 + medium customarily used for software interchange. 252 + 253 + If distribution of object code is made by offering access to copy 254 + from a designated place, then offering equivalent access to copy the 255 + source code from the same place satisfies the requirement to 256 + distribute the source code, even though third parties are not 257 + compelled to copy the source along with the object code. 258 + 259 + 5. A program that contains no derivative of any portion of the 260 + Library, but is designed to work with the Library by being compiled or 261 + linked with it, is called a "work that uses the Library". Such a 262 + work, in isolation, is not a derivative work of the Library, and 263 + therefore falls outside the scope of this License. 264 + 265 + However, linking a "work that uses the Library" with the Library 266 + creates an executable that is a derivative of the Library (because it 267 + contains portions of the Library), rather than a "work that uses the 268 + library". The executable is therefore covered by this License. 269 + Section 6 states terms for distribution of such executables. 270 + 271 + When a "work that uses the Library" uses material from a header file 272 + that is part of the Library, the object code for the work may be a 273 + derivative work of the Library even though the source code is not. 274 + Whether this is true is especially significant if the work can be 275 + linked without the Library, or if the work is itself a library. The 276 + threshold for this to be true is not precisely defined by law. 277 + 278 + If such an object file uses only numerical parameters, data 279 + structure layouts and accessors, and small macros and small inline 280 + functions (ten lines or less in length), then the use of the object 281 + file is unrestricted, regardless of whether it is legally a derivative 282 + work. (Executables containing this object code plus portions of the 283 + Library will still fall under Section 6.) 284 + 285 + Otherwise, if the work is a derivative of the Library, you may 286 + distribute the object code for the work under the terms of Section 6. 287 + Any executables containing that work also fall under Section 6, 288 + whether or not they are linked directly with the Library itself. 289 + 290 + 6. As an exception to the Sections above, you may also combine or 291 + link a "work that uses the Library" with the Library to produce a 292 + work containing portions of the Library, and distribute that work 293 + under terms of your choice, provided that the terms permit 294 + modification of the work for the customer's own use and reverse 295 + engineering for debugging such modifications. 296 + 297 + You must give prominent notice with each copy of the work that the 298 + Library is used in it and that the Library and its use are covered by 299 + this License. You must supply a copy of this License. If the work 300 + during execution displays copyright notices, you must include the 301 + copyright notice for the Library among them, as well as a reference 302 + directing the user to the copy of this License. Also, you must do one 303 + of these things: 304 + 305 + a) Accompany the work with the complete corresponding 306 + machine-readable source code for the Library including whatever 307 + changes were used in the work (which must be distributed under 308 + Sections 1 and 2 above); and, if the work is an executable linked 309 + with the Library, with the complete machine-readable "work that 310 + uses the Library", as object code and/or source code, so that the 311 + user can modify the Library and then relink to produce a modified 312 + executable containing the modified Library. (It is understood 313 + that the user who changes the contents of definitions files in the 314 + Library will not necessarily be able to recompile the application 315 + to use the modified definitions.) 316 + 317 + b) Use a suitable shared library mechanism for linking with the 318 + Library. A suitable mechanism is one that (1) uses at run time a 319 + copy of the library already present on the user's computer system, 320 + rather than copying library functions into the executable, and (2) 321 + will operate properly with a modified version of the library, if 322 + the user installs one, as long as the modified version is 323 + interface-compatible with the version that the work was made with. 324 + 325 + c) Accompany the work with a written offer, valid for at 326 + least three years, to give the same user the materials 327 + specified in Subsection 6a, above, for a charge no more 328 + than the cost of performing this distribution. 329 + 330 + d) If distribution of the work is made by offering access to copy 331 + from a designated place, offer equivalent access to copy the above 332 + specified materials from the same place. 333 + 334 + e) Verify that the user has already received a copy of these 335 + materials or that you have already sent this user a copy. 336 + 337 + For an executable, the required form of the "work that uses the 338 + Library" must include any data and utility programs needed for 339 + reproducing the executable from it. However, as a special exception, 340 + the materials to be distributed need not include anything that is 341 + normally distributed (in either source or binary form) with the major 342 + components (compiler, kernel, and so on) of the operating system on 343 + which the executable runs, unless that component itself accompanies 344 + the executable. 345 + 346 + It may happen that this requirement contradicts the license 347 + restrictions of other proprietary libraries that do not normally 348 + accompany the operating system. Such a contradiction means you cannot 349 + use both them and the Library together in an executable that you 350 + distribute. 351 + 352 + 7. You may place library facilities that are a work based on the 353 + Library side-by-side in a single library together with other library 354 + facilities not covered by this License, and distribute such a combined 355 + library, provided that the separate distribution of the work based on 356 + the Library and of the other library facilities is otherwise 357 + permitted, and provided that you do these two things: 358 + 359 + a) Accompany the combined library with a copy of the same work 360 + based on the Library, uncombined with any other library 361 + facilities. This must be distributed under the terms of the 362 + Sections above. 363 + 364 + b) Give prominent notice with the combined library of the fact 365 + that part of it is a work based on the Library, and explaining 366 + where to find the accompanying uncombined form of the same work. 367 + 368 + 8. You may not copy, modify, sublicense, link with, or distribute 369 + the Library except as expressly provided under this License. Any 370 + attempt otherwise to copy, modify, sublicense, link with, or 371 + distribute the Library is void, and will automatically terminate your 372 + rights under this License. However, parties who have received copies, 373 + or rights, from you under this License will not have their licenses 374 + terminated so long as such parties remain in full compliance. 375 + 376 + 9. You are not required to accept this License, since you have not 377 + signed it. However, nothing else grants you permission to modify or 378 + distribute the Library or its derivative works. These actions are 379 + prohibited by law if you do not accept this License. Therefore, by 380 + modifying or distributing the Library (or any work based on the 381 + Library), you indicate your acceptance of this License to do so, and 382 + all its terms and conditions for copying, distributing or modifying 383 + the Library or works based on it. 384 + 385 + 10. Each time you redistribute the Library (or any work based on the 386 + Library), the recipient automatically receives a license from the 387 + original licensor to copy, distribute, link with or modify the Library 388 + subject to these terms and conditions. You may not impose any further 389 + restrictions on the recipients' exercise of the rights granted herein. 390 + You are not responsible for enforcing compliance by third parties with 391 + this License. 392 + 393 + 11. If, as a consequence of a court judgment or allegation of patent 394 + infringement or for any other reason (not limited to patent issues), 395 + conditions are imposed on you (whether by court order, agreement or 396 + otherwise) that contradict the conditions of this License, they do not 397 + excuse you from the conditions of this License. If you cannot 398 + distribute so as to satisfy simultaneously your obligations under this 399 + License and any other pertinent obligations, then as a consequence you 400 + may not distribute the Library at all. For example, if a patent 401 + license would not permit royalty-free redistribution of the Library by 402 + all those who receive copies directly or indirectly through you, then 403 + the only way you could satisfy both it and this License would be to 404 + refrain entirely from distribution of the Library. 405 + 406 + If any portion of this section is held invalid or unenforceable under any 407 + particular circumstance, the balance of the section is intended to apply, 408 + and the section as a whole is intended to apply in other circumstances. 409 + 410 + It is not the purpose of this section to induce you to infringe any 411 + patents or other property right claims or to contest validity of any 412 + such claims; this section has the sole purpose of protecting the 413 + integrity of the free software distribution system which is 414 + implemented by public license practices. Many people have made 415 + generous contributions to the wide range of software distributed 416 + through that system in reliance on consistent application of that 417 + system; it is up to the author/donor to decide if he or she is willing 418 + to distribute software through any other system and a licensee cannot 419 + impose that choice. 420 + 421 + This section is intended to make thoroughly clear what is believed to 422 + be a consequence of the rest of this License. 423 + 424 + 12. If the distribution and/or use of the Library is restricted in 425 + certain countries either by patents or by copyrighted interfaces, the 426 + original copyright holder who places the Library under this License may add 427 + an explicit geographical distribution limitation excluding those countries, 428 + so that distribution is permitted only in or among countries not thus 429 + excluded. In such case, this License incorporates the limitation as if 430 + written in the body of this License. 431 + 432 + 13. The Free Software Foundation may publish revised and/or new 433 + versions of the Lesser General Public License from time to time. 434 + Such new versions will be similar in spirit to the present version, 435 + but may differ in detail to address new problems or concerns. 436 + 437 + Each version is given a distinguishing version number. If the Library 438 + specifies a version number of this License which applies to it and 439 + "any later version", you have the option of following the terms and 440 + conditions either of that version or of any later version published by 441 + the Free Software Foundation. If the Library does not specify a 442 + license version number, you may choose any version ever published by 443 + the Free Software Foundation. 444 + 445 + 14. If you wish to incorporate parts of the Library into other free 446 + programs whose distribution conditions are incompatible with these, 447 + write to the author to ask for permission. For software which is 448 + copyrighted by the Free Software Foundation, write to the Free 449 + Software Foundation; we sometimes make exceptions for this. Our 450 + decision will be guided by the two goals of preserving the free status 451 + of all derivatives of our free software and of promoting the sharing 452 + and reuse of software generally. 453 + 454 + NO WARRANTY 455 + 456 + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 457 + WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 458 + EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 459 + OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 460 + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 461 + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 462 + PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 463 + LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 464 + THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 465 + 466 + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 467 + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 468 + AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 469 + FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 470 + CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 471 + LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 472 + RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 473 + FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 474 + SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 475 + DAMAGES. 476 + 477 + END OF TERMS AND CONDITIONS 478 + 479 + How to Apply These Terms to Your New Libraries 480 + 481 + If you develop a new library, and you want it to be of the greatest 482 + possible use to the public, we recommend making it free software that 483 + everyone can redistribute and change. You can do so by permitting 484 + redistribution under these terms (or, alternatively, under the terms of the 485 + ordinary General Public License). 486 + 487 + To apply these terms, attach the following notices to the library. It is 488 + safest to attach them to the start of each source file to most effectively 489 + convey the exclusion of warranty; and each file should have at least the 490 + "copyright" line and a pointer to where the full notice is found. 491 + 492 + <one line to give the library's name and a brief idea of what it does.> 493 + Copyright (C) <year> <name of author> 494 + 495 + This library is free software; you can redistribute it and/or 496 + modify it under the terms of the GNU Lesser General Public 497 + License as published by the Free Software Foundation; either 498 + version 2 of the License, or (at your option) any later version. 499 + 500 + This library is distributed in the hope that it will be useful, 501 + but WITHOUT ANY WARRANTY; without even the implied warranty of 502 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 503 + Lesser General Public License for more details. 504 + 505 + You should have received a copy of the GNU Lesser General Public 506 + License along with this library; if not, write to the Free Software 507 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 508 + 509 + Also add information on how to contact you by electronic and paper mail. 510 + 511 + You should also get your employer (if you work as a programmer) or your 512 + school, if any, to sign a "copyright disclaimer" for the library, if 513 + necessary. Here is a sample; alter the names: 514 + 515 + Yoyodyne, Inc., hereby disclaims all copyright interest in the 516 + library `Frob' (a library for tweaking knobs) written by James Random Hacker. 517 + 518 + <signature of Ty Coon>, 1 April 1990 519 + Ty Coon, President of Vice 520 + 521 + That's all there is to it! 522 + 523 +
+19
vendor/opam/re/Makefile
··· 1 + DUNE ?= dune 2 + 3 + all: 4 + @$(DUNE) build 5 + 6 + test: 7 + @$(DUNE) runtest 8 + 9 + check: 10 + @$(DUNE) build @runtest @check 11 + 12 + .PHONY: check test all clean 13 + 14 + .PHONY: release 15 + release: ## Release on Opam 16 + dune-release distrib --skip-build --skip-lint --skip-tests 17 + dune-release publish distrib --verbose 18 + dune-release opam pkg 19 + dune-release opam submit
+77
vendor/opam/re/README.md
··· 1 + Description 2 + =========== 3 + 4 + Re is a regular expression library for OCaml. 5 + [![Build status](https://github.com/ocaml/ocaml-re/actions/workflows/main.yml/badge.svg)](https://github.com/ocaml/ocaml-re/actions/workflows/main.yml) 6 + 7 + Contact 8 + ======= 9 + 10 + This library has been written by Jerome Vouillon 11 + (Jerome.Vouillon@pps.univ-paris-diderot.fr). 12 + It can be downloaded from <https://github.com/ocaml/ocaml-re> 13 + 14 + Bug reports, suggestions and contributions are welcome. 15 + 16 + Features 17 + ======== 18 + 19 + The following styles of regular expressions are supported: 20 + - Perl-style regular expressions (module `Re.Perl`); 21 + - Posix extended regular expressions (module `Re.Posix`); 22 + - Emacs-style regular expressions (module `Re.Emacs`); 23 + - Shell-style file globbing (module `Re.Glob`). 24 + 25 + It is also possible to build regular expressions by combining simpler regular 26 + expressions (module `Re`). 27 + 28 + The most notable missing features are **back-references** and 29 + look-ahead/look-behind **assertions**. 30 + 31 + There is also a subset of the PCRE interface available in the `Re.Pcre` module. 32 + This makes it easier to port code from that library to Re with minimal changes. 33 + 34 + Performances 35 + ============ 36 + 37 + The matches are performed by lazily building a DFA (deterministic 38 + finite automaton) from the regular expression. As a consequence, 39 + matching takes linear time in the length of the matched string. 40 + 41 + The compilation of patterns is slower than with libraries using 42 + back-tracking, such as PCRE. But, once a large enough part of the 43 + DFA is built, matching is extremely fast. 44 + 45 + Of course, for some combinations of regular expression and string, the 46 + part of the DFA that needs to be build is so large that this point is 47 + never reached, and matching will be slow. This is not expected to 48 + happen often in practice, and actually a lot of expressions that 49 + behaves badly with a backtracking implementation are very efficient 50 + with this implementation. 51 + 52 + The library is at the moment entirely written in OCaml. As a 53 + consequence, regular expression matching is much slower when the 54 + library is compiled to bytecode than when it is compiled to native 55 + code. 56 + 57 + Here are some timing results (Pentium III 500Mhz): 58 + * Scanning a 1Mb string containing only `a`s, except for the last 59 + character which is a `b`, searching for the pattern `aa?b` 60 + (repeated 100 times): 61 + - RE: 2.6s 62 + - PCRE: 68s 63 + * Regular expression example from http://www.bagley.org/~doug/shootout/ [1] 64 + - RE: 0.43s 65 + - PCRE: 3.68s 66 + 67 + [1] this page is no longer up but is available via the Internet Archive 68 + http://web.archive.org/web/20010429190941/http://www.bagley.org/~doug/shootout/bench/regexmatch/ 69 + 70 + * The large regular expression (about 2000 characters long) that 71 + Unison uses with my preference file to decide whether a file should 72 + be ignored or not. This expression is matched against a filename 73 + about 20000 times. 74 + - RE: 0.31s 75 + - PCRE: 3.7s 76 + However, RE is only faster than PCRE when there are more than about 77 + 300 filenames.
+81
vendor/opam/re/TODO.txt
··· 1 + * To compile r{i,j} we need a sequence that does not match epsilon 2 + (or a constructor around an expression telling that this expression 3 + does not match epsilon) 4 + * A subexpression repeated by an asterisk ( '*' ) or an interval 5 + expression shall not match a null expression unless this is the only 6 + match for the repetition or it is necessary to satisfy the exact or 7 + minimum number of occurrences for the interval expression. 8 + * There might be a typo in deriv_1/delta_1: should we generate 'TMatch 9 + mark' or 'TMatch mark'? (neither is correct!) 10 + 11 + POSIX: 12 + "(a?)*" "b" "" 13 + "(a?)*" "ab" "a" 14 + "((a)|(b))*" "ab" -> "b" none "b" 15 + Str 16 + "(a?)*" "b" no submatch 17 + "(a?)*" "ab" "a" 18 + "((a)|(b))*" "ab" -> "b" "a" "b" 19 + Javascript 20 + "(a?)*" "b" no submatch 21 + "(a?)*" "ab" "a" 22 + "((a)|(b))*" "ab" -> "b" none "b" 23 + PCRE 24 + "(a?)*" "b" "" 25 + "(a?)*" "ab" "" 26 + "(a?)*?" "b" "" 27 + "(a?)*?" "ab" "a" 28 + "((a)|(b))*" "ab" -> "b" "a" "b" 29 + Emacs 30 + "(a?)*" "b" "" 31 + "(a?)*" "ab" "" 32 + "(a?)*?" "b" "" 33 + "(a?)*?" "ab" "a" 34 + "((a)|(b))*" "ab" -> "b" "a" "b" 35 + 36 + 37 + r{0,0} = eps 38 + r{i+1,j+1} = r,r{i,j} 39 + r{0,j+1} = r,r{0,j} | eps PCRE/Emacs 40 + r{0,j+1} = (r-eps},r{0,j} | eps JavaScript 41 + 42 + * Rewrite sequences of sequences when possible... 43 + 44 + High priority 45 + ============= 46 + * Improve the Perl regular expressions parser 47 + * Character classes (in the three regular expression parsers) 48 + 49 + * Reduce memory usage 50 + - More compact representation of character sequences 51 + - Special notation for "anything but this set of characters" 52 + (more generally, optimize the compilation of regular expressions) 53 + * Simple optimisations 54 + - alt containing alt 55 + - epsilon elimination 56 + - Seq (Seq (x,y), z) => Seq (x, Seq (y, z)) under some circumstances 57 + (x or y has a fixed length) 58 + ... 59 + 60 + * Test suite 61 + 62 + Medium priority 63 + =============== 64 + * Implement back-references 65 + * Implement look-ahead and look-behind assertions 66 + 67 + Low priority 68 + ============ 69 + * Optimize the main loop for processor that are not register starved 70 + * Rewrite the main loops in C 71 + (but keep the option to compile a pure OCaml version) 72 + * Limit the size of the cached DFAs by removing states that have not 73 + been used recently 74 + * Documentation 75 + 76 + Other ideas 77 + =========== 78 + * It would be great to have a more generic interface (parameterized 79 + over some abstract tokens). 80 + * Compile checked printers parameterized over match groups (DRY for 81 + literal subexpressions)
+222
vendor/opam/re/benchmarks/benchmark.ml
··· 1 + open Core 2 + open Core_bench 3 + 4 + let str_20_zeroes = String.make 20 '0' 5 + let re_20_zeroes = Re.(str str_20_zeroes) 6 + 7 + let lots_of_a's = 8 + String.init 101 ~f:(function 9 + | 100 -> 'b' 10 + | _ -> 'a') 11 + ;; 12 + 13 + let lots_o_a's_re = Re.(seq [ char 'a'; opt (char 'a'); char 'b' ]) 14 + 15 + let media_type_re = 16 + let re = Re.Emacs.re ~case:true "[ \t]*\\([^ \t;]+\\)" in 17 + Re.(seq [ start; re ]) 18 + ;; 19 + 20 + (* Taken from https://github.com/rgrinberg/ocaml-uri/blob/903ef1010f9808d6f3f6d9c1fe4b4eabbd76082d/lib/uri.ml*) 21 + let uri_reference = 22 + Re.Posix.re "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?" 23 + ;; 24 + 25 + let uris = 26 + [ "https://google.com" 27 + ; "http://yahoo.com/xxx/yyy?query=param&one=two" 28 + ; "file:/random_crap" 29 + ] 30 + ;; 31 + 32 + let benchmarks = 33 + [ "20 zeroes", re_20_zeroes, [ str_20_zeroes ] 34 + ; "lots of a's", lots_o_a's_re, [ lots_of_a's ] 35 + ; "media type match", media_type_re, [ " foo/bar ; charset=UTF-8" ] 36 + ; "uri", uri_reference, uris 37 + ] 38 + ;; 39 + 40 + let test ~name re f = 41 + [ Bench.Test.create ~name (fun () -> f re) 42 + ; (let re () = 43 + let re = lazy (re ()) in 44 + Lazy.force re 45 + in 46 + Bench.Test.create ~name:(sprintf "%s (compiled)" name) (fun () -> f re)) 47 + ] 48 + ;; 49 + 50 + let exec_bench exec name (re : Re.t) cases = 51 + Bench.Test.create_group 52 + ~name 53 + (List.concat_map cases ~f:(fun data -> 54 + let name = 55 + let len = String.length data in 56 + if len > 70 57 + then Printf.sprintf "%s .. (%d)" (String.sub data ~pos:0 ~len:10) len 58 + else data 59 + in 60 + let re () = Re.compile re in 61 + test ~name re (fun re -> ignore (exec (re ()) data)))) 62 + ;; 63 + 64 + let exec_bench_many exec name re cases = 65 + test 66 + ~name 67 + (fun () -> Re.compile re) 68 + (fun re -> 69 + let re = re () in 70 + List.iter cases ~f:(fun x -> ignore (exec re x))) 71 + ;; 72 + 73 + let string_traversal = 74 + let len = 1000 * 1000 in 75 + let s = String.make len 'a' in 76 + let re = 77 + let re = Re.Pcre.re "aaaaaaaaaaaaaaaaz" in 78 + fun () -> Re.compile re 79 + in 80 + test ~name:"string traversal from #210" re (fun re -> 81 + ignore (Re.execp (re ()) s ~pos:0)) 82 + ;; 83 + 84 + let compile_clean_star = 85 + let c = 'c' in 86 + let s = String.make 10_000 c in 87 + let re = Re.rep (Re.char 'c') in 88 + let re () = Re.compile re in 89 + test ~name:"kleene star compilation" re (fun re -> ignore (Re.execp (re ()) s)) 90 + ;; 91 + 92 + let repeated_sequence = 93 + let s = String.init 256 ~f:Char.of_int_exn in 94 + let re () = Re.repn (Re.str s) 50 (Some 50) |> Re.compile in 95 + let s = List.init 50 ~f:(fun _ -> s) |> String.concat ~sep:"" in 96 + test ~name:"repeated sequence re" re (fun re -> 97 + let re = re () in 98 + ignore (Re.execp re s)) 99 + ;; 100 + 101 + let split = 102 + let s = Bytes.make 1_000 '_' in 103 + for i = 0 to 100 do 104 + Bytes.set s (i * 9) ' ' 105 + done; 106 + let s = Bytes.to_string s in 107 + let re () = Re.(rep1 space |> compile) in 108 + test ~name:"split on whitespace" re (fun re -> ignore (Re.split_full (re ()) s)) 109 + ;; 110 + 111 + let prefixes = 112 + let make_ext = 113 + let chars = "abcdefghiklmnopqrstuvwxyz" in 114 + let buf = Buffer.create 4 in 115 + let rec loop remains = 116 + match remains with 117 + | 0 -> Buffer.contents buf 118 + | _ -> 119 + let char = remains mod String.length chars in 120 + Buffer.add_char buf chars.[char]; 121 + loop (remains / String.length chars) 122 + in 123 + fun n -> 124 + Buffer.clear buf; 125 + loop n 126 + in 127 + let n_extensions = 100 in 128 + let n_base = 20 in 129 + let base = String.make n_base 'x' ^ "." in 130 + let extensions = List.init n_extensions ~f:make_ext in 131 + let re () = 132 + (* This regular expression can be heavily optimized by computing the shared prefix *) 133 + List.init 100 ~f:(fun i -> 134 + let ext = make_ext i in 135 + let open Re in 136 + seq [ rep1 any; char '.'; str ext ]) 137 + |> Re.alt 138 + |> Re.compile 139 + in 140 + let extensions = Array.of_list extensions in 141 + test ~name:"shared prefixes" re (fun re -> 142 + let re = re () in 143 + for i = 0 to Array.length extensions - 1 do 144 + let extension = extensions.(i) in 145 + let str = base ^ extension in 146 + ignore (Re.execp re str) 147 + done) 148 + ;; 149 + 150 + let benchmarks = 151 + let benches = 152 + List.map benchmarks ~f:(fun (name, re, cases) -> 153 + Bench.Test.create_group 154 + ~name 155 + [ exec_bench Re.exec "exec" re cases 156 + ; exec_bench Re.execp "execp" re cases 157 + ; exec_bench Re.exec_opt "exec_opt" re cases 158 + ]) 159 + in 160 + let http_benches = 161 + let open Http.Export in 162 + let manual = 163 + [ request, "no group"; request_g, "group" ] 164 + |> List.concat_map ~f:(fun (re, name) -> 165 + let re () = Re.compile re in 166 + test ~name re (fun re -> 167 + let re = re () in 168 + Http.read_all 0 re Http.requests)) 169 + |> Bench.Test.create_group ~name:"manual" 170 + in 171 + let many = 172 + [ test 173 + ~name:"execp no group" 174 + (fun () -> Re.compile requests) 175 + (fun re -> ignore (Re.execp (re ()) Http.requests)) 176 + ; test 177 + ~name:"all_gen" 178 + (fun () -> Re.compile requests_g) 179 + (fun re -> Http.requests |> Re.all (re ())) 180 + ] 181 + |> List.concat 182 + |> Bench.Test.create_group ~name:"auto" 183 + in 184 + Bench.Test.create_group ~name:"http" [ manual; many ] 185 + in 186 + benches 187 + @ [ [ exec_bench_many Re.execp "execp"; exec_bench_many Re.exec_opt "exec_opt" ] 188 + |> List.concat_map ~f:(fun f -> f Tex.ignore_re Tex.ignore_filesnames) 189 + |> Bench.Test.create_group ~name:"tex gitignore" 190 + ] 191 + @ [ http_benches ] 192 + @ string_traversal 193 + @ compile_clean_star 194 + @ Memory.benchmarks 195 + @ repeated_sequence 196 + @ split 197 + @ prefixes 198 + ;; 199 + 200 + let () = 201 + let benchmarks = 202 + match Sys.getenv "RE_BENCH_FILTER" with 203 + | None -> benchmarks 204 + | Some only -> 205 + let only = String.split ~on:',' only in 206 + let filtered = 207 + List.filter benchmarks ~f:(fun bench -> 208 + let name = Bench.Test.name bench in 209 + List.mem only name ~equal:String.equal) 210 + in 211 + (match filtered with 212 + | _ :: _ -> filtered 213 + | [] -> 214 + print_endline "No benchmarks to run. Your options are:"; 215 + List.iter benchmarks ~f:(fun bench -> 216 + let name = Bench.Test.name bench in 217 + Printf.printf "- %s\n" name); 218 + exit 1) 219 + in 220 + Memtrace.trace_if_requested (); 221 + Command_unix.run (Bench.make_command benchmarks) 222 + ;;
+182
vendor/opam/re/benchmarks/compare.ml
··· 1 + open Core 2 + 3 + module Both = struct 4 + type 'a t = 5 + { lhs : 'a 6 + ; rhs : 'a 7 + } 8 + end 9 + 10 + module Value = struct 11 + type t = 12 + | Int of int 13 + | Float of float 14 + 15 + let of_string s = 16 + try Int (Int.of_string s) with 17 + | _ -> Float (Float.of_string s) 18 + ;; 19 + 20 + let rec percent_delta x y = 21 + match x, y with 22 + | Int x, Int y -> 23 + let delta = y - x in 24 + let open Float in 25 + Float (100. * Float.of_int delta / Float.of_int x) 26 + | Float x, Float y -> Float Float.(100. * (y - x) / x) 27 + | Float x, Int y -> percent_delta (Float x) (Float (Float.of_int y)) 28 + | Int x, Float y -> percent_delta (Float (Float.of_int x)) (Float y) 29 + ;; 30 + 31 + let to_csv t = 32 + match t with 33 + | Float f -> Float.to_string_hum f 34 + | Int x -> Int.to_string_hum x 35 + ;; 36 + 37 + let compare x y = 38 + match x, y with 39 + | Float x, Float y -> Float.compare x y 40 + | Int x, Int y -> Int.compare x y 41 + | _, _ -> assert false 42 + ;; 43 + end 44 + 45 + type 'a bench = 46 + { name : string 47 + ; time_per_run_nanos : 'a 48 + ; major_words_per_run : 'a 49 + ; promoted_words_per_run : 'a 50 + ; minor_words_per_run : 'a 51 + } 52 + 53 + let of_sexp (sexp : Sexp.t) = 54 + match sexp with 55 + | Atom _ -> failwith "expected list" 56 + | List fields -> 57 + let kv (sexp : Sexp.t) = 58 + match sexp with 59 + | List [ Atom k; Atom v ] -> Some (k, v) 60 + | _ -> None 61 + in 62 + let fields = List.filter_map fields ~f:kv in 63 + let field name = 64 + List.find_map_exn fields ~f:(fun (k, v) -> 65 + if String.equal k name then Some v else None) 66 + in 67 + let name = field "full_benchmark_name" in 68 + let time_per_run_nanos = Value.of_string (field "time_per_run_nanos") in 69 + let major_words_per_run = Value.of_string (field "major_words_per_run") in 70 + let promoted_words_per_run = Value.of_string (field "promoted_words_per_run") in 71 + let minor_words_per_run = Value.of_string (field "minor_words_per_run") in 72 + { name 73 + ; time_per_run_nanos 74 + ; major_words_per_run 75 + ; promoted_words_per_run 76 + ; minor_words_per_run 77 + } 78 + ;; 79 + 80 + let parse_all s = 81 + match Sexp.of_string s with 82 + | Atom _ -> failwith "list expected" 83 + | List benches -> 84 + List.map benches ~f:of_sexp 85 + |> String.Map.of_list_with_key_exn ~get_key:(fun v -> v.name) 86 + ;; 87 + 88 + let merge_one 89 + { name 90 + ; time_per_run_nanos 91 + ; major_words_per_run 92 + ; promoted_words_per_run 93 + ; minor_words_per_run 94 + } 95 + b 96 + = 97 + assert (String.equal name b.name); 98 + { b with 99 + time_per_run_nanos = { Both.lhs = time_per_run_nanos; rhs = b.time_per_run_nanos } 100 + ; major_words_per_run = { Both.lhs = major_words_per_run; rhs = b.major_words_per_run } 101 + ; promoted_words_per_run = 102 + { Both.lhs = promoted_words_per_run; rhs = b.promoted_words_per_run } 103 + ; minor_words_per_run = { Both.lhs = minor_words_per_run; rhs = b.minor_words_per_run } 104 + } 105 + ;; 106 + 107 + let merge lhs rhs = 108 + Map.merge lhs rhs ~f:(fun ~key:_ v -> 109 + match v with 110 + | `Left _ -> None 111 + | `Right _ -> None 112 + | `Both (lhs, rhs) -> Some (merge_one lhs rhs)) 113 + ;; 114 + 115 + let run ~prev ~next = 116 + let report = 117 + let prev = Stdio.In_channel.read_all prev |> parse_all in 118 + let next = Stdio.In_channel.read_all next |> parse_all in 119 + merge prev next 120 + in 121 + let records = 122 + let headers = 123 + [ "name" 124 + ; "time_per_run_nanos" 125 + ; "delta (%)" 126 + ; "major_words_per_run" 127 + ; "delta (%)" 128 + ; "promoted_words_per_run" 129 + ; "delta (%)" 130 + ; "minor_words_per_run" 131 + ; "delta (%)" 132 + ] 133 + in 134 + let values = 135 + Map.to_alist report 136 + |> List.map ~f:snd 137 + |> List.map 138 + ~f: 139 + (fun 140 + ({ name 141 + ; time_per_run_nanos 142 + ; major_words_per_run 143 + ; promoted_words_per_run 144 + ; minor_words_per_run 145 + } : 146 + Value.t Both.t bench) 147 + -> 148 + let time_delta = 149 + Value.percent_delta time_per_run_nanos.lhs time_per_run_nanos.rhs 150 + in 151 + let make_delta { Both.lhs; rhs } = 152 + let delta = Value.percent_delta lhs rhs in 153 + [ Value.to_csv lhs; Value.to_csv delta ] 154 + in 155 + ( time_delta 156 + , name 157 + :: List.concat 158 + [ make_delta time_per_run_nanos 159 + ; make_delta major_words_per_run 160 + ; make_delta promoted_words_per_run 161 + ; make_delta minor_words_per_run 162 + ] )) 163 + |> List.sort ~compare:(fun (x, _) (y, _) -> Value.compare x y) 164 + |> List.map ~f:snd 165 + in 166 + headers :: values 167 + in 168 + let chan = Csv.to_channel Stdio.stdout in 169 + Csv.output_all chan records 170 + ;; 171 + 172 + let command = 173 + let open Command.Param in 174 + let open Command.Param.Applicative_infix in 175 + Command.basic 176 + ~summary:"compare two runs" 177 + (let prev = flag "prev" (required string) ~doc:"sexp file" in 178 + let next = flag "next" (required string) ~doc:"sexp file" in 179 + Command.Param.return (fun prev next () -> run ~prev ~next) <*> prev <*> next) 180 + ;; 181 + 182 + let () = Command_unix.run command
+35
vendor/opam/re/benchmarks/dune
··· 1 + (env 2 + (dev 3 + (flags 4 + (:standard -w -58)))) 5 + 6 + (executables 7 + (enabled_if 8 + (not %{env:CI=false})) 9 + (libraries 10 + re 11 + core 12 + base 13 + stdio 14 + threads 15 + core_bench 16 + core_unix.command_unix 17 + memtrace) 18 + (modules :standard \ compare) 19 + (names benchmark)) 20 + 21 + (executable 22 + (enabled_if 23 + (not %{env:CI=false})) 24 + (name compare) 25 + (modules compare) 26 + (libraries 27 + core 28 + csv 29 + base 30 + core_unix 31 + core_unix.command_unix 32 + core_unix.filename_unix 33 + spawn 34 + stdio 35 + sexplib))
+1120
vendor/opam/re/benchmarks/files
··· 1 + ./.merlin 2 + ./re_match.native 3 + ./lib 4 + ./lib/re-api.odocl 5 + ./lib/re_glob.mllib 6 + ./lib/re.mli 7 + ./lib/re_cset.ml 8 + ./lib/re_automata.ml 9 + ./lib/re.ml 10 + ./lib/re_emacs.mli 11 + ./lib/re_glob.mldylib 12 + ./lib/re_pcre.mli 13 + ./lib/re_perl.mldylib 14 + ./lib/re_posix.mli 15 + ./lib/re_perl.mli 16 + ./lib/re.mldylib 17 + ./lib/re_posix.mldylib 18 + ./lib/re_automata.mli 19 + ./lib/re_glob.ml 20 + ./lib/re_emacs.ml 21 + ./lib/re_pcre.mllib 22 + ./lib/re_glob.mli 23 + ./lib/re_str.mldylib 24 + ./lib/re.mllib 25 + ./lib/re_posix.mllib 26 + ./lib/re_pcre.ml 27 + ./lib/re_emacs.mldylib 28 + ./lib/META 29 + ./lib/re_pcre.mldylib 30 + ./lib/re_cset.mli 31 + ./lib/re_emacs.mllib 32 + ./lib/re_str.mli 33 + ./lib/re_perl.ml 34 + ./lib/re_fmt.ml 35 + ./lib/re_perl.mllib 36 + ./lib/re_posix.ml 37 + ./lib/re_str.ml 38 + ./lib/re_str.mllib 39 + ./lib_test 40 + ./lib_test/test_easy.ml 41 + ./lib_test/test_emacs.ml 42 + ./lib_test/re_match.ml 43 + ./lib_test/longest.c 44 + ./lib_test/pcre_match.ml 45 + ./lib_test/.cvsignore 46 + ./lib_test/test_glob.ml 47 + ./lib_test/fort_unit.mllib 48 + ./lib_test/test_perl.ml 49 + ./lib_test/fort_unit.ml 50 + ./lib_test/test_exec_iter.ml 51 + ./lib_test/perl_scan.pl 52 + ./lib_test/Input 53 + ./lib_test/scan.ml 54 + ./lib_test/fort_unit.mldylib 55 + ./lib_test/unison2.ml 56 + ./lib_test/META 57 + ./lib_test/unison.ml 58 + ./lib_test/test_pcre.ml 59 + ./lib_test/glob.ml 60 + ./lib_test/pcre_scan.ml 61 + ./lib_test/re_scan.ml 62 + ./lib_test/Makefile 63 + ./lib_test/test_str.ml 64 + ./lib_test/test_re.ml 65 + ./lib_test/unison3.ml 66 + ./setup.exe 67 + ./_oasis 68 + ./repl.ml 69 + ./test_perl.native 70 + ./setup.data 71 + ./test_re.native 72 + ./setup.ml 73 + ./benchmarks 74 + ./benchmarks/.merlin 75 + ./benchmarks/benchmark.ml 76 + ./benchmarks/.#files 77 + ./benchmarks/.#tex.gitignore 78 + ./.gitignore 79 + ./.git 80 + ./.git/COMMIT_EDITMSG 81 + ./.git/objects 82 + ./.git/objects/bd 83 + ./.git/objects/bd/7b4a58cc13ca497618e5f8eaa664727a489c14 84 + ./.git/objects/04 85 + ./.git/objects/04/a2c275e68174559191e1f03369472ab6cc79a6 86 + ./.git/objects/04/266b2bfdc3cb6dd1557ddc6cca27dd1c2483de 87 + ./.git/objects/c3 88 + ./.git/objects/c3/b0f3506b6efa82e7d8455a51c40f674e362019 89 + ./.git/objects/ae 90 + ./.git/objects/ae/edba64f100def873a670083e7cc4dec013b461 91 + ./.git/objects/ae/e951b55c41573ce87f3e1e9ed7af59cfd03465 92 + ./.git/objects/ae/6fb476af3ed0c1c09bac3cca8825a1983f6baf 93 + ./.git/objects/80 94 + ./.git/objects/80/c9e3062a7a04de5f4fac4e99402caa9b51a06a 95 + ./.git/objects/80/c8e9cfeb808e093b68db94016ed90c821111f7 96 + ./.git/objects/pack 97 + ./.git/objects/pack/pack-866532c1406fa054e3eb4a18c69f02811d0d9218.pack 98 + ./.git/objects/pack/pack-866532c1406fa054e3eb4a18c69f02811d0d9218.idx 99 + ./.git/objects/ed 100 + ./.git/objects/ed/0f521c10cf8d6bff59836ec4ccbe7e5457833b 101 + ./.git/objects/7a 102 + ./.git/objects/7a/93d826a964cfcda511666ea90cae1c932fa420 103 + ./.git/objects/7a/948d869ac1991341c6a809fff33fe6f7578176 104 + ./.git/objects/7a/11dea700ff573997fa79ee6d720d8c36bb8c24 105 + ./.git/objects/57 106 + ./.git/objects/57/41501919c83c417773c4db93c40f064c01b9fa 107 + ./.git/objects/57/5df2075ef86ab5052cf3f640cfef0ade065079 108 + ./.git/objects/c1 109 + ./.git/objects/c1/b86cbaa2bc74068aa01996d5361165488ad90b 110 + ./.git/objects/d5 111 + ./.git/objects/d5/fae05fd2c4e4319d1d8b72b47c5bf7c5c988bc 112 + ./.git/objects/d5/a493ad0448a01ef3b090cafa65e4052e3e3443 113 + ./.git/objects/d5/18889bb8e29093ac8c151dbfb94ecdb55da37b 114 + ./.git/objects/c0 115 + ./.git/objects/c0/3edfcb9c4d1ba4d5c714784719f2babc0d4bc2 116 + ./.git/objects/ea 117 + ./.git/objects/ea/59fc8cae70bc30d4925b5d754d3eaa4c86fbe7 118 + ./.git/objects/ea/96d0c79a09edde6fb5fdca45fad5eeb6b94a3b 119 + ./.git/objects/ea/d533485541976b0e8651823b48dd3b893fd7bf 120 + ./.git/objects/bf 121 + ./.git/objects/bf/9238d7470f96c20ef3b8ae9ae800c29a24b7d0 122 + ./.git/objects/da 123 + ./.git/objects/da/5d5f8e2a5adf35ea1918972f87bae5ef20eba8 124 + ./.git/objects/da/9d6c16f47466f0483a426802c81a4e2f105565 125 + ./.git/objects/5d 126 + ./.git/objects/5d/68a2c24d022272086e02e201a34a7cc471a810 127 + ./.git/objects/d1 128 + ./.git/objects/d1/baa7c6cb5a197c2fa16d74d015cb65383befae 129 + ./.git/objects/d1/4a2f9a73098a607be995953a176a4c158eda31 130 + ./.git/objects/a8 131 + ./.git/objects/a8/385bd4963671a9f8e46367258ed74470230be8 132 + ./.git/objects/a8/88411f7ae15f92b0a4f115b6a198bb9fca17eb 133 + ./.git/objects/a8/6354c21c4ea14488a7749ce9ca7319dfd7962d 134 + ./.git/objects/f8 135 + ./.git/objects/f8/402f7182db519f40022913d9b7f545155e23da 136 + ./.git/objects/f8/fe27353f98e6449f9c140ed285c66111a83c8a 137 + ./.git/objects/32 138 + ./.git/objects/32/7e89b0ce8c6c488a6052e2de5204ef89e2f507 139 + ./.git/objects/32/46e88c270717153eee687e584c48c2b7611500 140 + ./.git/objects/d3 141 + ./.git/objects/d3/4bab001c846b49c144845ae06905122fc00d5b 142 + ./.git/objects/d3/14cca150738f34ec06d0a620746fa4b664d488 143 + ./.git/objects/d3/c1b11ad75157f9b7976205c02c5017edbe91e5 144 + ./.git/objects/7c 145 + ./.git/objects/7c/4fff7192504e558898de1a0a6a03f40b1ba383 146 + ./.git/objects/7c/ca263ea8cf851ed5e6b620b1ac975a52cd1ab9 147 + ./.git/objects/7c/c8bf775e67bee805e45e2c2de7292c060f31ce 148 + ./.git/objects/e3 149 + ./.git/objects/e3/fee6d0fba12db992dab0c59f0c0af51e00f0cc 150 + ./.git/objects/73 151 + ./.git/objects/73/e55a4522cb6094dbfa5259ea1246a80e3b8c40 152 + ./.git/objects/73/7cc095a1c47d9895cf38d27633f8fde7024868 153 + ./.git/objects/73/afa2a0065c795b73f8ac64879d85342765624a 154 + ./.git/objects/48 155 + ./.git/objects/48/85f690a7e2bbf6c95ab017ebeddf13d4adbf01 156 + ./.git/objects/48/a13cb1beef406dd4a4e2306e1e37f6836e4825 157 + ./.git/objects/8c 158 + ./.git/objects/8c/a9e8d133eef4f47c05922233619de5a86ee4ab 159 + ./.git/objects/8c/df1c29071e45af80bf897cac73b4c1566e2d50 160 + ./.git/objects/1b 161 + ./.git/objects/1b/9d5c43861498c1854465ac03e76a514d5cbaa8 162 + ./.git/objects/50 163 + ./.git/objects/50/ef8ba0f5817ad270ae921fea07bb8797b9c267 164 + ./.git/objects/50/48505dcfbfd75f4bbad53bf5d71105215052c7 165 + ./.git/objects/eb 166 + ./.git/objects/eb/31ab22a61ecfba506504fdf4b0f5cd28af2e11 167 + ./.git/objects/eb/bf41561fdfffa8b973ad8c8d60c00907c59571 168 + ./.git/objects/eb/dbd748cd4c6e3fcadd5087b9508a20a34c8125 169 + ./.git/objects/ef 170 + ./.git/objects/ef/5f4e84fc1fb16d0e6a3b6402b2ef7b4ed4597f 171 + ./.git/objects/ca 172 + ./.git/objects/ca/67f392b19172f6bc90132ef568aeadff4c47e4 173 + ./.git/objects/ca/9cd9a973452dcedfabe0bb1ee39eaa825856b7 174 + ./.git/objects/ca/0249ae201624a0915b20a04f0bea1e88fbac12 175 + ./.git/objects/c5 176 + ./.git/objects/c5/531af344c2046d8887b5a8414fca0034be08c4 177 + ./.git/objects/c5/c32cce665964562c01cb70dbd1d931d0fc9013 178 + ./.git/objects/c5/dd991dc612c5cd22a26633a5ab5cb1e19065c3 179 + ./.git/objects/75 180 + ./.git/objects/75/c564016f8ebf5726272c3f624f8f607002bbda 181 + ./.git/objects/4e 182 + ./.git/objects/4e/f45ea3fd278fb84e61bb004f62beeb6e58a461 183 + ./.git/objects/4e/af84d38158ff6aeab975f4b93bca267185ff75 184 + ./.git/objects/cb 185 + ./.git/objects/cb/a0873bb0fb8cdd095efea7fc00d244d9f33dd6 186 + ./.git/objects/6a 187 + ./.git/objects/6a/00cd81ccdbe607f9585878296c1e1e2c5b7cbd 188 + ./.git/objects/6a/93ab65f245de47a5a6c97f6b95e2b5ed93c6ce 189 + ./.git/objects/6a/521ac0a70a030b4570b17ce369ae7e0ccb5bcc 190 + ./.git/objects/6a/00c91ef0a06a2aa19cfb94ba06503cb1d0a2c5 191 + ./.git/objects/e8 192 + ./.git/objects/e8/4dc23cd8d2b83c0986002851ad228ca86f104b 193 + ./.git/objects/e8/ad3cd2087d55ff7928f7ad191a5c447a86a253 194 + ./.git/objects/06 195 + ./.git/objects/06/1a15896701e0696b9056e8c1f3ed0602b696c7 196 + ./.git/objects/06/8886279674c32c6c0189ca0eb9ca3427b6a73f 197 + ./.git/objects/06/96d3afa20ddbad8c4e09ffc80da6a062ecca0f 198 + ./.git/objects/26 199 + ./.git/objects/26/d94482417d0415bc3074d578ea15fa29bf61eb 200 + ./.git/objects/51 201 + ./.git/objects/51/21ef81a3c018e7ece82b8fa53804f49b187e61 202 + ./.git/objects/51/7475c493f88584541456158468830c728a385f 203 + ./.git/objects/f7 204 + ./.git/objects/f7/e5d4ab3ab0b9b806b17f166db3de7cb83e16ba 205 + ./.git/objects/49 206 + ./.git/objects/49/b13c62775b3f1ae207c1c7b937b8799d280a53 207 + ./.git/objects/49/9613067efd80e477704c5752e2e24d16b685e5 208 + ./.git/objects/e7 209 + ./.git/objects/e7/71a89a26f22e59b14d4537f341206ae7e2dd59 210 + ./.git/objects/5c 211 + ./.git/objects/5c/28f300f108705b0838519b16b64040e1753dac 212 + ./.git/objects/7d 213 + ./.git/objects/7d/24c5c18d327f576162279ec5c8d1040ae9f53a 214 + ./.git/objects/d0 215 + ./.git/objects/d0/bdcf3a2e68cf891369b37c0bdafe5b3a8c3721 216 + ./.git/objects/ad 217 + ./.git/objects/ad/dc2932430682c6f4aebf981bbdb60bd8650a46 218 + ./.git/objects/5e 219 + ./.git/objects/5e/5a6c6e318cbcc56ac17c785e42512984a54ffe 220 + ./.git/objects/5e/65dfb3785145e3359094f2da9a9308ca89f95a 221 + ./.git/objects/5e/e61c21b52ad286753d76024e686ae2188f3d9c 222 + ./.git/objects/5e/7211f1f557ceea2922e95c9353344a7d8011eb 223 + ./.git/objects/60 224 + ./.git/objects/60/825f155344cfac612ddb9aa4056cee1a3758fa 225 + ./.git/objects/60/df4d354a7d252d34d31d266064a498bae0c00e 226 + ./.git/objects/60/9434044eb5c63cfbe323346a76c37316f5d3cb 227 + ./.git/objects/68 228 + ./.git/objects/68/7f8ea68a53e8a91694db6e8e19309c7aaff242 229 + ./.git/objects/68/5de33ed341bc2e51a650f5c42f02a4cea86c74 230 + ./.git/objects/68/ba3add2e2f20ff74ca504aa69a067269748796 231 + ./.git/objects/68/54eba89564df3120ae33bd3905f70af0a9508e 232 + ./.git/objects/bb 233 + ./.git/objects/bb/26307254872961f81864ae695a2212da53e305 234 + ./.git/objects/bb/0b632d318e1cc55446ab86264a943dc662dedf 235 + ./.git/objects/bb/04232d06b8b1b51d0313c76ecdf53fbb38b133 236 + ./.git/objects/79 237 + ./.git/objects/79/05fb61e4f1057e53188709c091739c2adabdce 238 + ./.git/objects/3b 239 + ./.git/objects/3b/6969415623e49b583fd9623a21269d16cf67d8 240 + ./.git/objects/3b/a8e873cae0cd0d76051c8845a05ee7e5d6d2d1 241 + ./.git/objects/24 242 + ./.git/objects/24/18f0e1209770aeeb848a83fab8a87a5e9a3a86 243 + ./.git/objects/24/4d94f9094fe4b391a781a7b5059d19233558c0 244 + ./.git/objects/1a 245 + ./.git/objects/1a/a9a109bfb5e0100583062628741d37edbef198 246 + ./.git/objects/cf 247 + ./.git/objects/cf/b4058d5efe88c7e11216de67c3ddecfaeb74c1 248 + ./.git/objects/cf/ca9f3ec8ffd3a716e84a1816fd2f290aff45f3 249 + ./.git/objects/cf/249dc6bf90a05272ea34a37c179695ec1679e8 250 + ./.git/objects/41 251 + ./.git/objects/41/7e9c7be145d7ce950e2634e24bdb7ead9eaf27 252 + ./.git/objects/e0 253 + ./.git/objects/e0/cf46969ea651e5939b9d5f048eaec3ec1de4c2 254 + ./.git/objects/e0/56cae16e516031cd82e2190a7a021a95145026 255 + ./.git/objects/e0/897837a3548051e45ac861ab417adf7c59829f 256 + ./.git/objects/e0/d97cc471e24acd66068a44308c7abff19b1925 257 + ./.git/objects/91 258 + ./.git/objects/91/a4117c6026321105e7a694173a05b2644d77c2 259 + ./.git/objects/91/b1cee3be1539bb24a359d20d8a5e076a9cf30d 260 + ./.git/objects/fa 261 + ./.git/objects/fa/eb7cd164e1c586e7d45a09e0619cf9a74f54af 262 + ./.git/objects/fa/8e7262e1a26131ac68a1a911baca583f27dca4 263 + ./.git/objects/fa/9de6a7c9f2dee85a1145e1fc4c5d1b570e964b 264 + ./.git/objects/2b 265 + ./.git/objects/2b/4c9ad40ba8fde41829a22e88bd26d38cd513f9 266 + ./.git/objects/54 267 + ./.git/objects/54/f717fa1d49e761b89e8f8097e8e3afde5cc6f7 268 + ./.git/objects/54/f513d93e0e3263265c24591a7c874b53030436 269 + ./.git/objects/b4 270 + ./.git/objects/b4/6ae8881ee452f7a4ff0efb75bac923f36d14aa 271 + ./.git/objects/b4/8ffdfbe33be1dfd1783c8ff6b1e8fbe41db10d 272 + ./.git/objects/b4/e29997072acf52d882cfced7e85bb3b37460b5 273 + ./.git/objects/b4/25a61759c2334ae65b46e56533f54804906c7a 274 + ./.git/objects/ac 275 + ./.git/objects/ac/1468dfa7da0b2fea46f17a3525c19feacdc1a1 276 + ./.git/objects/ac/375885c60a0ea3a99d8bb439109c1fa895761d 277 + ./.git/objects/ac/fe49dc5da96f42f02493db63c143e2e2babad1 278 + ./.git/objects/ac/6c0f696722f17907f137f4c7fad91e64f49dac 279 + ./.git/objects/e9 280 + ./.git/objects/e9/cc98781f3762e4dd7e8be3b025723674999a31 281 + ./.git/objects/1e 282 + ./.git/objects/1e/08112d5532b7b52a6d51270e73b5bf019ebd0a 283 + ./.git/objects/6c 284 + ./.git/objects/6c/e4e9093f07b21a48bb122f10a347e38eac84a3 285 + ./.git/objects/03 286 + ./.git/objects/03/fb2ad72c7a8427949a2bd42155098c7ba5292b 287 + ./.git/objects/b5 288 + ./.git/objects/b5/3290a08b842bb02ec8b9a453ddcce593595285 289 + ./.git/objects/1f 290 + ./.git/objects/1f/b018c263111f5612dff4a0714d133fa14b47d0 291 + ./.git/objects/f5 292 + ./.git/objects/f5/5fa50d15939fef068814d393f10c47d6c24df0 293 + ./.git/objects/78 294 + ./.git/objects/78/c2eef20df32f85b780af9ea5cda026a0c597ec 295 + ./.git/objects/05 296 + ./.git/objects/05/c94e09c13c59b6b0313c670a3b2b05f104e9d5 297 + ./.git/objects/05/6aa0e5511235422238f4944ab543c1339ba472 298 + ./.git/objects/05/2233649e450bb03b929975139eeb624310852e 299 + ./.git/objects/05/0ac4c6759899cd6c1c48d74aaa8cdeb8802d67 300 + ./.git/objects/05/5c86781ebb8d7466e996d2a953ffb2701160b7 301 + ./.git/objects/3a 302 + ./.git/objects/3a/b09d8cd602c91f6b13418aedfc10c6dea50311 303 + ./.git/objects/3a/0080d9bd9df6701481c73c108df8f8aba270d6 304 + ./.git/objects/3f 305 + ./.git/objects/3f/121aca11150765ad412e552c38cb846cdf1b25 306 + ./.git/objects/9d 307 + ./.git/objects/9d/c192d47b5c60f58ea01b6fbb3cac7f95355920 308 + ./.git/objects/dc 309 + ./.git/objects/dc/81451f732d8886a46ba4be0eb8689c3ffa05ff 310 + ./.git/objects/dc/277721b85d2c24888d9b295d73e77dc0b56c47 311 + ./.git/objects/11 312 + ./.git/objects/11/f3056a841ad601f309f9bb45fd1e7a45bdc35a 313 + ./.git/objects/09 314 + ./.git/objects/09/83adb85f1e3af304b3219d112d87868940bd34 315 + ./.git/objects/09/9d1ab30c98206fe2cd21e5351e4e739ddca093 316 + ./.git/objects/a6 317 + ./.git/objects/a6/78884c9d14735ad62e6ffe8edeb237b153b31f 318 + ./.git/objects/90 319 + ./.git/objects/90/d315297656082d1d3fa42398237e6fd7ca8b77 320 + ./.git/objects/90/131c7cf785f05180b94d3fa03ea5a15bc3fc86 321 + ./.git/objects/9c 322 + ./.git/objects/9c/5bef9eb738539b7ef600afb5e4a4daf520ecf3 323 + ./.git/objects/9c/5e872385933c0748afbe0d04721d2d87fcef7a 324 + ./.git/objects/9e 325 + ./.git/objects/9e/967e175d46284466def0287af70684002ebc9b 326 + ./.git/objects/98 327 + ./.git/objects/98/2ac64fcb212641da96dd4aeba1c4d3a2089c8d 328 + ./.git/objects/83 329 + ./.git/objects/83/c7ca0b3a62936df5bdadf81866f2f42a60201d 330 + ./.git/objects/ee 331 + ./.git/objects/ee/905700bdc10dd27f0b9b5d3e8e7c63cdb003a8 332 + ./.git/objects/ee/137eb490291da49905c526776f3240dd994bde 333 + ./.git/objects/8b 334 + ./.git/objects/8b/b979b870b98d1421703d3c5f9b4506b34da31b 335 + ./.git/objects/8b/94333973de20dc2f9f6fba276d77957a585f19 336 + ./.git/objects/8b/49a1a69ac34a2a9133ff3cfb2b30d7ce21269c 337 + ./.git/objects/cd 338 + ./.git/objects/cd/149e97dcb42e9893f15b0908cc6e7be8c176ad 339 + ./.git/objects/f3 340 + ./.git/objects/f3/ff42162b9ceaa17323e15da2fcae4455acdc94 341 + ./.git/objects/df 342 + ./.git/objects/df/0cad1cb3e9fa09265d3f63deedc382639dd902 343 + ./.git/objects/74 344 + ./.git/objects/74/3d2df4b1818f0aa743f57a85a4a5fb41b01fa9 345 + ./.git/objects/74/01fc63e34bb3750d5b16c5d151653c8d6cfbc0 346 + ./.git/objects/01 347 + ./.git/objects/01/2e7dc0ac588f0e708ee8a8d115dc7c064c12b7 348 + ./.git/objects/01/b09c53d179d687bc0837662bc48601e928502e 349 + ./.git/objects/01/7b3e99b3434bfe6ef2edb0a75b080311844169 350 + ./.git/objects/dd 351 + ./.git/objects/dd/ad7182883890236f925f3353f4873c0b75034a 352 + ./.git/objects/18 353 + ./.git/objects/18/8fe3d25861b14cd4af1163410b61f73ca4a04e 354 + ./.git/objects/62 355 + ./.git/objects/62/064f59de8e93a5664bf43829e477bd9985cef6 356 + ./.git/objects/2f 357 + ./.git/objects/2f/cd5c7dea3df5fa12fcbb5f26c8582b2910c447 358 + ./.git/objects/b6 359 + ./.git/objects/b6/8cc01c492b43223b504821bfd73b4f583ef4e2 360 + ./.git/objects/be 361 + ./.git/objects/be/6b86d77fbb51906eacba3df56274612f1c3029 362 + ./.git/objects/be/0938c18155c11f355d0fdc81c489c599cde3a7 363 + ./.git/objects/be/d2ef86152fa9a0aabd84027e317733f0dfbae7 364 + ./.git/objects/be/f110dd4cfaa19684396aaf93b27a5fb3c0b945 365 + ./.git/objects/f6 366 + ./.git/objects/f6/354b6caad8336c77feff4de8509c274a27fb70 367 + ./.git/objects/21 368 + ./.git/objects/21/5eb4b90109c24b08014bba985aa654feb57c59 369 + ./.git/objects/f2 370 + ./.git/objects/f2/687c378697490c59291d1cec912fe66852453a 371 + ./.git/objects/f2/d72115d8389718be364c28fc13785e5277b180 372 + ./.git/objects/3d 373 + ./.git/objects/3d/a02568239608f630e802f4dd777449d0913e03 374 + ./.git/objects/1d 375 + ./.git/objects/1d/2143cfb7d3376ecd5486c18c779c9d144d384c 376 + ./.git/objects/6f 377 + ./.git/objects/6f/5fb29affd8ac04ecf3574d5e99a716b414f2ca 378 + ./.git/objects/6f/6df7bced1281095533e756c0d6b9e7373f1a8b 379 + ./.git/objects/6f/52a7ca4ac7a38e8705299c2d9473ca1058b627 380 + ./.git/objects/45 381 + ./.git/objects/45/f68c1233212098478ac83525e9e68e2df1fadb 382 + ./.git/objects/45/6f776946d4828283ba374a165742234590fcc9 383 + ./.git/objects/45/7aca0b40cef66eacf359630f145a4ff26364f2 384 + ./.git/objects/5a 385 + ./.git/objects/5a/de07472965b3a18ce368b40dc9c904278142b9 386 + ./.git/objects/info 387 + ./.git/objects/af 388 + ./.git/objects/af/f436ea457490f0752d934983bf1bbba2e2197a 389 + ./.git/objects/af/45c22cb2b534b5698562b3080e747fefa1b981 390 + ./.git/objects/d8 391 + ./.git/objects/d8/f83208765b69ade21aa13ffcdd38648bc54f14 392 + ./.git/objects/70 393 + ./.git/objects/70/e2c3dfaef29f8c8a3fa5d714105d3f5c3cd10f 394 + ./.git/objects/70/d74188dd90fb7e09d2d163dfa874e7c9e434bd 395 + ./.git/objects/61 396 + ./.git/objects/61/a4c4b922c4ef41400d990031f3ac12f6a0888c 397 + ./.git/objects/61/6f06980312fc46031d9f21f29beef5e17d46f1 398 + ./.git/objects/61/21078331176aaee1238c0f059f7f94663690b3 399 + ./.git/objects/61/b65d28779937e8010a8c9d5f7eeeddbc5e0294 400 + ./.git/objects/84 401 + ./.git/objects/84/6ed3f02af5b46751dc2b0ff84690a84abf8f52 402 + ./.git/objects/84/4378673c7db10ddc3e8d22a8187ebbc8905030 403 + ./.git/objects/23 404 + ./.git/objects/23/f56c7122758ebed362f40e98d4f6030659abb4 405 + ./.git/objects/23/52ab57fcf2e8a26f2bf625baf5b5bbfb831417 406 + ./.git/objects/23/b7b897cff7f35ae6566ce97c6c7c2590df15f2 407 + ./.git/objects/23/cb216300bc481ca8915b935e563f4d409199e1 408 + ./.git/objects/db 409 + ./.git/objects/db/06339ac988ad5c24e59b1e72038c9bc8dcc4d7 410 + ./.git/objects/db/1f143eeac8eeb55f3ef826718e1d6f915cc5f8 411 + ./.git/objects/f4 412 + ./.git/objects/f4/427b4d63bf1508f56f365c65e85280d1af5763 413 + ./.git/objects/f4/a591498b21a52c805a11509178fa5d0915f526 414 + ./.git/objects/f4/0c870089b85b6402c0a2243f740a1370c79286 415 + ./.git/objects/0e 416 + ./.git/objects/0e/189b2485f4535994863ca52a6420ec623f819d 417 + ./.git/objects/0e/e9b8159d8b6e430b82845f790cb54669e833f3 418 + ./.git/objects/0e/e16c90707c76e59789d809ab5fc41fc91f5f67 419 + ./.git/objects/0e/9d4bcf8f359d586197ff7e48bfb2662c0c0935 420 + ./.git/objects/d2 421 + ./.git/objects/d2/00c42d909a31c17dea48da932202860b406cf9 422 + ./.git/objects/d2/b9537b66981e8063b93ac516098a9ab07a531b 423 + ./.git/objects/2d 424 + ./.git/objects/2d/45d0f37ab6828e8531fbf86096bc9d8e895527 425 + ./.git/objects/2d/99122bb3539025961f0fda6ae664b7342b6b83 426 + ./.git/objects/2d/1e8b892f7ee580e10244ba83ac6cc89e7ba727 427 + ./.git/objects/2d/4b717bf8427170e5906538104c6d0fa4d630f0 428 + ./.git/objects/82 429 + ./.git/objects/82/56665942d2d563c29a09c8e8dd633014b4514b 430 + ./.git/objects/82/08d67320a0aff6533a4b7fac917ddc79f95418 431 + ./.git/objects/82/69e1621ff5621db953bb1e5c26ccc9141eb8b3 432 + ./.git/objects/0d 433 + ./.git/objects/0d/6a0b5fe6a1bafad0544e22510df8a62335a609 434 + ./.git/objects/0d/36a5901973e607b333be7b03ba47eea66dc403 435 + ./.git/objects/0d/42bacc3191f370f0f4bc276cd908061f9ac828 436 + ./.git/objects/0d/707ecbb8abf68b3ebfb525b63937f9c805cef1 437 + ./.git/objects/10 438 + ./.git/objects/10/48a1a8ae5742d323ae648c92a777d1d2d2015b 439 + ./.git/objects/59 440 + ./.git/objects/59/151f39243bb30f51e9dc7595311d93103d6eb4 441 + ./.git/objects/63 442 + ./.git/objects/63/9f63c06b29f39840edd73ad04cd3b8309204f0 443 + ./.git/objects/63/2775a8aa713d331205fa1d8c167e84ad9186cb 444 + ./.git/objects/5b 445 + ./.git/objects/5b/52231d17726d4ad4ea7994fe105eb81e9e9dd9 446 + ./.git/objects/14 447 + ./.git/objects/14/36d8a33498d27fa02e0f2e3c8862475bfacebd 448 + ./.git/objects/17 449 + ./.git/objects/17/662c8875023c93144ae394f2c76c8c3cda38a0 450 + ./.git/objects/17/54196f5997eef681179aedae446349ea1b8f95 451 + ./.git/objects/3e 452 + ./.git/objects/3e/997e9b6647df287339fcde654c42aa30505be4 453 + ./.git/objects/3e/cc46e96a32867bbe05b2290fc126ab93f85bcd 454 + ./.git/objects/56 455 + ./.git/objects/56/fd5d33c9c2bfaa8805dc058d7fde9152723a33 456 + ./.git/objects/56/f541e80ea129e6e064f8b43cacacb70e17953e 457 + ./.git/objects/bc 458 + ./.git/objects/bc/1bf84bbb65652f4b787dd7b446860a32c2e8ca 459 + ./.git/objects/bc/82b6b7fbd83ed55e18d675745ba2efb6239f5b 460 + ./.git/objects/8f 461 + ./.git/objects/8f/7dd0e6b24f8f93777152241f7891017c613e4e 462 + ./.git/objects/8f/a44135f287836c9c362922897cdf50c8abfb0a 463 + ./.git/objects/40 464 + ./.git/objects/40/953ed78adacbd5e220aad3cec4ac5e30b90bd8 465 + ./.git/objects/40/17069d256c4b4b46ace0a1d3a17ab474705571 466 + ./.git/objects/40/59ef7942ff3505c5ce73ce59f4a7bfd82ba6b9 467 + ./.git/objects/40/3ce1a8cdab4310a2e1867567be6e847f71efd9 468 + ./.git/objects/b2 469 + ./.git/objects/b2/6158a9e38f0450e55de2bcff275ceb5322c6ad 470 + ./.git/objects/b2/c32bc79af68feae3d4a621976396efe0820798 471 + ./.git/objects/9b 472 + ./.git/objects/9b/5e363c1cdd23d5c116b74644713ebc7fe73af4 473 + ./.git/objects/9b/e2d15472a28c004e57f8e223ed6d0141689f60 474 + ./.git/objects/29 475 + ./.git/objects/29/bc4dcda2ef8a866b6c44a8a86f06e38e3a486a 476 + ./.git/objects/29/e47e432042221c28bcf000f50ad6a08a75dbed 477 + ./.git/objects/29/2386fb0d6dca1127e6c05c2ecdba6e4a93cea7 478 + ./.git/objects/58 479 + ./.git/objects/58/ab0cfc01268a2ffd914ee9e62f9af1da78d178 480 + ./.git/objects/58/491745d53e90b2f018604a67a00e301c9dfdfd 481 + ./.git/objects/19 482 + ./.git/objects/19/1e9420d874de0715def8962f446e3aae2e05c7 483 + ./.git/objects/67 484 + ./.git/objects/67/96afd7d35321930d2c306f64c3ed4d72dfe482 485 + ./.git/objects/1c 486 + ./.git/objects/1c/9d91b14661081b506e4dee4daf78b1567e3323 487 + ./.git/objects/1c/3c0f6bc181c8c3904ad239102c183bfc5816d4 488 + ./.git/objects/4c 489 + ./.git/objects/4c/5a7864dd9e018485e98f98f84b706a5510ae30 490 + ./.git/objects/92 491 + ./.git/objects/92/36c995e938d2c12a9a49714b6258db02ae39c3 492 + ./.git/objects/92/7360fe2e74518ab716f01252c732a7269a7631 493 + ./.git/objects/92/d9903d9e8f6dc0216f8644be14fd733977dd79 494 + ./.git/objects/39 495 + ./.git/objects/39/7b5ce17fe342555c16de630d19ba1b4773fefd 496 + ./.git/objects/39/41aa48e3029a96c11c0f12f9e94043ec655815 497 + ./.git/objects/39/f544d4c59fd91822f5189ac7c70f6066bef54b 498 + ./.git/objects/6e 499 + ./.git/objects/6e/4bee91d25e88a35f0be2fc7a14552627915afe 500 + ./.git/objects/6e/2fab67530969884622b05d64c3d049465b5efa 501 + ./.git/objects/d7 502 + ./.git/objects/d7/775f3198f4dbbb284ac1d2bfbe0789f95bef26 503 + ./.git/objects/d7/b4d0ca5ca71281fdc77b49820272ddea245958 504 + ./.git/objects/4f 505 + ./.git/objects/4f/f6719cf0d54eddb41be1f095ceb9d272a92aae 506 + ./.git/objects/b0 507 + ./.git/objects/b0/4c7a44f9ab42e495553aa332bc80e3685021b8 508 + ./.git/objects/b0/4eb2c9a981a3a7459b0053d7b8436471066730 509 + ./.git/objects/fd 510 + ./.git/objects/fd/eb0e5a19478cca5377cb47fe41426975109205 511 + ./.git/objects/fd/cdf055082dc71e0f30f962578f214e6812631e 512 + ./.git/objects/fd/ff1ae9862d61a9e117e56b3548078193cbd078 513 + ./.git/objects/08 514 + ./.git/objects/08/2e3a2cb843392a72074b65718bc672f56835cd 515 + ./.git/objects/ec 516 + ./.git/objects/ec/5efce500afb6393d66da480b2b529a4f4f348d 517 + ./.git/objects/ec/6fc32ccaa7ee6a6f3e732578eb4c98817deb83 518 + ./.git/objects/16 519 + ./.git/objects/16/252d2718003ea39fa83a16a84db4fc616d73d8 520 + ./.git/objects/16/86d481b6ef09f351775a4dc1ce272c304df1ec 521 + ./.git/objects/2a 522 + ./.git/objects/2a/6f80a64c07b516b56c681e9d6e75598b43b207 523 + ./.git/objects/27 524 + ./.git/objects/27/045100d894b6044d1ae548948bdfa8b2b74874 525 + ./.git/objects/31 526 + ./.git/objects/31/9b57b742825237cdbd9b368d9cce7127be9775 527 + ./.git/objects/28 528 + ./.git/objects/28/77fdeda6264e50d9a6ec4cafa505de0507cbac 529 + ./.git/objects/28/7c7c56177b382323e8fb3b41db8e02d6b8bd1c 530 + ./.git/objects/28/bfeae2edb4cd27c3323cc44ada958aea2ec165 531 + ./.git/objects/64 532 + ./.git/objects/64/dbea3ab74738f8ee05cf874665a7c7181c5649 533 + ./.git/objects/9a 534 + ./.git/objects/9a/03b54f19d91702674f804179c0d86dc8f763f2 535 + ./.git/objects/34 536 + ./.git/objects/34/139b81408463cd1ce871a3e954bf062e1c9711 537 + ./.git/objects/34/912ecae4fdb5c0e898af5f0c5e2350dcad4cf0 538 + ./.git/objects/34/d776502fcdc7f0ccc2bd972e390133526b91a0 539 + ./.git/objects/7e 540 + ./.git/objects/7e/8a190738a7c9f6c5a6a520f817c85e41d02b46 541 + ./.git/objects/7e/b3436415d6bb988d8c0a533f4b7fc2f66491aa 542 + ./.git/objects/7f 543 + ./.git/objects/7f/423a93c268c328b5e161d986d4476e2cf4f571 544 + ./.git/objects/7f/c7ab857ad56796463f01c4f1cfc89e378ca221 545 + ./.git/objects/7f/10d6e0684b637206d6919b5956a1ac6ed37e49 546 + ./.git/objects/13 547 + ./.git/objects/13/4908aac9fe7db898b18a0a7e154072c1a3d7a2 548 + ./.git/objects/f9 549 + ./.git/objects/f9/85215f4f91d9cc3b848e56f78aa519ae49b5fa 550 + ./.git/objects/89 551 + ./.git/objects/89/abfc5bdc924ff5551bfaff18de67741966b15d 552 + ./.git/objects/89/1c6f722bff534ac88c0dde8e7e63454d199296 553 + ./.git/objects/89/735db4f10c18709ada2dc788a9743565f55388 554 + ./.git/objects/89/a9e26eeb0a3ffd689ab5e98e43a21a1c0a87ae 555 + ./.git/objects/89/855435ff72be41295f28ee57c2bee30202de47 556 + ./.git/objects/b1 557 + ./.git/objects/b1/c385a303bc2dd3b850b41a1ae0410af2c5786a 558 + ./.git/objects/b1/eefe4521c5ef85f8b779add575aecf58393ce5 559 + ./.git/objects/b1/bacc7a0b15fb01e09e1a59ee6e5bdfc2925b54 560 + ./.git/objects/b1/ec612772c1c2249e6af3e7ba77585ee5c13c58 561 + ./.git/objects/ff 562 + ./.git/objects/ff/3defee152ceda6082a9dc5040cd433c61efcf9 563 + ./.git/objects/ff/f440d7c7f9aad902701b385561ddc8b77f8fe3 564 + ./.git/objects/e5 565 + ./.git/objects/e5/3214c9e3cad529dc0d4dfb61b48f478bfbbd4c 566 + ./.git/objects/e5/f4ff38c22af8c8dc51a7c94b4f1fb83b6558e5 567 + ./.git/objects/e1 568 + ./.git/objects/e1/865c1c5fd94104ed9bacb4cd53adfcd83a9697 569 + ./.git/objects/7b 570 + ./.git/objects/7b/a0dbd949f60a1559d96d911cc33efc6939d01c 571 + ./.git/objects/7b/ea82ee2c4c1021b2e20ad5276414d1b4246c47 572 + ./.git/objects/3c 573 + ./.git/objects/3c/63515ea22b572d39b224cc508908853084b123 574 + ./.git/objects/8e 575 + ./.git/objects/8e/272b49dc5f3be82d469086ca9d3bed7253e70f 576 + ./.git/objects/8e/749d82d91ba0123f0bb4ebf646857049b8ef0c 577 + ./.git/objects/c9 578 + ./.git/objects/c9/df108c929b2e5a312cd86c704c090013039e69 579 + ./.git/objects/c9/e2566ac9d03be1f74c0ffb437998644dd60e02 580 + ./.git/objects/ab 581 + ./.git/objects/ab/52adec5fd340b834de7014d1f3471728801848 582 + ./.git/objects/ab/22631c8807eda2cb9fa48606aa58cbdb7dd1f4 583 + ./.git/objects/ab/0db94c4fba3033a1993b146fcb7d4e6fad191f 584 + ./.git/objects/6b 585 + ./.git/objects/6b/c97371f4936bd31bf71f37d410f67879d208fd 586 + ./.git/objects/6b/91cabb14b820197c4a396e195d6cf8dcc18eb3 587 + ./.git/objects/52 588 + ./.git/objects/52/9076f7a1acb9707376f59e0e1248c348867e34 589 + ./.git/objects/f1 590 + ./.git/objects/f1/84063fe783cae53b303f169c9af5bca7b0f82c 591 + ./.git/objects/f1/6282f7f2786e1f9f1130343dc8c94b0b6dbf9a 592 + ./.git/objects/77 593 + ./.git/objects/77/f0dc81400956ade5be5598af329b46c0fdeab9 594 + ./.git/objects/77/f3677d9db06f94d516209acdfc19569736cc9a 595 + ./.git/objects/77/b205d10b78dc1cc7b318d8ad3ef866f0b88435 596 + ./.git/objects/77/11a20542d388d93aa990522a45a432c2e5b61b 597 + ./.git/objects/00 598 + ./.git/objects/00/deef1c92d3b244f7392a54e2e0da3fcf73cccd 599 + ./.git/objects/aa 600 + ./.git/objects/aa/55b7f297a28c5663cb8051c5f4e5431150e36a 601 + ./.git/objects/aa/056834a4ab2e1d476b371a91206c396affa82b 602 + ./.git/objects/de 603 + ./.git/objects/de/11623e687555a843d60ecc3f0c70f550e98e3d 604 + ./.git/objects/de/19613e554cca5fab317d3605f5b0ad8a8f5711 605 + ./.git/objects/de/3effaea36556b96c74d86abf327517b289e3b7 606 + ./.git/objects/55 607 + ./.git/objects/55/04a585b2d05749a197cc648d4948585b002aeb 608 + ./.git/objects/55/5671ae38e662bc02b3e4f84af337732c725c41 609 + ./.git/objects/55/ac449d0e9a26a294d47152e964564bebf0cbb7 610 + ./.git/objects/55/1b2391f3cec5b8a7c6971bb6a4043f273eee8e 611 + ./.git/objects/69 612 + ./.git/objects/69/6bcb9994deb32a6198dbe7683bc43e33fa8a9f 613 + ./.git/objects/d6 614 + ./.git/objects/d6/c954feb40f1ee75fdcf00ca57f5c0d3d2e0f99 615 + ./.git/objects/d6/c49da67ff56cbfc86661c5dfffb3b144ed5eb0 616 + ./.git/objects/d6/811902b9ad236aad771ce776e1332736f7d88f 617 + ./.git/objects/2c 618 + ./.git/objects/2c/33e2d59e07e20924a9b25c6c737ad228ca9b0f 619 + ./.git/objects/2c/7cf5ed16ae8e4d7333984cbebaff7962b4eaef 620 + ./.git/objects/2c/6a5f8dd2ccd70f29683915413d5a7afb0c38e0 621 + ./.git/objects/2c/ea4a57dae3d943c974d35343fd14f857e4a537 622 + ./.git/objects/2c/90b9d946389975380bd8b96ab03a5c325ca355 623 + ./.git/objects/fb 624 + ./.git/objects/fb/143505c55d0b75752d2077621e7f6a057dbe0a 625 + ./.git/objects/0b 626 + ./.git/objects/0b/e9761371a503b2c6d83d8f7846543666377bab 627 + ./.git/objects/95 628 + ./.git/objects/95/26ddc2f80b69eb676be5908b863e221cc55311 629 + ./.git/objects/95/6fa5bf5ff46970f3646bb9d3a354587ce7a758 630 + ./.git/objects/95/d981e795f5c2beb635a3e70f3ddbfede70fbb8 631 + ./.git/objects/b8 632 + ./.git/objects/b8/b07af1a1bc02d22ca70807a2e4604ed94bca68 633 + ./.git/objects/65 634 + ./.git/objects/65/2752f82065b53bd9e241d3b1ee260dd0dc7787 635 + ./.git/objects/65/88c2c23bcac12f9692c2cd06480cee422c1c8d 636 + ./.git/objects/65/29f3b232b42e48a7ef1f935c765e60f34ef170 637 + ./.git/objects/65/b10e153969f46f3d80b866741c0151876da8e7 638 + ./.git/objects/65/964392595e262f0571912b5bacd9c999b002c4 639 + ./.git/objects/c7 640 + ./.git/objects/c7/7f3f64c1e9bfca7efb514ba08af74c9fae2885 641 + ./.git/objects/94 642 + ./.git/objects/94/87dd0b25009cbd8debaf3cb2edc383790677a5 643 + ./.git/objects/42 644 + ./.git/objects/42/f4ec8e259667b739c89b30684fa10b1dc8ea3d 645 + ./.git/objects/53 646 + ./.git/objects/53/27fba844b2bc564d0aa3f1e3eb930bac3fb032 647 + ./.git/objects/53/5ed8fc72b4b1e307dd19e89267438c4423db3a 648 + ./.git/objects/35 649 + ./.git/objects/35/deb323feeaf3ca7e9bc101029176e11734d199 650 + ./.git/objects/35/2afae96809d801c4b45997ee4431e5bb680ede 651 + ./.git/objects/35/fd399b11365e08ffbe39585abd3be44321c406 652 + ./.git/objects/35/d2c09301c92eab37e03723c505065e494e10d1 653 + ./.git/objects/35/cc754c3415cc8aad653e8b09af109fe391711a 654 + ./.git/objects/a1 655 + ./.git/objects/a1/6cb5eafaef7a2354723f9c54d400f8ee743818 656 + ./.git/objects/37 657 + ./.git/objects/37/581301a02ffae12602a136cad472ea76cbdb8d 658 + ./.git/objects/97 659 + ./.git/objects/97/26766d221f3303009799db3e7ea3bec6ed2cfe 660 + ./.git/objects/97/b4363d1844eda0f9979ff4734d54a160ea6064 661 + ./.git/objects/97/e8f520105d1f196900c45665086a68b569b7e8 662 + ./.git/objects/ba 663 + ./.git/objects/ba/cd1431be4d953a1388bbb2685601f8b66b6710 664 + ./.git/objects/e6 665 + ./.git/objects/e6/f4ae3427fdc975b344464f9437fd6e783cbc2d 666 + ./.git/objects/e6/1fa3ced7bb7e13d8ee87f4eac3d1f00cb30ccb 667 + ./.git/objects/e2 668 + ./.git/objects/e2/c6fe08e2c69707b9817a09375f099e1a93efc1 669 + ./.git/objects/b7 670 + ./.git/objects/b7/eab6d5e5b62a0a594a2b52998cecb5ec993800 671 + ./.git/objects/b7/306f863c71df9b62eb25319df5aa04de67d1ed 672 + ./.git/objects/b7/755aefc6109b0581f359cfef5050110780bdc5 673 + ./.git/objects/b7/6d3f36ede46cd4e3868631cd56d2f89ca420c0 674 + ./.git/objects/72 675 + ./.git/objects/72/f7b77e29f727976e5cef2bbf573ff3ed2be79f 676 + ./.git/objects/25 677 + ./.git/objects/25/0e21592a948efb3b81f3d325d5e6a92f7b57bb 678 + ./.git/objects/25/d7ba5250934e6ccf724f22997447dd929a992c 679 + ./.git/objects/93 680 + ./.git/objects/93/0be3835b8225191fc3e25bac75b46f59f1e4ec 681 + ./.git/objects/93/468fafb296570203c5ea7f53f3b0ca969b781b 682 + ./.git/objects/a7 683 + ./.git/objects/a7/665a4d00775a6736b3bf9251fd402ed5214b0a 684 + ./.git/objects/a7/eb3f631f1391d84d787c36d5d81f1db6d64ff4 685 + ./.git/objects/5f 686 + ./.git/objects/5f/2e350ec9cc6ed80e7ec93285d796b50ded711b 687 + ./.git/objects/6d 688 + ./.git/objects/6d/a9005dd1a094e5fdd61f98d55552c8ed25b758 689 + ./.git/objects/6d/d60283ba8de90e73c86a0a1b3a0262faa83ca9 690 + ./.git/objects/6d/0ea5ad50c394ef01a3691451aa546d2ad7aa3a 691 + ./.git/objects/4a 692 + ./.git/objects/4a/254c4789f8b2cfcfb690215dd3bf16774b060f 693 + ./.git/objects/4a/97cd73b86af93d38715655b2922602bf5effd6 694 + ./.git/objects/4a/91acf8a657f209e77074dea27f43dece276dd9 695 + ./.git/objects/12 696 + ./.git/objects/12/cd765ea7be32a73ea2ec12268ccc7a978dd975 697 + ./.git/objects/12/848fa310de1e10eb83f41ef8359b148f3ed74a 698 + ./.git/objects/12/0d81b2e9e89ed11a8c86fcaac0f19f44b5f4eb 699 + ./.git/objects/0c 700 + ./.git/objects/0c/caecffa9374685010200f29c869dce83ed02be 701 + ./.git/objects/fc 702 + ./.git/objects/fc/8440f85ef023184513b2b606ee6e0b40e5c6e9 703 + ./.git/objects/fc/986c42168c88cefaefd8a8201d4455b4205672 704 + ./.git/objects/fc/0781a4dc652c45cdf8122833f5f1638fe087ca 705 + ./.git/objects/0f 706 + ./.git/objects/0f/1f15d28a517a5dee0e6d81a1804c02380c26f3 707 + ./.git/objects/f0 708 + ./.git/objects/f0/0a2246063ebd8671cafe9983de72bbc6e45f4c 709 + ./.git/objects/96 710 + ./.git/objects/96/e4b97449ae85fad317880fe76a35207c9d419a 711 + ./.git/objects/96/67c6e2e8bfa8504c9af78bcfc698418349a3d1 712 + ./.git/objects/96/005d21f7fc36c9c9a8767c7b457e51730aa953 713 + ./.git/objects/4b 714 + ./.git/objects/4b/7bd2c810157b639d753ee04bafa89fd31d7c9e 715 + ./.git/objects/4b/7646b2252c04719e5b897e28f35510415a5a3a 716 + ./.git/description 717 + ./.git/config 718 + ./.git/index 719 + ./.git/ORIG_HEAD 720 + ./.git/refs 721 + ./.git/refs/remotes 722 + ./.git/refs/remotes/drup 723 + ./.git/refs/remotes/drup/master 724 + ./.git/refs/remotes/drup/rgrinberg-pp 725 + ./.git/refs/remotes/drup/no_exception 726 + ./.git/refs/remotes/origin 727 + ./.git/refs/remotes/origin/pp 728 + ./.git/refs/remotes/origin/master 729 + ./.git/refs/remotes/origin/re_automata-module-refactor 730 + ./.git/refs/remotes/origin/format-group 731 + ./.git/refs/remotes/origin/re_str-infinite-loop-fix 732 + ./.git/refs/remotes/origin/re_str-fixes 733 + ./.git/refs/remotes/origin/prepare-1.6.1 734 + ./.git/refs/remotes/origin/travis-403 735 + ./.git/refs/remotes/origin/benchmarks 736 + ./.git/refs/remotes/origin/HEAD 737 + ./.git/refs/remotes/origin/re-cleanups 738 + ./.git/refs/remotes/origin/exec-no-group 739 + ./.git/refs/remotes/origin/prepare-1.6.0 740 + ./.git/refs/remotes/origin/4.00-compat 741 + ./.git/refs/remotes/origin/labelize-match-str 742 + ./.git/refs/remotes/origin/status-lazy 743 + ./.git/refs/remotes/origin/dead-code-deriv 744 + ./.git/refs/remotes/gt 745 + ./.git/refs/remotes/gt/master 746 + ./.git/refs/heads 747 + ./.git/refs/heads/master 748 + ./.git/refs/heads/re_automata-module-refactor 749 + ./.git/refs/heads/re_cset-abstract 750 + ./.git/refs/heads/re_str-infinite-loop-fix 751 + ./.git/refs/heads/re_str-fixes 752 + ./.git/refs/heads/infinite-loop-cleanup 753 + ./.git/refs/heads/dev 754 + ./.git/refs/heads/re-cleanups 755 + ./.git/refs/heads/status-lazy 756 + ./.git/refs/heads/exec-no-group-with-bench 757 + ./.git/refs/heads/dead-code-deriv 758 + ./.git/refs/tags 759 + ./.git/refs/tags/1.3.0 760 + ./.git/refs/tags/1.1.0 761 + ./.git/refs/tags/1.2.2 762 + ./.git/refs/tags/1.6.1 763 + ./.git/refs/tags/1.2.0 764 + ./.git/refs/tags/1.6.0 765 + ./.git/refs/tags/1.3.2 766 + ./.git/refs/tags/1.3.1 767 + ./.git/refs/tags/1.2.1 768 + ./.git/refs/tags/1.5.0 769 + ./.git/refs/tags/1.0.0 770 + ./.git/refs/tags/1.4.1 771 + ./.git/HEAD 772 + ./.git/branches 773 + ./.git/info 774 + ./.git/info/exclude 775 + ./.git/FETCH_HEAD 776 + ./.git/logs 777 + ./.git/logs/refs 778 + ./.git/logs/refs/remotes 779 + ./.git/logs/refs/remotes/drup 780 + ./.git/logs/refs/remotes/drup/master 781 + ./.git/logs/refs/remotes/drup/rgrinberg-pp 782 + ./.git/logs/refs/remotes/drup/no_exception 783 + ./.git/logs/refs/remotes/origin 784 + ./.git/logs/refs/remotes/origin/pp 785 + ./.git/logs/refs/remotes/origin/master 786 + ./.git/logs/refs/remotes/origin/re_automata-module-refactor 787 + ./.git/logs/refs/remotes/origin/format-group 788 + ./.git/logs/refs/remotes/origin/re_str-infinite-loop-fix 789 + ./.git/logs/refs/remotes/origin/re_str-fixes 790 + ./.git/logs/refs/remotes/origin/prepare-1.6.1 791 + ./.git/logs/refs/remotes/origin/travis-403 792 + ./.git/logs/refs/remotes/origin/benchmarks 793 + ./.git/logs/refs/remotes/origin/HEAD 794 + ./.git/logs/refs/remotes/origin/re-cleanups 795 + ./.git/logs/refs/remotes/origin/exec-no-group 796 + ./.git/logs/refs/remotes/origin/prepare-1.6.0 797 + ./.git/logs/refs/remotes/origin/4.00-compat 798 + ./.git/logs/refs/remotes/origin/labelize-match-str 799 + ./.git/logs/refs/remotes/origin/status-lazy 800 + ./.git/logs/refs/remotes/origin/dead-code-deriv 801 + ./.git/logs/refs/remotes/gt 802 + ./.git/logs/refs/remotes/gt/master 803 + ./.git/logs/refs/heads 804 + ./.git/logs/refs/heads/master 805 + ./.git/logs/refs/heads/re_automata-module-refactor 806 + ./.git/logs/refs/heads/re_cset-abstract 807 + ./.git/logs/refs/heads/re_str-infinite-loop-fix 808 + ./.git/logs/refs/heads/re_str-fixes 809 + ./.git/logs/refs/heads/infinite-loop-cleanup 810 + ./.git/logs/refs/heads/dev 811 + ./.git/logs/refs/heads/re-cleanups 812 + ./.git/logs/refs/heads/status-lazy 813 + ./.git/logs/refs/heads/exec-no-group-with-bench 814 + ./.git/logs/refs/heads/dead-code-deriv 815 + ./.git/logs/HEAD 816 + ./.git/hooks 817 + ./.git/hooks/prepare-commit-msg.sample 818 + ./.git/hooks/pre-commit.sample 819 + ./.git/hooks/update.sample 820 + ./.git/hooks/pre-rebase.sample 821 + ./.git/hooks/pre-push.sample 822 + ./.git/hooks/pre-applypatch.sample 823 + ./.git/hooks/applypatch-msg.sample 824 + ./.git/hooks/post-update.sample 825 + ./.git/hooks/commit-msg.sample 826 + ./.git/packed-refs 827 + ./_build 828 + ./_build/oUnit-test_perl-rgcaml#02.log 829 + ./_build/oUnit-test_str.cache 830 + ./_build/lib 831 + ./_build/lib/re.a 832 + ./_build/lib/re_emacs.o 833 + ./_build/lib/re_glob.mllib 834 + ./_build/lib/re_posix.cmi 835 + ./_build/lib/re_str.cmi 836 + ./_build/lib/re_perl.cmx 837 + ./_build/lib/re_glob.cmi 838 + ./_build/lib/re.mli 839 + ./_build/lib/re_pcre.annot 840 + ./_build/lib/re_emacs.annot 841 + ./_build/lib/re_cset.ml 842 + ./_build/lib/re_fmt.o 843 + ./_build/lib/re_perl.mli.depends 844 + ./_build/lib/re_posix.cma 845 + ./_build/lib/re_perl.cmi 846 + ./_build/lib/re_glob.o 847 + ./_build/lib/re_str.cmti 848 + ./_build/lib/re_automata.ml 849 + ./_build/lib/re_str.mli.depends 850 + ./_build/lib/re.ml 851 + ./_build/lib/re_emacs.mli 852 + ./_build/lib/re_pcre.cmx 853 + ./_build/lib/re_perl.cmt 854 + ./_build/lib/re_posix.cmti 855 + ./_build/lib/re_glob.mldylib 856 + ./_build/lib/re_pcre.mli 857 + ./_build/lib/re.cmti 858 + ./_build/lib/re_emacs.mli.depends 859 + ./_build/lib/re_perl.a 860 + ./_build/lib/re_pcre.cmxa 861 + ./_build/lib/re_str.cmxa 862 + ./_build/lib/re_cset.ml.depends 863 + ./_build/lib/re_glob.cmxs 864 + ./_build/lib/re_pcre.a 865 + ./_build/lib/re_perl.mldylib 866 + ./_build/lib/re.cmxa 867 + ./_build/lib/re_pcre.cmo 868 + ./_build/lib/re_pcre.cmt 869 + ./_build/lib/re_str.annot 870 + ./_build/lib/re_posix.mli 871 + ./_build/lib/re_perl.mli 872 + ./_build/lib/re_cset.cmt 873 + ./_build/lib/re.mli.depends 874 + ./_build/lib/re.mldylib 875 + ./_build/lib/re_str.cmx 876 + ./_build/lib/re_pcre.o 877 + ./_build/lib/re_automata.cmo 878 + ./_build/lib/re_posix.mldylib 879 + ./_build/lib/re_automata.mli 880 + ./_build/lib/re_cset.annot 881 + ./_build/lib/re_fmt.cmt 882 + ./_build/lib/re_posix.a 883 + ./_build/lib/re_glob.ml 884 + ./_build/lib/re.cmxs 885 + ./_build/lib/re.cmi 886 + ./_build/lib/re_str.cmt 887 + ./_build/lib/re_pcre.cmxs 888 + ./_build/lib/re_pcre.mli.depends 889 + ./_build/lib/re_emacs.ml 890 + ./_build/lib/re_fmt.cmi 891 + ./_build/lib/re_perl.ml.depends 892 + ./_build/lib/re_emacs.cmxa 893 + ./_build/lib/re_pcre.mllib 894 + ./_build/lib/re.o 895 + ./_build/lib/re_pcre.cmi 896 + ./_build/lib/re_emacs.cmo 897 + ./_build/lib/re_glob.cma 898 + ./_build/lib/re_str.a 899 + ./_build/lib/re.cmt 900 + ./_build/lib/re_str.o 901 + ./_build/lib/re_cset.cmti 902 + ./_build/lib/re_posix.annot 903 + ./_build/lib/re.ml.depends 904 + ./_build/lib/re_posix.cmo 905 + ./_build/lib/re.annot 906 + ./_build/lib/re_automata.cmx 907 + ./_build/lib/re_perl.cma 908 + ./_build/lib/re_posix.cmx 909 + ./_build/lib/re_perl.annot 910 + ./_build/lib/re_glob.cmxa 911 + ./_build/lib/re_glob.mli 912 + ./_build/lib/re_cset.cmo 913 + ./_build/lib/re_cset.cmx 914 + ./_build/lib/re_glob.a 915 + ./_build/lib/re_cset.cmi 916 + ./_build/lib/re_str.mldylib 917 + ./_build/lib/re_pcre.cmti 918 + ./_build/lib/re_automata.mli.depends 919 + ./_build/lib/re.mllib 920 + ./_build/lib/re_posix.mllib 921 + ./_build/lib/re_emacs.cmxs 922 + ./_build/lib/re_fmt.annot 923 + ./_build/lib/re_emacs.cmt 924 + ./_build/lib/re_fmt.cmo 925 + ./_build/lib/re_pcre.ml 926 + ./_build/lib/re_glob.cmti 927 + ./_build/lib/re_glob.cmx 928 + ./_build/lib/re_posix.mli.depends 929 + ./_build/lib/re_emacs.cmti 930 + ./_build/lib/re_str.ml.depends 931 + ./_build/lib/re_automata.cmi 932 + ./_build/lib/re_emacs.mldylib 933 + ./_build/lib/re_pcre.cma 934 + ./_build/lib/re_glob.cmt 935 + ./_build/lib/re_pcre.ml.depends 936 + ./_build/lib/re_posix.cmxs 937 + ./_build/lib/re_automata.annot 938 + ./_build/lib/re_emacs.a 939 + ./_build/lib/re_posix.cmxa 940 + ./_build/lib/re_pcre.mldylib 941 + ./_build/lib/re_cset.mli 942 + ./_build/lib/re_str.cmxs 943 + ./_build/lib/re_posix.o 944 + ./_build/lib/re_emacs.mllib 945 + ./_build/lib/re_perl.cmo 946 + ./_build/lib/re_cset.mli.depends 947 + ./_build/lib/re_str.mli 948 + ./_build/lib/re_glob.ml.depends 949 + ./_build/lib/re_posix.cmt 950 + ./_build/lib/re_perl.o 951 + ./_build/lib/re_str.cma 952 + ./_build/lib/re.cma 953 + ./_build/lib/re_emacs.cmx 954 + ./_build/lib/re_fmt.cmx 955 + ./_build/lib/re_str.cmo 956 + ./_build/lib/re_glob.annot 957 + ./_build/lib/re_perl.cmti 958 + ./_build/lib/re_perl.ml 959 + ./_build/lib/re_perl.cmxs 960 + ./_build/lib/re.cmo 961 + ./_build/lib/re_fmt.ml.depends 962 + ./_build/lib/re_posix.ml.depends 963 + ./_build/lib/re_automata.ml.depends 964 + ./_build/lib/re_fmt.ml 965 + ./_build/lib/re_perl.mllib 966 + ./_build/lib/re_glob.mli.depends 967 + ./_build/lib/re_emacs.cmi 968 + ./_build/lib/re.cmx 969 + ./_build/lib/re_emacs.ml.depends 970 + ./_build/lib/re_automata.o 971 + ./_build/lib/re_posix.ml 972 + ./_build/lib/re_perl.cmxa 973 + ./_build/lib/re_str.ml 974 + ./_build/lib/re_cset.o 975 + ./_build/lib/re_glob.cmo 976 + ./_build/lib/re_str.mllib 977 + ./_build/lib/re_emacs.cma 978 + ./_build/lib/re_automata.cmt 979 + ./_build/lib/re_automata.cmti 980 + ./_build/oUnit-test_perl-rgcaml#01.log 981 + ./_build/lib_test 982 + ./_build/lib_test/test_glob.ml.depends 983 + ./_build/lib_test/test_emacs.cmo 984 + ./_build/lib_test/test_glob.cmt 985 + ./_build/lib_test/test_easy.ml 986 + ./_build/lib_test/test_str.cmi 987 + ./_build/lib_test/re_match.native 988 + ./_build/lib_test/test_emacs.ml 989 + ./_build/lib_test/test_glob.cmo 990 + ./_build/lib_test/test_pcre.cmt 991 + ./_build/lib_test/re_match.ml 992 + ./_build/lib_test/re_match.cmo 993 + ./_build/lib_test/test_pcre.cmi 994 + ./_build/lib_test/fort_unit.cmxa 995 + ./_build/lib_test/fort_unit.cmo 996 + ./_build/lib_test/re_match.o 997 + ./_build/lib_test/test_pcre.cmx 998 + ./_build/lib_test/re_match.ml.depends 999 + ./_build/lib_test/fort_unit.cmt 1000 + ./_build/lib_test/test_glob.ml 1001 + ./_build/lib_test/test_str.o 1002 + ./_build/lib_test/test_perl.native 1003 + ./_build/lib_test/re_match.cmx 1004 + ./_build/lib_test/fort_unit.mllib 1005 + ./_build/lib_test/test_perl.ml 1006 + ./_build/lib_test/test_perl.annot 1007 + ./_build/lib_test/fort_unit.ml 1008 + ./_build/lib_test/test_re.native 1009 + ./_build/lib_test/test_perl.cmt 1010 + ./_build/lib_test/test_emacs.o 1011 + ./_build/lib_test/test_easy.cmi 1012 + ./_build/lib_test/test_pcre.o 1013 + ./_build/lib_test/test_emacs.ml.depends 1014 + ./_build/lib_test/test_emacs.cmx 1015 + ./_build/lib_test/test_str.cmo 1016 + ./_build/lib_test/test_perl.cmx 1017 + ./_build/lib_test/fort_unit.mldylib 1018 + ./_build/lib_test/re_match.cmt 1019 + ./_build/lib_test/test_pcre.cmo 1020 + ./_build/lib_test/test_easy.cmo 1021 + ./_build/lib_test/fort_unit.cma 1022 + ./_build/lib_test/test_str.cmx 1023 + ./_build/lib_test/test_easy.cmx 1024 + ./_build/lib_test/test_pcre.native 1025 + ./_build/lib_test/test_emacs.cmt 1026 + ./_build/lib_test/fort_unit.o 1027 + ./_build/lib_test/fort_unit.cmx 1028 + ./_build/lib_test/test_re.cmo 1029 + ./_build/lib_test/test_glob.cmi 1030 + ./_build/lib_test/fort_unit.a 1031 + ./_build/lib_test/test_easy.annot 1032 + ./_build/lib_test/re_match.annot 1033 + ./_build/lib_test/test_emacs.native 1034 + ./_build/lib_test/test_emacs.annot 1035 + ./_build/lib_test/test_re.cmx 1036 + ./_build/lib_test/fort_unit.annot 1037 + ./_build/lib_test/test_re.cmi 1038 + ./_build/lib_test/test_emacs.cmi 1039 + ./_build/lib_test/test_perl.cmo 1040 + ./_build/lib_test/test_re.annot 1041 + ./_build/lib_test/test_easy.native 1042 + ./_build/lib_test/test_pcre.annot 1043 + ./_build/lib_test/test_glob.native 1044 + ./_build/lib_test/test_glob.cmx 1045 + ./_build/lib_test/test_str.cmt 1046 + ./_build/lib_test/test_re.cmt 1047 + ./_build/lib_test/test_re.ml.depends 1048 + ./_build/lib_test/test_pcre.ml 1049 + ./_build/lib_test/test_glob.o 1050 + ./_build/lib_test/fort_unit.ml.depends 1051 + ./_build/lib_test/test_easy.o 1052 + ./_build/lib_test/test_perl.cmi 1053 + ./_build/lib_test/fort_unit.cmi 1054 + ./_build/lib_test/test_pcre.ml.depends 1055 + ./_build/lib_test/test_perl.ml.depends 1056 + ./_build/lib_test/re_match.cmi 1057 + ./_build/lib_test/test_str.ml.depends 1058 + ./_build/lib_test/fort_unit.cmxs 1059 + ./_build/lib_test/test_re.o 1060 + ./_build/lib_test/test_str.annot 1061 + ./_build/lib_test/test_easy.ml.depends 1062 + ./_build/lib_test/test_str.ml 1063 + ./_build/lib_test/test_str.native 1064 + ./_build/lib_test/test_re.ml 1065 + ./_build/lib_test/test_glob.annot 1066 + ./_build/lib_test/test_easy.cmt 1067 + ./_build/lib_test/test_perl.o 1068 + ./_build/_digests 1069 + ./_build/oUnit-test_emacs-rgcaml#02.log 1070 + ./_build/benchmarks 1071 + ./_build/benchmarks/benchmark.cmt 1072 + ./_build/benchmarks/benchmark.cmx 1073 + ./_build/benchmarks/benchmark.ml 1074 + ./_build/benchmarks/benchmark.cmi 1075 + ./_build/benchmarks/benchmark.cmo 1076 + ./_build/benchmarks/benchmark.ml.depends 1077 + ./_build/benchmarks/benchmark.native 1078 + ./_build/benchmarks/benchmark.annot 1079 + ./_build/benchmarks/benchmark.o 1080 + ./_build/myocamlbuild.cmi 1081 + ./_build/oUnit-test_re.cache 1082 + ./_build/oUnit-test_re-rgcaml#02.log 1083 + ./_build/myocamlbuild.cmx 1084 + ./_build/_log 1085 + ./_build/ocamlc.where 1086 + ./_build/oUnit-test_emacs-rgcaml#00.log 1087 + ./_build/oUnit-test_emacs-rgcaml#01.log 1088 + ./_build/oUnit-test_perl-rgcaml#00.log 1089 + ./_build/oUnit-test_perl.cache 1090 + ./_build/oUnit-test_str-rgcaml#01.log 1091 + ./_build/oUnit-test_str-rgcaml#00.log 1092 + ./_build/oUnit-test_re-rgcaml#00.log 1093 + ./_build/oUnit-anon.cache 1094 + ./_build/myocamlbuild.o 1095 + ./_build/oUnit-test_emacs.cache 1096 + ./_build/oUnit-test_str-rgcaml#02.log 1097 + ./_build/myocamlbuild 1098 + ./_build/oUnit-test_re-rgcaml#01.log 1099 + ./_build/myocamlbuild.ml 1100 + ./setup.log 1101 + ./.travis.yml 1102 + ./_tags 1103 + ./test_pcre.native 1104 + ./LICENSE 1105 + ./test_emacs.native 1106 + ./README.md 1107 + ./TODO.txt 1108 + ./test_easy.native 1109 + ./benchmark.native 1110 + ./test_glob.native 1111 + ./tags 1112 + ./dev.org 1113 + ./INSTALL 1114 + ./configure 1115 + ./Makefile 1116 + ./CHANGES 1117 + ./opam 1118 + ./test_str.native 1119 + ./myocamlbuild.ml 1120 + ./compare.pl
+494
vendor/opam/re/benchmarks/http-requests.txt
··· 1 + GET / HTTP/1.1 2 + Host: www.reddit.com 3 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 4 + Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 5 + Accept-Language: en-us,en;q=0.5 6 + Accept-Encoding: gzip, deflate 7 + Connection: keep-alive 8 + 9 + GET /reddit.v_EZwRzV-Ns.css HTTP/1.1 10 + Host: www.redditstatic.com 11 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 12 + Accept: text/css,*/*;q=0.1 13 + Accept-Language: en-us,en;q=0.5 14 + Accept-Encoding: gzip, deflate 15 + Connection: keep-alive 16 + Referer: http://www.reddit.com/ 17 + 18 + GET /reddit-init.en-us.O1zuMqOOQvY.js HTTP/1.1 19 + Host: www.redditstatic.com 20 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 21 + Accept: */* 22 + Accept-Language: en-us,en;q=0.5 23 + Accept-Encoding: gzip, deflate 24 + Connection: keep-alive 25 + Referer: http://www.reddit.com/ 26 + 27 + GET /reddit.en-us.31yAfSoTsfo.js HTTP/1.1 28 + Host: www.redditstatic.com 29 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 30 + Accept: */* 31 + Accept-Language: en-us,en;q=0.5 32 + Accept-Encoding: gzip, deflate 33 + Connection: keep-alive 34 + Referer: http://www.reddit.com/ 35 + 36 + GET /kill.png HTTP/1.1 37 + Host: www.redditstatic.com 38 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 39 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 40 + Accept-Language: en-us,en;q=0.5 41 + Accept-Encoding: gzip, deflate 42 + Connection: keep-alive 43 + Referer: http://www.reddit.com/ 44 + 45 + GET /icon.png HTTP/1.1 46 + Host: www.redditstatic.com 47 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 48 + Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 49 + Accept-Language: en-us,en;q=0.5 50 + Accept-Encoding: gzip, deflate 51 + Connection: keep-alive 52 + 53 + GET /favicon.ico HTTP/1.1 54 + Host: www.redditstatic.com 55 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 56 + Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 57 + Accept-Language: en-us,en;q=0.5 58 + Accept-Encoding: gzip, deflate 59 + Connection: keep-alive 60 + 61 + GET /AMZM4CWd6zstSC8y.jpg HTTP/1.1 62 + Host: b.thumbs.redditmedia.com 63 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 64 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 65 + Accept-Language: en-us,en;q=0.5 66 + Accept-Encoding: gzip, deflate 67 + Connection: keep-alive 68 + Referer: http://www.reddit.com/ 69 + 70 + GET /jz1d5Nm0w97-YyNm.jpg HTTP/1.1 71 + Host: b.thumbs.redditmedia.com 72 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 73 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 74 + Accept-Language: en-us,en;q=0.5 75 + Accept-Encoding: gzip, deflate 76 + Connection: keep-alive 77 + Referer: http://www.reddit.com/ 78 + 79 + GET /aWGO99I6yOcNUKXB.jpg HTTP/1.1 80 + Host: a.thumbs.redditmedia.com 81 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 82 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 83 + Accept-Language: en-us,en;q=0.5 84 + Accept-Encoding: gzip, deflate 85 + Connection: keep-alive 86 + Referer: http://www.reddit.com/ 87 + 88 + GET /rZ_rD5TjrJM0E9Aj.css HTTP/1.1 89 + Host: e.thumbs.redditmedia.com 90 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 91 + Accept: text/css,*/*;q=0.1 92 + Accept-Language: en-us,en;q=0.5 93 + Accept-Encoding: gzip, deflate 94 + Connection: keep-alive 95 + Referer: http://www.reddit.com/ 96 + 97 + GET /tmsPwagFzyTvrGRx.jpg HTTP/1.1 98 + Host: a.thumbs.redditmedia.com 99 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 100 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 101 + Accept-Language: en-us,en;q=0.5 102 + Accept-Encoding: gzip, deflate 103 + Connection: keep-alive 104 + Referer: http://www.reddit.com/ 105 + 106 + GET /KYgUaLvXCK3TCEJx.jpg HTTP/1.1 107 + Host: a.thumbs.redditmedia.com 108 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 109 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 110 + Accept-Language: en-us,en;q=0.5 111 + Accept-Encoding: gzip, deflate 112 + Connection: keep-alive 113 + Referer: http://www.reddit.com/ 114 + 115 + GET /81pzxT5x2ozuEaxX.jpg HTTP/1.1 116 + Host: e.thumbs.redditmedia.com 117 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 118 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 119 + Accept-Language: en-us,en;q=0.5 120 + Accept-Encoding: gzip, deflate 121 + Connection: keep-alive 122 + Referer: http://www.reddit.com/ 123 + 124 + GET /MFqCUiUVPO5V8t6x.jpg HTTP/1.1 125 + Host: a.thumbs.redditmedia.com 126 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 127 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 128 + Accept-Language: en-us,en;q=0.5 129 + Accept-Encoding: gzip, deflate 130 + Connection: keep-alive 131 + Referer: http://www.reddit.com/ 132 + 133 + GET /TFpYTiAO5aEowokv.jpg HTTP/1.1 134 + Host: e.thumbs.redditmedia.com 135 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 136 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 137 + Accept-Language: en-us,en;q=0.5 138 + Accept-Encoding: gzip, deflate 139 + Connection: keep-alive 140 + Referer: http://www.reddit.com/ 141 + 142 + GET /eMWMpmm9APNeNqcF.jpg HTTP/1.1 143 + Host: e.thumbs.redditmedia.com 144 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 145 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 146 + Accept-Language: en-us,en;q=0.5 147 + Accept-Encoding: gzip, deflate 148 + Connection: keep-alive 149 + Referer: http://www.reddit.com/ 150 + 151 + GET /S-IpsJrOKuaK9GZ8.jpg HTTP/1.1 152 + Host: c.thumbs.redditmedia.com 153 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 154 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 155 + Accept-Language: en-us,en;q=0.5 156 + Accept-Encoding: gzip, deflate 157 + Connection: keep-alive 158 + Referer: http://www.reddit.com/ 159 + 160 + GET /3V6dj9PDsNnheDXn.jpg HTTP/1.1 161 + Host: c.thumbs.redditmedia.com 162 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 163 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 164 + Accept-Language: en-us,en;q=0.5 165 + Accept-Encoding: gzip, deflate 166 + Connection: keep-alive 167 + Referer: http://www.reddit.com/ 168 + 169 + GET /wQ3-VmNXhv8sg4SJ.jpg HTTP/1.1 170 + Host: c.thumbs.redditmedia.com 171 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 172 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 173 + Accept-Language: en-us,en;q=0.5 174 + Accept-Encoding: gzip, deflate 175 + Connection: keep-alive 176 + Referer: http://www.reddit.com/ 177 + 178 + GET /ixd1C1njpczEWC22.jpg HTTP/1.1 179 + Host: c.thumbs.redditmedia.com 180 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 181 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 182 + Accept-Language: en-us,en;q=0.5 183 + Accept-Encoding: gzip, deflate 184 + Connection: keep-alive 185 + Referer: http://www.reddit.com/ 186 + 187 + GET /nGsQj15VyOHMwmq8.jpg HTTP/1.1 188 + Host: c.thumbs.redditmedia.com 189 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 190 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 191 + Accept-Language: en-us,en;q=0.5 192 + Accept-Encoding: gzip, deflate 193 + Connection: keep-alive 194 + Referer: http://www.reddit.com/ 195 + 196 + GET /zT4yQmDxQLbIxK1b.jpg HTTP/1.1 197 + Host: c.thumbs.redditmedia.com 198 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 199 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 200 + Accept-Language: en-us,en;q=0.5 201 + Accept-Encoding: gzip, deflate 202 + Connection: keep-alive 203 + Referer: http://www.reddit.com/ 204 + 205 + GET /L5e1HcZLv1iu4nrG.jpg HTTP/1.1 206 + Host: f.thumbs.redditmedia.com 207 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 208 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 209 + Accept-Language: en-us,en;q=0.5 210 + Accept-Encoding: gzip, deflate 211 + Connection: keep-alive 212 + Referer: http://www.reddit.com/ 213 + 214 + GET /WJFFPxD8X4JO_lIG.jpg HTTP/1.1 215 + Host: f.thumbs.redditmedia.com 216 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 217 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 218 + Accept-Language: en-us,en;q=0.5 219 + Accept-Encoding: gzip, deflate 220 + Connection: keep-alive 221 + Referer: http://www.reddit.com/ 222 + 223 + GET /hVMVTDdjuY3bQox5.jpg HTTP/1.1 224 + Host: f.thumbs.redditmedia.com 225 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 226 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 227 + Accept-Language: en-us,en;q=0.5 228 + Accept-Encoding: gzip, deflate 229 + Connection: keep-alive 230 + Referer: http://www.reddit.com/ 231 + 232 + GET /rnWf8CjBcyPQs5y_.jpg HTTP/1.1 233 + Host: f.thumbs.redditmedia.com 234 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 235 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 236 + Accept-Language: en-us,en;q=0.5 237 + Accept-Encoding: gzip, deflate 238 + Connection: keep-alive 239 + Referer: http://www.reddit.com/ 240 + 241 + GET /gZJL1jNylKbGV4d-.jpg HTTP/1.1 242 + Host: d.thumbs.redditmedia.com 243 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 244 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 245 + Accept-Language: en-us,en;q=0.5 246 + Accept-Encoding: gzip, deflate 247 + Connection: keep-alive 248 + Referer: http://www.reddit.com/ 249 + 250 + GET /aNd2zNRLXiMnKUFh.jpg HTTP/1.1 251 + Host: c.thumbs.redditmedia.com 252 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 253 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 254 + Accept-Language: en-us,en;q=0.5 255 + Accept-Encoding: gzip, deflate 256 + Connection: keep-alive 257 + Referer: http://www.reddit.com/ 258 + 259 + GET /droparrowgray.gif HTTP/1.1 260 + Host: www.redditstatic.com 261 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 262 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 263 + Accept-Language: en-us,en;q=0.5 264 + Accept-Encoding: gzip, deflate 265 + Connection: keep-alive 266 + Referer: http://www.redditstatic.com/reddit.v_EZwRzV-Ns.css 267 + 268 + GET /sprite-reddit.an0Lnf61Ap4.png HTTP/1.1 269 + Host: www.redditstatic.com 270 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 271 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 272 + Accept-Language: en-us,en;q=0.5 273 + Accept-Encoding: gzip, deflate 274 + Connection: keep-alive 275 + Referer: http://www.redditstatic.com/reddit.v_EZwRzV-Ns.css 276 + 277 + GET /ga.js HTTP/1.1 278 + Host: www.google-analytics.com 279 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 280 + Accept: */* 281 + Accept-Language: en-us,en;q=0.5 282 + Accept-Encoding: gzip, deflate 283 + Connection: keep-alive 284 + Referer: http://www.reddit.com/ 285 + If-Modified-Since: Tue, 29 Oct 2013 19:33:51 GMT 286 + 287 + GET /reddit/ads.html?sr=-reddit.com&bust2 HTTP/1.1 288 + Host: static.adzerk.net 289 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 290 + Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 291 + Accept-Language: en-us,en;q=0.5 292 + Accept-Encoding: gzip, deflate 293 + Connection: keep-alive 294 + Referer: http://www.reddit.com/ 295 + 296 + GET /pixel/of_destiny.png?v=hOlmDALJCWWdjzfBV4ZxJPmrdCLWB%2Ftq7Z%2Ffp4Q%2FxXbVPPREuMJMVGzKraTuhhNWxCCwi6yFEZg%3D&r=783333388 HTTP/1.1 297 + Host: pixel.redditmedia.com 298 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 299 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 300 + Accept-Language: en-us,en;q=0.5 301 + Accept-Encoding: gzip, deflate 302 + Connection: keep-alive 303 + Referer: http://www.reddit.com/ 304 + 305 + GET /UNcO-h_QcS9PD-Gn.jpg HTTP/1.1 306 + Host: c.thumbs.redditmedia.com 307 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 308 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 309 + Accept-Language: en-us,en;q=0.5 310 + Accept-Encoding: gzip, deflate 311 + Connection: keep-alive 312 + Referer: http://e.thumbs.redditmedia.com/rZ_rD5TjrJM0E9Aj.css 313 + 314 + GET /welcome-lines.png HTTP/1.1 315 + Host: www.redditstatic.com 316 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 317 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 318 + Accept-Language: en-us,en;q=0.5 319 + Accept-Encoding: gzip, deflate 320 + Connection: keep-alive 321 + Referer: http://www.redditstatic.com/reddit.v_EZwRzV-Ns.css 322 + 323 + GET /welcome-upvote.png HTTP/1.1 324 + Host: www.redditstatic.com 325 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 326 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 327 + Accept-Language: en-us,en;q=0.5 328 + Accept-Encoding: gzip, deflate 329 + Connection: keep-alive 330 + Referer: http://www.redditstatic.com/reddit.v_EZwRzV-Ns.css 331 + 332 + GET /__utm.gif?utmwv=5.5.1&utms=1&utmn=720496082&utmhn=www.reddit.com&utme=8(site*srpath*usertype*uitype)9(%20reddit.com*%20reddit.com-GET_listing*guest*web)11(3!2)&utmcs=UTF-8&utmsr=2560x1600&utmvp=1288x792&utmsc=24-bit&utmul=en-us&utmje=1&utmfl=13.0%20r0&utmdt=reddit%3A%20the%20front%20page%20of%20the%20internet&utmhid=2129416330&utmr=-&utmp=%2F&utmht=1400862512705&utmac=UA-12131688-1&utmcc=__utma%3D55650728.585571751.1400862513.1400862513.1400862513.1%3B%2B__utmz%3D55650728.1400862513.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=qR~ HTTP/1.1 333 + Host: www.google-analytics.com 334 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 335 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 336 + Accept-Language: en-us,en;q=0.5 337 + Accept-Encoding: gzip, deflate 338 + Connection: keep-alive 339 + Referer: http://www.reddit.com/ 340 + 341 + GET /ImnpOQhbXUPkwceN.png HTTP/1.1 342 + Host: a.thumbs.redditmedia.com 343 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 344 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 345 + Accept-Language: en-us,en;q=0.5 346 + Accept-Encoding: gzip, deflate 347 + Connection: keep-alive 348 + Referer: http://www.reddit.com/ 349 + 350 + GET /ajax/libs/jquery/1.7.1/jquery.min.js HTTP/1.1 351 + Host: ajax.googleapis.com 352 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 353 + Accept: */* 354 + Accept-Language: en-us,en;q=0.5 355 + Accept-Encoding: gzip, deflate 356 + Connection: keep-alive 357 + Referer: http://static.adzerk.net/reddit/ads.html?sr=-reddit.com&bust2 358 + 359 + GET /__utm.gif?utmwv=5.5.1&utms=2&utmn=1493472678&utmhn=www.reddit.com&utmt=event&utme=5(AdBlock*enabled*false)(0)8(site*srpath*usertype*uitype)9(%20reddit.com*%20reddit.com-GET_listing*guest*web)11(3!2)&utmcs=UTF-8&utmsr=2560x1600&utmvp=1288x792&utmsc=24-bit&utmul=en-us&utmje=1&utmfl=13.0%20r0&utmdt=reddit%3A%20the%20front%20page%20of%20the%20internet&utmhid=2129416330&utmr=-&utmp=%2F&utmht=1400862512708&utmac=UA-12131688-1&utmni=1&utmcc=__utma%3D55650728.585571751.1400862513.1400862513.1400862513.1%3B%2B__utmz%3D55650728.1400862513.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=6R~ HTTP/1.1 360 + Host: www.google-analytics.com 361 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 362 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 363 + Accept-Language: en-us,en;q=0.5 364 + Accept-Encoding: gzip, deflate 365 + Connection: keep-alive 366 + Referer: http://www.reddit.com/ 367 + 368 + GET /ados.js?q=43 HTTP/1.1 369 + Host: secure.adzerk.net 370 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 371 + Accept: */* 372 + Accept-Language: en-us,en;q=0.5 373 + Accept-Encoding: gzip, deflate 374 + Connection: keep-alive 375 + Referer: http://static.adzerk.net/reddit/ads.html?sr=-reddit.com&bust2 376 + 377 + GET /fetch-trackers?callback=jQuery111005268222517967478_1400862512407&ids%5B%5D=t3_25jzeq-t8_k2ii&_=1400862512408 HTTP/1.1 378 + Host: tracker.redditmedia.com 379 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 380 + Accept: */* 381 + Accept-Language: en-us,en;q=0.5 382 + Accept-Encoding: gzip, deflate 383 + Connection: keep-alive 384 + Referer: http://www.reddit.com/ 385 + 386 + GET /ados?t=1400862512892&request={%22Placements%22:[{%22A%22:5146,%22S%22:24950,%22D%22:%22main%22,%22AT%22:5},{%22A%22:5146,%22S%22:24950,%22D%22:%22sponsorship%22,%22AT%22:8}],%22Keywords%22:%22-reddit.com%22,%22Referrer%22:%22http%3A%2F%2Fwww.reddit.com%2F%22,%22IsAsync%22:true,%22WriteResults%22:true} HTTP/1.1 387 + Host: engine.adzerk.net 388 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 389 + Accept: */* 390 + Accept-Language: en-us,en;q=0.5 391 + Accept-Encoding: gzip, deflate 392 + Connection: keep-alive 393 + Referer: http://static.adzerk.net/reddit/ads.html?sr=-reddit.com&bust2 394 + 395 + GET /pixel/of_doom.png?id=t3_25jzeq-t8_k2ii&hash=da31d967485cdbd459ce1e9a5dde279fef7fc381&r=1738649500 HTTP/1.1 396 + Host: pixel.redditmedia.com 397 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 398 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 399 + Accept-Language: en-us,en;q=0.5 400 + Accept-Encoding: gzip, deflate 401 + Connection: keep-alive 402 + Referer: http://www.reddit.com/ 403 + 404 + GET /Extensions/adFeedback.js HTTP/1.1 405 + Host: static.adzrk.net 406 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 407 + Accept: */* 408 + Accept-Language: en-us,en;q=0.5 409 + Accept-Encoding: gzip, deflate 410 + Connection: keep-alive 411 + Referer: http://static.adzerk.net/reddit/ads.html?sr=-reddit.com&bust2 412 + 413 + GET /Extensions/adFeedback.css HTTP/1.1 414 + Host: static.adzrk.net 415 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 416 + Accept: text/css,*/*;q=0.1 417 + Accept-Language: en-us,en;q=0.5 418 + Accept-Encoding: gzip, deflate 419 + Connection: keep-alive 420 + Referer: http://static.adzerk.net/reddit/ads.html?sr=-reddit.com&bust2 421 + 422 + GET /reddit/ads-load.html?bust2 HTTP/1.1 423 + Host: static.adzerk.net 424 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 425 + Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 426 + Accept-Language: en-us,en;q=0.5 427 + Accept-Encoding: gzip, deflate 428 + Connection: keep-alive 429 + Referer: http://www.reddit.com/ 430 + 431 + GET /Advertisers/a774d7d6148046efa89403a8db635a81.jpg HTTP/1.1 432 + Host: static.adzerk.net 433 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 434 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 435 + Accept-Language: en-us,en;q=0.5 436 + Accept-Encoding: gzip, deflate 437 + Connection: keep-alive 438 + Referer: http://static.adzerk.net/reddit/ads.html?sr=-reddit.com&bust2 439 + 440 + GET /i.gif?e=eyJhdiI6NjIzNTcsImF0Ijo1LCJjbSI6MTE2MzUxLCJjaCI6Nzk4NCwiY3IiOjMzNzAxNSwiZGkiOiI4NmI2Y2UzYWM5NDM0MjhkOTk2ZTg4MjYwZDE5ZTE1YyIsImRtIjoxLCJmYyI6NDE2MTI4LCJmbCI6MjEwNDY0LCJrdyI6Ii1yZWRkaXQuY29tIiwibWsiOiItcmVkZGl0LmNvbSIsIm53Ijo1MTQ2LCJwYyI6MCwicHIiOjIwMzYyLCJydCI6MSwicmYiOiJodHRwOi8vd3d3LnJlZGRpdC5jb20vIiwic3QiOjI0OTUwLCJ1ayI6InVlMS01ZWIwOGFlZWQ5YTc0MDFjOTE5NWNiOTMzZWI3Yzk2NiIsInRzIjoxNDAwODYyNTkzNjQ1fQ&s=lwlbFf2Uywt7zVBFRj_qXXu7msY HTTP/1.1 441 + Host: engine.adzerk.net 442 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 443 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 444 + Accept-Language: en-us,en;q=0.5 445 + Accept-Encoding: gzip, deflate 446 + Connection: keep-alive 447 + Referer: http://static.adzerk.net/reddit/ads.html?sr=-reddit.com&bust2 448 + Cookie: azk=ue1-5eb08aeed9a7401c9195cb933eb7c966 449 + 450 + GET /BurstingPipe/adServer.bs?cn=tf&c=19&mc=imp&pli=9994987&PluID=0&ord=1400862593644&rtu=-1 HTTP/1.1 451 + Host: bs.serving-sys.com 452 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 453 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 454 + Accept-Language: en-us,en;q=0.5 455 + Accept-Encoding: gzip, deflate 456 + Connection: keep-alive 457 + Referer: http://static.adzerk.net/reddit/ads.html?sr=-reddit.com&bust2 458 + 459 + GET /Advertisers/63cfd0044ffd49c0a71a6626f7a1d8f0.jpg HTTP/1.1 460 + Host: static.adzerk.net 461 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 462 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 463 + Accept-Language: en-us,en;q=0.5 464 + Accept-Encoding: gzip, deflate 465 + Connection: keep-alive 466 + Referer: http://static.adzerk.net/reddit/ads-load.html?bust2 467 + 468 + GET /BurstingPipe/adServer.bs?cn=tf&c=19&mc=imp&pli=9962555&PluID=0&ord=1400862593645&rtu=-1 HTTP/1.1 469 + Host: bs.serving-sys.com 470 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 471 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 472 + Accept-Language: en-us,en;q=0.5 473 + Accept-Encoding: gzip, deflate 474 + Connection: keep-alive 475 + Referer: http://static.adzerk.net/reddit/ads-load.html?bust2 476 + Cookie: S_9994987=6754579095859875029; A4=01fmFvgRnI09SF00000; u2=d1263d39-874b-4a89-86cd-a2ab0860ed4e3Zl040 477 + 478 + GET /i.gif?e=eyJhdiI6NjIzNTcsImF0Ijo4LCJjbSI6MTE2MzUxLCJjaCI6Nzk4NCwiY3IiOjMzNzAxOCwiZGkiOiI3OTdlZjU3OWQ5NjE0ODdiODYyMGMyMGJkOTE4YzNiMSIsImRtIjoxLCJmYyI6NDE2MTMxLCJmbCI6MjEwNDY0LCJrdyI6Ii1yZWRkaXQuY29tIiwibWsiOiItcmVkZGl0LmNvbSIsIm53Ijo1MTQ2LCJwYyI6MCwicHIiOjIwMzYyLCJydCI6MSwicmYiOiJodHRwOi8vd3d3LnJlZGRpdC5jb20vIiwic3QiOjI0OTUwLCJ1ayI6InVlMS01ZWIwOGFlZWQ5YTc0MDFjOTE5NWNiOTMzZWI3Yzk2NiIsInRzIjoxNDAwODYyNTkzNjQ2fQ&s=OjzxzXAgQksbdQOHNm-bjZcnZPA HTTP/1.1 479 + Host: engine.adzerk.net 480 + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 481 + Accept: image/png,image/*;q=0.8,*/*;q=0.5 482 + Accept-Language: en-us,en;q=0.5 483 + Accept-Encoding: gzip, deflate 484 + Connection: keep-alive 485 + Referer: http://static.adzerk.net/reddit/ads-load.html?bust2 486 + Cookie: azk=ue1-5eb08aeed9a7401c9195cb933eb7c966 487 + 488 + GET /subscribe?host_int=1042356184&ns_map=571794054_374233948806,464381511_13349283399&user_id=245722467&nid=1399334269710011966&ts=1400862514 HTTP/1.1 489 + Host: notify8.dropbox.com 490 + Accept-Encoding: identity 491 + Connection: keep-alive 492 + X-Dropbox-Locale: en_US 493 + User-Agent: DropboxDesktopClient/2.7.54 (Macintosh; 10.8; ('i32',); en_US) 494 +
+40
vendor/opam/re/benchmarks/http.ml
··· 1 + open Re 2 + 3 + let space = rep blank 4 + let crlf = str "\r\n" 5 + let token = rep1 @@ compl [ rg '\000' '\031'; set "\127)(<>@,;:\\/[]?={}" ] 6 + let meth = token 7 + 8 + let version = 9 + let digits = rep1 digit in 10 + let decimal = seq [ digits; opt (seq [ char '.'; digits ]) ] in 11 + seq [ str "HTTP/"; decimal ] 12 + ;; 13 + 14 + let uri = rep1 (compl [ char '\n' ]) 15 + let request_line = [ space; group meth; space; group uri; group version; space ] |> seq 16 + 17 + let header = 18 + let key = group (rep1 (Re.compl [ char ':' ])) in 19 + let value = group (rep1 (Re.compl [ char '\n' ])) in 20 + seq [ space; key; space; char ':'; space; value; space; crlf ] 21 + ;; 22 + 23 + let request' = seq [ request_line; crlf; rep header; crlf ] 24 + 25 + module Export = struct 26 + let request = request' 27 + let request_g = request' |> no_group 28 + let requests = request' |> rep1 29 + let requests_g = request' |> no_group |> rep1 30 + end 31 + 32 + let requests = Stdio.In_channel.read_all "benchmarks/http-requests.txt" 33 + 34 + let rec read_all pos re reqs = 35 + if pos < String.length reqs 36 + then ( 37 + let g = Re.exec ~pos re reqs in 38 + let _, pos = Re.Group.offset g 0 in 39 + read_all (pos + 1) re reqs) 40 + ;;
+31
vendor/opam/re/benchmarks/memory.ml
··· 1 + open Core 2 + (* This set of benchmarks is designed for testing re's memory usage rather than 3 + speed. *) 4 + 5 + module Bench = Core_bench.Bench 6 + 7 + let size = 1_000 8 + 9 + (* a pathological re that will consume a bunch of memory *) 10 + let re () = 11 + let open Re in 12 + compile @@ seq [ rep (set "01"); char '1'; repn (set "01") size (Some size) ] 13 + ;; 14 + 15 + (* Another pathological case that is a simplified version of the above *) 16 + let re2 () = 17 + let open Re in 18 + seq [ rep (set "01"); char '1'; repn (set "01") size (Some size); char 'x' ] |> compile 19 + ;; 20 + 21 + let str = "01" ^ String.make size '1' 22 + 23 + let benchmarks = 24 + [ "memory 1", re; "memory 2", re2 ] 25 + |> ListLabels.map ~f:(fun (name, re) -> 26 + Bench.Test.create_indexed ~name ~args:[ 10; 20; 40; 80; 100; size ] (fun len -> 27 + Staged.stage (fun () -> 28 + let re = re () in 29 + let len = Int.min (String.length str) len in 30 + ignore (Re.execp ~pos:0 ~len re str)))) 31 + ;;
+1
vendor/opam/re/benchmarks/memory.mli
··· 1 + val benchmarks : Core_bench.Bench.Test.t list
+194
vendor/opam/re/benchmarks/tex.gitignore
··· 1 + ## Core latex/pdflatex auxiliary files: 2 + *.aux 3 + *.lof 4 + *.log 5 + *.lot 6 + *.fls 7 + *.out 8 + *.toc 9 + *.fmt 10 + *.fot 11 + *.cb 12 + *.cb2 13 + 14 + ## Intermediate documents: 15 + *.dvi 16 + *-converted-to.* 17 + # these rules might exclude image files for figures etc. 18 + # *.ps 19 + # *.eps 20 + # *.pdf 21 + 22 + ## Generated if empty string is given at "Please type another file name for output:" 23 + .pdf 24 + 25 + ## Bibliography auxiliary files (bibtex/biblatex/biber): 26 + *.bbl 27 + *.bcf 28 + *.blg 29 + *-blx.aux 30 + *-blx.bib 31 + *.brf 32 + *.run.xml 33 + 34 + ## Build tool auxiliary files: 35 + *.fdb_latexmk 36 + *.synctex 37 + *.synctex(busy) 38 + *.synctex.gz 39 + *.synctex.gz(busy) 40 + *.pdfsync 41 + 42 + ## Auxiliary and intermediate files from other packages: 43 + # algorithms 44 + *.alg 45 + *.loa 46 + 47 + # achemso 48 + acs-*.bib 49 + 50 + # amsthm 51 + *.thm 52 + 53 + # beamer 54 + *.nav 55 + *.snm 56 + *.vrb 57 + 58 + # cprotect 59 + *.cpt 60 + 61 + # fixme 62 + *.lox 63 + 64 + #(r)(e)ledmac/(r)(e)ledpar 65 + *.end 66 + *.?end 67 + *.[1-9] 68 + *.[1-9][0-9] 69 + *.[1-9][0-9][0-9] 70 + *.[1-9]R 71 + *.[1-9][0-9]R 72 + *.[1-9][0-9][0-9]R 73 + *.eledsec[1-9] 74 + *.eledsec[1-9]R 75 + *.eledsec[1-9][0-9] 76 + *.eledsec[1-9][0-9]R 77 + *.eledsec[1-9][0-9][0-9] 78 + *.eledsec[1-9][0-9][0-9]R 79 + 80 + # glossaries 81 + *.acn 82 + *.acr 83 + *.glg 84 + *.glo 85 + *.gls 86 + *.glsdefs 87 + 88 + # gnuplottex 89 + *-gnuplottex-* 90 + 91 + # gregoriotex 92 + *.gaux 93 + *.gtex 94 + 95 + # hyperref 96 + *.brf 97 + 98 + # knitr 99 + *-concordance.tex 100 + # TODO Comment the next line if you want to keep your tikz graphics files 101 + *.tikz 102 + *-tikzDictionary 103 + 104 + # listings 105 + *.lol 106 + 107 + # makeidx 108 + *.idx 109 + *.ilg 110 + *.ind 111 + *.ist 112 + 113 + # minitoc 114 + *.maf 115 + *.mlf 116 + *.mlt 117 + *.mtc 118 + *.mtc[0-9] 119 + *.mtc[1-9][0-9] 120 + 121 + # minted 122 + _minted* 123 + *.pyg 124 + 125 + # morewrites 126 + *.mw 127 + 128 + # mylatexformat 129 + *.fmt 130 + 131 + # nomencl 132 + *.nlo 133 + 134 + # sagetex 135 + *.sagetex.sage 136 + *.sagetex.py 137 + *.sagetex.scmd 138 + 139 + # scrwfile 140 + *.wrt 141 + 142 + # sympy 143 + *.sout 144 + *.sympy 145 + sympy-plots-for-*.tex/ 146 + 147 + # pdfcomment 148 + *.upa 149 + *.upb 150 + 151 + # pythontex 152 + *.pytxcode 153 + pythontex-files-*/ 154 + 155 + # thmtools 156 + *.loe 157 + 158 + # TikZ & PGF 159 + *.dpth 160 + *.md5 161 + *.auxlock 162 + 163 + # todonotes 164 + *.tdo 165 + 166 + # easy-todo 167 + *.lod 168 + 169 + # xindy 170 + *.xdy 171 + 172 + # xypic precompiled matrices 173 + *.xyc 174 + 175 + # endfloat 176 + *.ttt 177 + *.fff 178 + 179 + # Latexian 180 + TSWLatexianTemp* 181 + 182 + ## Editors: 183 + # WinEdt 184 + *.bak 185 + *.sav 186 + 187 + # Texpad 188 + .texpadtmp 189 + 190 + # Kile 191 + *.backup 192 + 193 + # KBibTeX 194 + *~[0-9]*
+17
vendor/opam/re/benchmarks/tex.ml
··· 1 + open Core 2 + 3 + let ignore_re = 4 + Stdio.In_channel.read_lines "benchmarks/tex.gitignore" 5 + |> List.map ~f:(fun s -> 6 + match Base.String.lsplit2 s ~on:'#' with 7 + | Some (pattern, _comment) -> pattern 8 + | None -> s) 9 + |> List.filter_map ~f:(fun s -> 10 + match Base.String.strip s with 11 + | "" -> None 12 + | s -> Some s) 13 + |> List.map ~f:Re.Glob.glob 14 + |> Re.alt 15 + ;; 16 + 17 + let ignore_filesnames = Stdio.In_channel.read_lines "benchmarks/files"
+52
vendor/opam/re/deprecated/dune
··· 1 + (env 2 + (_ 3 + (flags 4 + (:standard -w -53)))) 5 + 6 + (library 7 + (name re_str) 8 + (public_name re.str) 9 + (wrapped false) 10 + (modules re_str) 11 + (synopsis "Deprecated. Use Re.Str") 12 + (libraries re)) 13 + 14 + (library 15 + (name re_pcre) 16 + (public_name re.pcre) 17 + (wrapped false) 18 + (modules re_pcre) 19 + (synopsis "Deprecated. Use Re.Pcre") 20 + (libraries re)) 21 + 22 + (library 23 + (name re_perl) 24 + (public_name re.perl) 25 + (wrapped false) 26 + (modules re_perl) 27 + (synopsis "Deprecated. Use Re.Perl") 28 + (libraries re)) 29 + 30 + (library 31 + (name re_posix) 32 + (public_name re.posix) 33 + (wrapped false) 34 + (modules re_posix) 35 + (synopsis "Deprecated. Use Re.Posix") 36 + (libraries re)) 37 + 38 + (library 39 + (name re_emacs) 40 + (public_name re.emacs) 41 + (wrapped false) 42 + (modules re_emacs) 43 + (synopsis "Deprecated. Use Re.Emacs") 44 + (libraries re)) 45 + 46 + (library 47 + (name re_glob) 48 + (public_name re.glob) 49 + (wrapped false) 50 + (modules re_glob) 51 + (synopsis "Deprecated. Use Re.Glob") 52 + (libraries re))
+3
vendor/opam/re/deprecated/re_emacs.ml
··· 1 + [@@@deprecated "Use Re.Emacs"] 2 + 3 + include Re.Emacs
+3
vendor/opam/re/deprecated/re_glob.ml
··· 1 + [@@@deprecated "Use Re.Glob"] 2 + 3 + include Re.Glob
+3
vendor/opam/re/deprecated/re_pcre.ml
··· 1 + [@@@deprecated "Use Re.Pcre"] 2 + 3 + include Re.Pcre
+3
vendor/opam/re/deprecated/re_perl.ml
··· 1 + [@@@deprecated "Use Re.Perl"] 2 + 3 + include Re.Perl
+3
vendor/opam/re/deprecated/re_posix.ml
··· 1 + [@@@deprecated "Use Re.Posix"] 2 + 3 + include Re.Posix
+3
vendor/opam/re/deprecated/re_str.ml
··· 1 + [@@@deprecated "Use Re.Str"] 2 + 3 + include Re.Str
+4
vendor/opam/re/dune
··· 1 + (env 2 + (_ 3 + (flags 4 + (:standard -w -50))))
+35
vendor/opam/re/dune-project
··· 1 + (lang dune 3.15) 2 + 3 + (name re) 4 + 5 + (generate_opam_files true) 6 + 7 + (implicit_transitive_deps false) 8 + 9 + (license "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception") 10 + (maintainers "Rudi Grinberg <me@rgrinberg.com>") 11 + (authors 12 + "Jerome Vouillon" 13 + "Thomas Gazagnaire" 14 + "Anil Madhavapeddy" 15 + "Rudi Grinberg" 16 + "Gabriel Radanne") 17 + 18 + (source (github ocaml/ocaml-re)) 19 + 20 + (package 21 + (name re) 22 + (synopsis "RE is a regular expression library for OCaml") 23 + (depends 24 + (ocaml (>= 4.08.0)) 25 + (ppx_expect :with-test) 26 + (ounit2 :with-test) 27 + (js_of_ocaml :with-test)) 28 + (description " 29 + Pure OCaml regular expressions with: 30 + * Perl-style regular expressions (module Re.Perl) 31 + * Posix extended regular expressions (module Re.Posix) 32 + * Emacs-style regular expressions (module Re.Emacs) 33 + * Shell-style file globbing (module Re.Glob) 34 + * Compatibility layer for OCaml's built-in Str module (module Re.Str) 35 + "))
+79
vendor/opam/re/flake.lock
··· 1 + { 2 + "nodes": { 3 + "flake-utils": { 4 + "inputs": { 5 + "systems": "systems" 6 + }, 7 + "locked": { 8 + "lastModified": 1731533236, 9 + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", 10 + "owner": "numtide", 11 + "repo": "flake-utils", 12 + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", 13 + "type": "github" 14 + }, 15 + "original": { 16 + "owner": "numtide", 17 + "repo": "flake-utils", 18 + "type": "github" 19 + } 20 + }, 21 + "nixpkgs": { 22 + "inputs": { 23 + "nixpkgs": "nixpkgs_2" 24 + }, 25 + "locked": { 26 + "lastModified": 1752953760, 27 + "narHash": "sha256-HEskLVQGF48brLMmo3Dhb9rdm0D0mCG4ymPJcZylmgc=", 28 + "owner": "nix-ocaml", 29 + "repo": "nix-overlays", 30 + "rev": "324e1583c2104ebee89ebb8872b0ee9231fb568c", 31 + "type": "github" 32 + }, 33 + "original": { 34 + "owner": "nix-ocaml", 35 + "repo": "nix-overlays", 36 + "type": "github" 37 + } 38 + }, 39 + "nixpkgs_2": { 40 + "locked": { 41 + "lastModified": 1752385071, 42 + "narHash": "sha256-lj4vD716tbbWtDzGITJGfPPIRU54H5uynlnALJHyhOk=", 43 + "owner": "NixOS", 44 + "repo": "nixpkgs", 45 + "rev": "e2e7b4a2013f5f73eb85956aa28e9655e5d9601a", 46 + "type": "github" 47 + }, 48 + "original": { 49 + "owner": "NixOS", 50 + "repo": "nixpkgs", 51 + "rev": "e2e7b4a2013f5f73eb85956aa28e9655e5d9601a", 52 + "type": "github" 53 + } 54 + }, 55 + "root": { 56 + "inputs": { 57 + "flake-utils": "flake-utils", 58 + "nixpkgs": "nixpkgs" 59 + } 60 + }, 61 + "systems": { 62 + "locked": { 63 + "lastModified": 1681028828, 64 + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 65 + "owner": "nix-systems", 66 + "repo": "default", 67 + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 68 + "type": "github" 69 + }, 70 + "original": { 71 + "owner": "nix-systems", 72 + "repo": "default", 73 + "type": "github" 74 + } 75 + } 76 + }, 77 + "root": "root", 78 + "version": 7 79 + }
+85
vendor/opam/re/flake.nix
··· 1 + { 2 + description = "ocaml-re flake"; 3 + 4 + inputs.flake-utils.url = "github:numtide/flake-utils"; 5 + inputs.nixpkgs.url = "github:nix-ocaml/nix-overlays"; 6 + 7 + outputs = { self, nixpkgs, flake-utils }: 8 + flake-utils.lib.eachDefaultSystem (system: 9 + let 10 + extraBuildInputs = pkgs: 11 + with pkgs.ocamlPackages; [ 12 + core_bench 13 + memtrace 14 + ]; 15 + checkInputs = pkgs: 16 + with pkgs.ocamlPackages; [ 17 + ounit 18 + js_of_ocaml 19 + ppx_expect 20 + pkgs.nodejs-slim 21 + ]; 22 + devInputs = pkgs: 23 + with pkgs.ocamlPackages; [ 24 + ocaml-lsp 25 + pkgs.ocamlformat_0_26_2 26 + csv 27 + pkgs.tabview 28 + ]; 29 + makePackages = pkgs: rec { 30 + default = re; 31 + re = pkgs.ocamlPackages.buildDunePackage { 32 + pname = "re"; 33 + version = "n/a"; 34 + src = ./.; 35 + duneVersion = "3"; 36 + propagatedBuildInputs = with pkgs.ocamlPackages; [ seq ]; 37 + # Other check deps depend on re itself 38 + checkInputs = with pkgs.ocamlPackages; [ ounit ]; 39 + doCheck = true; 40 + }; 41 + }; 42 + ocamlVersionOverlay = 43 + (ocaml: self: super: { ocamlPackages = ocaml super.ocaml-ng; }); 44 + framePointers = ocaml: ocaml.override { framePointerSupport = true; }; 45 + framePointersOverlay = self: super: { 46 + ocamlPackages = super.ocamlPackages.overrideScope 47 + (oself: osuper: { ocaml = framePointers osuper.ocaml; }); 48 + }; 49 + makeNixpkgs = ocaml: 50 + nixpkgs.legacyPackages.${system}.appendOverlays 51 + [ (ocamlVersionOverlay ocaml) ]; 52 + in rec { 53 + devShells.test = let 54 + pkgs = makeNixpkgs (ocaml: ocaml.ocamlPackages_5_2); 55 + packages = makePackages pkgs; 56 + in pkgs.mkShell { 57 + inputsFrom = pkgs.lib.attrValues packages; 58 + buildInputs = extraBuildInputs pkgs ++ checkInputs pkgs; 59 + }; 60 + devShells.default = let 61 + pkgs = makeNixpkgs (ocaml: ocaml.ocamlPackages_5_2); 62 + packages = makePackages pkgs; 63 + in pkgs.mkShell { 64 + inputsFrom = pkgs.lib.attrValues packages; 65 + buildInputs = extraBuildInputs pkgs ++ devInputs pkgs 66 + ++ checkInputs pkgs; 67 + }; 68 + devShells.fp = let 69 + pkgs = (makeNixpkgs (ocaml: ocaml.ocamlPackages_5_2)).appendOverlays 70 + [ framePointersOverlay ]; 71 + packages = makePackages pkgs; 72 + in pkgs.mkShell { 73 + inputsFrom = pkgs.lib.attrValues packages; 74 + buildInputs = extraBuildInputs pkgs ++ devInputs pkgs; 75 + }; 76 + devShells.memtrace = let 77 + pkgs = makeNixpkgs (ocaml: ocaml.ocamlPackages_4_14); 78 + packages = makePackages pkgs; 79 + in pkgs.mkShell { 80 + inputsFrom = pkgs.lib.attrValues packages; 81 + buildInputs = extraBuildInputs pkgs 82 + ++ [ pkgs.ocamlPackages.memtrace_viewer ]; 83 + }; 84 + }); 85 + }
+444
vendor/opam/re/lib/ast.ml
··· 1 + open Import 2 + 3 + type ('a, _) ast = 4 + | Alternative : 'a list -> ('a, [> `Uncased ]) ast 5 + | No_case : 'a -> ('a, [> `Cased ]) ast 6 + | Case : 'a -> ('a, [> `Cased ]) ast 7 + 8 + let dyn_of_ast f = 9 + let open Dyn in 10 + function 11 + | Alternative xs -> variant "Alternative" (List.map xs ~f) 12 + | No_case a -> variant "No_case" [ f a ] 13 + | Case a -> variant "Case" [ f a ] 14 + ;; 15 + 16 + let empty_alternative : ('a, 'b) ast = Alternative [] 17 + 18 + let equal_ast (type a) eq (x : (a, [ `Uncased ]) ast) (y : (a, [ `Uncased ]) ast) = 19 + match x, y with 20 + | Alternative a, Alternative b -> List.equal ~eq a b 21 + ;; 22 + 23 + let pp_ast (type a b) f fmt (ast : (a, b) ast) = 24 + let open Fmt in 25 + let var s re = sexp fmt s f re in 26 + match ast with 27 + | Alternative alt -> sexp fmt "Alternative" (list f) alt 28 + | Case c -> var "Case" c 29 + | No_case c -> var "No_case" c 30 + ;; 31 + 32 + type cset = 33 + | Cset of Cset.t 34 + | Intersection of cset list 35 + | Complement of cset list 36 + | Difference of cset * cset 37 + | Cast of (cset, [ `Cased | `Uncased ]) ast 38 + 39 + let rec dyn_of_cset = 40 + let open Dyn in 41 + function 42 + | Cset cset -> variant "Cset" [ Cset.to_dyn cset ] 43 + | Intersection xs -> variant "Intersection" (List.map xs ~f:dyn_of_cset) 44 + | Complement xs -> variant "Complement" (List.map xs ~f:dyn_of_cset) 45 + | Difference (x, y) -> variant "Difference" [ dyn_of_cset x; dyn_of_cset y ] 46 + | Cast c -> variant "Cast" [ dyn_of_ast dyn_of_cset c ] 47 + ;; 48 + 49 + type ('a, 'case) gen = 50 + | Set of 'a 51 + | Ast of (('a, 'case) gen, 'case) ast 52 + | Sequence of ('a, 'case) gen list 53 + | Repeat of ('a, 'case) gen * int * int option 54 + | Beg_of_line 55 + | End_of_line 56 + | Beg_of_word 57 + | End_of_word 58 + | Not_bound 59 + | Beg_of_str 60 + | End_of_str 61 + | Last_end_of_line 62 + | Start 63 + | Stop 64 + | Group of string option * ('a, 'case) gen 65 + | No_group of ('a, 'case) gen 66 + | Nest of ('a, 'case) gen 67 + | Pmark of Pmark.t * ('a, 'case) gen 68 + | Sem of Automata.Sem.t * ('a, 'case) gen 69 + | Sem_greedy of Automata.Rep_kind.t * ('a, 'case) gen 70 + 71 + let rec dyn_of_gen f = 72 + let open Dyn in 73 + function 74 + | Set a -> variant "Set" [ f a ] 75 + | Ast ast -> variant "Ast" [ dyn_of_ast (dyn_of_gen f) ast ] 76 + | Sequence xs -> variant "Sequence" (List.map xs ~f:(dyn_of_gen f)) 77 + | Repeat (gen, min, max) -> 78 + let base = 79 + match max with 80 + | None -> [] 81 + | Some x -> [ int x ] 82 + in 83 + variant "Repeat" (dyn_of_gen f gen :: int min :: base) 84 + | Beg_of_line -> enum "Beg_of_line" 85 + | End_of_line -> enum "End_of_line" 86 + | Beg_of_word -> enum "Beg_of_word" 87 + | End_of_word -> enum "End_of_word" 88 + | Not_bound -> enum "Not_bound" 89 + | Beg_of_str -> enum "Beg_of_str" 90 + | End_of_str -> enum "End_of_str" 91 + | Last_end_of_line -> enum "Last_end_of_line" 92 + | Start -> enum "Start" 93 + | Stop -> enum "Stop" 94 + | Group (name, t) -> 95 + let args = 96 + let args = [ dyn_of_gen f t ] in 97 + match name with 98 + | None -> args 99 + | Some name -> string name :: args 100 + in 101 + variant "Group" args 102 + | No_group x -> variant "No_group" [ dyn_of_gen f x ] 103 + | Nest x -> variant "Nest" [ dyn_of_gen f x ] 104 + | Pmark (pmark, t) -> variant "Pmark" [ Pmark.to_dyn pmark; dyn_of_gen f t ] 105 + | Sem (sem, t) -> variant "Sem" [ Automata.Sem.to_dyn sem; dyn_of_gen f t ] 106 + | Sem_greedy (rep, t) -> 107 + variant "Sem_greedy" [ Automata.Rep_kind.to_dyn rep; dyn_of_gen f t ] 108 + ;; 109 + 110 + let rec pp_gen pp_cset fmt t = 111 + let open Format in 112 + let open Fmt in 113 + let pp = pp_gen pp_cset in 114 + let var s re = sexp fmt s pp re in 115 + let seq s rel = sexp fmt s (list pp) rel in 116 + match t with 117 + | Set cset -> pp_cset fmt cset 118 + | Sequence sq -> seq "Sequence" sq 119 + | Repeat (re, start, stop) -> 120 + let pp' fmt () = fprintf fmt "%a@ %d%a" pp re start optint stop in 121 + sexp fmt "Repeat" pp' () 122 + | Beg_of_line -> str fmt "Beg_of_line" 123 + | End_of_line -> str fmt "End_of_line" 124 + | Beg_of_word -> str fmt "Beg_of_word" 125 + | End_of_word -> str fmt "End_of_word" 126 + | Not_bound -> str fmt "Not_bound" 127 + | Beg_of_str -> str fmt "Beg_of_str" 128 + | End_of_str -> str fmt "End_of_str" 129 + | Last_end_of_line -> str fmt "Last_end_of_line" 130 + | Start -> str fmt "Start" 131 + | Stop -> str fmt "Stop" 132 + | Group (None, c) -> var "Group" c 133 + | Group (Some n, c) -> sexp fmt "Named_group" (pair str pp) (n, c) 134 + | Nest c -> var "Nest" c 135 + | Pmark (m, r) -> sexp fmt "Pmark" (pair Pmark.pp pp) (m, r) 136 + | Ast a -> pp_ast pp fmt a 137 + | Sem (sem, a) -> sexp fmt "Sem" (pair Automata.Sem.pp pp) (sem, a) 138 + | Sem_greedy (k, re) -> sexp fmt "Sem_greedy" (pair Automata.Rep_kind.pp pp) (k, re) 139 + | No_group c -> var "No_group" c 140 + ;; 141 + 142 + let rec pp_cset fmt cset = 143 + let open Fmt in 144 + let seq s rel = sexp fmt s (list pp_cset) rel in 145 + match cset with 146 + | Cast s -> pp_ast pp_cset fmt s 147 + | Cset s -> sexp fmt "Set" Cset.pp s 148 + | Intersection c -> seq "Intersection" c 149 + | Complement c -> seq "Complement" c 150 + | Difference (a, b) -> sexp fmt "Difference" (pair pp_cset pp_cset) (a, b) 151 + ;; 152 + 153 + let rec equal cset x1 x2 = 154 + match x1, x2 with 155 + | Set s1, Set s2 -> cset s1 s2 156 + | Sequence l1, Sequence l2 -> List.equal ~eq:(equal cset) l1 l2 157 + | Repeat (x1', i1, j1), Repeat (x2', i2, j2) -> 158 + Int.equal i1 i2 && Option.equal Int.equal j1 j2 && equal cset x1' x2' 159 + | Beg_of_line, Beg_of_line 160 + | End_of_line, End_of_line 161 + | Beg_of_word, Beg_of_word 162 + | End_of_word, End_of_word 163 + | Not_bound, Not_bound 164 + | Beg_of_str, Beg_of_str 165 + | End_of_str, End_of_str 166 + | Last_end_of_line, Last_end_of_line 167 + | Start, Start 168 + | Stop, Stop -> true 169 + | Group _, Group _ -> 170 + (* Do not merge groups! *) 171 + false 172 + | Pmark (m1, r1), Pmark (m2, r2) -> Pmark.equal m1 m2 && equal cset r1 r2 173 + | Nest x, Nest y -> equal cset x y 174 + | Ast x, Ast y -> equal_ast (equal cset) x y 175 + | Sem (sem, a), Sem (sem', a') -> Poly.equal sem sem' && equal cset a a' 176 + | Sem_greedy (rep, a), Sem_greedy (rep', a') -> Poly.equal rep rep' && equal cset a a' 177 + | _ -> false 178 + ;; 179 + 180 + type t = (cset, [ `Cased | `Uncased ]) gen 181 + type no_case = (Cset.t, [ `Uncased ]) gen 182 + 183 + let to_dyn = dyn_of_gen dyn_of_cset 184 + let pp = pp_gen pp_cset 185 + let cset cset = Set (Cset cset) 186 + 187 + let rec handle_case_cset ign_case = function 188 + | Cset s -> if ign_case then Cset.case_insens s else s 189 + | Cast (Alternative l) -> List.map ~f:(handle_case_cset ign_case) l |> Cset.union_all 190 + | Complement l -> 191 + List.map ~f:(handle_case_cset ign_case) l |> Cset.union_all |> Cset.diff Cset.cany 192 + | Difference (r, r') -> 193 + Cset.inter 194 + (handle_case_cset ign_case r) 195 + (Cset.diff Cset.cany (handle_case_cset ign_case r')) 196 + | Intersection l -> List.map ~f:(handle_case_cset ign_case) l |> Cset.intersect_all 197 + | Cast (No_case a) -> handle_case_cset true a 198 + | Cast (Case a) -> handle_case_cset false a 199 + ;; 200 + 201 + let rec handle_case ign_case : t -> (Cset.t, [ `Uncased ]) gen = function 202 + | Set s -> Set (handle_case_cset ign_case s) 203 + | Sequence l -> Sequence (List.map ~f:(handle_case ign_case) l) 204 + | Ast (Alternative l) -> 205 + let l = List.map ~f:(handle_case ign_case) l in 206 + Ast (Alternative l) 207 + | Repeat (r, i, j) -> Repeat (handle_case ign_case r, i, j) 208 + | ( Beg_of_line 209 + | End_of_line 210 + | Beg_of_word 211 + | End_of_word 212 + | Not_bound 213 + | Beg_of_str 214 + | End_of_str 215 + | Last_end_of_line 216 + | Start 217 + | Stop ) as r -> r 218 + | Sem (k, r) -> Sem (k, handle_case ign_case r) 219 + | Sem_greedy (k, r) -> Sem_greedy (k, handle_case ign_case r) 220 + | Group (n, r) -> Group (n, handle_case ign_case r) 221 + | No_group r -> No_group (handle_case ign_case r) 222 + | Nest r -> Nest (handle_case ign_case r) 223 + | Ast (Case r) -> handle_case false r 224 + | Ast (No_case r) -> handle_case true r 225 + | Pmark (i, r) -> Pmark (i, handle_case ign_case r) 226 + ;; 227 + 228 + module Export = struct 229 + type nonrec t = t 230 + 231 + let pp = pp 232 + 233 + let seq = function 234 + | [ r ] -> r 235 + | l -> Sequence l 236 + ;; 237 + 238 + let char = 239 + let f = Dense_map.make ~size:256 ~f:(fun i -> cset (Cset.csingle (Char.chr i))) in 240 + fun c -> f (Char.code c) 241 + ;; 242 + 243 + let any = cset Cset.cany 244 + 245 + let str s : t = 246 + let l = ref [] in 247 + for i = String.length s - 1 downto 0 do 248 + l := char s.[i] :: !l 249 + done; 250 + seq !l 251 + ;; 252 + 253 + let as_set_elems elems = 254 + match 255 + List.map elems ~f:(function 256 + | Set e -> e 257 + | _ -> raise_notrace Exit) 258 + with 259 + | exception Exit -> None 260 + | e -> Some e 261 + ;; 262 + 263 + let empty : t = Ast empty_alternative 264 + 265 + let alt (elems : t list) : t = 266 + match elems with 267 + | [] -> empty 268 + | [ x ] -> x 269 + | _ -> 270 + (match as_set_elems elems with 271 + | None -> Ast (Alternative elems) 272 + | Some elems -> Set (Cast (Alternative elems))) 273 + ;; 274 + 275 + let epsilon = seq [] 276 + 277 + let repn r i j = 278 + if i < 0 then invalid_arg "Re.repn"; 279 + match j, i with 280 + | Some j, _ when j < i -> invalid_arg "Re.repn" 281 + | Some 0, 0 -> epsilon 282 + | Some 1, 1 -> r 283 + | _ -> Repeat (r, i, j) 284 + ;; 285 + 286 + let rep r = repn r 0 None 287 + let rep1 r = repn r 1 None 288 + let opt r = repn r 0 (Some 1) 289 + let bol = Beg_of_line 290 + let eol = End_of_line 291 + let bow = Beg_of_word 292 + let eow = End_of_word 293 + let word r = seq [ bow; r; eow ] 294 + let not_boundary = Not_bound 295 + let bos = Beg_of_str 296 + let eos = End_of_str 297 + let whole_string r = seq [ bos; r; eos ] 298 + let leol = Last_end_of_line 299 + let start = Start 300 + let stop = Stop 301 + 302 + type 'b f = { f : 'a. 'a -> ('a, 'b) ast } 303 + 304 + let make_set f t = 305 + match t with 306 + | Set x -> Set (Cast (f.f x)) 307 + | _ -> Ast (f.f t) 308 + ;; 309 + 310 + let preserve_set f t = 311 + match t with 312 + | Set _ -> t 313 + | _ -> f t 314 + ;; 315 + 316 + let longest = preserve_set (fun t -> Sem (`Longest, t)) 317 + let shortest = preserve_set (fun t -> Sem (`Shortest, t)) 318 + let first = preserve_set (fun t -> Sem (`First, t)) 319 + let greedy = preserve_set (fun t -> Sem_greedy (`Greedy, t)) 320 + let non_greedy = preserve_set (fun t -> Sem_greedy (`Non_greedy, t)) 321 + let group ?name r = Group (name, r) 322 + let no_group = preserve_set (fun t -> No_group t) 323 + let nest r = Nest r 324 + let set str = cset (Cset.set str) 325 + 326 + let mark r = 327 + let i = Pmark.gen () in 328 + i, Pmark (i, r) 329 + ;; 330 + 331 + (**** Character sets ****) 332 + let as_set_or_error name elems = 333 + match as_set_elems elems with 334 + | None -> invalid_arg name 335 + | Some s -> s 336 + ;; 337 + 338 + let inter elems = Set (Intersection (as_set_or_error "Re.inter" elems)) 339 + let compl elems = Set (Complement (as_set_or_error "Re.compl" elems)) 340 + 341 + let diff r r' = 342 + match r, r' with 343 + | Set r, Set r' -> Set (Difference (r, r')) 344 + | _, _ -> invalid_arg "Re.diff" 345 + ;; 346 + 347 + let case = 348 + let f = { f = (fun r -> Case r) } in 349 + fun t -> make_set f t 350 + ;; 351 + 352 + let no_case = 353 + let f = { f = (fun r -> No_case r) } in 354 + fun t -> make_set f t 355 + ;; 356 + 357 + let witness t = 358 + let rec witness (t : no_case) = 359 + match t with 360 + | Set c -> String.make 1 (Cset.to_char (Cset.pick c)) 361 + | Sequence xs -> String.concat "" (List.map ~f:witness xs) 362 + | Ast (Alternative (x :: _)) -> witness x 363 + | Ast (Alternative []) -> assert false 364 + | Repeat (r, from, _to) -> 365 + let w = witness r in 366 + let b = Buffer.create (String.length w * from) in 367 + for _i = 1 to from do 368 + Buffer.add_string b w 369 + done; 370 + Buffer.contents b 371 + | No_group r -> witness r 372 + | Sem_greedy (_, r) | Sem (_, r) | Nest r | Pmark (_, r) | Group (_, r) -> witness r 373 + | Beg_of_line 374 + | End_of_line 375 + | Beg_of_word 376 + | End_of_word 377 + | Not_bound 378 + | Beg_of_str 379 + | Last_end_of_line 380 + | Start 381 + | Stop 382 + | End_of_str -> "" 383 + in 384 + witness (handle_case false t) 385 + ;; 386 + end 387 + 388 + open Export 389 + 390 + let rec merge_sequences = function 391 + | [] -> [] 392 + | Ast (Alternative l') :: r -> merge_sequences (l' @ r) 393 + | Sequence (x :: y) :: r -> 394 + (match merge_sequences r with 395 + | Sequence (x' :: y') :: r' when equal Cset.equal x x' -> 396 + Sequence [ x; Ast (Alternative [ seq y; seq y' ]) ] :: r' 397 + | r' -> Sequence (x :: y) :: r') 398 + | x :: r -> x :: merge_sequences r 399 + ;; 400 + 401 + (*XXX Use a better algorithm allowing non-contiguous regions? *) 402 + 403 + let colorize color_map (regexp : no_case) = 404 + let lnl = ref false in 405 + let rec colorize regexp = 406 + match (regexp : no_case) with 407 + | Set s -> Color_map.split color_map s 408 + | Sequence l -> List.iter ~f:colorize l 409 + | Ast (Alternative l) -> List.iter ~f:colorize l 410 + | Repeat (r, _, _) -> colorize r 411 + | Beg_of_line | End_of_line -> Color_map.split color_map Cset.nl 412 + | Beg_of_word | End_of_word | Not_bound -> Color_map.split color_map Cset.cword 413 + | Beg_of_str | End_of_str | Start | Stop -> () 414 + | Last_end_of_line -> lnl := true 415 + | No_group r | Group (_, r) | Nest r | Pmark (_, r) -> colorize r 416 + | Sem (_, r) | Sem_greedy (_, r) -> colorize r 417 + in 418 + colorize regexp; 419 + !lnl 420 + ;; 421 + 422 + let rec anchored_ast : (t, _) ast -> bool = function 423 + | Alternative als -> List.for_all ~f:anchored als 424 + | No_case r | Case r -> anchored r 425 + 426 + and anchored : t -> bool = function 427 + | Ast a -> anchored_ast a 428 + | Sequence l -> List.exists ~f:anchored l 429 + | Repeat (r, i, _) -> i > 0 && anchored r 430 + | No_group r | Sem (_, r) | Sem_greedy (_, r) | Group (_, r) | Nest r | Pmark (_, r) -> 431 + anchored r 432 + | Set _ 433 + | Beg_of_line 434 + | End_of_line 435 + | Beg_of_word 436 + | End_of_word 437 + | Not_bound 438 + | End_of_str 439 + | Last_end_of_line 440 + | Stop -> false 441 + | Beg_of_str | Start -> true 442 + ;; 443 + 444 + let t_of_cset x = Set x
+91
vendor/opam/re/lib/ast.mli
··· 1 + type ('a, _) ast = private 2 + | Alternative : 'a list -> ('a, [> `Uncased ]) ast 3 + | No_case : 'a -> ('a, [> `Cased ]) ast 4 + | Case : 'a -> ('a, [> `Cased ]) ast 5 + 6 + type cset = private 7 + | Cset of Cset.t 8 + | Intersection of cset list 9 + | Complement of cset list 10 + | Difference of cset * cset 11 + | Cast of (cset, [ `Cased | `Uncased ]) ast 12 + 13 + type ('a, 'case) gen = private 14 + | Set of 'a 15 + | Ast of (('a, 'case) gen, 'case) ast 16 + | Sequence of ('a, 'case) gen list 17 + | Repeat of ('a, 'case) gen * int * int option 18 + | Beg_of_line 19 + | End_of_line 20 + | Beg_of_word 21 + | End_of_word 22 + | Not_bound 23 + | Beg_of_str 24 + | End_of_str 25 + | Last_end_of_line 26 + | Start 27 + | Stop 28 + | Group of string option * ('a, 'case) gen 29 + | No_group of ('a, 'case) gen 30 + | Nest of ('a, 'case) gen 31 + | Pmark of Pmark.t * ('a, 'case) gen 32 + | Sem of Automata.Sem.t * ('a, 'case) gen 33 + | Sem_greedy of Automata.Rep_kind.t * ('a, 'case) gen 34 + 35 + type t = (cset, [ `Cased | `Uncased ]) gen 36 + type no_case = (Cset.t, [ `Uncased ]) gen 37 + 38 + val to_dyn : t -> Dyn.t 39 + val pp : t Fmt.t 40 + val merge_sequences : (Cset.t, [ `Uncased ]) gen list -> (Cset.t, [ `Uncased ]) gen list 41 + val handle_case : bool -> t -> (Cset.t, [ `Uncased ]) gen 42 + val anchored : t -> bool 43 + val colorize : Color_map.t -> (Cset.t, [ `Uncased ]) gen -> bool 44 + 45 + module Export : sig 46 + type nonrec t = t 47 + 48 + val empty : t 49 + val epsilon : t 50 + val str : string -> t 51 + val no_case : t -> t 52 + val case : t -> t 53 + val diff : t -> t -> t 54 + val compl : t list -> t 55 + val repn : t -> int -> int option -> t 56 + val inter : t list -> t 57 + val char : char -> t 58 + val any : t 59 + val set : string -> t 60 + val mark : t -> Pmark.t * t 61 + val nest : t -> t 62 + val no_group : t -> t 63 + val whole_string : t -> t 64 + val leol : t 65 + val longest : t -> t 66 + val greedy : t -> t 67 + val non_greedy : t -> t 68 + val stop : t 69 + val not_boundary : t 70 + val group : ?name:string -> t -> t 71 + val word : t -> t 72 + val first : t -> t 73 + val bos : t 74 + val bow : t 75 + val eow : t 76 + val eos : t 77 + val bol : t 78 + val start : t 79 + val eol : t 80 + val opt : t -> t 81 + val rep : t -> t 82 + val rep1 : t -> t 83 + val alt : t list -> t 84 + val shortest : t -> t 85 + val seq : t list -> t 86 + val pp : t Fmt.t 87 + val witness : t -> string 88 + end 89 + 90 + val cset : Cset.t -> t 91 + val t_of_cset : cset -> t
+781
vendor/opam/re/lib/automata.ml
··· 1 + open Import 2 + 3 + (* 4 + RE - A regular expression library 5 + 6 + Copyright (C) 2001 Jerome Vouillon 7 + email: Jerome.Vouillon@pps.jussieu.fr 8 + 9 + This library is free software; you can redistribute it and/or 10 + modify it under the terms of the GNU Lesser General Public 11 + License as published by the Free Software Foundation, with 12 + linking exception; either version 2.1 of the License, or (at 13 + your option) any later version. 14 + 15 + This library is distributed in the hope that it will be useful, 16 + but WITHOUT ANY WARRANTY; without even the implied warranty of 17 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 + Lesser General Public License for more details. 19 + 20 + You should have received a copy of the GNU Lesser General Public 21 + License along with this library; if not, write to the Free Software 22 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 + *) 24 + 25 + let hash_combine h accu = (accu * 65599) + h 26 + 27 + module Ids : sig 28 + module Id : sig 29 + type t 30 + 31 + val equal : t -> t -> bool 32 + val zero : t 33 + val hash : t -> int 34 + val pp : t Fmt.t 35 + 36 + module Hash_set : sig 37 + type id := t 38 + type t 39 + 40 + val create : unit -> t 41 + val mem : t -> id -> bool 42 + val add : t -> id -> unit 43 + val clear : t -> unit 44 + end 45 + end 46 + 47 + type t 48 + 49 + val create : unit -> t 50 + val next : t -> Id.t 51 + end = struct 52 + module Id = struct 53 + type t = int 54 + 55 + module Hash_set = Hash_set 56 + 57 + let equal = Int.equal 58 + let zero = 0 59 + let hash x = x 60 + let pp = Fmt.int 61 + end 62 + 63 + type t = int ref 64 + 65 + let create () = ref 0 66 + 67 + let next t = 68 + incr t; 69 + !t 70 + ;; 71 + end 72 + 73 + module Id = Ids.Id 74 + 75 + module Sem = struct 76 + type t = 77 + [ `Longest 78 + | `Shortest 79 + | `First 80 + ] 81 + 82 + let to_string = function 83 + | `Shortest -> "short" 84 + | `Longest -> "long" 85 + | `First -> "first" 86 + ;; 87 + 88 + let to_dyn t = Dyn.enum (to_string t) 89 + let equal = Poly.equal 90 + let pp ch k = Format.pp_print_string ch (to_string k) 91 + end 92 + 93 + module Rep_kind = struct 94 + type t = 95 + [ `Greedy 96 + | `Non_greedy 97 + ] 98 + 99 + let to_string = function 100 + | `Greedy -> "Greedy" 101 + | `Non_greedy -> "Non_greedy" 102 + ;; 103 + 104 + let to_dyn t = Dyn.enum (to_string t) 105 + let pp fmt t = Format.pp_print_string fmt (to_string t) 106 + end 107 + 108 + module Mark : sig 109 + type t = private int 110 + 111 + val compare : t -> t -> int 112 + val equal : t -> t -> bool 113 + val pp : t Fmt.t 114 + val to_dyn : t -> Dyn.t 115 + val start : t 116 + val prev : t -> t 117 + val next : t -> t 118 + val next2 : t -> t 119 + val group_count : t -> int 120 + val outside_range : t -> start_inclusive:t -> stop_inclusive:t -> bool 121 + end = struct 122 + type t = int 123 + 124 + let equal = Int.equal 125 + let compare = Int.compare 126 + let pp = Format.pp_print_int 127 + let to_dyn = Dyn.int 128 + let start = 0 129 + let prev x = pred x 130 + let next x = succ x 131 + let next2 x = x + 2 132 + let group_count x = x / 2 133 + 134 + let outside_range t ~start_inclusive ~stop_inclusive = 135 + t < start_inclusive || t > stop_inclusive 136 + ;; 137 + end 138 + 139 + module Idx : sig 140 + type t = private int 141 + 142 + val pp : t Fmt.t 143 + val to_dyn : t -> Dyn.t 144 + val to_int : t -> int 145 + val unknown : t 146 + val initial : t 147 + val used : t -> bool 148 + val make : int -> t 149 + val equal : t -> t -> bool 150 + end = struct 151 + type t = int 152 + 153 + let to_dyn = Dyn.int 154 + let to_int x = x 155 + let pp = Format.pp_print_int 156 + let used t = t >= 0 157 + let make x = x 158 + let equal = Int.equal 159 + let unknown = -1 160 + let initial = 0 161 + end 162 + 163 + module Expr = struct 164 + type t = 165 + { id : Id.t 166 + ; def : def 167 + } 168 + 169 + and def = 170 + | Cst of Cset.t 171 + | Alt of t list 172 + | Seq of Sem.t * t * t 173 + | Eps 174 + | Rep of Rep_kind.t * Sem.t * t 175 + | Mark of Mark.t 176 + | Erase of Mark.t * Mark.t 177 + | Before of Category.t 178 + | After of Category.t 179 + | Pmark of Pmark.t 180 + 181 + let wrap_sem sem sem' v = 182 + let open Dyn in 183 + let name = Sem.to_string sem' in 184 + match sem with 185 + | Some sem when Sem.equal sem sem' -> v 186 + | None | Some _ -> 187 + (match v with 188 + | List v -> variant name v 189 + | _ -> variant name [ v ]) 190 + ;; 191 + 192 + let rec seq_as_list sem = function 193 + | Eps -> [] 194 + | Cst cs -> [ Cst cs ] 195 + | Seq (sem', x, y) -> 196 + if Sem.equal sem sem' 197 + then x.def :: seq_as_list sem y.def 198 + else raise_notrace Not_found 199 + | _ -> raise_notrace Not_found 200 + ;; 201 + 202 + let seq_as_list sem t = 203 + match seq_as_list sem t with 204 + | exception Not_found -> None 205 + | s -> Some s 206 + ;; 207 + 208 + let rec dyn_of_def sem = 209 + let open Dyn in 210 + function 211 + | Cst cset -> Cset.to_dyn cset 212 + | Alt alt -> variant "Alt" (List.map ~f:(to_dyn sem) alt) 213 + | Seq (sem', x, y) -> 214 + let to_dyn = to_dyn (Some sem') in 215 + let x = 216 + match seq_as_list sem' y.def with 217 + | None -> variant "Seq" [ to_dyn x; to_dyn y ] 218 + | Some y -> variant "Seq" (to_dyn x :: List.map y ~f:(dyn_of_def sem)) 219 + in 220 + wrap_sem sem sem' x 221 + | Eps -> Enum "Eps" 222 + | Rep (_, sem', t) -> wrap_sem sem sem' (variant "Rep" [ to_dyn (Some sem') t ]) 223 + | Mark m -> variant "Mark" [ Mark.to_dyn m ] 224 + | Pmark m -> variant "Pmark" [ Pmark.to_dyn m ] 225 + | Erase (x, y) -> variant "Erase" [ Mark.to_dyn x; Mark.to_dyn y ] 226 + | Before c -> variant "Before" [ Category.to_dyn c ] 227 + | After c -> variant "After" [ Category.to_dyn c ] 228 + 229 + and to_dyn sem { id = _; def } = dyn_of_def sem def 230 + 231 + let rec pp_with_sem sem ch e = 232 + let open Fmt in 233 + match e.def with 234 + | Cst l -> sexp ch "cst" Cset.pp l 235 + | Alt l -> sexp ch "alt" (list (pp_with_sem sem)) l 236 + | Seq (k, e, e') -> 237 + sexp ch "seq" (triple Sem.pp (pp_with_sem sem) (pp_with_sem sem)) (k, e, e') 238 + | Eps -> str ch "eps" 239 + | Rep (_rk, k, e) -> sexp ch "rep" (pair Sem.pp (pp_with_sem (Some k))) (k, e) 240 + | Mark i -> sexp ch "mark" Mark.pp i 241 + | Pmark i -> sexp ch "pmark" Pmark.pp i 242 + | Erase (b, e) -> sexp ch "erase" (pair Mark.pp Mark.pp) (b, e) 243 + | Before c -> sexp ch "before" Category.pp c 244 + | After c -> sexp ch "after" Category.pp c 245 + ;; 246 + 247 + let pp = pp_with_sem None 248 + let eps_expr = { id = Id.zero; def = Eps } 249 + let mk ids def = { id = Ids.next ids; def } 250 + let empty ids = mk ids (Alt []) 251 + let cst ids s = if Cset.is_empty s then empty ids else mk ids (Cst s) 252 + let eps ids = mk ids Eps 253 + let rep ids kind sem x = mk ids (Rep (kind, sem, x)) 254 + let mark ids m = mk ids (Mark m) 255 + let pmark ids i = mk ids (Pmark i) 256 + let erase ids m m' = mk ids (Erase (m, m')) 257 + let before ids c = mk ids (Before c) 258 + let after ids c = mk ids (After c) 259 + 260 + let alt ids = function 261 + | [] -> empty ids 262 + | [ c ] -> c 263 + | l -> mk ids (Alt l) 264 + ;; 265 + 266 + let seq ids (kind : Sem.t) x y = 267 + match x.def, y.def with 268 + | Alt [], _ -> x 269 + | _, Alt [] -> y 270 + | Eps, _ -> y 271 + | _, Eps when Sem.equal kind `First -> x 272 + | _ -> mk ids (Seq (kind, x, y)) 273 + ;; 274 + 275 + let is_eps expr = 276 + match expr.def with 277 + | Eps -> true 278 + | _ -> false 279 + ;; 280 + 281 + let rec rename ids x = 282 + match x.def with 283 + | Cst _ | Eps | Mark _ | Pmark _ | Erase _ | Before _ | After _ -> mk ids x.def 284 + | Alt l -> mk ids (Alt (List.map ~f:(rename ids) l)) 285 + | Seq (k, y, z) -> mk ids (Seq (k, rename ids y, rename ids z)) 286 + | Rep (g, k, y) -> mk ids (Rep (g, k, rename ids y)) 287 + ;; 288 + end 289 + 290 + type expr = Expr.t 291 + 292 + include Expr 293 + 294 + module Marks = struct 295 + type t = 296 + { marks : (Mark.t * Idx.t) list 297 + ; pmarks : Pmark.Set.t 298 + } 299 + 300 + let to_dyn { marks; pmarks } : Dyn.t = 301 + let open Dyn in 302 + record 303 + [ ( "marks" 304 + , List.map marks ~f:(fun (m, idx) -> pair (Mark.to_dyn m) (Idx.to_dyn idx)) 305 + |> list ) 306 + ; "pmarks", Pmark.Set.to_list pmarks |> List.map ~f:Pmark.to_dyn |> list 307 + ] 308 + ;; 309 + 310 + let equal { marks; pmarks } t = 311 + List.equal 312 + ~eq:(fun (x, y) (x', y') -> Mark.equal x x' && Idx.equal y y') 313 + marks 314 + t.marks 315 + && Pmark.Set.equal pmarks t.pmarks 316 + ;; 317 + 318 + let empty = { marks = []; pmarks = Pmark.Set.empty } 319 + 320 + let hash_marks_offset = 321 + let f acc ((a : Mark.t), (i : Idx.t)) = 322 + hash_combine (a :> int) (hash_combine (i :> int) acc) 323 + in 324 + fun l init -> List.fold_left l ~init ~f 325 + ;; 326 + 327 + let hash m accu = hash_marks_offset m.marks (hash_combine (Hashtbl.hash m.pmarks) accu) 328 + 329 + let marks_set_idx = 330 + let rec marks_set_idx idx marks = 331 + match marks with 332 + | [] -> [] 333 + | (a, idx') :: rem -> 334 + if Idx.equal idx' Idx.unknown then (a, idx) :: marks_set_idx idx rem else marks 335 + in 336 + fun marks idx -> { marks with marks = marks_set_idx idx marks.marks } 337 + ;; 338 + 339 + let filter t (b : Mark.t) (e : Mark.t) = 340 + { t with 341 + marks = 342 + List.filter t.marks ~f:(fun ((i : Mark.t), _) -> 343 + Mark.outside_range i ~start_inclusive:b ~stop_inclusive:e) 344 + } 345 + ;; 346 + 347 + let set_mark t (i : Mark.t) = 348 + { t with marks = (i, Idx.unknown) :: List.remove_assq i t.marks } 349 + ;; 350 + 351 + let set_pmark t i = { t with pmarks = Pmark.Set.add i t.pmarks } 352 + 353 + let pp fmt { marks; pmarks } = 354 + Format.pp_open_box fmt 1; 355 + (match marks with 356 + | [] -> () 357 + | _ :: _ -> 358 + Format.fprintf 359 + fmt 360 + "@[<2>marks@ %a@]" 361 + (Format.pp_print_list (fun fmt (a, i) -> 362 + Format.fprintf fmt "%a-%a" Mark.pp a Idx.pp i)) 363 + marks); 364 + (match Pmark.Set.to_list pmarks with 365 + | [] -> () 366 + | pmarks -> 367 + Format.fprintf fmt "@[<2>pmarks %a@]" (Format.pp_print_list Pmark.pp) pmarks); 368 + Format.pp_close_box fmt () 369 + ;; 370 + end 371 + 372 + module Status = struct 373 + type t = 374 + | Failed 375 + | Match of Mark_infos.t * Pmark.Set.t 376 + | Running 377 + end 378 + 379 + module Desc : sig 380 + type t 381 + 382 + val pp : t Fmt.t 383 + 384 + module E : sig 385 + type nonrec t = private 386 + | TSeq of Sem.t * t * Expr.t 387 + | TExp of Marks.t * Expr.t 388 + | TMatch of Marks.t 389 + end 390 + 391 + val to_dyn : t -> Dyn.t 392 + val fold_right : t -> init:'acc -> f:(E.t -> 'acc -> 'acc) -> 'acc 393 + val tseq : Sem.t -> t -> Expr.t -> t -> t 394 + val initial : Expr.t -> t 395 + val empty : t 396 + val set_idx : Idx.t -> t -> t 397 + val hash : t -> int -> int 398 + val equal : t -> t -> bool 399 + val status : t -> Status.t 400 + val first_match : t -> Marks.t option 401 + val remove_matches : t -> t 402 + val split_at_match : t -> t * t 403 + val add_match : t -> Marks.t -> t 404 + val add_eps : t -> Marks.t -> t 405 + val add_expr : t -> E.t -> t 406 + val iter_marks : t -> f:(Marks.t -> unit) -> unit 407 + val remove_duplicates : Id.Hash_set.t -> t -> Expr.t -> t 408 + end = struct 409 + module E = struct 410 + type t = 411 + | TSeq of Sem.t * t list * Expr.t 412 + | TExp of Marks.t * Expr.t 413 + | TMatch of Marks.t 414 + 415 + let rec equal_list l1 l2 = List.equal ~eq:equal l1 l2 416 + 417 + and equal x y = 418 + match x, y with 419 + | TSeq (_, l1, e1), TSeq (_, l2, e2) -> Id.equal e1.id e2.id && equal_list l1 l2 420 + | TExp (marks1, e1), TExp (marks2, e2) -> 421 + Id.equal e1.id e2.id && Marks.equal marks1 marks2 422 + | TMatch marks1, TMatch marks2 -> Marks.equal marks1 marks2 423 + | _, _ -> false 424 + ;; 425 + 426 + let rec hash (t : t) accu = 427 + match t with 428 + | TSeq (_, l, e) -> 429 + hash_combine 0x172a1bce (hash_combine (Id.hash e.id) (hash_list l accu)) 430 + | TExp (marks, e) -> 431 + hash_combine 0x2b4c0d77 (hash_combine (Id.hash e.id) (Marks.hash marks accu)) 432 + | TMatch marks -> hash_combine 0x1c205ad5 (Marks.hash marks accu) 433 + 434 + and hash_list = 435 + let f acc x = hash x acc in 436 + fun l init -> List.fold_left l ~init ~f 437 + ;; 438 + end 439 + 440 + type t = E.t list 441 + 442 + let rec to_dyn sem t = Dyn.list (List.map ~f:(dyn_of_e sem) t) 443 + 444 + and dyn_of_e sem = 445 + let open Dyn in 446 + function 447 + | E.TSeq (sem', x, y) -> 448 + wrap_sem 449 + sem 450 + sem' 451 + (variant "TSeq" [ to_dyn (Some sem') x; Expr.to_dyn (Some sem') y ]) 452 + | TExp (marks, e) -> 453 + let e = 454 + let base = [ Expr.to_dyn sem e ] in 455 + if Marks.(equal empty marks) then base else Marks.to_dyn marks :: base 456 + in 457 + variant "TExp" e 458 + | TMatch m -> variant "TMarks" [ Marks.to_dyn m ] 459 + ;; 460 + 461 + let to_dyn t = to_dyn None t 462 + 463 + open E 464 + 465 + let equal = E.equal_list 466 + let hash = E.hash_list 467 + 468 + let tseq' kind x y = 469 + match x with 470 + | [] -> [] 471 + | [ TExp (marks, { def = Eps; _ }) ] -> [ TExp (marks, y) ] 472 + | _ -> [ TSeq (kind, x, y) ] 473 + ;; 474 + 475 + let tseq kind x y rem = tseq' kind x y @ rem 476 + 477 + let rec fold_right t ~init ~f = 478 + match t with 479 + | [] -> init 480 + | x :: xs -> f x (fold_right xs ~init ~f) 481 + ;; 482 + 483 + let rec iter_marks t ~f = 484 + List.iter t ~f:(fun (e : E.t) -> 485 + match e with 486 + | TSeq (_, l, _) -> iter_marks l ~f 487 + | TExp (marks, _) | TMatch marks -> f marks) 488 + ;; 489 + 490 + let rec print_state_rec ch e (y : Expr.t) = 491 + match e with 492 + | TMatch marks -> Format.fprintf ch "@[<2>(TMatch@ %a)@]" Marks.pp marks 493 + | TSeq (sem, l', x) -> 494 + Format.fprintf ch "@[<2>(TSeq@ %a@ " Sem.pp sem; 495 + print_state_lst ch l' x; 496 + Format.fprintf ch "@ %a)@]" Expr.pp x 497 + | TExp (marks, { def = Eps; _ }) -> 498 + Format.fprintf ch "@[<2>(TExp@ %a@ (%a)@ (eps))@]" Id.pp y.id Marks.pp marks 499 + | TExp (marks, x) -> 500 + Format.fprintf ch "@[<2>(TExp@ %a@ (%a)@ %a)@]" Id.pp x.id Marks.pp marks Expr.pp x 501 + 502 + and print_state_lst ch l y = 503 + match l with 504 + | [] -> Format.fprintf ch "()" 505 + | e :: rem -> 506 + print_state_rec ch e y; 507 + List.iter rem ~f:(fun e -> 508 + Format.fprintf ch "@ | "; 509 + print_state_rec ch e y) 510 + ;; 511 + 512 + let pp ch t = print_state_lst ch [ t ] { id = Id.zero; def = Eps } 513 + 514 + let rec first_match = function 515 + | [] -> None 516 + | TMatch marks :: _ -> Some marks 517 + | _ :: r -> first_match r 518 + ;; 519 + 520 + let remove_matches t = 521 + List.filter t ~f:(function 522 + | TMatch _ -> false 523 + | _ -> true) 524 + ;; 525 + 526 + let split_at_match = 527 + let rec split_at_match_rec l = function 528 + | [] -> assert false 529 + | TMatch _ :: r -> List.rev l, remove_matches r 530 + | x :: r -> split_at_match_rec (x :: l) r 531 + in 532 + fun l -> split_at_match_rec [] l 533 + ;; 534 + 535 + let status : _ -> Status.t = function 536 + | [] -> Failed 537 + | TMatch m :: _ -> Match (Mark_infos.make (m.marks :> (int * int) list), m.pmarks) 538 + | _ -> Running 539 + ;; 540 + 541 + let set_idx = 542 + let rec f idx = function 543 + | TMatch marks -> TMatch (Marks.marks_set_idx marks idx) 544 + | TSeq (kind, l, x) -> TSeq (kind, set_idx idx l, x) 545 + | TExp (marks, x) -> TExp (Marks.marks_set_idx marks idx, x) 546 + and set_idx idx xs = List.map xs ~f:(f idx) in 547 + set_idx 548 + ;; 549 + 550 + let[@ocaml.warning "-32"] pp fmt t = 551 + Format.fprintf fmt "[%a]" (Format.pp_print_list ~pp_sep:(Fmt.lit "; ") pp) t 552 + ;; 553 + 554 + let empty = [] 555 + let initial expr = [ TExp (Marks.empty, expr) ] 556 + let add_match t marks = TMatch marks :: t 557 + let add_eps t marks = TExp (marks, eps_expr) :: t 558 + let add_expr t expr = expr :: t 559 + 560 + let remove_duplicates = 561 + let rec loop seen l y = 562 + match l with 563 + | [] -> [] 564 + | (TMatch _ as x) :: _ -> 565 + (* Truncate after first match *) 566 + [ x ] 567 + | TSeq (kind, l, x) :: r -> 568 + let l = loop seen l x in 569 + let r = loop seen r y in 570 + tseq kind l x r 571 + | (TExp (_marks, { def = Eps; _ }) as e) :: r -> 572 + if Id.Hash_set.mem seen y.id 573 + then loop seen r y 574 + else ( 575 + Id.Hash_set.add seen y.id; 576 + e :: loop seen r y) 577 + | (TExp (_marks, x) as e) :: r -> 578 + if Id.Hash_set.mem seen x.id 579 + then loop seen r y 580 + else ( 581 + Id.Hash_set.add seen x.id; 582 + e :: loop seen r y) 583 + in 584 + fun seen l y -> 585 + Id.Hash_set.clear seen; 586 + loop seen l y 587 + ;; 588 + end 589 + 590 + module E = Desc.E 591 + 592 + module State = struct 593 + type t = 594 + { idx : Idx.t 595 + ; category : Category.t 596 + ; desc : Desc.t 597 + ; mutable status : Status.t option 598 + ; hash : int 599 + } 600 + (* Thread-safety: We use double-checked locking to access field 601 + [status] in function [status] below. *) 602 + 603 + let pp fmt t = Desc.pp fmt t.desc 604 + let[@inline] idx t = t.idx 605 + let to_dyn t = Desc.to_dyn t.desc 606 + 607 + let dummy = 608 + { idx = Idx.unknown 609 + ; category = Category.dummy 610 + ; desc = Desc.empty 611 + ; status = None 612 + ; hash = -1 613 + } 614 + ;; 615 + 616 + let hash idx cat desc = 617 + Desc.hash desc (hash_combine idx (hash_combine (Category.to_int cat) 0)) 618 + land 0x3FFFFFFF 619 + ;; 620 + 621 + let mk idx cat desc = 622 + { idx; category = cat; desc; status = None; hash = hash (idx :> int) cat desc } 623 + ;; 624 + 625 + let create cat e = mk Idx.initial cat (Desc.initial e) 626 + 627 + let equal { idx; category; desc; status = _; hash } t = 628 + Int.equal hash t.hash 629 + && Idx.equal idx t.idx 630 + && Category.equal category t.category 631 + && Desc.equal desc t.desc 632 + ;; 633 + 634 + (* To be called when the mutex has already been acquired *) 635 + let status_no_mutex s = 636 + match s.status with 637 + | Some s -> s 638 + | None -> 639 + let st = Desc.status s.desc in 640 + s.status <- Some st; 641 + st 642 + ;; 643 + 644 + let status m s = 645 + match s.status with 646 + | Some s -> s 647 + | None -> 648 + Mutex.lock m; 649 + let st = status_no_mutex s in 650 + Mutex.unlock m; 651 + st 652 + ;; 653 + 654 + module Table = Hashtbl.Make (struct 655 + type nonrec t = t 656 + 657 + let equal = equal 658 + let hash t = t.hash 659 + end) 660 + end 661 + 662 + (**** Find a free index ****) 663 + 664 + module Working_area = struct 665 + type t = 666 + { mutable ids : Bit_vector.t 667 + ; seen : Id.Hash_set.t 668 + ; index_count : int Atomic.t 669 + } 670 + 671 + let create () = 672 + { ids = Bit_vector.create_zero 1 673 + ; seen = Id.Hash_set.create () 674 + ; index_count = Atomic.make 0 675 + } 676 + ;; 677 + 678 + let index_count w = Atomic.get w.index_count 679 + 680 + let mark_used_indices tbl = 681 + Desc.iter_marks ~f:(fun marks -> 682 + List.iter marks.marks ~f:(fun (_, i) -> 683 + if Idx.used i then Bit_vector.set tbl (i :> int) true)) 684 + ;; 685 + 686 + let rec find_free tbl idx len = 687 + if idx = len || not (Bit_vector.get tbl idx) then idx else find_free tbl (idx + 1) len 688 + ;; 689 + 690 + let free_index t l = 691 + Bit_vector.reset_zero t.ids; 692 + mark_used_indices t.ids l; 693 + let len = Bit_vector.length t.ids in 694 + let idx = find_free t.ids 0 len in 695 + if idx = len 696 + then ( 697 + t.ids <- Bit_vector.create_zero (2 * len); 698 + (* This function is only called when the mutex is locked. So we 699 + are sure that this is always coherent with the length of 700 + [t.ids]. *) 701 + Atomic.set t.index_count (2 * len)); 702 + Idx.make idx 703 + ;; 704 + end 705 + 706 + (**** Computation of the next state ****) 707 + 708 + type ctx = 709 + { c : Cset.c 710 + ; prev_cat : Category.t 711 + ; next_cat : Category.t 712 + } 713 + 714 + let rec delta_expr ({ c; _ } as ctx) marks (x : Expr.t) rem = 715 + (*Format.eprintf "%d@." x.id;*) 716 + match x.def with 717 + | Cst s -> if Cset.mem c s then Desc.add_eps rem marks else rem 718 + | Alt l -> delta_alt ctx marks l rem 719 + | Seq (kind, y, z) -> 720 + let y = delta_expr ctx marks y Desc.empty in 721 + delta_seq ctx kind y z rem 722 + | Rep (rep_kind, kind, y) -> delta_rep ctx marks x rep_kind kind y rem 723 + | Eps -> Desc.add_match rem marks 724 + | Mark i -> Desc.add_match rem (Marks.set_mark marks i) 725 + | Pmark i -> Desc.add_match rem (Marks.set_pmark marks i) 726 + | Erase (b, e) -> Desc.add_match rem (Marks.filter marks b e) 727 + | Before cat -> 728 + if Category.intersect ctx.next_cat cat then Desc.add_match rem marks else rem 729 + | After cat -> 730 + if Category.intersect ctx.prev_cat cat then Desc.add_match rem marks else rem 731 + 732 + and delta_rep ctx marks x rep_kind kind y rem = 733 + let y, marks' = 734 + let y = delta_expr ctx marks y Desc.empty in 735 + match Desc.first_match y with 736 + | None -> y, marks 737 + | Some marks -> Desc.remove_matches y, marks 738 + in 739 + match rep_kind with 740 + | `Greedy -> Desc.tseq kind y x (Desc.add_match rem marks') 741 + | `Non_greedy -> Desc.add_match (Desc.tseq kind y x rem) marks 742 + 743 + and delta_alt ctx marks l rem = List.fold_right l ~init:rem ~f:(delta_expr ctx marks) 744 + 745 + and delta_seq ctx (kind : Sem.t) y z rem = 746 + match Desc.first_match y with 747 + | None -> Desc.tseq kind y z rem 748 + | Some marks -> 749 + (match kind with 750 + | `Longest -> Desc.tseq kind (Desc.remove_matches y) z (delta_expr ctx marks z rem) 751 + | `Shortest -> delta_expr ctx marks z (Desc.tseq kind (Desc.remove_matches y) z rem) 752 + | `First -> 753 + let y, y' = Desc.split_at_match y in 754 + Desc.tseq kind y z (delta_expr ctx marks z (Desc.tseq kind y' z rem))) 755 + ;; 756 + 757 + let rec delta_e ctx marks (x : E.t) rem = 758 + match x with 759 + | TSeq (kind, y, z) -> 760 + let y = delta_desc ctx marks y Desc.empty in 761 + delta_seq ctx kind y z rem 762 + | TExp (marks, e) -> delta_expr ctx marks e rem 763 + | TMatch _ -> Desc.add_expr rem x 764 + 765 + and delta_desc ctx marks (l : Desc.t) rem = 766 + Desc.fold_right l ~init:rem ~f:(fun y acc -> delta_e ctx marks y acc) 767 + ;; 768 + 769 + let delta (tbl_ref : Working_area.t) next_cat char (st : State.t) = 770 + let expr = 771 + let prev_cat = st.category in 772 + let ctx = { c = char; next_cat; prev_cat } in 773 + Desc.remove_duplicates 774 + tbl_ref.seen 775 + (delta_desc ctx Marks.empty st.desc Desc.empty) 776 + Expr.eps_expr 777 + in 778 + let idx = Working_area.free_index tbl_ref expr in 779 + let expr = Desc.set_idx idx expr in 780 + State.mk idx next_cat expr 781 + ;;
+123
vendor/opam/re/lib/automata.mli
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + (* Regular expressions *) 24 + 25 + module Mark : sig 26 + type t [@@immediate] 27 + 28 + val compare : t -> t -> int 29 + val start : t 30 + val prev : t -> t 31 + val next : t -> t 32 + val next2 : t -> t 33 + val group_count : t -> int 34 + end 35 + 36 + module Sem : sig 37 + type t = 38 + [ `Longest 39 + | `Shortest 40 + | `First 41 + ] 42 + 43 + val to_dyn : t -> Dyn.t 44 + val pp : t Fmt.t 45 + end 46 + 47 + module Rep_kind : sig 48 + type t = 49 + [ `Greedy 50 + | `Non_greedy 51 + ] 52 + 53 + val to_dyn : t -> Dyn.t 54 + val pp : t Fmt.t 55 + end 56 + 57 + type expr 58 + 59 + val is_eps : expr -> bool 60 + val pp : expr Fmt.t 61 + 62 + module Ids : sig 63 + type t 64 + 65 + val create : unit -> t 66 + end 67 + 68 + val cst : Ids.t -> Cset.t -> expr 69 + val empty : Ids.t -> expr 70 + val alt : Ids.t -> expr list -> expr 71 + val seq : Ids.t -> Sem.t -> expr -> expr -> expr 72 + val eps : Ids.t -> expr 73 + val rep : Ids.t -> Rep_kind.t -> Sem.t -> expr -> expr 74 + val mark : Ids.t -> Mark.t -> expr 75 + val pmark : Ids.t -> Pmark.t -> expr 76 + val erase : Ids.t -> Mark.t -> Mark.t -> expr 77 + val before : Ids.t -> Category.t -> expr 78 + val after : Ids.t -> Category.t -> expr 79 + val rename : Ids.t -> expr -> expr 80 + 81 + (****) 82 + 83 + (* States of the automata *) 84 + 85 + module Idx : sig 86 + type t 87 + 88 + val to_int : t -> int 89 + end 90 + 91 + module Status : sig 92 + type t = 93 + | Failed 94 + | Match of Mark_infos.t * Pmark.Set.t 95 + | Running 96 + end 97 + 98 + module State : sig 99 + type t 100 + 101 + val pp : t Fmt.t 102 + val dummy : t 103 + val create : Category.t -> expr -> t 104 + val idx : t -> Idx.t 105 + val status_no_mutex : t -> Status.t 106 + val status : Mutex.t -> t -> Status.t 107 + val to_dyn : t -> Dyn.t 108 + 109 + module Table : Hashtbl.S with type key = t 110 + end 111 + 112 + (****) 113 + 114 + (* Computation of the states following a given state *) 115 + 116 + module Working_area : sig 117 + type t 118 + 119 + val create : unit -> t 120 + val index_count : t -> int 121 + end 122 + 123 + val delta : Working_area.t -> Category.t -> Cset.c -> State.t -> State.t
+48
vendor/opam/re/lib/bit_vector.ml
··· 1 + type t = 2 + { len : int 3 + ; bits : Bytes.t 4 + } 5 + 6 + let byte s i = Char.code (Bytes.unsafe_get s i) 7 + let set_byte s i x = Bytes.unsafe_set s i (Char.chr x) 8 + let length t = t.len 9 + 10 + let unsafe_set v n b = 11 + let i = n lsr 3 in 12 + let c = byte v.bits i in 13 + let mask = 1 lsl (n land 7) in 14 + set_byte v.bits i (if b then c lor mask else c land lnot mask) 15 + ;; 16 + 17 + let set v n b = 18 + if n < 0 || n >= v.len then invalid_arg "Bit_vector.set"; 19 + unsafe_set v n b 20 + ;; 21 + 22 + let unsafe_get v n = 23 + let i = n lsr 3 in 24 + byte v.bits i land (1 lsl (n land 7)) > 0 25 + ;; 26 + 27 + let get v n = 28 + if n < 0 || n >= v.len then invalid_arg "Bit_vector.get"; 29 + unsafe_get v n 30 + ;; 31 + 32 + let reset_zero t = Bytes.fill t.bits 0 (Bytes.length t.bits) '\000' 33 + 34 + let create_zero len = 35 + let bits = 36 + let r = len land 7 in 37 + let q = len lsr 3 in 38 + let len = if r = 0 then q else q + 1 in 39 + Bytes.make len '\000' 40 + in 41 + { len; bits } 42 + ;; 43 + 44 + let pp fmt { len; bits } = 45 + let len fmt () = Fmt.sexp fmt "len" Fmt.int len in 46 + let bits fmt () = Fmt.sexp fmt "bits" Fmt.bytes bits in 47 + Format.fprintf fmt "%a@.%a@." len () bits () 48 + ;;
+8
vendor/opam/re/lib/bit_vector.mli
··· 1 + type t 2 + 3 + val length : t -> int 4 + val set : t -> int -> bool -> unit 5 + val create_zero : int -> t 6 + val get : t -> int -> bool 7 + val reset_zero : t -> unit 8 + val pp : t Fmt.t
+29
vendor/opam/re/lib/category.ml
··· 1 + type t = int 2 + 3 + let equal (x : int) (y : int) = x = y 4 + let compare (x : int) (y : int) = compare x y 5 + let to_int x = x 6 + let pp = Format.pp_print_int 7 + let intersect x y = x land y <> 0 8 + let ( ++ ) x y = x lor y 9 + let dummy = -1 10 + let inexistant = 1 11 + let letter = 2 12 + let not_letter = 4 13 + let newline = 8 14 + let lastnewline = 16 15 + let search_boundary = 32 16 + let to_dyn = Dyn.int 17 + 18 + let from_char = function 19 + (* Should match [cword] definition *) 20 + | 'a' .. 'z' 21 + | 'A' .. 'Z' 22 + | '0' .. '9' 23 + | '_' | '\170' | '\181' | '\186' 24 + | '\192' .. '\214' 25 + | '\216' .. '\246' 26 + | '\248' .. '\255' -> letter 27 + | '\n' -> not_letter ++ newline 28 + | _ -> not_letter 29 + ;;
+22
vendor/opam/re/lib/category.mli
··· 1 + (** Categories represent the various kinds of characters that can be tested 2 + by look-ahead and look-behind operations. 3 + 4 + This is more restricted than Cset, but faster. *) 5 + 6 + type t [@@immediate] 7 + 8 + val ( ++ ) : t -> t -> t 9 + val from_char : char -> t 10 + val dummy : t 11 + val inexistant : t 12 + val letter : t 13 + val not_letter : t 14 + val newline : t 15 + val lastnewline : t 16 + val search_boundary : t 17 + val to_int : t -> int 18 + val equal : t -> t -> bool 19 + val compare : t -> t -> int 20 + val intersect : t -> t -> bool 21 + val pp : t Fmt.t 22 + val to_dyn : t -> Dyn.t
+56
vendor/opam/re/lib/color_map.ml
··· 1 + (* In reality, this can really be represented as a bool array. 2 + 3 + The representation is best thought of as a list of all chars along with a 4 + flag: 5 + 6 + (a, 0), (b, 1), (c, 0), (d, 0), ... 7 + 8 + characters belonging to the same color are represented by sequnces of 9 + characters with the flag set to 0. 10 + *) 11 + 12 + type t = Bytes.t 13 + 14 + module Repr = struct 15 + type t = string 16 + 17 + let repr t color = t.[Cset.to_int color] 18 + let length = String.length 19 + end 20 + 21 + module Table = struct 22 + type t = string 23 + 24 + let get_char t c = t.[Cset.to_int c] 25 + let get t c = Cset.of_char (String.unsafe_get t (Char.code c)) 26 + 27 + let translate_colors (cm : t) cset = 28 + Cset.fold_right cset ~init:Cset.empty ~f:(fun i j l -> 29 + let start = get_char cm i in 30 + let stop = get_char cm j in 31 + Cset.union (Cset.cseq start stop) l) 32 + ;; 33 + end 34 + 35 + let make () = Bytes.make 257 '\000' 36 + 37 + let flatten cm = 38 + let c = Bytes.create 256 in 39 + let color_repr = Bytes.create 256 in 40 + let v = ref 0 in 41 + Bytes.set c 0 '\000'; 42 + Bytes.set color_repr 0 '\000'; 43 + for i = 1 to 255 do 44 + if Bytes.get cm i <> '\000' then incr v; 45 + Bytes.set c i (Char.chr !v); 46 + Bytes.set color_repr !v (Char.chr i) 47 + done; 48 + Bytes.unsafe_to_string c, Bytes.sub_string color_repr 0 (!v + 1) 49 + ;; 50 + 51 + (* mark all the endpoints of the intervals of the char set with the 1 byte *) 52 + let split t set = 53 + Cset.iter set ~f:(fun i j -> 54 + Bytes.set t (Cset.to_int i) '\001'; 55 + Bytes.set t (Cset.to_int j + 1) '\001') 56 + ;;
+27
vendor/opam/re/lib/color_map.mli
··· 1 + (* Color maps exists to provide an optimization for the regex engine. The fact 2 + that some characters are entirely equivalent for some regexes means that we 3 + can use them interchangeably. 4 + 5 + A color map assigns a color to every character in our character set. Any two 6 + characters with the same color will be treated equivalently by the automaton. 7 + *) 8 + type t 9 + 10 + module Repr : sig 11 + type t 12 + 13 + val repr : t -> Cset.c -> char 14 + val length : t -> int 15 + end 16 + 17 + module Table : sig 18 + type t 19 + 20 + val get_char : t -> Cset.c -> char 21 + val get : t -> char -> Cset.c 22 + val translate_colors : t -> Cset.t -> Cset.t 23 + end 24 + 25 + val make : unit -> t 26 + val flatten : t -> Table.t * Repr.t 27 + val split : t -> Cset.t -> unit
+835
vendor/opam/re/lib/compile.ml
··· 1 + open Import 2 + 3 + let rec iter n f v = if Int.equal n 0 then v else iter (n - 1) f (f v) 4 + 5 + module Idx : sig 6 + type t [@@immediate] 7 + 8 + val unknown : t 9 + val make_break : Automata.Idx.t -> t 10 + val of_idx : Automata.Idx.t -> t 11 + val is_idx : t -> bool 12 + val is_break : t -> bool 13 + val is_unknown : t -> bool 14 + val idx : t -> int 15 + val break_idx : t -> int 16 + end = struct 17 + type t = int 18 + 19 + let unknown = -2 20 + let break = -3 21 + let of_idx (x : Automata.Idx.t) = Automata.Idx.to_int x [@@inline always] 22 + let is_idx t = t >= 0 [@@inline always] 23 + let is_break x = x <= break [@@inline always] 24 + let is_unknown x = x = unknown [@@inline always] 25 + let idx t = t [@@inline always] 26 + let make_break (idx : Automata.Idx.t) = -5 - Automata.Idx.to_int idx [@@inline always] 27 + let break_idx t = (t + 5) * -1 [@@inline always] 28 + end 29 + 30 + type match_info = 31 + | Match of Group.t 32 + | Failed 33 + | Running of { no_match_starts_before : int } 34 + 35 + type state_info = 36 + { idx : Idx.t 37 + ; (* Index of the current position in the position table. 38 + Not yet computed transitions point to a dummy state where 39 + [idx] is set to [unknown]; 40 + If [idx] is set to [break] for states that either always 41 + succeed or always fail. *) 42 + mutable final : (Category.t * (Automata.Idx.t * Automata.Status.t)) list 43 + ; (* Mapping from the category of the next character to 44 + - the index where the next position should be saved 45 + - possibly, the list of marks (and the corresponding indices) 46 + corresponding to the best match *) 47 + desc : Automata.State.t (* Description of this state of the automata *) 48 + } 49 + 50 + (* Thread-safety: we use double-checked locking to access field [final]. *) 51 + 52 + (* A state [t] is a pair composed of some information about the 53 + state [state_info] and a transition table [t array], indexed by 54 + color. For performance reason, to avoid an indirection, we manually 55 + unbox the transition table: we allocate a single array, with the 56 + state information at index 0, followed by the transitions. *) 57 + module State : sig 58 + type t 59 + 60 + val make : ncol:int -> state_info -> t 61 + val make_break : state_info -> t 62 + val get_info : t -> state_info 63 + val follow_transition : t -> color:Cset.c -> t 64 + val set_transition : t -> color:Cset.c -> t -> unit 65 + val is_unknown_transition : t -> color:Cset.c -> bool 66 + end = struct 67 + type t = Table of t array [@@unboxed] 68 + 69 + (* Thread-safety: 70 + We store the state information at index 0. For other elements 71 + of the transition table, which are lazily computed, we use 72 + double-checked locking. *) 73 + 74 + let get_info (Table st) : state_info = Obj.magic (Array.unsafe_get st 0) 75 + [@@inline always] 76 + ;; 77 + 78 + let set_info (Table st) (info : state_info) = st.(0) <- Obj.magic info 79 + 80 + let follow_transition (Table st) ~color = Array.unsafe_get st (1 + Cset.to_int color) 81 + [@@inline always] 82 + ;; 83 + 84 + let set_transition (Table st) ~color st' = st.(1 + Cset.to_int color) <- st' 85 + 86 + let is_unknown_transition st ~color = 87 + let st' = follow_transition st ~color in 88 + let info = get_info st' in 89 + Idx.is_unknown info.idx 90 + ;; 91 + 92 + let dummy (info : state_info) = Table [| Obj.magic info |] 93 + let unknown_state = dummy { idx = Idx.unknown; final = []; desc = Automata.State.dummy } 94 + 95 + let make ~ncol state = 96 + let st = Table (Array.make (ncol + 1) unknown_state) in 97 + set_info st state; 98 + st 99 + ;; 100 + 101 + let make_break state = Table [| Obj.magic state |] 102 + end 103 + 104 + (* Automata (compiled regular expression) *) 105 + type re = 106 + { initial : Automata.expr 107 + ; (* The whole regular expression *) 108 + mutable initial_states : (Category.t * State.t) list 109 + ; (* Initial states, indexed by initial category *) 110 + colors : Color_map.Table.t 111 + ; (* Color table *) 112 + color_repr : Color_map.Repr.t 113 + ; (* Table from colors to one character of this color *) 114 + ncolor : int 115 + ; (* Number of colors. *) 116 + lnl : Cset.c 117 + ; (* Color of the last newline. [Cset.null_char] if unnecessary *) 118 + tbl : Automata.Working_area.t 119 + ; (* Temporary table used to compute the first available index 120 + when computing a new state *) 121 + states : State.t Automata.State.Table.t 122 + ; (* States of the deterministic automata *) 123 + group_names : (string * int) list 124 + ; (* Named groups in the regular expression *) 125 + group_count : int 126 + ; (* Number of groups in the regular expression *) 127 + mutex : Mutex.t 128 + } 129 + 130 + (* Thread-safety: 131 + We use double-checked locking to access field [initial_states]. The 132 + state table [states] and the working area [tbl] are only accessed 133 + with the mutex [mutex] locked. 134 + The working area is shared between all threads. This might be 135 + inefficient if many threads are updating the automaton. It seems 136 + complicated to manage a working area per domain and per regular 137 + expression. So, if this becomes an issue, it might just be simpler 138 + to allocate a fresh working area whenever needed. 139 + *) 140 + 141 + let pp_re ch re = Automata.pp ch re.initial 142 + let group_count re = re.group_count 143 + let group_names re = re.group_names 144 + 145 + module Positions = struct 146 + (* Information used during matching *) 147 + type t = 148 + { mutable positions : int array 149 + ; (* Array of mark positions 150 + The mark are off by one for performance reasons *) 151 + mutable length : int 152 + } 153 + 154 + let empty = { positions = [||]; length = 0 } 155 + let length t = t.length 156 + let unsafe_set t idx pos = Array.unsafe_set t.positions idx pos 157 + 158 + let rec resize idx t = 159 + t.length <- 2 * t.length; 160 + if idx >= t.length 161 + then resize idx t 162 + else ( 163 + let pos = t.positions in 164 + t.positions <- Array.make t.length 0; 165 + Array.blit pos 0 t.positions 0 (Array.length pos)) 166 + ;; 167 + 168 + let set t idx pos = 169 + if idx >= length t then resize idx t; 170 + unsafe_set t idx pos 171 + ;; 172 + 173 + let all t = t.positions 174 + let first t = t.positions.(0) 175 + 176 + let make ~groups re = 177 + if groups 178 + then ( 179 + (* We initialize this table with a reasonable size. The required 180 + size may change when the automaton gets updated. So we are 181 + always checking whether it is large enough before modifying it. *) 182 + let length = Automata.Working_area.index_count re.tbl + 1 in 183 + { positions = Array.make length 0; length }) 184 + else empty 185 + ;; 186 + end 187 + 188 + (****) 189 + 190 + let category re ~color = 191 + if Cset.equal_c color Cset.null_char 192 + then Category.inexistant (* Special category for the last newline *) 193 + else if Cset.equal_c color re.lnl 194 + then Category.(lastnewline ++ newline ++ not_letter) 195 + else Category.from_char (Color_map.Repr.repr re.color_repr color) 196 + ;; 197 + 198 + (****) 199 + 200 + let find_state re desc = 201 + try Automata.State.Table.find re.states desc with 202 + | Not_found -> 203 + let st = 204 + let break_state = 205 + match Automata.State.status_no_mutex desc with 206 + | Running -> false 207 + | Failed | Match _ -> true 208 + in 209 + let st = 210 + { idx = 211 + (let idx = Automata.State.idx desc in 212 + if break_state then Idx.make_break idx else Idx.of_idx idx) 213 + ; final = [] 214 + ; desc 215 + } 216 + in 217 + if break_state then State.make_break st else State.make ~ncol:re.ncolor st 218 + in 219 + Automata.State.Table.add re.states desc st; 220 + st 221 + ;; 222 + 223 + (**** Match with marks ****) 224 + 225 + let delta re cat ~color st = Automata.delta re.tbl cat color st.desc 226 + 227 + let validate re (s : string) ~pos st = 228 + let color = Color_map.Table.get re.colors s.[pos] in 229 + Mutex.lock re.mutex; 230 + if State.is_unknown_transition st ~color 231 + then ( 232 + let st' = 233 + let desc' = 234 + let cat = category re ~color in 235 + delta re cat ~color (State.get_info st) 236 + in 237 + find_state re desc' 238 + in 239 + State.set_transition st ~color st'); 240 + Mutex.unlock re.mutex 241 + ;; 242 + 243 + let next colors st s pos = 244 + State.follow_transition st ~color:(Color_map.Table.get colors (String.unsafe_get s pos)) 245 + ;; 246 + 247 + let rec loop re ~colors ~positions s ~pos ~last st0 st = 248 + if pos < last 249 + then ( 250 + let st' = next colors st s pos in 251 + let idx = (State.get_info st').idx in 252 + if Idx.is_idx idx 253 + then 254 + if Idx.idx idx < Positions.length positions 255 + then ( 256 + Positions.unsafe_set positions (Idx.idx idx) pos; 257 + loop re ~colors ~positions s ~pos:(pos + 1) ~last st' st') 258 + else ( 259 + (* Resize position array *) 260 + Positions.set positions (Idx.idx idx) pos; 261 + loop re ~colors ~positions s ~pos:(pos + 1) ~last st' st') 262 + else if Idx.is_break idx 263 + then ( 264 + Positions.set positions (Idx.break_idx idx) pos; 265 + st') 266 + else ( 267 + (* Unknown *) 268 + validate re s ~pos st0; 269 + loop re ~colors ~positions s ~pos ~last st0 st0)) 270 + else st 271 + ;; 272 + 273 + let rec loop_no_mark re ~colors s ~pos ~last st0 st = 274 + if pos < last 275 + then ( 276 + let st' = next colors st s pos in 277 + let idx = (State.get_info st').idx in 278 + if Idx.is_idx idx 279 + then loop_no_mark re ~colors s ~pos:(pos + 1) ~last st' st' 280 + else if Idx.is_break idx 281 + then st' 282 + else ( 283 + (* Unknown *) 284 + validate re s ~pos st0; 285 + loop_no_mark re ~colors s ~pos ~last st0 st0)) 286 + else st 287 + ;; 288 + 289 + let final re st cat = 290 + try List.assq cat st.final with 291 + | Not_found -> 292 + Mutex.lock re.mutex; 293 + let res = 294 + try List.assq cat st.final with 295 + | Not_found -> 296 + let st' = delta re cat ~color:Cset.null_char st in 297 + let res = Automata.State.idx st', Automata.State.status_no_mutex st' in 298 + st.final <- (cat, res) :: st.final; 299 + res 300 + in 301 + Mutex.unlock re.mutex; 302 + res 303 + ;; 304 + 305 + let find_initial_state re cat = 306 + try List.assq cat re.initial_states with 307 + | Not_found -> 308 + Mutex.lock re.mutex; 309 + let res = 310 + try List.assq cat re.initial_states with 311 + | Not_found -> 312 + let st = find_state re (Automata.State.create cat re.initial) in 313 + re.initial_states <- (cat, st) :: re.initial_states; 314 + st 315 + in 316 + Mutex.unlock re.mutex; 317 + res 318 + ;; 319 + 320 + let get_color re (s : string) pos = 321 + if pos < 0 322 + then Cset.null_char 323 + else ( 324 + let slen = String.length s in 325 + if pos >= slen 326 + then Cset.null_char 327 + else if pos = slen - 1 328 + && (not (Cset.equal_c re.lnl Cset.null_char)) 329 + && Char.equal (String.unsafe_get s pos) '\n' 330 + then (* Special case for the last newline *) 331 + re.lnl 332 + else Color_map.Table.get re.colors (String.unsafe_get s pos)) 333 + ;; 334 + 335 + let rec handle_last_newline re positions ~pos st ~groups = 336 + let st' = State.follow_transition st ~color:re.lnl in 337 + let info = State.get_info st' in 338 + if Idx.is_idx info.idx 339 + then ( 340 + if groups then Positions.set positions (Idx.idx info.idx) pos; 341 + st') 342 + else if Idx.is_break info.idx 343 + then ( 344 + if groups then Positions.set positions (Idx.break_idx info.idx) pos; 345 + st') 346 + else ( 347 + (* Unknown *) 348 + let color = re.lnl in 349 + Mutex.lock re.mutex; 350 + if State.is_unknown_transition st ~color 351 + then ( 352 + let st' = 353 + let desc = 354 + let cat = category re ~color in 355 + let real_c = Color_map.Table.get re.colors '\n' in 356 + delta re cat ~color:real_c (State.get_info st) 357 + in 358 + find_state re desc 359 + in 360 + State.set_transition st ~color st'); 361 + Mutex.unlock re.mutex; 362 + handle_last_newline re positions ~pos st ~groups) 363 + ;; 364 + 365 + let rec scan_str re positions (s : string) initial_state ~last ~pos ~groups = 366 + if last = String.length s 367 + && (not (Cset.equal_c re.lnl Cset.null_char)) 368 + && last > pos 369 + && Char.equal (String.get s (last - 1)) '\n' 370 + then ( 371 + let last = last - 1 in 372 + let st = scan_str re positions ~pos s initial_state ~last ~groups in 373 + if Idx.is_break (State.get_info st).idx 374 + then st 375 + else handle_last_newline re positions ~pos:last st ~groups) 376 + else if groups 377 + then loop re ~colors:re.colors ~positions s ~pos ~last initial_state initial_state 378 + else loop_no_mark re ~colors:re.colors s ~pos ~last initial_state initial_state 379 + ;; 380 + 381 + (* This function adds a final boundary check on the input. 382 + This is useful to indicate that the output failed because 383 + of insufficient input, or to verify that the output actually 384 + matches for regex that have boundary conditions with respect 385 + to the input string. 386 + *) 387 + let final_boundary_check re positions ~last ~slen s state_info ~groups = 388 + let idx, res = 389 + let final_cat = 390 + Category.( 391 + search_boundary 392 + ++ if last = slen then inexistant else category re ~color:(get_color re s last)) 393 + in 394 + final re state_info final_cat 395 + in 396 + (match groups, res with 397 + | true, Match _ -> Positions.set positions (Automata.Idx.to_int idx) last 398 + | _ -> ()); 399 + res 400 + ;; 401 + 402 + let make_match_str re positions ~len ~groups ~partial s ~pos = 403 + let slen = String.length s in 404 + let last = if len = -1 then slen else pos + len in 405 + let st = 406 + let initial_state = 407 + let initial_cat = 408 + Category.( 409 + search_boundary 410 + ++ if pos = 0 then inexistant else category re ~color:(get_color re s (pos - 1))) 411 + in 412 + find_initial_state re initial_cat 413 + in 414 + scan_str re positions s initial_state ~pos ~last ~groups 415 + in 416 + let state_info = State.get_info st in 417 + if Idx.is_break state_info.idx || (partial && not groups) 418 + then Automata.State.status re.mutex state_info.desc 419 + else if partial && groups 420 + then ( 421 + match Automata.State.status re.mutex state_info.desc with 422 + | (Match _ | Failed) as status -> status 423 + | Running -> 424 + (* This could be because it's still not fully matched, or it 425 + could be that because we need to run special end of input 426 + checks. *) 427 + (match final_boundary_check re positions ~last ~slen s state_info ~groups with 428 + | Match _ as status -> status 429 + | Failed | Running -> 430 + (* A failure here just means that we need more data, i.e. 431 + it's a partial match. *) 432 + Running)) 433 + else final_boundary_check re positions ~last ~slen s state_info ~groups 434 + ;; 435 + 436 + module Stream = struct 437 + type nonrec t = 438 + { state : State.t 439 + ; re : re 440 + } 441 + 442 + type 'a feed = 443 + | Ok of 'a 444 + | No_match 445 + 446 + let create re = 447 + let category = Category.(search_boundary ++ inexistant) in 448 + let state = find_initial_state re category in 449 + { state; re } 450 + ;; 451 + 452 + let feed t s ~pos ~len = 453 + (* TODO bound checks? *) 454 + let last = pos + len in 455 + let state = loop_no_mark t.re ~colors:t.re.colors s ~last ~pos t.state t.state in 456 + let info = State.get_info state in 457 + if Idx.is_break info.idx 458 + && 459 + match Automata.State.status t.re.mutex info.desc with 460 + | Failed -> true 461 + | Match _ | Running -> false 462 + then No_match 463 + else Ok { t with state } 464 + ;; 465 + 466 + let finalize t s ~pos ~len = 467 + (* TODO bound checks? *) 468 + let last = pos + len in 469 + let state = scan_str t.re Positions.empty s t.state ~last ~pos ~groups:false in 470 + let info = State.get_info state in 471 + match 472 + let _idx, res = 473 + let final_cat = Category.(search_boundary ++ inexistant) in 474 + final t.re info final_cat 475 + in 476 + res 477 + with 478 + | Running | Failed -> false 479 + | Match _ -> true 480 + ;; 481 + 482 + module Group = struct 483 + type nonrec t = 484 + { t : t 485 + ; positions : Positions.t 486 + ; slices : Slice.L.t 487 + ; abs_pos : int 488 + ; first_match_pos : int 489 + } 490 + 491 + let no_match_starts_before t = t.first_match_pos 492 + 493 + let create t = 494 + { t 495 + ; positions = Positions.make ~groups:true t.re 496 + ; slices = [] 497 + ; abs_pos = 0 498 + ; first_match_pos = 0 499 + } 500 + ;; 501 + 502 + module Match = struct 503 + type t = 504 + { pmarks : Pmark.Set.t 505 + ; slices : Slice.L.t 506 + ; marks : Mark_infos.t 507 + ; positions : int array 508 + ; start_pos : int 509 + } 510 + 511 + let test_mark t mark = Pmark.Set.mem mark t.pmarks 512 + 513 + let get t i = 514 + Mark_infos.offset t.marks i 515 + |> Option.map (fun (start, stop) -> 516 + let start = t.positions.(start) - t.start_pos in 517 + let stop = t.positions.(stop) - t.start_pos in 518 + Slice.L.get_substring t.slices ~start ~stop) 519 + ;; 520 + 521 + let make ~start_pos ~pmarks ~slices ~marks ~positions = 522 + let positions = Positions.all positions in 523 + { pmarks; slices; positions; marks; start_pos } 524 + ;; 525 + end 526 + 527 + let rec loop re ~abs_pos ~colors ~positions s ~pos ~last st0 st = 528 + if pos < last 529 + then ( 530 + let st' = next colors st s pos in 531 + let idx = (State.get_info st').idx in 532 + if Idx.is_idx idx 533 + then 534 + if Idx.idx idx < Positions.length positions 535 + then ( 536 + Positions.unsafe_set positions (Idx.idx idx) (abs_pos + pos); 537 + loop re ~abs_pos ~colors ~positions s ~pos:(pos + 1) ~last st' st') 538 + else ( 539 + (* Resize position array *) 540 + Positions.set positions (Idx.idx idx) (abs_pos + pos); 541 + loop re ~abs_pos ~colors ~positions s ~pos:(pos + 1) ~last st' st') 542 + else if Idx.is_break idx 543 + then ( 544 + Positions.set positions (Idx.break_idx idx) (abs_pos + pos); 545 + st') 546 + else ( 547 + (* Unknown *) 548 + validate re s ~pos st0; 549 + loop re ~abs_pos ~colors ~positions s ~pos ~last st0 st0)) 550 + else st 551 + ;; 552 + 553 + let feed ({ t; positions; slices; abs_pos; first_match_pos = _ } as tt) s ~pos ~len = 554 + let state = 555 + (* TODO bound checks? *) 556 + let last = pos + len in 557 + loop t.re ~abs_pos ~colors:t.re.colors s ~positions ~last ~pos t.state t.state 558 + in 559 + let info = State.get_info state in 560 + if Idx.is_break info.idx 561 + && 562 + match Automata.State.status t.re.mutex info.desc with 563 + | Failed -> true 564 + | Match _ | Running -> false 565 + then No_match 566 + else ( 567 + let t = { t with state } in 568 + let slices = { Slice.s; pos; len } :: slices in 569 + let first_match_pos = Positions.first positions in 570 + let slices = Slice.L.drop_rev slices (first_match_pos - tt.first_match_pos) in 571 + let abs_pos = abs_pos + len in 572 + Ok { tt with t; slices; abs_pos; first_match_pos }) 573 + ;; 574 + 575 + let finalize 576 + ({ t; positions; slices; abs_pos; first_match_pos = _ } as tt) 577 + s 578 + ~pos 579 + ~len 580 + : Match.t feed 581 + = 582 + (* TODO bound checks? *) 583 + let last = pos + len in 584 + let info = 585 + let state = 586 + loop t.re ~abs_pos ~colors:t.re.colors s ~positions ~last ~pos t.state t.state 587 + in 588 + State.get_info state 589 + in 590 + match 591 + match Automata.State.status t.re.mutex info.desc with 592 + | (Match _ | Failed) as s -> s 593 + | Running -> 594 + let idx, res = 595 + let final_cat = Category.(search_boundary ++ inexistant) in 596 + final t.re info final_cat 597 + in 598 + (match res with 599 + | Running | Failed -> () 600 + | Match _ -> Positions.set positions (Automata.Idx.to_int idx) (abs_pos + last)); 601 + res 602 + with 603 + | Running | Failed -> No_match 604 + | Match (marks, pmarks) -> 605 + let first_match_position = Positions.first positions in 606 + let slices = 607 + let slices = 608 + let slices = { Slice.s; pos; len } :: slices in 609 + Slice.L.drop_rev slices (first_match_position - tt.first_match_pos) 610 + in 611 + List.rev slices 612 + in 613 + Ok (Match.make ~start_pos:first_match_position ~pmarks ~marks ~slices ~positions) 614 + ;; 615 + end 616 + end 617 + 618 + let match_str_no_bounds ~groups ~partial re s ~pos ~len = 619 + let positions = Positions.make ~groups re in 620 + match make_match_str re positions ~len ~groups ~partial s ~pos with 621 + | Match (marks, pmarks) -> 622 + Match 623 + (Group.create s marks pmarks ~gpos:(Positions.all positions) ~gcount:re.group_count) 624 + | Failed -> Failed 625 + | Running -> 626 + let no_match_starts_before = if groups then Positions.first positions else 0 in 627 + Running { no_match_starts_before } 628 + ;; 629 + 630 + let match_str_p re s ~pos ~len = 631 + if pos < 0 || len < -1 || pos + len > String.length s 632 + then invalid_arg "Re.exec: out of bounds"; 633 + match make_match_str re Positions.empty ~len ~groups:false ~partial:false s ~pos with 634 + | Match _ -> true 635 + | _ -> false 636 + ;; 637 + 638 + let match_str ~groups ~partial re s ~pos ~len = 639 + if pos < 0 || len < -1 || pos + len > String.length s 640 + then invalid_arg "Re.exec: out of bounds"; 641 + match_str_no_bounds ~groups ~partial re s ~pos ~len 642 + ;; 643 + 644 + let mk_re ~initial ~colors ~color_repr ~ncolor ~lnl ~group_names ~group_count = 645 + { initial 646 + ; initial_states = [] 647 + ; colors 648 + ; color_repr 649 + ; ncolor 650 + ; lnl 651 + ; tbl = Automata.Working_area.create () 652 + ; states = Automata.State.Table.create 97 653 + ; group_names 654 + ; group_count 655 + ; mutex = Mutex.create () 656 + } 657 + ;; 658 + 659 + (**** Compilation ****) 660 + 661 + module A = Automata 662 + 663 + let enforce_kind ids kind kind' cr = 664 + match kind, kind' with 665 + | `First, `First -> cr 666 + | `First, k -> A.seq ids k cr (A.eps ids) 667 + | _ -> cr 668 + ;; 669 + 670 + type context = 671 + { ids : A.Ids.t 672 + ; kind : A.Sem.t 673 + ; ign_group : bool 674 + ; greedy : A.Rep_kind.t 675 + ; pos : A.Mark.t ref 676 + ; names : (string * int) list ref 677 + ; cache : Cset.t Cset.CSetMap.t ref 678 + ; colors : Color_map.Table.t 679 + } 680 + 681 + let trans_set cache (cm : Color_map.Table.t) s = 682 + match Cset.one_char s with 683 + | Some i -> Cset.csingle (Color_map.Table.get_char cm i) 684 + | None -> 685 + let v = Cset.hash s, s in 686 + (try Cset.CSetMap.find v !cache with 687 + | Not_found -> 688 + let l = Color_map.Table.translate_colors cm s in 689 + cache := Cset.CSetMap.add v l !cache; 690 + l) 691 + ;; 692 + 693 + let make_repeater ids cr kind greedy = 694 + match greedy with 695 + | `Greedy -> fun rem -> A.alt ids [ A.seq ids kind (A.rename ids cr) rem; A.eps ids ] 696 + | `Non_greedy -> 697 + fun rem -> A.alt ids [ A.eps ids; A.seq ids kind (A.rename ids cr) rem ] 698 + ;; 699 + 700 + (* XXX should probably compute a category mask *) 701 + let rec translate 702 + ({ ids; kind; ign_group; greedy; pos; names; cache; colors } as ctx) 703 + (ast : Ast.no_case) 704 + = 705 + match ast with 706 + | Set s -> A.cst ids (trans_set cache colors s), kind 707 + | Sequence l -> trans_seq ctx l, kind 708 + | Ast (Alternative l) -> 709 + (match Ast.merge_sequences l with 710 + | [ r' ] -> 711 + let cr, kind' = translate ctx r' in 712 + enforce_kind ids kind kind' cr, kind 713 + | merged_sequences -> 714 + ( A.alt 715 + ids 716 + (List.map merged_sequences ~f:(fun r' -> 717 + let cr, kind' = translate ctx r' in 718 + enforce_kind ids kind kind' cr)) 719 + , kind )) 720 + | Repeat (r', i, j) -> 721 + let cr, kind' = translate ctx r' in 722 + let rem = 723 + match j with 724 + | None -> A.rep ids greedy kind' cr 725 + | Some j -> 726 + let f = make_repeater ids cr kind' greedy in 727 + iter (j - i) f (A.eps ids) 728 + in 729 + iter i (fun rem -> A.seq ids kind' (A.rename ids cr) rem) rem, kind 730 + | Beg_of_line -> A.after ids Category.(inexistant ++ newline), kind 731 + | End_of_line -> A.before ids Category.(inexistant ++ newline), kind 732 + | Beg_of_word -> 733 + ( A.seq 734 + ids 735 + `First 736 + (A.after ids Category.(inexistant ++ not_letter)) 737 + (A.before ids Category.letter) 738 + , kind ) 739 + | End_of_word -> 740 + ( A.seq 741 + ids 742 + `First 743 + (A.after ids Category.letter) 744 + (A.before ids Category.(inexistant ++ not_letter)) 745 + , kind ) 746 + | Not_bound -> 747 + ( A.alt 748 + ids 749 + [ A.seq ids `First (A.after ids Category.letter) (A.before ids Category.letter) 750 + ; (let cat = Category.(inexistant ++ not_letter) in 751 + A.seq ids `First (A.after ids cat) (A.before ids cat)) 752 + ] 753 + , kind ) 754 + | Beg_of_str -> A.after ids Category.inexistant, kind 755 + | End_of_str -> A.before ids Category.inexistant, kind 756 + | Last_end_of_line -> A.before ids Category.(inexistant ++ lastnewline), kind 757 + | Start -> A.after ids Category.search_boundary, kind 758 + | Stop -> A.before ids Category.search_boundary, kind 759 + | Sem (kind', r') -> 760 + let cr, kind'' = translate { ctx with kind = kind' } r' in 761 + enforce_kind ids kind' kind'' cr, kind' 762 + | Sem_greedy (greedy', r') -> translate { ctx with greedy = greedy' } r' 763 + | Group (n, r') -> 764 + if ign_group 765 + then translate ctx r' 766 + else ( 767 + let p = !pos in 768 + let () = 769 + match n with 770 + | Some name -> names := (name, A.Mark.group_count p) :: !names 771 + | None -> () 772 + in 773 + pos := A.Mark.next2 !pos; 774 + let cr, kind' = translate ctx r' in 775 + ( A.seq ids `First (A.mark ids p) (A.seq ids `First cr (A.mark ids (A.Mark.next p))) 776 + , kind' )) 777 + | No_group r' -> translate { ctx with ign_group = true } r' 778 + | Nest r' -> 779 + let b = !pos in 780 + let cr, kind' = translate ctx r' in 781 + let e = A.Mark.prev !pos in 782 + if A.Mark.compare e b = -1 783 + then cr, kind' 784 + else A.seq ids `First (A.erase ids b e) cr, kind' 785 + | Pmark (i, r') -> 786 + let cr, kind' = translate ctx r' in 787 + A.seq ids `First (A.pmark ids i) cr, kind' 788 + 789 + and trans_seq ({ ids; kind; _ } as ctx) = function 790 + | [] -> A.eps ids 791 + | [ r ] -> 792 + let cr', kind' = translate ctx r in 793 + enforce_kind ids kind kind' cr' 794 + | r :: rem -> 795 + let cr', kind' = translate ctx r in 796 + let cr'' = trans_seq ctx rem in 797 + if A.is_eps cr'' then cr' else if A.is_eps cr' then cr'' else A.seq ids kind' cr' cr'' 798 + ;; 799 + 800 + let compile_1 regexp = 801 + let regexp = Ast.handle_case false regexp in 802 + let color_map = Color_map.make () in 803 + let need_lnl = Ast.colorize color_map regexp in 804 + let colors, color_repr = Color_map.flatten color_map in 805 + let ncolor = Color_map.Repr.length color_repr in 806 + let lnl = if need_lnl then Cset.of_int ncolor else Cset.null_char in 807 + let ncolor = if need_lnl then ncolor + 1 else ncolor in 808 + let ctx = 809 + { ids = A.Ids.create () 810 + ; kind = `First 811 + ; ign_group = false 812 + ; greedy = `Greedy 813 + ; pos = ref A.Mark.start 814 + ; names = ref [] 815 + ; cache = ref Cset.CSetMap.empty 816 + ; colors 817 + } 818 + in 819 + let r, kind = translate ctx regexp in 820 + let r = enforce_kind ctx.ids `First kind r in 821 + (*Format.eprintf "<%d %d>@." !ids ncol;*) 822 + mk_re 823 + ~initial:r 824 + ~colors 825 + ~color_repr 826 + ~ncolor 827 + ~lnl 828 + ~group_names:(List.rev !(ctx.names)) 829 + ~group_count:(A.Mark.group_count !(ctx.pos)) 830 + ;; 831 + 832 + let compile r = 833 + let open Ast.Export in 834 + compile_1 (if Ast.anchored r then group r else seq [ shortest (rep any); group r ]) 835 + ;;
+59
vendor/opam/re/lib/compile.mli
··· 1 + type re 2 + 3 + module Stream : sig 4 + type t 5 + 6 + type 'a feed = 7 + | Ok of 'a 8 + | No_match 9 + 10 + val create : re -> t 11 + val feed : t -> string -> pos:int -> len:int -> t feed 12 + val finalize : t -> string -> pos:int -> len:int -> bool 13 + 14 + module Group : sig 15 + type stream := t 16 + type t 17 + 18 + module Match : sig 19 + type t 20 + 21 + val get : t -> int -> string option 22 + val test_mark : t -> Pmark.t -> bool 23 + end 24 + 25 + val create : stream -> t 26 + val feed : t -> string -> pos:int -> len:int -> t feed 27 + val finalize : t -> string -> pos:int -> len:int -> Match.t feed 28 + val no_match_starts_before : t -> int 29 + end 30 + end 31 + 32 + type match_info = 33 + | Match of Group.t 34 + | Failed 35 + | Running of { no_match_starts_before : int } 36 + 37 + val match_str_no_bounds 38 + : groups:bool 39 + -> partial:bool 40 + -> re 41 + -> string 42 + -> pos:int 43 + -> len:int 44 + -> match_info 45 + 46 + val match_str 47 + : groups:bool 48 + -> partial:bool 49 + -> re 50 + -> string 51 + -> pos:int 52 + -> len:int 53 + -> match_info 54 + 55 + val match_str_p : re -> string -> pos:int -> len:int -> bool 56 + val compile : Ast.t -> re 57 + val group_count : re -> int 58 + val group_names : re -> (string * int) list 59 + val pp_re : re Fmt.t
+173
vendor/opam/re/lib/core.ml
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + open Import 24 + 25 + include struct 26 + let cset = Ast.cset 27 + let rg c c' = cset (Cset.cseq c c') 28 + let notnl = cset Cset.notnl 29 + let lower = cset Cset.lower 30 + let upper = cset Cset.upper 31 + let alpha = cset Cset.alpha 32 + let digit = cset Cset.cdigit 33 + let alnum = cset Cset.alnum 34 + let wordc = cset Cset.wordc 35 + let ascii = cset Cset.ascii 36 + let blank = cset Cset.blank 37 + let cntrl = cset Cset.cntrl 38 + let graph = cset Cset.graph 39 + let print = cset Cset.print 40 + let punct = cset Cset.punct 41 + let space = cset Cset.space 42 + let xdigit = cset Cset.xdigit 43 + end 44 + 45 + include Ast.Export 46 + 47 + let exec_internal ?(pos = 0) ?(len = -1) ~partial ~groups re s = 48 + Compile.match_str ~groups ~partial re s ~pos ~len 49 + ;; 50 + 51 + let exec ?pos ?len re s = 52 + match exec_internal ?pos ?len ~groups:true ~partial:false re s with 53 + | Match substr -> substr 54 + | _ -> raise Not_found 55 + ;; 56 + 57 + let exec_opt ?pos ?len re s = 58 + match exec_internal ?pos ?len ~groups:true ~partial:false re s with 59 + | Match substr -> Some substr 60 + | _ -> None 61 + ;; 62 + 63 + let execp ?(pos = 0) ?(len = -1) re s = Compile.match_str_p ~pos ~len re s 64 + 65 + let exec_partial ?pos ?len re s = 66 + match exec_internal ~groups:false ~partial:true ?pos ?len re s with 67 + | Match _ -> `Full 68 + | Running _ -> `Partial 69 + | Failed -> `Mismatch 70 + ;; 71 + 72 + let exec_partial_detailed ?pos ?len re s = 73 + match exec_internal ~groups:true ~partial:true ?pos ?len re s with 74 + | Match group -> `Full group 75 + | Running { no_match_starts_before } -> `Partial no_match_starts_before 76 + | Failed -> `Mismatch 77 + ;; 78 + 79 + module Mark = struct 80 + type t = Pmark.t 81 + 82 + let test (g : Group.t) p = Pmark.Set.mem p (Group.pmarks g) 83 + let all (g : Group.t) = Group.pmarks g 84 + 85 + module Set = Pmark.Set 86 + 87 + let equal = Pmark.equal 88 + let compare = Pmark.compare 89 + end 90 + 91 + type split_token = 92 + [ `Text of string 93 + | `Delim of Group.t 94 + ] 95 + 96 + module Gen = struct 97 + type 'a gen = unit -> 'a option 98 + 99 + let gen_of_seq (s : 'a Seq.t) : 'a gen = 100 + let r = ref s in 101 + fun () -> 102 + match !r () with 103 + | Seq.Nil -> None 104 + | Seq.Cons (x, tl) -> 105 + r := tl; 106 + Some x 107 + ;; 108 + 109 + let split ?pos ?len re s : _ gen = Search.split ?pos ?len re s |> gen_of_seq 110 + let split_full ?pos ?len re s : _ gen = Search.split_full ?pos ?len re s |> gen_of_seq 111 + let all ?pos ?len re s = Search.all ?pos ?len re s |> gen_of_seq 112 + let matches ?pos ?len re s = Search.matches ?pos ?len re s |> gen_of_seq 113 + end 114 + 115 + module Group = Group 116 + 117 + (** {2 Deprecated functions} *) 118 + 119 + let split_full_seq = Search.split_full 120 + let split_seq = Search.split 121 + let matches_seq = Search.matches 122 + let all_seq = Search.all 123 + 124 + type 'a gen = 'a Gen.gen 125 + 126 + let all_gen = Gen.all 127 + let matches_gen = Gen.matches 128 + let split_gen = Gen.split 129 + let split_full_gen = Gen.split_full 130 + 131 + type substrings = Group.t 132 + 133 + let get = Group.get 134 + let get_ofs = Group.offset 135 + let get_all = Group.all 136 + let get_all_ofs = Group.all_offset 137 + let test = Group.test 138 + 139 + type markid = Mark.t 140 + 141 + let marked = Mark.test 142 + let mark_set = Mark.all 143 + 144 + type groups = Group.t 145 + 146 + module List = struct 147 + let list_of_seq (s : 'a Seq.t) : 'a list = 148 + Seq.fold_left (fun l x -> x :: l) [] s |> List.rev 149 + ;; 150 + 151 + let all ?pos ?len re s = Search.all ?pos ?len re s |> list_of_seq 152 + let matches ?pos ?len re s = Search.matches ?pos ?len re s |> list_of_seq 153 + let split_full ?pos ?len re s = Search.split_full ?pos ?len re s |> list_of_seq 154 + let split ?pos ?len re s = Search.split ?pos ?len re s |> list_of_seq 155 + let split_delim ?pos ?len re s = Search.split_delim ?pos ?len re s |> list_of_seq 156 + end 157 + 158 + include List 159 + 160 + include struct 161 + open Compile 162 + 163 + type nonrec re = re 164 + 165 + let compile = compile 166 + let pp_re = pp_re 167 + let print_re = pp_re 168 + let group_names = group_names 169 + let group_count = group_count 170 + end 171 + 172 + module Seq = Search 173 + module Stream = Compile.Stream
+813
vendor/opam/re/lib/core.mli
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + (** Module [Re]: code for creating and using regular expressions, 24 + independently of regular expression syntax. *) 25 + 26 + (** Regular expression *) 27 + type t = Ast.t 28 + 29 + (** Compiled regular expression *) 30 + type re = Compile.re 31 + 32 + (** Manipulate matching groups. *) 33 + module Group : sig 34 + (** Information about groups in a match. As is conventional, every 35 + match implicitly has a group 0 that covers the whole match, and 36 + explicit groups are numbered from 1. *) 37 + type t = Group.t 38 + 39 + (** Raise [Not_found] if the group did not match *) 40 + val get : t -> int -> string 41 + 42 + (** Similar to {!get}, but returns an option instead of using an exception. *) 43 + val get_opt : t -> int -> string option 44 + 45 + (** Raise [Not_found] if the group did not match *) 46 + val offset : t -> int -> int * int 47 + 48 + (** Similar to {!offset}, but returns an option instead of using an exception. *) 49 + val offset_opt : t -> int -> (int * int) option 50 + 51 + (** Return the start of the match. Raise [Not_found] if the group did not match. *) 52 + val start : t -> int -> int 53 + 54 + (** Similar to {!start_opt}, but returns an option instead of using an exception. *) 55 + val start_opt : t -> int -> int option 56 + 57 + (** Return the end of the match. Raise [Not_found] if the group did not match. *) 58 + val stop : t -> int -> int 59 + 60 + (** Similar to {!stop_opt}, but returns an option instead of using an exception. *) 61 + val stop_opt : t -> int -> int option 62 + 63 + (** Return the empty string for each group which did not match *) 64 + val all : t -> string array 65 + 66 + (** Return [(-1,-1)] for each group which did not match *) 67 + val all_offset : t -> (int * int) array 68 + 69 + (** Test whether a group matched *) 70 + val test : t -> int -> bool 71 + 72 + (** Returns the total number of groups defined - matched or not. 73 + This function is experimental. *) 74 + val nb_groups : t -> int 75 + 76 + val pp : Format.formatter -> t -> unit 77 + end 78 + 79 + type groups = Group.t [@@ocaml.deprecated "Use Group.t"] 80 + 81 + (** {2 Compilation and execution of a regular expression} *) 82 + 83 + (** Compile a regular expression into an executable version that can be 84 + used to match strings, e.g. with {!exec}. *) 85 + val compile : t -> re 86 + 87 + (** Return the number of capture groups (including the one 88 + corresponding to the entire regexp). *) 89 + val group_count : re -> int 90 + 91 + (** Return named capture groups with their index. *) 92 + val group_names : re -> (string * int) list 93 + 94 + (** [exec re str] searches [str] for a match of the compiled expression [re], 95 + and returns the matched groups if any. 96 + 97 + More specifically, when a match exists, [exec] returns a match that 98 + starts at the earliest position possible. If multiple such matches are 99 + possible, the one specified by the match semantics described below is 100 + returned. 101 + 102 + {5 Examples:} 103 + {[ 104 + # let regex = Re.compile Re.(seq [str "//"; rep print ]);; 105 + val regex : re = <abstr> 106 + 107 + # Re.exec regex "// a C comment";; 108 + - : Re.Group.t = <abstr> 109 + 110 + # Re.exec regex "# a C comment?";; 111 + Exception: Not_found 112 + 113 + # Re.exec ~pos:1 regex "// a C comment";; 114 + Exception: Not_found 115 + ]} 116 + 117 + @param pos optional beginning of the string (default 0) 118 + @param len 119 + length of the substring of [str] that can be matched (default [-1], 120 + meaning to the end of the string) 121 + @raise Not_found if the regular expression can't be found in [str] *) 122 + val exec 123 + : ?pos:int (** Default: 0 *) 124 + -> ?len:int (** Default: -1 (until end of string) *) 125 + -> re 126 + -> string 127 + -> Group.t 128 + 129 + (** Similar to {!exec}, but returns an option instead of using an exception. 130 + 131 + {5 Examples:} 132 + {[ 133 + # let regex = Re.compile Re.(seq [str "//"; rep print ]);; 134 + val regex : re = <abstr> 135 + 136 + # Re.exec_opt regex "// a C comment";; 137 + - : Re.Group.t option = Some <abstr> 138 + 139 + # Re.exec_opt regex "# a C comment?";; 140 + - : Re.Group.t option = None 141 + 142 + # Re.exec_opt ~pos:1 regex "// a C comment";; 143 + - : Re.Group.t option = None 144 + ]} *) 145 + val exec_opt 146 + : ?pos:int (** Default: 0 *) 147 + -> ?len:int (** Default: -1 (until end of string) *) 148 + -> re 149 + -> string 150 + -> Group.t option 151 + 152 + (** Similar to {!exec}, but returns [true] if the expression matches, 153 + and [false] if it doesn't. This function is more efficient than 154 + calling {!exec} or {!exec_opt} and ignoring the returned group. 155 + 156 + {5 Examples:} 157 + {[ 158 + # let regex = Re.compile Re.(seq [str "//"; rep print ]);; 159 + val regex : re = <abstr> 160 + 161 + # Re.execp regex "// a C comment";; 162 + - : bool = true 163 + 164 + # Re.execp ~pos:1 regex "// a C comment";; 165 + - : bool = false 166 + ]} *) 167 + val execp 168 + : ?pos:int (** Default: 0 *) 169 + -> ?len:int (** Default: -1 (until end of string) *) 170 + -> re 171 + -> string 172 + -> bool 173 + 174 + (** More detailed version of {!execp}. [`Full] is equivalent to [true], 175 + while [`Mismatch] and [`Partial] are equivalent to [false], but [`Partial] 176 + indicates the input string could be extended to create a match. 177 + 178 + {5 Examples:} 179 + {[ 180 + # let regex = Re.compile Re.(seq [bos; str "// a C comment"]);; 181 + val regex : re = <abstr> 182 + 183 + # Re.exec_partial regex "// a C comment here.";; 184 + - : [ `Full | `Mismatch | `Partial ] = `Full 185 + 186 + # Re.exec_partial regex "// a C comment";; 187 + - : [ `Full | `Mismatch | `Partial ] = `Partial 188 + 189 + # Re.exec_partial regex "//";; 190 + - : [ `Full | `Mismatch | `Partial ] = `Partial 191 + 192 + # Re.exec_partial regex "# a C comment?";; 193 + - : [ `Full | `Mismatch | `Partial ] = `Mismatch 194 + ]} *) 195 + val exec_partial 196 + : ?pos:int (** Default: 0 *) 197 + -> ?len:int (** Default: -1 (until end of string) *) 198 + -> re 199 + -> string 200 + -> [ `Full | `Partial | `Mismatch ] 201 + 202 + (** More detailed version of {!exec_opt}. [`Full group] is equivalent to [Some group], 203 + while [`Mismatch] and [`Partial _] are equivalent to [None], but [`Partial position] 204 + indicates that the input string could be extended to create a match, and no match could 205 + start in the input string before the given position. 206 + This could be used to not have to search the entirety of the input if more 207 + becomes available, and use the given position as the [?pos] argument. *) 208 + val exec_partial_detailed 209 + : ?pos:int (** Default: 0 *) 210 + -> ?len:int (** Default: -1 (until end of string) *) 211 + -> re 212 + -> string 213 + -> [ `Full of Group.t | `Partial of int | `Mismatch ] 214 + 215 + (** Marks *) 216 + module Mark : sig 217 + (** Mark id *) 218 + type t = Pmark.t 219 + 220 + (** Tell if a mark was matched. *) 221 + val test : Group.t -> t -> bool 222 + 223 + module Set : Set.S with type elt = t 224 + 225 + (** Return all the mark matched. *) 226 + val all : Group.t -> Set.t 227 + 228 + val equal : t -> t -> bool 229 + val compare : t -> t -> int 230 + end 231 + 232 + (** {2 High Level Operations} *) 233 + 234 + type split_token = 235 + [ `Text of string (** Text between delimiters *) 236 + | `Delim of Group.t (** Delimiter *) 237 + ] 238 + 239 + (** Repeatedly calls {!exec} on the given string, starting at given position and 240 + length. 241 + 242 + {5 Examples:} 243 + {[ 244 + # let regex = Re.compile Re.(seq [str "my"; blank; word(rep alpha)]);; 245 + val regex : re = <abstr> 246 + 247 + # Re.all regex "my head, my shoulders, my knees, my toes ...";; 248 + - : Re.Group.t list = [<abstr>; <abstr>; <abstr>; <abstr>] 249 + 250 + # Re.all regex "My head, My shoulders, My knees, My toes ...";; 251 + - : Re.Group.t list = [] 252 + ]} *) 253 + val all : ?pos:int -> ?len:int -> re -> string -> Group.t list 254 + 255 + type 'a gen = unit -> 'a option 256 + 257 + (** @deprecated Use {!module-Seq.all} instead. *) 258 + val all_gen : ?pos:int -> ?len:int -> re -> string -> Group.t gen 259 + [@@ocaml.deprecated "Use Seq.all"] 260 + 261 + (** @deprecated Use {!module-Seq.all} instead. *) 262 + val all_seq : ?pos:int -> ?len:int -> re -> string -> Group.t Seq.t 263 + [@@ocaml.deprecated "Use Seq.all"] 264 + 265 + (** Same as {!all}, but extracts the matched substring rather than returning 266 + the whole group. This basically iterates over matched strings. 267 + 268 + {5 Examples:} 269 + {[ 270 + # let regex = Re.compile Re.(seq [str "my"; blank; word(rep alpha)]);; 271 + val regex : re = <abstr> 272 + 273 + # Re.matches regex "my head, my shoulders, my knees, my toes ...";; 274 + - : string list = ["my head"; "my shoulders"; "my knees"; "my toes"] 275 + 276 + # Re.matches regex "My head, My shoulders, My knees, My toes ...";; 277 + - : string list = [] 278 + 279 + # Re.matches regex "my my my my head my 1 toe my ...";; 280 + - : string list = ["my my"; "my my"] 281 + 282 + # Re.matches ~pos:2 regex "my my my my head my +1 toe my ...";; 283 + - : string list = ["my my"; "my head"] 284 + ]} *) 285 + val matches : ?pos:int -> ?len:int -> re -> string -> string list 286 + 287 + (** @deprecated Use {!module-Seq.matches} instead. *) 288 + val matches_gen : ?pos:int -> ?len:int -> re -> string -> string gen 289 + [@@ocaml.deprecated "Use Seq.matches"] 290 + 291 + (** @deprecated Use {!module-Seq.matches} instead. *) 292 + val matches_seq : ?pos:int -> ?len:int -> re -> string -> string Seq.t 293 + [@@ocaml.deprecated "Use Seq.matches"] 294 + 295 + (** [split re s] splits [s] into chunks separated by [re]. It yields 296 + the chunks themselves, not the separator. An occurence of the 297 + separator at the beginning or the end of the string is ignoring. 298 + 299 + {5 Examples:} 300 + {[ 301 + # let regex = Re.compile (Re.char ',');; 302 + val regex : re = <abstr> 303 + 304 + # Re.split regex "Re,Ocaml,Jerome Vouillon";; 305 + - : string list = ["Re"; "Ocaml"; "Jerome Vouillon"] 306 + 307 + # Re.split regex "No commas in this sentence.";; 308 + - : string list = ["No commas in this sentence."] 309 + 310 + # Re.split regex ",1,2,";; 311 + - : string list = ["1"; "2"] 312 + 313 + # Re.split ~pos:3 regex "1,2,3,4. Commas go brrr.";; 314 + - : string list = ["3"; "4. Commas go brrr."] 315 + ]} 316 + 317 + {6 Zero-length patterns:} 318 + 319 + Be careful when using [split] with zero-length patterns like [eol], [bow], 320 + and [eow]. Because they don't have any width, they will still be present in 321 + the result. (Note the position of the [\n] and space characters in the 322 + output.) 323 + 324 + {[ 325 + # Re.split (Re.compile Re.eol) "a\nb";; 326 + - : string list = ["a"; "\nb"] 327 + 328 + # Re.split (Re.compile Re.bow) "a b";; 329 + - : string list = ["a "; "b"] 330 + 331 + # Re.split (Re.compile Re.eow) "a b";; 332 + - : string list = ["a"; " b"] 333 + ]} 334 + 335 + Compare this to the behavior of splitting on the char itself. (Note that 336 + the delimiters are not present in the output.) 337 + 338 + {[ 339 + # Re.split (Re.compile (Re.char '\n')) "a\nb";; 340 + - : string list = ["a"; "b"] 341 + 342 + # Re.split (Re.compile (Re.char ' ')) "a b";; 343 + - : string list = ["a"; "b"] 344 + ]} *) 345 + val split : ?pos:int -> ?len:int -> re -> string -> string list 346 + 347 + (** [split_delim re s] splits [s] into chunks separated by [re]. It 348 + yields the chunks themselves, not the separator. Occurences of the 349 + separator at the beginning or the end of the string will produce 350 + empty chunks. 351 + 352 + {5 Examples:} 353 + {[ 354 + # let regex = Re.compile (Re.char ',');; 355 + val regex : re = <abstr> 356 + 357 + # Re.split regex "Re,Ocaml,Jerome Vouillon";; 358 + - : string list = ["Re"; "Ocaml"; "Jerome Vouillon"] 359 + 360 + # Re.split regex "No commas in this sentence.";; 361 + - : string list = ["No commas in this sentence."] 362 + 363 + # Re.split regex ",1,2,";; 364 + - : string list = [""; "1"; "2"; ""] 365 + 366 + # Re.split ~pos:3 regex "1,2,3,4. Commas go brrr.";; 367 + - : string list = ["3"; "4. Commas go brrr."] 368 + ]} 369 + 370 + {6 Zero-length patterns:} 371 + 372 + Be careful when using [split_delim] with zero-length patterns like [eol], 373 + [bow], and [eow]. Because they don't have any width, they will still be 374 + present in the result. (Note the position of the [\n] and space characters 375 + in the output.) 376 + 377 + {[ 378 + # Re.split_delim (Re.compile Re.eol) "a\nb";; 379 + - : string list = ["a"; "\nb"; ""] 380 + 381 + # Re.split_delim (Re.compile Re.bow) "a b";; 382 + - : string list = [""; "a "; "b"] 383 + 384 + # Re.split_delim (Re.compile Re.eow) "a b";; 385 + - : string list = ["a"; " b"; ""] 386 + ]} 387 + 388 + Compare this to the behavior of splitting on the char itself. (Note that 389 + the delimiters are not present in the output.) 390 + 391 + {[ 392 + # Re.split_delim (Re.compile (Re.char '\n')) "a\nb";; 393 + - : string list = ["a"; "b"] 394 + 395 + # Re.split_delim (Re.compile (Re.char ' ')) "a b";; 396 + - : string list = ["a"; "b"] 397 + ]} *) 398 + val split_delim : ?pos:int -> ?len:int -> re -> string -> string list 399 + 400 + (** @deprecated Use {!module-Seq.split} instead. *) 401 + val split_gen : ?pos:int -> ?len:int -> re -> string -> string gen 402 + [@@ocaml.deprecated "Use Seq.split"] 403 + 404 + (** @deprecated Use {!module-Seq.split} instead. *) 405 + val split_seq : ?pos:int -> ?len:int -> re -> string -> string Seq.t 406 + [@@ocaml.deprecated "Use Seq.split"] 407 + 408 + (** [split re s] splits [s] into chunks separated by [re]. It yields the chunks 409 + along with the separators. For instance this can be used with a 410 + whitespace-matching re such as ["[\t ]+"]. 411 + 412 + {5 Examples:} 413 + {[ 414 + # let regex = Re.compile (Re.char ',');; 415 + val regex : re = <abstr> 416 + 417 + # Re.split_full regex "Re,Ocaml,Jerome Vouillon";; 418 + - : Re.split_token list = 419 + [`Text "Re"; `Delim <abstr>; `Text "Ocaml"; `Delim <abstr>; 420 + `Text "Jerome Vouillon"] 421 + 422 + # Re.split_full regex "No commas in this sentence.";; 423 + - : Re.split_token list = [`Text "No commas in this sentence."] 424 + 425 + # Re.split_full ~pos:3 regex "1,2,3,4. Commas go brrr.";; 426 + - : Re.split_token list = 427 + [`Delim <abstr>; `Text "3"; `Delim <abstr>; `Text "4. Commas go brrr."] 428 + ]} *) 429 + val split_full : ?pos:int -> ?len:int -> re -> string -> split_token list 430 + 431 + (** @deprecated Use {!module-Seq.split_full} instead. *) 432 + val split_full_gen : ?pos:int -> ?len:int -> re -> string -> split_token gen 433 + [@@ocaml.deprecated "Use Seq.split_full"] 434 + 435 + (** @deprecated Use {!module-Seq.split_full} instead. *) 436 + val split_full_seq : ?pos:int -> ?len:int -> re -> string -> split_token Seq.t 437 + [@@ocaml.deprecated "Use Seq.split_full"] 438 + 439 + module Seq : sig 440 + (** Same as {!module-Re.val-all} but returns an iterator. 441 + 442 + {5 Examples:} 443 + {[ 444 + # let regex = Re.compile Re.(seq [str "my"; blank; word(rep alpha)]);; 445 + val regex : re = <abstr> 446 + 447 + # Re.Seq.all regex "my head, my shoulders, my knees, my toes ...";; 448 + - : Re.Group.t Seq.t = <fun> 449 + ]} 450 + @since 1.10.0 *) 451 + val all : ?pos:int (** Default: 0 *) -> ?len:int -> re -> string -> Group.t Seq.t 452 + 453 + (** Same as {!module-Re.val-matches}, but returns an iterator. 454 + 455 + {5 Example:} 456 + {[ 457 + # let regex = Re.compile Re.(seq [str "my"; blank; word(rep alpha)]);; 458 + val regex : re = <abstr> 459 + 460 + # Re.Seq.matches regex "my head, my shoulders, my knees, my toes ...";; 461 + - : string Seq.t = <fun> 462 + ]} 463 + @since 1.10.0 *) 464 + val matches : ?pos:int (** Default: 0 *) -> ?len:int -> re -> string -> string Seq.t 465 + 466 + (** Same as {!module-Re.val-split} but returns an iterator. 467 + 468 + {5 Example:} 469 + {[ 470 + # let regex = Re.compile (Re.char ',');; 471 + val regex : re = <abstr> 472 + 473 + # Re.Seq.split regex "Re,Ocaml,Jerome Vouillon";; 474 + - : string Seq.t = <fun> 475 + ]} 476 + @since 1.10.0 *) 477 + val split : ?pos:int (** Default: 0 *) -> ?len:int -> re -> string -> string Seq.t 478 + 479 + (** Same as {!module-Re.val-split_delim} but returns an iterator. 480 + 481 + {5 Example:} 482 + {[ 483 + # let regex = Re.compile (Re.char ',');; 484 + val regex : re = <abstr> 485 + 486 + # Re.Seq.split regex "Re,Ocaml,Jerome Vouillon";; 487 + - : string Seq.t = <fun> 488 + ]} 489 + @since 1.11.1 *) 490 + val split_delim : ?pos:int (** Default: 0 *) -> ?len:int -> re -> string -> string Seq.t 491 + 492 + (** Same as {!module-Re.val-split_full} but returns an iterator. 493 + 494 + {5 Example:} 495 + {[ 496 + # let regex = Re.compile (Re.char ',');; 497 + val regex : re = <abstr> 498 + 499 + # Re.Seq.split_full regex "Re,Ocaml,Jerome Vouillon";; 500 + - : Re.split_token Seq.t = <fun> 501 + ]} 502 + @since 1.10.0 *) 503 + val split_full 504 + : ?pos:int (** Default: 0 *) 505 + -> ?len:int 506 + -> re 507 + -> string 508 + -> split_token Seq.t 509 + end 510 + 511 + (** {2 String expressions (literal match)} *) 512 + 513 + val str : string -> t 514 + val char : char -> t 515 + 516 + (** {2 Basic operations on regular expressions} *) 517 + 518 + (** Alternative. 519 + 520 + [alt []] is equivalent to {!empty}. 521 + 522 + By default, the leftmost match is preferred (see match semantics below). *) 523 + val alt : t list -> t 524 + 525 + (** Sequence *) 526 + val seq : t list -> t 527 + 528 + (** Match nothing *) 529 + val empty : t 530 + 531 + (** Empty word *) 532 + val epsilon : t 533 + 534 + (** 0 or more matches *) 535 + val rep : t -> t 536 + 537 + (** 1 or more matches *) 538 + val rep1 : t -> t 539 + 540 + (** [repn re i j] matches [re] at least [i] times 541 + and at most [j] times, bounds included. 542 + [j = None] means no upper bound. *) 543 + val repn : t -> int -> int option -> t 544 + 545 + (** 0 or 1 matches *) 546 + val opt : t -> t 547 + 548 + (** {2 String, line, word} 549 + 550 + We define a word as a sequence of latin1 letters, digits and underscore. *) 551 + 552 + (** Beginning of line *) 553 + val bol : t 554 + 555 + (** End of line *) 556 + val eol : t 557 + 558 + (** Beginning of word *) 559 + val bow : t 560 + 561 + (** End of word *) 562 + val eow : t 563 + 564 + (** Beginning of string. This differs from {!start} because it matches 565 + the beginning of the input string even when using [~pos] arguments: 566 + 567 + {[ 568 + let b = execp (compile (seq [ bos; str "a" ])) "aa" ~pos:1 in 569 + assert (not b) 570 + ]} *) 571 + val bos : t 572 + 573 + (** End of string. This is different from {!stop} in the way described 574 + in {!bos}. *) 575 + val eos : t 576 + 577 + (** Last end of line or end of string *) 578 + val leol : t 579 + 580 + (** Initial position. This differs from {!bos} because it takes into 581 + account the [~pos] arguments: 582 + 583 + {[ 584 + let b = execp (compile (seq [ start; str "a" ])) "aa" ~pos:1 in 585 + assert b 586 + ]} *) 587 + val start : t 588 + 589 + (** Final position. This is different from {!eos} in the way described 590 + in {!start}. *) 591 + val stop : t 592 + 593 + (** Word *) 594 + val word : t -> t 595 + 596 + (** Not at a word boundary *) 597 + val not_boundary : t 598 + 599 + (** Only matches the whole string, i.e. [fun t -> seq [ bos; t; eos ]]. *) 600 + val whole_string : t -> t 601 + 602 + (** {2 Match semantics} 603 + 604 + A regular expression frequently matches a string in multiple ways. For 605 + instance [exec (compile (opt (str "a"))) "ab"] can match "" or "a". Match 606 + semantic can be modified with the functions below, allowing one to choose 607 + which of these is preferable. 608 + 609 + By default, the leftmost branch of alternations is preferred, and repetitions 610 + are greedy. 611 + 612 + Note that the existence of matches cannot be changed by specifying match 613 + semantics. [seq [ bos; str "a"; non_greedy (opt (str "b")); eos ]] will 614 + match when applied to "ab". However if [seq [ bos; str "a"; non_greedy (opt 615 + (str "b")) ]] is applied to "ab", it will match "a" rather than "ab". 616 + 617 + Also note that multiple match semantics can conflict. In this case, the one 618 + executed earlier takes precedence. For instance, any match of [shortest (seq 619 + [ bos; group (rep (str "a")); group (rep (str "a")); eos ])] will always have 620 + an empty first group. Conversely, if we use [longest] instead of [shortest], 621 + the second group will always be empty. *) 622 + 623 + (** Longest match semantics. That is, matches will match as many bytes as 624 + possible. If multiple choices match the maximum amount of bytes, the one 625 + respecting the inner match semantics is preferred. *) 626 + val longest : t -> t 627 + 628 + (** Same as {!longest}, but matching the least number of bytes. *) 629 + val shortest : t -> t 630 + 631 + (** First match semantics for alternations (not repetitions). That is, matches 632 + will prefer the leftmost branch of the alternation that matches the text. *) 633 + val first : t -> t 634 + 635 + (** Greedy matches for repetitions ({!opt}, {!rep}, {!rep1}, {!repn}): they will 636 + match as many times as possible. *) 637 + val greedy : t -> t 638 + 639 + (** Non-greedy matches for repetitions ({!opt}, {!rep}, {!rep1}, {!repn}): they 640 + will match as few times as possible. *) 641 + val non_greedy : t -> t 642 + 643 + (** {2 Groups (or submatches)} *) 644 + 645 + (** Delimit a group. The group is considered as matching if it is used at least 646 + once (it may be used multiple times if is nested inside {!rep} for 647 + instance). If it is used multiple times, the last match is what gets 648 + captured. *) 649 + val group : ?name:string -> t -> t 650 + 651 + (** Remove all groups *) 652 + val no_group : t -> t 653 + 654 + (** When matching against [nest e], only the group matching in the 655 + last match of e will be considered as matching. 656 + 657 + For instance: 658 + {[ 659 + let re = compile (rep1 (nest (alt [ group (str "a"); str "b" ]))) in 660 + let group = Re.exec re "ab" in 661 + assert (Group.get_opt group 1 = None); 662 + (* same thing but without [nest] *) 663 + let re = compile (rep1 (alt [ group (str "a"); str "b" ])) in 664 + let group = Re.exec re "ab" in 665 + assert (Group.get_opt group 1 = Some "a") 666 + ]} *) 667 + val nest : t -> t 668 + 669 + (** Mark a regexp. the markid can then be used to know if this regexp was used. *) 670 + val mark : t -> Mark.t * t 671 + 672 + (** {2 Character sets} *) 673 + 674 + (** Any character of the string *) 675 + val set : string -> t 676 + 677 + (** Character ranges *) 678 + val rg : char -> char -> t 679 + 680 + (** Intersection of character sets *) 681 + val inter : t list -> t 682 + 683 + (** Difference of character sets *) 684 + val diff : t -> t -> t 685 + 686 + (** Complement of union *) 687 + val compl : t list -> t 688 + 689 + (** {2 Predefined character sets} *) 690 + 691 + (** Any character *) 692 + val any : t 693 + 694 + (** Any character but a newline *) 695 + val notnl : t 696 + 697 + val alnum : t 698 + val wordc : t 699 + val alpha : t 700 + val ascii : t 701 + val blank : t 702 + val cntrl : t 703 + val digit : t 704 + val graph : t 705 + val lower : t 706 + val print : t 707 + val punct : t 708 + val space : t 709 + val upper : t 710 + val xdigit : t 711 + 712 + (** {2 Case modifiers} *) 713 + 714 + (** Case sensitive matching. Note that this works on latin1, not ascii and not 715 + utf8. *) 716 + val case : t -> t 717 + 718 + (** Case insensitive matching. Note that this works on latin1, not ascii and not 719 + utf8. *) 720 + val no_case : t -> t 721 + 722 + (****) 723 + 724 + (** {2 Internal debugging} *) 725 + 726 + val pp : Format.formatter -> t -> unit 727 + val pp_re : Format.formatter -> re -> unit 728 + 729 + (** Alias for {!pp_re}. Deprecated *) 730 + val print_re : Format.formatter -> re -> unit 731 + 732 + (** {2 Experimental functions} *) 733 + 734 + (** [witness r] generates a string [s] such that [execp (compile r) s] is true. 735 + 736 + Be warned that this function is buggy because it ignores zero-width 737 + assertions like beginning of words. As a result it can generate incorrect 738 + results. *) 739 + val witness : t -> string 740 + 741 + (** {2 Deprecated functions} *) 742 + 743 + (** Alias for {!Group.t}. Deprecated *) 744 + type substrings = Group.t [@@ocaml.deprecated "Use Group.t"] 745 + 746 + (** Same as {!Group.get}. Deprecated *) 747 + val get : Group.t -> int -> string 748 + [@@ocaml.deprecated "Use Group.get"] 749 + 750 + (** Same as {!Group.offset}. Deprecated *) 751 + val get_ofs : Group.t -> int -> int * int 752 + [@@ocaml.deprecated "Use Group.offset"] 753 + 754 + (** Same as {!Group.all}. Deprecated *) 755 + val get_all : Group.t -> string array 756 + [@@ocaml.deprecated "Use Group.all"] 757 + 758 + (** Same as {!Group.all_offset}. Deprecated *) 759 + val get_all_ofs : Group.t -> (int * int) array 760 + [@@ocaml.deprecated "Use Group.all_offset"] 761 + 762 + (** Same as {!Group.test}. Deprecated *) 763 + val test : Group.t -> int -> bool 764 + [@@ocaml.deprecated "Use Group.test"] 765 + 766 + (** Alias for {!Mark.t}. Deprecated *) 767 + type markid = Mark.t [@@ocaml.deprecated "Use Mark."] 768 + 769 + (** Same as {!Mark.test}. Deprecated *) 770 + val marked : Group.t -> Mark.t -> bool 771 + [@@ocaml.deprecated "Use Mark.test"] 772 + 773 + (** Same as {!Mark.all}. Deprecated *) 774 + val mark_set : Group.t -> Mark.Set.t 775 + [@@ocaml.deprecated "Use Mark.all"] 776 + 777 + module Stream : sig 778 + (** An experimental for matching a regular expression by feeding individual 779 + string chunks. 780 + 781 + This module is not covered by semver's stability guarantee. *) 782 + 783 + type t 784 + 785 + type 'a feed = 786 + | Ok of 'a 787 + | No_match 788 + 789 + val create : re -> t 790 + val feed : t -> string -> pos:int -> len:int -> t feed 791 + 792 + (** [finalize s ~pos ~len] feed [s] from [pos] to [len] and return whether 793 + the regular expression matched. *) 794 + val finalize : t -> string -> pos:int -> len:int -> bool 795 + 796 + module Group : sig 797 + (** Match a string against a regular expression with capture groups *) 798 + 799 + type stream := t 800 + type t 801 + 802 + module Match : sig 803 + type t 804 + 805 + val get : t -> int -> string option 806 + val test_mark : t -> Pmark.t -> bool 807 + end 808 + 809 + val create : stream -> t 810 + val feed : t -> string -> pos:int -> len:int -> t feed 811 + val finalize : t -> string -> pos:int -> len:int -> Match.t feed 812 + end 813 + end
+250
vendor/opam/re/lib/cset.ml
··· 1 + module List = struct end 2 + open Import 3 + 4 + (* 5 + RE - A regular expression library 6 + 7 + Copyright (C) 2001 Jerome Vouillon 8 + email: Jerome.Vouillon@pps.jussieu.fr 9 + 10 + This library is free software; you can redistribute it and/or 11 + modify it under the terms of the GNU Lesser General Public 12 + License as published by the Free Software Foundation, with 13 + linking exception; either version 2.1 of the License, or (at 14 + your option) any later version. 15 + 16 + This library is distributed in the hope that it will be useful, 17 + but WITHOUT ANY WARRANTY; without even the implied warranty of 18 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 + Lesser General Public License for more details. 20 + 21 + You should have received a copy of the GNU Lesser General Public 22 + License along with this library; if not, write to the Free Software 23 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 + *) 25 + 26 + type c = int 27 + 28 + let equal_c = Int.equal 29 + let to_int x = x 30 + let of_int x = x 31 + let to_char t = Char.chr t 32 + let of_char c = Char.code c 33 + let null_char = -1 34 + 35 + type t = (c * c) list 36 + 37 + let compare_pair (x, y) (x', y') = 38 + match Int.compare x x' with 39 + | 0 -> Int.compare y y' 40 + | x -> x 41 + ;; 42 + 43 + let equal_pair (x, y) (x', y') = Int.equal x x' && Int.equal y y' 44 + let equal x y = List.equal ~eq:equal_pair x y 45 + let compare x y = List.compare ~cmp:compare_pair x y 46 + 47 + let rec union l l' = 48 + match l, l' with 49 + | _, [] -> l 50 + | [], _ -> l' 51 + | (c1, c2) :: r, (c1', c2') :: r' -> 52 + if c2 + 1 < c1' 53 + then (c1, c2) :: union r l' 54 + else if c2' + 1 < c1 55 + then (c1', c2') :: union l r' 56 + else if c2 < c2' 57 + then union r ((min c1 c1', c2') :: r') 58 + else union ((min c1 c1', c2) :: r) r' 59 + ;; 60 + 61 + let rec inter l l' = 62 + match l, l' with 63 + | _, [] -> [] 64 + | [], _ -> [] 65 + | (c1, c2) :: r, (c1', c2') :: r' -> 66 + if c2 < c1' 67 + then inter r l' 68 + else if c2' < c1 69 + then inter l r' 70 + else if c2 < c2' 71 + then (max c1 c1', c2) :: inter r l' 72 + else (max c1 c1', c2') :: inter l r' 73 + ;; 74 + 75 + let rec diff l l' = 76 + match l, l' with 77 + | _, [] -> l 78 + | [], _ -> [] 79 + | (c1, c2) :: r, (c1', c2') :: r' -> 80 + if c2 < c1' 81 + then (c1, c2) :: diff r l' 82 + else if c2' < c1 83 + then diff l r' 84 + else ( 85 + let r'' = if c2' < c2 then (c2' + 1, c2) :: r else r in 86 + if c1 < c1' then (c1, c1' - 1) :: diff r'' r' else diff r'' r') 87 + ;; 88 + 89 + let single = 90 + let single c = [ c, c ] in 91 + Dense_map.make (* an extra color for lnl *) ~size:257 ~f:single 92 + ;; 93 + 94 + let csingle i = single (Char.code i) 95 + let add c l = union (single c) l 96 + let seq c c' = if c <= c' then [ c, c' ] else [ c', c ] 97 + 98 + let rec offset o l = 99 + match l with 100 + | [] -> [] 101 + | (c1, c2) :: r -> (c1 + o, c2 + o) :: offset o r 102 + ;; 103 + 104 + let empty : t = [] 105 + let cany = [ 0, 255 ] 106 + let union_all ts = List.fold_left ~init:empty ~f:union ts 107 + let intersect_all ts = List.fold_left ~init:cany ~f:inter ts 108 + 109 + let rec mem (c : int) s = 110 + match s with 111 + | [] -> false 112 + | (c1, c2) :: rem -> if c <= c2 then c >= c1 else mem c rem 113 + ;; 114 + 115 + (****) 116 + 117 + let rec hash_rec = function 118 + | [] -> 0 119 + | (i, j) :: r -> i + (13 * j) + (257 * hash_rec r) 120 + ;; 121 + 122 + let hash l = hash_rec l land 0x3FFFFFFF 123 + 124 + (****) 125 + 126 + let print_one ch (c1, c2) = 127 + if Int.equal c1 c2 then Format.fprintf ch "%d" c1 else Format.fprintf ch "%d-%d" c1 c2 128 + ;; 129 + 130 + let pp ts = Fmt.list ~pp_sep:(Fmt.lit ", ") print_one ts 131 + 132 + let to_dyn t = 133 + let open Dyn in 134 + match t with 135 + | [ (x, y) ] when Int.equal x y -> int x 136 + | _ -> List.map t ~f:(fun (x, y) -> pair (int x) (int y)) |> list 137 + ;; 138 + 139 + let rec iter t ~f = 140 + match t with 141 + | [] -> () 142 + | (x, y) :: xs -> 143 + f x y; 144 + iter xs ~f 145 + ;; 146 + 147 + let one_char = function 148 + | [ (i, j) ] when Int.equal i j -> Some i 149 + | _ -> None 150 + ;; 151 + 152 + module CSetMap = Map.Make (struct 153 + type t = int * (int * int) list 154 + 155 + let compare (i, u) (j, v) = 156 + let c = Int.compare i j in 157 + if c <> 0 then c else compare u v 158 + ;; 159 + end) 160 + 161 + let fold_right t ~init ~f = List.fold_right ~f:(fun (x, y) acc -> f x y acc) t ~init 162 + 163 + let is_empty = function 164 + | [] -> true 165 + | _ -> false 166 + ;; 167 + 168 + let rec prepend s x l = 169 + match s, l with 170 + | [], _ -> l 171 + | _r, [] -> [] 172 + | (_c, c') :: r, ([ (d, _d') ], _x') :: _r' when c' < d -> prepend r x l 173 + | (c, c') :: r, ([ (d, d') ], x') :: r' -> 174 + if c <= d 175 + then 176 + if c' < d' 177 + then ([ d, c' ], x @ x') :: prepend r x (([ c' + 1, d' ], x') :: r') 178 + else ([ d, d' ], x @ x') :: prepend s x r' 179 + else if c > d' 180 + then ([ d, d' ], x') :: prepend s x r' 181 + else ([ d, c - 1 ], x') :: prepend s x (([ c, d' ], x') :: r') 182 + | _ -> assert false 183 + ;; 184 + 185 + let pick = function 186 + | [] -> invalid_arg "Re_cset.pick" 187 + | (x, _) :: _ -> x 188 + ;; 189 + 190 + let cseq c c' = seq (of_char c) (of_char c') 191 + let rg = cseq 192 + let char = csingle 193 + let upper = union_all [ cseq 'A' 'Z'; cseq '\192' '\214'; cseq '\216' '\222' ] 194 + let clower = offset 32 upper 195 + let cdigit = cseq '0' '9' 196 + let ascii = cseq '\000' '\127' 197 + let cadd c s = add (of_char c) s 198 + let space = add (of_char ' ') (cseq '\009' '\013') 199 + let xdigit = union_all [ cdigit; cseq 'a' 'f'; cseq 'A' 'F' ] 200 + 201 + let calpha = 202 + List.fold_right 203 + ~f:cadd 204 + [ '\170'; '\181'; '\186'; '\223'; '\255' ] 205 + ~init:(union clower upper) 206 + ;; 207 + 208 + let calnum = union calpha cdigit 209 + 210 + let case_insens s = 211 + union_all [ s; offset 32 (inter s upper); offset (-32) (inter s clower) ] 212 + ;; 213 + 214 + let cword = cadd '_' calnum 215 + let notnl = diff cany (csingle '\n') 216 + let nl = csingle '\n' 217 + 218 + let set str = 219 + let s = ref empty in 220 + for i = 0 to String.length str - 1 do 221 + s := union (csingle str.[i]) !s 222 + done; 223 + !s 224 + ;; 225 + 226 + let blank = set "\t " 227 + 228 + (* CR-someday rgrinberg: this [lower] doesn't match [clower] *) 229 + let lower = union_all [ rg 'a' 'z'; char '\181'; rg '\223' '\246'; rg '\248' '\255' ] 230 + let alpha = union_all [ lower; upper; char '\170'; char '\186' ] 231 + let alnum = union_all [ alpha; cdigit ] 232 + let wordc = union_all [ alnum; char '_' ] 233 + let cntrl = union_all [ rg '\000' '\031'; rg '\127' '\159' ] 234 + let graph = union_all [ rg '\033' '\126'; rg '\160' '\255' ] 235 + let print = union_all [ rg '\032' '\126'; rg '\160' '\255' ] 236 + 237 + let punct = 238 + union_all 239 + [ rg '\033' '\047' 240 + ; rg '\058' '\064' 241 + ; rg '\091' '\096' 242 + ; rg '\123' '\126' 243 + ; rg '\160' '\169' 244 + ; rg '\171' '\180' 245 + ; rg '\182' '\185' 246 + ; rg '\187' '\191' 247 + ; char '\215' 248 + ; char '\247' 249 + ] 250 + ;;
+84
vendor/opam/re/lib/cset.mli
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + (* Character sets, represented as sorted list of intervals *) 24 + 25 + type c [@@immediate] 26 + 27 + val equal_c : c -> c -> bool 28 + val to_int : c -> int 29 + val of_int : int -> c 30 + val to_char : c -> char 31 + val of_char : char -> c 32 + 33 + type t 34 + 35 + (** special characters which isn't present in any set (not even in [cany]) *) 36 + val null_char : c 37 + 38 + val equal : t -> t -> bool 39 + val iter : t -> f:(c -> c -> unit) -> unit 40 + val union : t -> t -> t 41 + val union_all : t list -> t 42 + val intersect_all : t list -> t 43 + val inter : t -> t -> t 44 + val diff : t -> t -> t 45 + val empty : t 46 + val single : c -> t 47 + val add : c -> t -> t 48 + val mem : c -> t -> bool 49 + val case_insens : t -> t 50 + val cdigit : t 51 + val calpha : t 52 + val cword : t 53 + val notnl : t 54 + val ascii : t 55 + val nl : t 56 + val cseq : char -> char -> t 57 + val set : string -> t 58 + val blank : t 59 + val space : t 60 + val xdigit : t 61 + val lower : t 62 + val upper : t 63 + val alpha : t 64 + val alnum : t 65 + val wordc : t 66 + val cntrl : t 67 + val graph : t 68 + val print : t 69 + val punct : t 70 + val pp : t Fmt.t 71 + val one_char : t -> c option 72 + val fold_right : t -> init:'acc -> f:(c -> c -> 'acc -> 'acc) -> 'acc 73 + val hash : t -> int 74 + val compare : t -> t -> int 75 + 76 + module CSetMap : Map.S with type key = int * t 77 + 78 + val cany : t 79 + val csingle : char -> t 80 + val is_empty : t -> bool 81 + val prepend : t -> 'a list -> (t * 'a list) list -> (t * 'a list) list 82 + val pick : t -> c 83 + val offset : int -> t -> t 84 + val to_dyn : t -> Dyn.t
+4
vendor/opam/re/lib/dense_map.ml
··· 1 + let make ~size ~f = 2 + let cache = Array.init size f in 3 + fun i -> cache.(i) 4 + ;;
+1
vendor/opam/re/lib/dense_map.mli
··· 1 + val make : size:int -> f:(int -> 'a) -> int -> 'a
+9
vendor/opam/re/lib/dune
··· 1 + (library 2 + (name re) 3 + (synopsis "Pure OCaml regular expression library") 4 + (public_name re)) 5 + 6 + (copy_files# 7 + (enabled_if 8 + (< %{ocaml_version} 5)) 9 + (files fake/*))
+26
vendor/opam/re/lib/dyn.ml
··· 1 + type t = 2 + | Int of int 3 + | Tuple of t list 4 + | Enum of string 5 + | String of string 6 + | List of t list 7 + | Variant of string * t list 8 + | Record of (string * t) list 9 + 10 + let variant x y = Variant (x, y) 11 + let list x = List x 12 + let int x = Int x 13 + let pair x y = Tuple [ x; y ] 14 + let record fields = Record fields 15 + let enum x = Enum x 16 + let string s = String s 17 + 18 + let result ok err = function 19 + | Ok s -> variant "Ok" [ ok s ] 20 + | Error e -> variant "Error" [ err e ] 21 + ;; 22 + 23 + let option f = function 24 + | None -> enum "None" 25 + | Some s -> variant "Some" [ f s ] 26 + ;;
+146
vendor/opam/re/lib/emacs.ml
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + module Re = Core 24 + open Import 25 + 26 + exception Parse_error 27 + exception Not_supported 28 + 29 + let by_code f c c' = 30 + let c = Char.code c in 31 + let c' = Char.code c' in 32 + Char.chr (f c c') 33 + ;; 34 + 35 + let parse ~emacs_only s = 36 + let buf = Parse_buffer.create s in 37 + let accept = Parse_buffer.accept buf in 38 + let eos () = Parse_buffer.eos buf in 39 + let test2 = Parse_buffer.test2 buf in 40 + let get () = Parse_buffer.get buf in 41 + let rec regexp () = regexp' [ branch () ] 42 + and regexp' left = 43 + if Parse_buffer.accept_s buf {|\||} 44 + then regexp' (branch () :: left) 45 + else Re.alt (List.rev left) 46 + and branch () = branch' [] 47 + and branch' left = 48 + if eos () || test2 '\\' '|' || test2 '\\' ')' 49 + then Re.seq (List.rev left) 50 + else branch' (piece () :: left) 51 + and piece () = 52 + let r = atom () in 53 + if accept '*' 54 + then Re.rep r 55 + else if accept '+' 56 + then Re.rep1 r 57 + else if accept '?' 58 + then Re.opt r 59 + else r 60 + and atom () = 61 + if accept '.' 62 + then Re.notnl 63 + else if accept '^' 64 + then Re.bol 65 + else if accept '$' 66 + then Re.eol 67 + else if accept '[' 68 + then if accept '^' then Re.compl (bracket []) else Re.alt (bracket []) 69 + else if accept '\\' 70 + then 71 + if accept '(' 72 + then ( 73 + let r = regexp () in 74 + if not (Parse_buffer.accept_s buf {|\)|}) then raise Parse_error; 75 + Re.group r) 76 + else if emacs_only && accept '`' 77 + then Re.bos 78 + else if emacs_only && accept '\'' 79 + then Re.eos 80 + else if accept '=' 81 + then Re.start 82 + else if accept 'b' 83 + then Re.alt [ Re.bow; Re.eow ] 84 + else if emacs_only && accept 'B' 85 + then Re.not_boundary 86 + else if emacs_only && accept '<' 87 + then Re.bow 88 + else if emacs_only && accept '>' 89 + then Re.eow 90 + else if accept 'w' 91 + then Re.alt [ Re.alnum; Re.char '_' ] 92 + else if accept 'W' 93 + then Re.compl [ Re.alnum; Re.char '_' ] 94 + else ( 95 + if eos () then raise Parse_error; 96 + match get () with 97 + | ('*' | '+' | '?' | '[' | ']' | '.' | '^' | '$' | '\\') as c -> Re.char c 98 + | '0' .. '9' -> raise Not_supported 99 + | c -> if emacs_only then raise Parse_error else Re.char c) 100 + else ( 101 + if eos () then raise Parse_error; 102 + match get () with 103 + | '*' | '+' | '?' -> raise Parse_error 104 + | c -> Re.char c) 105 + and bracket s = 106 + if s <> [] && accept ']' 107 + then s 108 + else ( 109 + let c = char () in 110 + if accept '-' 111 + then 112 + if accept ']' 113 + then Re.char c :: Re.char '-' :: s 114 + else ( 115 + let c' = char () in 116 + let c' = by_code Int.max c c' in 117 + bracket (Re.rg c c' :: s)) 118 + else bracket (Re.char c :: s)) 119 + and char () = 120 + if eos () then raise Parse_error; 121 + get () 122 + in 123 + let res = regexp () in 124 + if not (eos ()) then raise Parse_error; 125 + res 126 + ;; 127 + 128 + let re ?(case = true) s = 129 + let r = parse s ~emacs_only:true in 130 + if case then r else Re.no_case r 131 + ;; 132 + 133 + let re_no_emacs ~case s = 134 + let r = parse s ~emacs_only:false in 135 + if case then r else Re.no_case r 136 + ;; 137 + 138 + let re_result ?case s = 139 + match re ?case s with 140 + | s -> Ok s 141 + | exception Not_supported -> Error `Not_supported 142 + | exception Parse_error -> Error `Parse_error 143 + ;; 144 + 145 + let compile = Re.compile 146 + let compile_pat ?(case = true) s = compile (re ~case s)
+41
vendor/opam/re/lib/emacs.mli
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + (** Emacs-style regular expressions *) 24 + 25 + exception Parse_error 26 + 27 + (** Errors that can be raised during the parsing of the regular expression *) 28 + exception Not_supported 29 + 30 + (** Parsing of an Emacs-style regular expression *) 31 + val re : ?case:bool -> string -> Core.t 32 + 33 + val re_result : ?case:bool -> string -> (Core.t, [ `Not_supported | `Parse_error ]) result 34 + 35 + (** Regular expression compilation *) 36 + val compile : Core.t -> Core.re 37 + 38 + (** Same as [Core.compile] *) 39 + val compile_pat : ?case:bool -> string -> Core.re 40 + 41 + val re_no_emacs : case:bool -> string -> Core.t
+10
vendor/opam/re/lib/fake/atomic.ml
··· 1 + type 'a t = 'a ref 2 + 3 + let make x = ref x 4 + let get x = !x 5 + let set atomic v = atomic := v 6 + 7 + let fetch_and_add atomic n = 8 + let v = !atomic in 9 + atomic := v + n; 10 + v
+5
vendor/opam/re/lib/fake/domain.ml
··· 1 + module DLS = struct 2 + let new_key f = ref (f()) 3 + let set x y = x := y 4 + let get x = !x 5 + end
+26
vendor/opam/re/lib/fake/mutex.ml
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2025 Jerome Vouillon 5 + 6 + This library is free software; you can redistribute it and/or 7 + modify it under the terms of the GNU Lesser General Public 8 + License as published by the Free Software Foundation, with 9 + linking exception; either version 2.1 of the License, or (at 10 + your option) any later version. 11 + 12 + This library is distributed in the hope that it will be useful, 13 + but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 + Lesser General Public License for more details. 16 + 17 + You should have received a copy of the GNU Lesser General Public 18 + License along with this library; if not, write to the Free Software 19 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 + *) 21 + 22 + type t = unit 23 + 24 + let create _ = () 25 + let lock _ = () 26 + let unlock _ = ()
+51
vendor/opam/re/lib/fmt.ml
··· 1 + (** Very small tooling for format printers. *) 2 + 3 + include Format 4 + 5 + type 'a t = Format.formatter -> 'a -> unit 6 + 7 + let list = pp_print_list 8 + let array ?pp_sep f fmt arr = list ?pp_sep f fmt (Array.to_list arr) 9 + let str = pp_print_string 10 + let sexp fmt s pp x = fprintf fmt "@[<3>(%s@ %a)@]" s pp x 11 + let bytes fmt t = Format.fprintf fmt "%S" (Bytes.to_string t) 12 + 13 + let pair pp1 pp2 fmt (v1, v2) = 14 + pp1 fmt v1; 15 + pp_print_space fmt (); 16 + pp2 fmt v2 17 + ;; 18 + 19 + let triple pp1 pp2 pp3 fmt (v1, v2, v3) = 20 + pp1 fmt v1; 21 + pp_print_space fmt (); 22 + pp2 fmt v2; 23 + pp_print_space fmt (); 24 + pp3 fmt v3 25 + ;; 26 + 27 + let opt f fmt x = 28 + match x with 29 + | None -> pp_print_string fmt "<None>" 30 + | Some x -> fprintf fmt "%a" f x 31 + ;; 32 + 33 + let int = pp_print_int 34 + 35 + let optint fmt = function 36 + | None -> () 37 + | Some i -> fprintf fmt "@ %d" i 38 + ;; 39 + 40 + let char fmt c = Format.fprintf fmt "%c" c 41 + let bool = Format.pp_print_bool 42 + let lit s fmt () = pp_print_string fmt s 43 + 44 + let to_to_string pp x = 45 + let b = Buffer.create 16 in 46 + let fmt = Format.formatter_of_buffer b in 47 + pp fmt x; 48 + Buffer.contents b 49 + ;; 50 + 51 + let quoted_string fmt s = Format.fprintf fmt "%S" s
+18
vendor/opam/re/lib/fmt.mli
··· 1 + type formatter := Format.formatter 2 + type 'a t = formatter -> 'a -> unit 3 + 4 + val sexp : formatter -> string -> 'a t -> 'a -> unit 5 + val str : string t 6 + val optint : int option t 7 + val opt : 'a t -> 'a option t 8 + val char : char t 9 + val bool : bool t 10 + val int : int t 11 + val pair : 'a t -> 'b t -> ('a * 'b) t 12 + val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t 13 + val list : ?pp_sep:unit t -> 'a t -> 'a list t 14 + val bytes : Bytes.t t 15 + val array : ?pp_sep:unit t -> 'a t -> 'a array t 16 + val lit : string -> unit t 17 + val to_to_string : 'a t -> 'a -> string 18 + val quoted_string : string t
+337
vendor/opam/re/lib/glob.ml
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + module Re = Core 24 + 25 + exception Parse_error = Parse_buffer.Parse_error 26 + 27 + type enclosed = 28 + | Char of char 29 + | Range of char * char 30 + 31 + type piece = 32 + | Exactly of char 33 + | Any_of of enclosed list 34 + | Any_but of enclosed list 35 + | One 36 + | Many 37 + | ManyMany 38 + 39 + type t = piece list 40 + 41 + let of_string ~double_asterisk s : t = 42 + let buf = Parse_buffer.create s in 43 + let eos () = Parse_buffer.eos buf in 44 + let read c = Parse_buffer.accept buf c in 45 + let char () = 46 + ignore (read '\\' : bool); 47 + if eos () then raise Parse_error; 48 + Parse_buffer.get buf 49 + in 50 + let enclosed () : enclosed list = 51 + let rec loop s = 52 + (* This returns the list in reverse order, but order isn't important 53 + anyway *) 54 + if s <> [] && read ']' 55 + then s 56 + else ( 57 + let c = char () in 58 + if not (read '-') 59 + then loop (Char c :: s) 60 + else if read ']' 61 + then Char c :: Char '-' :: s 62 + else ( 63 + let c' = char () in 64 + loop (Range (c, c') :: s))) 65 + in 66 + loop [] 67 + in 68 + let piece acc = 69 + if double_asterisk && Parse_buffer.accept_s buf "/**" 70 + then ManyMany :: (if eos () then Exactly '/' :: acc else acc) 71 + else if read '*' 72 + then (if double_asterisk && read '*' then ManyMany else Many) :: acc 73 + else if read '?' 74 + then One :: acc 75 + else if not (read '[') 76 + then Exactly (char ()) :: acc 77 + else if read '^' || read '!' 78 + then Any_but (enclosed ()) :: acc 79 + else Any_of (enclosed ()) :: acc 80 + in 81 + let rec loop pieces = if eos () then List.rev pieces else loop (piece pieces) in 82 + loop [] 83 + ;; 84 + 85 + let mul l l' = List.flatten (List.map (fun s -> List.map (fun s' -> s ^ s') l') l) 86 + 87 + let explode str = 88 + let l = String.length str in 89 + let rec expl inner s i acc beg = 90 + if i >= l 91 + then ( 92 + if inner then raise Parse_error; 93 + mul beg [ String.sub str s (i - s) ], i) 94 + else ( 95 + match str.[i] with 96 + | '\\' -> expl inner s (i + 2) acc beg 97 + | '{' -> 98 + let t, i' = expl true (i + 1) (i + 1) [] [ "" ] in 99 + expl inner i' i' acc (mul beg (mul [ String.sub str s (i - s) ] t)) 100 + | ',' when inner -> 101 + expl inner (i + 1) (i + 1) (mul beg [ String.sub str s (i - s) ] @ acc) [ "" ] 102 + | '}' when inner -> mul beg [ String.sub str s (i - s) ] @ acc, i + 1 103 + | _ -> expl inner s (i + 1) acc beg) 104 + in 105 + List.rev (fst (expl false 0 0 [] [ "" ])) 106 + ;; 107 + 108 + module State = struct 109 + type t = 110 + { re_pieces : Re.t list (* last piece at head of list. *) 111 + ; remaining : piece list (* last piece at tail of list. *) 112 + ; am_at_start_of_pattern : bool (* true at start of pattern *) 113 + ; am_at_start_of_component : bool 114 + (* true at start of pattern or immediately 115 + after '/' *) 116 + ; pathname : bool 117 + ; match_backslashes : bool 118 + ; period : bool 119 + } 120 + 121 + let create ~period ~pathname ~match_backslashes remaining = 122 + { re_pieces = [] 123 + ; am_at_start_of_pattern = true 124 + ; am_at_start_of_component = true 125 + ; pathname 126 + ; match_backslashes 127 + ; period 128 + ; remaining 129 + } 130 + ;; 131 + 132 + let explicit_period t = 133 + t.period && (t.am_at_start_of_pattern || (t.am_at_start_of_component && t.pathname)) 134 + ;; 135 + 136 + let explicit_slash t = t.pathname 137 + let slashes t = if t.match_backslashes then [ '/'; '\\' ] else [ '/' ] 138 + 139 + let append ?(am_at_start_of_component = false) t piece = 140 + { t with 141 + re_pieces = piece :: t.re_pieces 142 + ; am_at_start_of_pattern = false 143 + ; am_at_start_of_component 144 + } 145 + ;; 146 + 147 + let to_re t = Re.seq (List.rev t.re_pieces) 148 + 149 + let next t = 150 + match t.remaining with 151 + | [] -> None 152 + | piece :: remaining -> Some (piece, { t with remaining }) 153 + ;; 154 + end 155 + 156 + let one ~explicit_slash ~slashes ~explicit_period = 157 + Re.compl 158 + (List.concat 159 + [ (if explicit_slash then List.map Re.char slashes else []) 160 + ; (if explicit_period then [ Re.char '.' ] else []) 161 + ]) 162 + ;; 163 + 164 + let enclosed enclosed = 165 + match enclosed with 166 + | Char c -> Re.char c 167 + | Range (low, high) -> Re.rg low high 168 + ;; 169 + 170 + let enclosed_set ~explicit_slash ~slashes ~explicit_period kind set = 171 + let set = List.map enclosed set in 172 + let enclosure = 173 + match kind with 174 + | `Any_of -> Re.alt set 175 + | `Any_but -> Re.compl set 176 + in 177 + Re.inter [ enclosure; one ~explicit_slash ~slashes ~explicit_period ] 178 + ;; 179 + 180 + let exactly state c = 181 + let slashes = State.slashes state in 182 + let am_at_start_of_component = List.mem c slashes in 183 + let chars = if am_at_start_of_component then slashes else [ c ] in 184 + State.append state (Re.alt (List.map Re.char chars)) ~am_at_start_of_component 185 + ;; 186 + 187 + let many_many state = 188 + let explicit_period = state.State.period && state.State.pathname in 189 + let first_explicit_period = State.explicit_period state in 190 + let slashes = State.slashes state in 191 + let match_component ~explicit_period = 192 + Re.seq 193 + [ one ~explicit_slash:true ~slashes ~explicit_period 194 + ; Re.rep (one ~explicit_slash:true ~slashes ~explicit_period:false) 195 + ] 196 + in 197 + (* We must match components individually when [period] flag is set, 198 + making sure to not match ["foo/.bar"]. *) 199 + State.append 200 + state 201 + (Re.seq 202 + [ Re.opt (match_component ~explicit_period:first_explicit_period) 203 + ; Re.rep 204 + (Re.seq 205 + [ Re.alt (List.map Re.char slashes) 206 + ; Re.opt (match_component ~explicit_period) 207 + ]) 208 + ]) 209 + ;; 210 + 211 + let many (state : State.t) = 212 + let explicit_slash = State.explicit_slash state in 213 + let explicit_period = State.explicit_period state in 214 + let slashes = State.slashes state in 215 + (* Whether we must explicitly match period depends on the surrounding 216 + characters, but slashes are easy to explicit match. This conditional 217 + splits out some simple cases. *) 218 + if not explicit_period 219 + then State.append state (Re.rep (one ~explicit_slash ~slashes ~explicit_period)) 220 + else if not explicit_slash 221 + then 222 + (* In this state, we explicitly match periods only at the very beginning *) 223 + State.append 224 + state 225 + (Re.opt 226 + (Re.seq 227 + [ one ~explicit_slash:false ~slashes ~explicit_period 228 + ; Re.rep (one ~explicit_slash:false ~slashes ~explicit_period:false) 229 + ])) 230 + else ( 231 + let not_empty = 232 + Re.seq 233 + [ one ~explicit_slash:true ~slashes ~explicit_period:true 234 + ; Re.rep (one ~explicit_slash:true ~slashes ~explicit_period:false) 235 + ] 236 + in 237 + (* [maybe_empty] is the default translation of Many, except in some special 238 + cases. *) 239 + let maybe_empty = Re.opt not_empty in 240 + let enclosed_set state kind set = 241 + State.append 242 + state 243 + (Re.alt 244 + [ enclosed_set kind set ~explicit_slash:true ~slashes ~explicit_period:true 245 + ; Re.seq 246 + [ not_empty 247 + ; (* Since [not_empty] matched, subsequent dots are not leading. *) 248 + enclosed_set 249 + kind 250 + set 251 + ~explicit_slash:true 252 + ~slashes 253 + ~explicit_period:false 254 + ] 255 + ]) 256 + in 257 + let rec lookahead state = 258 + match State.next state with 259 + | None -> State.append state maybe_empty 260 + (* glob ** === glob * . *) 261 + | Some (Many, state) -> lookahead state 262 + | Some (Exactly c, state) -> 263 + let state = State.append state (if c = '.' then not_empty else maybe_empty) in 264 + exactly state c 265 + (* glob *? === glob ?* *) 266 + | Some (One, state) -> State.append state not_empty 267 + | Some (Any_of enclosed, state) -> enclosed_set state `Any_of enclosed 268 + | Some (Any_but enclosed, state) -> enclosed_set state `Any_but enclosed 269 + (* * then ** === ** *) 270 + | Some (ManyMany, state) -> many_many state 271 + in 272 + lookahead state) 273 + ;; 274 + 275 + let piece state piece = 276 + let explicit_slash = State.explicit_slash state in 277 + let explicit_period = State.explicit_period state in 278 + let slashes = State.slashes state in 279 + match piece with 280 + | One -> State.append state (one ~explicit_slash ~slashes ~explicit_period) 281 + | Many -> many state 282 + | Any_of enclosed -> 283 + State.append 284 + state 285 + (enclosed_set `Any_of ~explicit_slash ~slashes ~explicit_period enclosed) 286 + | Any_but enclosed -> 287 + State.append 288 + state 289 + (enclosed_set `Any_but ~explicit_slash ~slashes ~explicit_period enclosed) 290 + | Exactly c -> exactly state c 291 + | ManyMany -> many_many state 292 + ;; 293 + 294 + let glob ~pathname ~match_backslashes ~period glob = 295 + let rec loop state = 296 + match State.next state with 297 + | None -> State.to_re state 298 + | Some (p, state) -> loop (piece state p) 299 + in 300 + loop (State.create ~pathname ~match_backslashes ~period glob) 301 + ;; 302 + 303 + let glob 304 + ?(anchored = false) 305 + ?(pathname = true) 306 + ?(match_backslashes = false) 307 + ?(period = true) 308 + ?(expand_braces = false) 309 + ?(double_asterisk = true) 310 + s 311 + = 312 + let to_re s = 313 + let re = glob ~pathname ~match_backslashes ~period (of_string ~double_asterisk s) in 314 + if anchored then Re.whole_string re else re 315 + in 316 + if expand_braces then Re.alt (List.map to_re (explode s)) else to_re s 317 + ;; 318 + 319 + let glob_result 320 + ?anchored 321 + ?pathname 322 + ?match_backslashes 323 + ?period 324 + ?expand_braces 325 + ?double_asterisk 326 + s 327 + = 328 + match 329 + glob ?anchored ?pathname ?match_backslashes ?period ?expand_braces ?double_asterisk s 330 + with 331 + | re -> Ok re 332 + | exception Parse_error -> Error `Parse_error 333 + ;; 334 + 335 + let glob' ?anchored period s = glob ?anchored ~period s 336 + let globx ?anchored s = glob ?anchored ~expand_braces:true s 337 + let globx' ?anchored period s = glob ?anchored ~expand_braces:true ~period s
+95
vendor/opam/re/lib/glob.mli
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + (** Shell-style regular expressions *) 24 + 25 + exception Parse_error 26 + 27 + (** Implements the semantics of shells patterns. The returned regular 28 + expression is unanchored by default. 29 + 30 + Character '*' matches any sequence of characters and character 31 + '?' matches a single character. 32 + A sequence '[...]' matches any one of the enclosed characters. 33 + A sequence '[^...]' or '[!...]' matches any character *but* the enclosed characters. 34 + A backslash escapes the following character. The last character of the string cannot 35 + be a backslash. 36 + 37 + [anchored] controls whether the regular expression will only match entire 38 + strings. Defaults to false. 39 + 40 + [pathname]: If this flag is set, match a slash in string only with a slash in pattern 41 + and not by an asterisk ('*') or a question mark ('?') metacharacter, nor by a bracket 42 + expression ('[]') containing a slash. Defaults to true. 43 + 44 + [match_backslashes]: If this flag is set, a forward slash will also match a 45 + backslash (useful when globbing Windows paths). Note that a backslash in the 46 + pattern will continue to escape the following character. Defaults to 47 + [false]. 48 + 49 + [period]: If this flag is set, a leading period in string has to be matched exactly by 50 + a period in pattern. A period is considered to be leading if it is the first 51 + character in string, or if both [pathname] is set and the period immediately follows a 52 + slash. Defaults to true. 53 + 54 + If [expand_braces] is true, braced sets will expand into multiple globs, 55 + e.g. a\{x,y\}b\{1,2\} matches axb1, axb2, ayb1, ayb2. As specified for bash, brace 56 + expansion is purely textual and can be nested. Defaults to false. 57 + 58 + [double_asterisk]: If this flag is set, double asterisks ('**') will match slash 59 + characters, even if [pathname] is set. The [period] flag still applies. Default to 60 + true. *) 61 + val glob 62 + : ?anchored:bool 63 + -> ?pathname:bool 64 + -> ?match_backslashes:bool 65 + -> ?period:bool 66 + -> ?expand_braces:bool 67 + -> ?double_asterisk:bool 68 + -> string 69 + -> Core.t 70 + 71 + val glob_result 72 + : ?anchored:bool 73 + -> ?pathname:bool 74 + -> ?match_backslashes:bool 75 + -> ?period:bool 76 + -> ?expand_braces:bool 77 + -> ?double_asterisk:bool 78 + -> string 79 + -> (Core.t, [ `Parse_error ]) result 80 + 81 + (** Same, but allows to choose whether dots at the beginning of a 82 + file name need to be explicitly matched (true) or not (false) 83 + 84 + @deprecated Use [glob ~period]. *) 85 + val glob' : ?anchored:bool -> bool -> string -> Core.t 86 + 87 + (** This version of [glob] also recognizes the pattern \{..,..\} 88 + 89 + @deprecated Prefer [glob ~expand_braces:true]. *) 90 + val globx : ?anchored:bool -> string -> Core.t 91 + 92 + (** This version of [glob'] also recognizes the pattern \{..,..\} 93 + 94 + @deprecated Prefer [glob ~expand_braces:true ~period]. *) 95 + val globx' : ?anchored:bool -> bool -> string -> Core.t
+103
vendor/opam/re/lib/group.ml
··· 1 + (* Result of a successful match. *) 2 + type t = 3 + { (* Input string. Matched strings are substrings of s *) 4 + s : string 5 + (* Mapping from group indices to positions in gpos. group i has positions 2*i 6 + - 1, 2*i + 1 in gpos. If the group wasn't matched, then its corresponding 7 + values in marks will be -1,-1 *) 8 + ; marks : Mark_infos.t 9 + ; (* Marks positions. i.e. those marks created with Re.marks *) 10 + pmarks : Pmark.Set.t 11 + ; (* Group positions. Adjacent elements are (start, stop) of group match. 12 + indexed by the values in marks. So group i in an re would be the substring: 13 + 14 + start = t.gpos.(marks.(2*i)) - 1 15 + stop = t.gpos.(marks.(2*i + 1)) - 1 *) 16 + gpos : int array 17 + ; (* Number of groups the regular expression contains. Matched or not *) 18 + gcount : int 19 + } 20 + 21 + let create s ~gcount ~gpos marks pmarks = { s; gcount; gpos; marks; pmarks } 22 + 23 + module Offset = struct 24 + type t = int 25 + 26 + let absent = -1 27 + let is_present t = t >= 0 28 + let get_no_check t = t 29 + end 30 + 31 + let start_offset t i = 32 + let i = Mark_infos.start_offset t.marks i in 33 + if Mark_infos.Offset.is_present i 34 + then t.gpos.(Mark_infos.Offset.get_no_check i) 35 + else Offset.absent 36 + ;; 37 + 38 + let stop_offset t i = 39 + let i = Mark_infos.stop_offset t.marks i in 40 + if Mark_infos.Offset.is_present i 41 + then t.gpos.(Mark_infos.Offset.get_no_check i) 42 + else Offset.absent 43 + ;; 44 + 45 + let offset_opt t i = 46 + Mark_infos.offset t.marks i 47 + |> Option.map (fun (start, stop) -> t.gpos.(start), t.gpos.(stop)) 48 + ;; 49 + 50 + let or_not_found = function 51 + | None -> raise Not_found 52 + | Some s -> s 53 + ;; 54 + 55 + let offset t i = offset_opt t i |> or_not_found 56 + 57 + let get_opt t i = 58 + offset_opt t i |> Option.map (fun (p1, p2) -> String.sub t.s p1 (p2 - p1)) 59 + ;; 60 + 61 + let pmarks t = t.pmarks 62 + let get t i = get_opt t i |> or_not_found 63 + let start_opt subs i = offset_opt subs i |> Option.map fst 64 + let start subs i = start_opt subs i |> or_not_found 65 + let stop_opt subs i = offset_opt subs i |> Option.map snd 66 + let stop subs i = stop_opt subs i |> or_not_found 67 + let test t i = Mark_infos.test t.marks i 68 + let get_opt t i = if test t i then Some (get t i) else None 69 + let dummy_offset = -1, -1 70 + 71 + let all_offset t = 72 + let res = Array.make t.gcount dummy_offset in 73 + Mark_infos.iteri t.marks ~f:(fun i start stop -> 74 + let p1 = t.gpos.(start) in 75 + let p2 = t.gpos.(stop) in 76 + res.(i) <- p1, p2); 77 + res 78 + ;; 79 + 80 + let dummy_string = "" 81 + 82 + let all t = 83 + let res = Array.make t.gcount dummy_string in 84 + Mark_infos.iteri t.marks ~f:(fun i start stop -> 85 + let p1 = t.gpos.(start) in 86 + let p2 = t.gpos.(stop) in 87 + res.(i) <- String.sub t.s p1 (p2 - p1)); 88 + res 89 + ;; 90 + 91 + let pp fmt t = 92 + let matches = 93 + let offsets = all_offset t in 94 + let strs = all t in 95 + Array.to_list (Array.init (Array.length strs) (fun i -> strs.(i), offsets.(i))) 96 + in 97 + let open Format in 98 + let open Fmt in 99 + let pp_match fmt (str, (start, stop)) = fprintf fmt "@[(%s (%d %d))@]" str start stop in 100 + sexp fmt "Group" (list pp_match) matches 101 + ;; 102 + 103 + let nb_groups t = t.gcount
+54
vendor/opam/re/lib/group.mli
··· 1 + (** Information about groups in a match. *) 2 + 3 + (** Result of a successful match. *) 4 + type t 5 + 6 + val create : string -> gcount:int -> gpos:int array -> Mark_infos.t -> Pmark.Set.t -> t 7 + 8 + (** Raise [Not_found] if the group did not match *) 9 + val get : t -> int -> string 10 + 11 + (** Similar to {!get}, but returns an option instead of using an exception. *) 12 + val get_opt : t -> int -> string option 13 + 14 + (** Raise [Not_found] if the group did not match *) 15 + val offset : t -> int -> int * int 16 + 17 + val offset_opt : t -> int -> (int * int) option 18 + 19 + (** Return the start of the match. Raise [Not_found] if the group did not match. *) 20 + val start : t -> int -> int 21 + 22 + val start_opt : t -> int -> int option 23 + 24 + (** Return the end of the match. Raise [Not_found] if the group did not match. *) 25 + val stop : t -> int -> int 26 + 27 + val stop_opt : t -> int -> int option 28 + 29 + (** Return the empty string for each group which did not match *) 30 + val all : t -> string array 31 + 32 + (** Return [(-1,-1)] for each group which did not match *) 33 + val all_offset : t -> (int * int) array 34 + 35 + (** Test whether a group matched *) 36 + val test : t -> int -> bool 37 + 38 + val pmarks : t -> Pmark.Set.t 39 + 40 + (** Returns the total number of groups defined - matched or not. 41 + This function is experimental. *) 42 + val nb_groups : t -> int 43 + 44 + val pp : t Fmt.t 45 + 46 + module Offset : sig 47 + type t 48 + 49 + val is_present : t -> bool 50 + val get_no_check : t -> int 51 + end 52 + 53 + val start_offset : t -> int -> Offset.t 54 + val stop_offset : t -> int -> Offset.t
+155
vendor/opam/re/lib/hash_set.ml
··· 1 + open Import 2 + 3 + module Array = struct 4 + type nonrec t = Bytes.t 5 + 6 + let words = 8 7 + let[@inline] length t = Bytes.length t / words 8 + let[@inline] unsafe_get t i = Int64.to_int (Bytes.get_int64_ne t (i * words)) 9 + let[@inline] unsafe_set t i x = Bytes.set_int64_ne t (i * words) (Int64.of_int x) 10 + 11 + let[@inline] make len x = 12 + let t = Bytes.create (len * words) in 13 + for i = 0 to length t - 1 do 14 + unsafe_set t i x 15 + done; 16 + t 17 + ;; 18 + 19 + let[@inline] make_absent len = Bytes.make (len * words) '\255' 20 + let clear t = Bytes.fill t 0 (Bytes.length t) '\255' 21 + 22 + let fold_left t ~init ~f = 23 + let init = ref init in 24 + for i = 0 to length t - 1 do 25 + init := f !init (unsafe_get t i) 26 + done; 27 + !init 28 + ;; 29 + end 30 + 31 + (* A specialized hash table that makes the following trade-offs: 32 + - Open addresing. Bucketing is quite memory intensive and dune is already 33 + a memory hog. 34 + - No boxing for empty slots. We make use of the fact that id's are never 35 + negative to achieve this. 36 + - No saving of the hash. Recomputing the hash for id's is a no-op. 37 + *) 38 + 39 + type nonrec table = 40 + { mutable table : Array.t 41 + ; mutable size : int 42 + } 43 + 44 + type t = table Option.t ref 45 + 46 + let init t = 47 + if Option.is_none !t then t := Option.some { size = 0; table = Array.make 0 (-1) }; 48 + Option.get !t 49 + ;; 50 + 51 + let[@inline] should_grow t = 52 + let slots = Array.length t.table in 53 + slots = 0 || (t.size > 0 && slots / t.size < 2) 54 + ;; 55 + 56 + let absent = -1 57 + 58 + let () = 59 + let x = Array.make_absent 1 in 60 + assert (Array.unsafe_get x 0 = absent) 61 + ;; 62 + 63 + let create () = ref None 64 + 65 + let[@inline] index_of_offset slots index i = 66 + let i = index + !i in 67 + if i >= slots then i - slots else i 68 + ;; 69 + 70 + let clear t = 71 + match !t with 72 + | None -> () 73 + | Some t -> 74 + t.size <- 0; 75 + Array.clear t.table 76 + ;; 77 + 78 + let add t x = 79 + let hash = Int.hash x in 80 + let slots = Array.length t.table in 81 + let index = hash land (slots - 1) in 82 + let inserting = ref true in 83 + let i = ref 0 in 84 + while !inserting do 85 + let idx = index_of_offset slots index i in 86 + let elem = Array.unsafe_get t.table idx in 87 + if elem = absent 88 + then ( 89 + Array.unsafe_set t.table idx x; 90 + inserting := false) 91 + else incr i 92 + done; 93 + t.size <- t.size + 1 94 + ;; 95 + 96 + let resize t = 97 + let old_table = t.table in 98 + let slots = Array.length old_table in 99 + let table = Array.make_absent (if slots = 0 then 1 else slots lsl 1) in 100 + t.table <- table; 101 + for i = 0 to slots - 1 do 102 + let elem = Array.unsafe_get old_table i in 103 + if elem <> absent then add t elem 104 + done 105 + ;; 106 + 107 + let add t x = 108 + let t = init t in 109 + if should_grow t then resize t; 110 + add t x 111 + ;; 112 + 113 + let[@inline] is_empty t = 114 + let t = !t in 115 + if Option.is_none t 116 + then true 117 + else ( 118 + let t = Option.get t in 119 + t.size = 0) 120 + ;; 121 + 122 + let mem t x = 123 + let t = !t in 124 + if Option.is_none t || (Option.get t).size = 0 125 + then false 126 + else ( 127 + let t = Option.get t in 128 + let hash = Int.hash x in 129 + let slots = Array.length t.table in 130 + let index = hash land (slots - 1) in 131 + let i = ref 0 in 132 + let found = ref false in 133 + while (not !found) && !i < slots do 134 + let idx = index_of_offset slots index i in 135 + let elem = Array.unsafe_get t.table idx in 136 + if Int.equal elem x 137 + then found := true 138 + else if Int.equal elem absent 139 + then i := slots 140 + else incr i 141 + done; 142 + !found) 143 + ;; 144 + 145 + let pp fmt t = 146 + let { table; size } = init t in 147 + let table = 148 + Array.fold_left table ~init:[] ~f:(fun acc i -> if i = absent then acc else i :: acc) 149 + |> List.rev 150 + |> Stdlib.Array.of_list 151 + in 152 + let table fmt () = Fmt.sexp fmt "table" Fmt.(array int) table in 153 + let size fmt () = Fmt.sexp fmt "size" Fmt.int size in 154 + Format.fprintf fmt "%a@.%a@." table () size () 155 + ;;
+8
vendor/opam/re/lib/hash_set.mli
··· 1 + type t 2 + 3 + val create : unit -> t 4 + val is_empty : t -> bool 5 + val add : t -> int -> unit 6 + val mem : t -> int -> bool 7 + val clear : t -> unit 8 + val pp : t Fmt.t
+40
vendor/opam/re/lib/import.ml
··· 1 + module List = struct 2 + let[@warning "-32"] rec equal ~eq l1 l2 = match l1, l2 with 3 + | [], [] -> true 4 + | [], _::_ | _::_, [] -> false 5 + | x::xs, y::ys -> if eq x y then equal ~eq xs ys else false 6 + 7 + let[@warning "-32"] rec compare ~cmp l1 l2 = match l1, l2 with 8 + | [], [] -> 0 9 + | [], _::_ -> -1 10 + | _::_, [] -> 1 11 + | x::xs, y::ys -> 12 + let r = cmp x y in 13 + if r = 0 then compare ~cmp xs ys else r 14 + 15 + include Stdlib.ListLabels 16 + end 17 + 18 + module Poly = struct 19 + let equal = ( = ) 20 + let compare = compare 21 + end 22 + 23 + module Phys_equal = struct 24 + let equal = ( == ) 25 + end 26 + 27 + let ( = ) = Int.equal 28 + let ( == ) = [ `Use_phys_equal ] 29 + let ( < ) (x : int) (y : int) = x < y 30 + let ( > ) (x : int) (y : int) = x > y 31 + let min (x : int) (y : int) = if x <= y then x else y 32 + let max (x : int) (y : int) = if x >= y then x else y 33 + let compare = Int.compare 34 + 35 + module Int = struct 36 + let[@warning "-32"] hash (x : int) = Hashtbl.hash x 37 + let[@warning "-32"] max (x : int) (y : int) = if x >= y then x else y 38 + 39 + include Stdlib.Int 40 + end
+55
vendor/opam/re/lib/mark_infos.ml
··· 1 + open Import 2 + 3 + type t = int array 4 + 5 + let make marks = 6 + let len = 1 + List.fold_left ~f:(fun ma (i, _) -> max ma i) ~init:(-1) marks in 7 + let t = Array.make len (-1) in 8 + let set (i, v) = t.(i) <- v in 9 + List.iter ~f:set marks; 10 + t 11 + ;; 12 + 13 + let test t i = if 2 * i >= Array.length t then false else t.(2 * i) <> -1 14 + 15 + module Offset = struct 16 + type t = int 17 + 18 + let is_present t = t >= 0 19 + let get_no_check t = t 20 + end 21 + 22 + let start_offset t i = 23 + let start_i = 2 * i in 24 + if start_i + 1 >= Array.length t then -1 else t.(start_i) 25 + ;; 26 + 27 + let stop_offset t i = 28 + let stop_i = (2 * i) + 1 in 29 + if stop_i >= Array.length t then -1 else t.(stop_i) 30 + ;; 31 + 32 + let offset t i = 33 + let start_i = 2 * i in 34 + let stop_i = start_i + 1 in 35 + if stop_i >= Array.length t 36 + then None 37 + else ( 38 + let start = t.(start_i) in 39 + if start = -1 40 + then None 41 + else ( 42 + let stop = t.(stop_i) in 43 + Some (start, stop))) 44 + ;; 45 + 46 + let iteri t ~f = 47 + for i = 0 to (Array.length t / 2) - 1 do 48 + let idx = 2 * i in 49 + let start = t.(idx) in 50 + if start <> -1 51 + then ( 52 + let stop = t.(idx + 1) in 53 + f i start stop) 54 + done 55 + ;;
+17
vendor/opam/re/lib/mark_infos.mli
··· 1 + (** store mark information for groups in an array *) 2 + type t 3 + 4 + val make : (int * int) list -> t 5 + val offset : t -> int -> (int * int) option 6 + val test : t -> int -> bool 7 + val iteri : t -> f:(int -> int -> int -> unit) -> unit 8 + 9 + module Offset : sig 10 + type t 11 + 12 + val is_present : t -> bool 13 + val get_no_check : t -> int 14 + end 15 + 16 + val start_offset : t -> int -> Offset.t 17 + val stop_offset : t -> int -> Offset.t
+67
vendor/opam/re/lib/parse_buffer.ml
··· 1 + type t = 2 + { str : string 3 + ; mutable pos : int 4 + } 5 + 6 + exception Parse_error 7 + 8 + let create str = { str; pos = 0 } 9 + let unget t = t.pos <- t.pos - 1 10 + let junk t = t.pos <- t.pos + 1 11 + let eos t = t.pos = String.length t.str 12 + let test t c = (not (eos t)) && t.str.[t.pos] = c 13 + 14 + let test2 t c c' = 15 + t.pos + 1 < String.length t.str && t.str.[t.pos] = c && t.str.[t.pos + 1] = c' 16 + ;; 17 + 18 + let accept t c = 19 + let r = test t c in 20 + if r then t.pos <- t.pos + 1; 21 + r 22 + ;; 23 + 24 + let get t = 25 + let r = t.str.[t.pos] in 26 + t.pos <- t.pos + 1; 27 + r 28 + ;; 29 + 30 + let accept_s t s' = 31 + let len = String.length s' in 32 + try 33 + for j = 0 to len - 1 do 34 + (* CR-someday rgrinberg: stop relying on bound checks *) 35 + try if s'.[j] <> t.str.[t.pos + j] then raise_notrace Exit with 36 + | _ -> raise_notrace Exit 37 + done; 38 + t.pos <- t.pos + len; 39 + true 40 + with 41 + | Exit -> false 42 + ;; 43 + 44 + let rec integer' t i = 45 + if eos t 46 + then Some i 47 + else ( 48 + match get t with 49 + | '0' .. '9' as d -> 50 + let i' = (10 * i) + (Char.code d - Char.code '0') in 51 + if i' < i then raise Parse_error; 52 + integer' t i' 53 + | _ -> 54 + unget t; 55 + Some i) 56 + ;; 57 + 58 + let integer t = 59 + if eos t 60 + then None 61 + else ( 62 + match get t with 63 + | '0' .. '9' as d -> integer' t (Char.code d - Char.code '0') 64 + | _ -> 65 + unget t; 66 + None) 67 + ;;
+14
vendor/opam/re/lib/parse_buffer.mli
··· 1 + type t 2 + 3 + exception Parse_error 4 + 5 + val create : string -> t 6 + val junk : t -> unit 7 + val unget : t -> unit 8 + val eos : t -> bool 9 + val test : t -> char -> bool 10 + val test2 : t -> char -> char -> bool 11 + val get : t -> char 12 + val accept : t -> char -> bool 13 + val accept_s : t -> string -> bool 14 + val integer : t -> int option
+179
vendor/opam/re/lib/pcre.ml
··· 1 + module Re = Core 2 + 3 + exception Parse_error = Perl.Parse_error 4 + exception Not_supported = Perl.Not_supported 5 + 6 + type regexp = Re.re 7 + 8 + type flag = 9 + [ `CASELESS 10 + | `MULTILINE 11 + | `ANCHORED 12 + | `DOTALL 13 + ] 14 + 15 + type split_result = 16 + | Text of string 17 + | Delim of string 18 + | Group of int * string 19 + | NoGroup 20 + 21 + type groups = Core.Group.t 22 + 23 + let re ?(flags = []) pat = 24 + let opts = 25 + List.map 26 + (function 27 + | `CASELESS -> `Caseless 28 + | `MULTILINE -> `Multiline 29 + | `ANCHORED -> `Anchored 30 + | `DOTALL -> `Dotall) 31 + flags 32 + in 33 + Perl.re ~opts pat 34 + ;; 35 + 36 + let re_result ?flags s = 37 + match re ?flags s with 38 + | s -> Ok s 39 + | exception Not_supported -> Error `Not_supported 40 + | exception Parse_error -> Error `Parse_error 41 + ;; 42 + 43 + let regexp ?flags pat = Re.compile (re ?flags pat) 44 + let extract ~rex s = Re.Group.all (Re.exec rex s) 45 + let exec ~rex ?pos s = Re.exec rex ?pos s 46 + let names rex = Re.group_names rex |> List.map fst |> Array.of_list 47 + 48 + let get_named_substring_opt rex name s = 49 + let rec loop = function 50 + | [] -> None 51 + | (n, i) :: rem when n = name -> 52 + (match Re.Group.get_opt s i with 53 + | None -> loop rem 54 + | Some _ as s -> s) 55 + | _ :: rem -> loop rem 56 + in 57 + loop (Re.group_names rex) 58 + ;; 59 + 60 + let get_substring_ofs s i = Re.Group.offset s i 61 + let pmatch ~rex s = Re.execp rex s 62 + 63 + let substitute ~rex ~subst str = 64 + let b = Buffer.create 1024 in 65 + let rec loop pos on_match = 66 + if Re.execp ~pos rex str 67 + then ( 68 + let ss = Re.exec ~pos rex str in 69 + let start, fin = Re.Group.offset ss 0 in 70 + if on_match && start = pos && start = fin 71 + then ( 72 + if (* Empty match following a match *) 73 + pos < String.length str 74 + then ( 75 + Buffer.add_char b str.[pos]; 76 + loop (pos + 1) false)) 77 + else ( 78 + let pat = Re.Group.get ss 0 in 79 + Buffer.add_substring b str pos (start - pos); 80 + Buffer.add_string b (subst pat); 81 + if start = fin 82 + then ( 83 + if (* Manually advance by one after an empty match *) 84 + fin < String.length str 85 + then ( 86 + Buffer.add_char b str.[fin]; 87 + loop (fin + 1) false)) 88 + else loop fin true)) 89 + else Buffer.add_substring b str pos (String.length str - pos) 90 + in 91 + loop 0 false; 92 + Buffer.contents b 93 + ;; 94 + 95 + let split ~rex s = 96 + let rec split accu start = 97 + if start = String.length s 98 + then accu 99 + else ( 100 + match 101 + let g = Re.exec rex s ~pos:start in 102 + if Group.stop g 0 = start then Re.exec rex s ~pos:(start + 1) else g 103 + with 104 + | exception Not_found -> String.sub s start (String.length s - start) :: accu 105 + | g -> 106 + let next = Group.stop g 0 in 107 + split (String.sub s start (Group.start g 0 - start) :: accu) next) 108 + in 109 + match Re.exec rex s ~pos:0 with 110 + | g -> 111 + List.rev 112 + (if Group.start g 0 = 0 113 + then split [] (Group.stop g 0) 114 + else split [ String.sub s 0 (Group.start g 0) ] (Group.stop g 0)) 115 + | exception Not_found -> if s = "" then [] else [ s ] 116 + ;; 117 + 118 + (* From PCRE *) 119 + let string_unsafe_sub s ofs len = 120 + let r = Bytes.create len in 121 + Bytes.unsafe_blit s ofs r 0 len; 122 + Bytes.unsafe_to_string r 123 + ;; 124 + 125 + let quote s = 126 + let len = String.length s in 127 + let buf = Bytes.create (len lsl 1) in 128 + let pos = ref 0 in 129 + for i = 0 to len - 1 do 130 + match String.unsafe_get s i with 131 + | ('\\' | '^' | '$' | '.' | '[' | '|' | '(' | ')' | '?' | '*' | '+' | '{') as c -> 132 + Bytes.unsafe_set buf !pos '\\'; 133 + incr pos; 134 + Bytes.unsafe_set buf !pos c; 135 + incr pos 136 + | c -> 137 + Bytes.unsafe_set buf !pos c; 138 + incr pos 139 + done; 140 + string_unsafe_sub buf 0 !pos 141 + ;; 142 + 143 + let full_split ?(max = 0) ~rex s = 144 + if String.length s = 0 145 + then [] 146 + else if max = 1 147 + then [ Text s ] 148 + else ( 149 + let results = Re.split_full rex s in 150 + let matches = 151 + List.map 152 + (function 153 + | `Text s -> [ Text s ] 154 + | `Delim d -> 155 + let matches = Re.Group.all_offset d in 156 + let delim = Re.Group.get d 0 in 157 + Delim delim 158 + :: 159 + (let l = ref [] in 160 + for i = 1 to Array.length matches - 1 do 161 + l 162 + := (if matches.(i) = (-1, -1) then NoGroup else Group (i, Re.Group.get d i)) 163 + :: !l 164 + done; 165 + List.rev !l)) 166 + results 167 + in 168 + List.concat matches) 169 + ;; 170 + 171 + type substrings = Group.t 172 + 173 + let get_substring s i = Re.Group.get s i 174 + 175 + let get_named_substring rex name s = 176 + match get_named_substring_opt rex name s with 177 + | None -> raise Not_found 178 + | Some s -> s 179 + ;;
+67
vendor/opam/re/lib/pcre.mli
··· 1 + (** NOTE: Only a subset of the PCRE spec is supported *) 2 + 3 + exception Parse_error 4 + exception Not_supported 5 + 6 + type regexp = Core.re 7 + 8 + type flag = 9 + [ `CASELESS 10 + | `MULTILINE 11 + | `ANCHORED 12 + | `DOTALL 13 + ] 14 + 15 + type groups = Core.Group.t 16 + 17 + (** Result of a {!Pcre.full_split} *) 18 + type split_result = 19 + | Text of string (** Text part of splitted string *) 20 + | Delim of string (** Delimiter part of splitted string *) 21 + | Group of int * string (** Subgroup of matched delimiter (subgroup_nr, subgroup_str) *) 22 + | NoGroup (** Unmatched subgroup *) 23 + 24 + (** [re ~flags s] creates the regexp [s] using the pcre syntax. *) 25 + val re : ?flags:flag list -> string -> Core.t 26 + 27 + val re_result 28 + : ?flags:flag list 29 + -> string 30 + -> (Core.t, [ `Not_supported | `Parse_error ]) result 31 + 32 + (** [re ~flags s] compiles the regexp [s] using the pcre syntax. *) 33 + val regexp : ?flags:flag list -> string -> regexp 34 + 35 + (** [extract ~rex s] executes [rex] on [s] and returns the matching groups. *) 36 + val extract : rex:regexp -> string -> string array 37 + 38 + (** Equivalent to {!Core.exec}. *) 39 + val exec : rex:regexp -> ?pos:int -> string -> groups 40 + 41 + (** Equivalent to {!Core.Group.get}. *) 42 + val get_substring : groups -> int -> string 43 + 44 + (** Return the names of named groups. *) 45 + val names : regexp -> string array 46 + 47 + (** Return the first matched named group, or raise [Not_found]. Prefer to use 48 + the non-raising version [get_named_substring_opt] *) 49 + val get_named_substring : regexp -> string -> groups -> string 50 + 51 + (** Return the first matched named group, or raise [Not_found]. *) 52 + val get_named_substring_opt : regexp -> string -> groups -> string option 53 + 54 + (** Equivalent to {!Core.Group.offset}. *) 55 + val get_substring_ofs : groups -> int -> int * int 56 + 57 + (** Equivalent to {!Core.execp}. *) 58 + val pmatch : rex:regexp -> string -> bool 59 + 60 + val substitute : rex:Core.re -> subst:(string -> string) -> string -> string 61 + val full_split : ?max:int -> rex:regexp -> string -> split_result list 62 + val split : rex:regexp -> string -> string list 63 + val quote : string -> string 64 + 65 + (** {2 Deprecated} *) 66 + 67 + type substrings = Group.t
+360
vendor/opam/re/lib/perl.ml
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + module Re = Core 24 + 25 + exception Parse_error = Parse_buffer.Parse_error 26 + exception Not_supported 27 + 28 + let acc_digits = 29 + let rec loop base digits acc i = 30 + match digits with 31 + | [] -> acc 32 + | d :: digits -> 33 + let acc = acc + (d * i) in 34 + let i = i * i in 35 + loop base digits acc i 36 + in 37 + fun ~base ~digits -> loop base digits 0 1 38 + ;; 39 + 40 + let char_of_int x = 41 + match char_of_int x with 42 + | x -> x 43 + | exception _ -> raise Parse_error 44 + ;; 45 + 46 + type elem = 47 + | Char of char 48 + | Set of Ast.t 49 + 50 + let char_b = Char '\008' 51 + let char_newline = Char '\n' 52 + let char_cr = Char '\r' 53 + let char_tab = Char '\t' 54 + let word_char = [ Re.alnum; Re.char '_' ] 55 + let word = Set (Re.alt word_char) 56 + let not_word = Set (Re.alt word_char) 57 + let space = Set Re.space 58 + let not_space = Set (Re.compl [ Re.space ]) 59 + let digit = Set Re.digit 60 + let not_digit = Set (Re.compl [ Re.digit ]) 61 + 62 + let parse ~multiline ~dollar_endonly ~dotall ~ungreedy s = 63 + let buf = Parse_buffer.create s in 64 + let accept = Parse_buffer.accept buf in 65 + let eos () = Parse_buffer.eos buf in 66 + let test c = Parse_buffer.test buf c in 67 + let unget () = Parse_buffer.unget buf in 68 + let get () = Parse_buffer.get buf in 69 + let greedy_mod r = 70 + let gr = accept '?' in 71 + let gr = if ungreedy then not gr else gr in 72 + if gr then Re.non_greedy r else Re.greedy r 73 + in 74 + let rec regexp () = regexp' [ branch () ] 75 + and regexp' left = 76 + if accept '|' then regexp' (branch () :: left) else Re.alt (List.rev left) 77 + and branch () = branch' [] 78 + and branch' left = 79 + if eos () || test '|' || test ')' 80 + then Re.seq (List.rev left) 81 + else branch' (piece () :: left) 82 + and in_brace ~f ~init = 83 + match accept '{' with 84 + | false -> None 85 + | true -> 86 + let rec loop acc = 87 + if accept '}' 88 + then acc 89 + else ( 90 + let acc = f acc in 91 + loop acc) 92 + in 93 + Some (loop init) 94 + and piece () = 95 + let r = atom () in 96 + if accept '*' 97 + then greedy_mod (Re.rep r) 98 + else if accept '+' 99 + then greedy_mod (Re.rep1 r) 100 + else if accept '?' 101 + then greedy_mod (Re.opt r) 102 + else if accept '{' 103 + then ( 104 + match Parse_buffer.integer buf with 105 + | Some i -> 106 + let j = if accept ',' then Parse_buffer.integer buf else Some i in 107 + if not (accept '}') then raise Parse_error; 108 + (match j with 109 + | Some j when j < i -> raise Parse_error 110 + | _ -> ()); 111 + greedy_mod (Re.repn r i j) 112 + | None -> 113 + unget (); 114 + r) 115 + else r 116 + and atom () = 117 + if accept '.' 118 + then if dotall then Re.any else Re.notnl 119 + else if accept '(' 120 + then 121 + if accept '?' 122 + then 123 + if accept ':' 124 + then ( 125 + let r = regexp () in 126 + if not (accept ')') then raise Parse_error; 127 + r) 128 + else if accept '#' 129 + then comment () 130 + else if accept '<' 131 + then ( 132 + let name = name () in 133 + let r = regexp () in 134 + if not (accept ')') then raise Parse_error; 135 + Re.group ~name r) 136 + else raise Parse_error 137 + else ( 138 + let r = regexp () in 139 + if not (accept ')') then raise Parse_error; 140 + Re.group r) 141 + else if accept '^' 142 + then if multiline then Re.bol else Re.bos 143 + else if accept '$' 144 + then if multiline then Re.eol else if dollar_endonly then Re.leol else Re.eos 145 + else if accept '[' 146 + then if accept '^' then Re.compl (bracket []) else Re.alt (bracket []) 147 + else if accept '\\' 148 + then ( 149 + (* XXX 150 + - Back-references 151 + - \cx (control-x), \ddd 152 + *) 153 + if eos () then raise Parse_error; 154 + match get () with 155 + | 'w' -> Re.alt [ Re.alnum; Re.char '_' ] 156 + | 'W' -> Re.compl [ Re.alnum; Re.char '_' ] 157 + | 's' -> Re.space 158 + | 'S' -> Re.compl [ Re.space ] 159 + | 'd' -> Re.digit 160 + | 'D' -> Re.compl [ Re.digit ] 161 + | 'b' -> Re.alt [ Re.bow; Re.eow ] 162 + | 'B' -> Re.not_boundary 163 + | 'A' -> Re.bos 164 + | 'Z' -> Re.leol 165 + | 'z' -> Re.eos 166 + | 'G' -> Re.start 167 + | 'e' -> Re.char '\x1b' 168 + | 'f' -> Re.char '\x0c' 169 + | 'n' -> Re.char '\n' 170 + | 'r' -> Re.char '\r' 171 + | 't' -> Re.char '\t' 172 + | 'Q' -> quote (Buffer.create 12) 173 + | 'E' -> raise Parse_error 174 + | 'x' -> 175 + let c1, c2 = 176 + match in_brace ~init:[] ~f:(fun acc -> hexdigit () :: acc) with 177 + | Some [ c1; c2 ] -> c1, c2 178 + | Some [ c2 ] -> 0, c2 179 + | Some _ -> raise Parse_error 180 + | None -> 181 + let c1 = hexdigit () in 182 + let c2 = hexdigit () in 183 + c1, c2 184 + in 185 + let code = (c1 * 16) + c2 in 186 + Re.char (char_of_int code) 187 + | 'o' -> 188 + (match 189 + in_brace ~init:[] ~f:(fun acc -> 190 + match maybe_octaldigit () with 191 + | None -> raise Parse_error 192 + | Some p -> p :: acc) 193 + with 194 + | None -> raise Parse_error 195 + | Some digits -> Re.char (char_of_int (acc_digits ~base:8 ~digits))) 196 + | 'a' .. 'z' | 'A' .. 'Z' -> raise Parse_error 197 + | '0' .. '7' as n1 -> 198 + let n2 = maybe_octaldigit () in 199 + let n3 = maybe_octaldigit () in 200 + (match n2, n3 with 201 + | Some n2, Some n3 -> 202 + let n1 = Char.code n1 - Char.code '0' in 203 + Re.char (char_of_int ((n1 * (8 * 8)) + (n2 * 8) + n3)) 204 + | _, _ -> raise Not_supported) 205 + | '8' .. '9' -> raise Not_supported 206 + | c -> Re.char c) 207 + else ( 208 + if eos () then raise Parse_error; 209 + match get () with 210 + | '*' | '+' | '?' | '{' | '\\' -> raise Parse_error 211 + | c -> Re.char c) 212 + and quote buf = 213 + if accept '\\' 214 + then ( 215 + if eos () then raise Parse_error; 216 + match get () with 217 + | 'E' -> Re.str (Buffer.contents buf) 218 + | c -> 219 + Buffer.add_char buf '\\'; 220 + Buffer.add_char buf c; 221 + quote buf) 222 + else ( 223 + if eos () then raise Parse_error; 224 + Buffer.add_char buf (get ()); 225 + quote buf) 226 + and hexdigit () = 227 + if eos () then raise Parse_error; 228 + match get () with 229 + | '0' .. '9' as d -> Char.code d - Char.code '0' 230 + | 'a' .. 'f' as d -> Char.code d - Char.code 'a' + 10 231 + | 'A' .. 'F' as d -> Char.code d - Char.code 'A' + 10 232 + | _ -> raise Parse_error 233 + and maybe_octaldigit () = 234 + if eos () 235 + then None 236 + else ( 237 + match get () with 238 + | '0' .. '7' as d -> Some (Char.code d - Char.code '0') 239 + | _ -> None) 240 + and name () = 241 + if eos () 242 + then raise Parse_error 243 + else ( 244 + match get () with 245 + | ('_' | 'a' .. 'z' | 'A' .. 'Z') as c -> 246 + let b = Buffer.create 32 in 247 + Buffer.add_char b c; 248 + name' b 249 + | _ -> raise Parse_error) 250 + and name' b = 251 + if eos () 252 + then raise Parse_error 253 + else ( 254 + match get () with 255 + | ('_' | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9') as c -> 256 + Buffer.add_char b c; 257 + name' b 258 + | '>' -> Buffer.contents b 259 + | _ -> raise Parse_error) 260 + and bracket s = 261 + if s <> [] && accept ']' 262 + then s 263 + else ( 264 + match char () with 265 + | Set st -> bracket (st :: s) 266 + | Char c -> 267 + if accept '-' 268 + then 269 + if accept ']' 270 + then Re.char c :: Re.char '-' :: s 271 + else 272 + bracket 273 + (match char () with 274 + | Char c' -> Re.rg c c' :: s 275 + | Set st' -> Re.char c :: Re.char '-' :: st' :: s) 276 + else bracket (Re.char c :: s)) 277 + and char () = 278 + if eos () then raise Parse_error; 279 + let c = get () in 280 + if c = '[' 281 + then ( 282 + if accept '=' then raise Not_supported; 283 + match Posix_class.parse buf with 284 + | Some set -> Set set 285 + | None -> 286 + if accept '.' 287 + then ( 288 + if eos () then raise Parse_error; 289 + let c = get () in 290 + if not (accept '.') then raise Not_supported; 291 + if not (accept ']') then raise Parse_error; 292 + Char c) 293 + else Char c) 294 + else if c = '\\' 295 + then ( 296 + if eos () then raise Parse_error; 297 + let c = get () in 298 + (* XXX 299 + \127, ... 300 + *) 301 + match c with 302 + | 'b' -> char_b 303 + | 'n' -> char_newline (*XXX*) 304 + | 'r' -> char_cr (*XXX*) 305 + | 't' -> char_tab (*XXX*) 306 + | 'w' -> word 307 + | 'W' -> not_word 308 + | 's' -> space 309 + | 'S' -> not_space 310 + | 'd' -> digit 311 + | 'D' -> not_digit 312 + | 'a' .. 'z' | 'A' .. 'Z' -> raise Parse_error 313 + | '0' .. '9' -> raise Not_supported 314 + | _ -> Char c) 315 + else Char c 316 + and comment () = 317 + if eos () then raise Parse_error; 318 + if accept ')' 319 + then Re.epsilon 320 + else ( 321 + Parse_buffer.junk buf; 322 + comment ()) 323 + in 324 + let res = regexp () in 325 + if not (eos ()) then raise Parse_error; 326 + res 327 + ;; 328 + 329 + type opt = 330 + [ `Ungreedy 331 + | `Dotall 332 + | `Dollar_endonly 333 + | `Multiline 334 + | `Anchored 335 + | `Caseless 336 + ] 337 + 338 + let re ?(opts = []) s = 339 + let r = 340 + parse 341 + ~multiline:(List.memq `Multiline opts) 342 + ~dollar_endonly:(List.memq `Dollar_endonly opts) 343 + ~dotall:(List.memq `Dotall opts) 344 + ~ungreedy:(List.memq `Ungreedy opts) 345 + s 346 + in 347 + let r = if List.memq `Anchored opts then Re.seq [ Re.start; r ] else r in 348 + let r = if List.memq `Caseless opts then Re.no_case r else r in 349 + r 350 + ;; 351 + 352 + let compile = Re.compile 353 + let compile_pat ?(opts = []) s = compile (re ~opts s) 354 + 355 + let re_result ?opts s = 356 + match re ?opts s with 357 + | s -> Ok s 358 + | exception Not_supported -> Error `Not_supported 359 + | exception Parse_error -> Error `Parse_error 360 + ;;
+51
vendor/opam/re/lib/perl.mli
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + (** Perl-style regular expressions *) 24 + 25 + exception Parse_error 26 + 27 + (** Errors that can be raised during the parsing of the regular expression *) 28 + exception Not_supported 29 + 30 + type opt = 31 + [ `Ungreedy 32 + | `Dotall 33 + | `Dollar_endonly 34 + | `Multiline 35 + | `Anchored 36 + | `Caseless 37 + ] 38 + 39 + (** Parsing of a Perl-style regular expression *) 40 + val re : ?opts:opt list -> string -> Core.t 41 + 42 + val re_result 43 + : ?opts:opt list 44 + -> string 45 + -> (Core.t, [ `Not_supported | `Parse_error ]) result 46 + 47 + (** (Same as [Re.compile]) *) 48 + val compile : Core.t -> Core.re 49 + 50 + (** Regular expression compilation *) 51 + val compile_pat : ?opts:opt list -> string -> Core.re
+24
vendor/opam/re/lib/pmark.ml
··· 1 + module Pmark = struct 2 + type t = int 3 + 4 + let equal (x : int) (y : int) = x = y 5 + let compare (x : int) (y : int) = compare x y 6 + let r = Atomic.make 1 7 + let gen () = Atomic.fetch_and_add r 1 8 + let pp = Format.pp_print_int 9 + end 10 + 11 + include Pmark 12 + 13 + module Set = struct 14 + module Set = Set.Make (Pmark) 15 + 16 + let[@warning "-32"] to_list x = 17 + let open Set in 18 + to_seq x |> List.of_seq 19 + ;; 20 + 21 + include Set 22 + end 23 + 24 + let to_dyn = Dyn.int
+13
vendor/opam/re/lib/pmark.mli
··· 1 + type t = private int 2 + 3 + val equal : t -> t -> bool 4 + val compare : t -> t -> int 5 + val gen : unit -> t 6 + val pp : t Fmt.t 7 + val to_dyn : t -> Dyn.t 8 + 9 + module Set : sig 10 + include Set.S with type elt = t 11 + 12 + val to_list : t -> elt list 13 + end
+163
vendor/opam/re/lib/posix.ml
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + (* 24 + What we could (should?) do: 25 + - a* ==> longest ((shortest (no_group a)* ), a | ()) (!!!) 26 + - abc understood as (ab)c 27 + - "((a?)|b)" against "ab" should not bind the first subpattern to anything 28 + 29 + Note that it should be possible to handle "(((ab)c)d)e" efficiently 30 + *) 31 + module Re = Core 32 + 33 + exception Parse_error = Parse_buffer.Parse_error 34 + exception Not_supported 35 + 36 + let parse newline s = 37 + let buf = Parse_buffer.create s in 38 + let accept = Parse_buffer.accept buf in 39 + let eos () = Parse_buffer.eos buf in 40 + let test c = Parse_buffer.test buf c in 41 + let unget () = Parse_buffer.unget buf in 42 + let get () = Parse_buffer.get buf in 43 + let rec regexp () = regexp' [ branch () ] 44 + and regexp' left = 45 + if accept '|' then regexp' (branch () :: left) else Re.alt (List.rev left) 46 + and branch () = branch' [] 47 + and branch' left = 48 + if eos () || test '|' || test ')' 49 + then Re.seq (List.rev left) 50 + else branch' (piece () :: left) 51 + and piece () = 52 + let r = atom () in 53 + if accept '*' 54 + then Re.rep (Re.nest r) 55 + else if accept '+' 56 + then Re.rep1 (Re.nest r) 57 + else if accept '?' 58 + then Re.opt r 59 + else if accept '{' 60 + then ( 61 + match Parse_buffer.integer buf with 62 + | Some i -> 63 + let j = if accept ',' then Parse_buffer.integer buf else Some i in 64 + if not (accept '}') then raise Parse_error; 65 + (match j with 66 + | Some j when j < i -> raise Parse_error 67 + | _ -> ()); 68 + Re.repn (Re.nest r) i j 69 + | None -> 70 + unget (); 71 + r) 72 + else r 73 + and atom () = 74 + if accept '.' 75 + then if newline then Re.notnl else Re.any 76 + else if accept '(' 77 + then ( 78 + let r = regexp () in 79 + if not (accept ')') then raise Parse_error; 80 + Re.group r) 81 + else if accept '^' 82 + then if newline then Re.bol else Re.bos 83 + else if accept '$' 84 + then if newline then Re.eol else Re.eos 85 + else if accept '[' 86 + then 87 + if accept '^' 88 + then Re.diff (Re.compl (bracket [])) (Re.char '\n') 89 + else Re.alt (bracket []) 90 + else if accept '\\' 91 + then ( 92 + if eos () then raise Parse_error; 93 + match get () with 94 + | ('|' | '(' | ')' | '*' | '+' | '?' | '[' | '.' | '^' | '$' | '{' | '\\') as c -> 95 + Re.char c 96 + | _ -> raise Parse_error) 97 + else ( 98 + if eos () then raise Parse_error; 99 + match get () with 100 + | '*' | '+' | '?' | '{' | '\\' -> raise Parse_error 101 + | c -> Re.char c) 102 + and bracket s = 103 + if s <> [] && accept ']' 104 + then s 105 + else ( 106 + match char () with 107 + | `Set st -> bracket (st :: s) 108 + | `Char c -> 109 + if accept '-' 110 + then 111 + if accept ']' 112 + then Re.char c :: Re.char '-' :: s 113 + else 114 + bracket 115 + (match char () with 116 + | `Char c' -> Re.rg c c' :: s 117 + | `Set st' -> Re.char c :: Re.char '-' :: st' :: s) 118 + else bracket (Re.char c :: s)) 119 + and char () = 120 + if eos () then raise Parse_error; 121 + let c = get () in 122 + if c = '[' 123 + then ( 124 + match Posix_class.parse buf with 125 + | Some set -> `Set set 126 + | None -> 127 + if accept '.' 128 + then ( 129 + if eos () then raise Parse_error; 130 + let c = get () in 131 + if not (accept '.') then raise Not_supported; 132 + if not (accept ']') then raise Parse_error; 133 + `Char c) 134 + else `Char c) 135 + else `Char c 136 + in 137 + let res = regexp () in 138 + if not (eos ()) then raise Parse_error; 139 + res 140 + ;; 141 + 142 + type opt = 143 + [ `ICase 144 + | `NoSub 145 + | `Newline 146 + ] 147 + 148 + let re ?(opts = []) s = 149 + let r = parse (List.memq `Newline opts) s in 150 + let r = if List.memq `ICase opts then Re.no_case r else r in 151 + let r = if List.memq `NoSub opts then Re.no_group r else r in 152 + r 153 + ;; 154 + 155 + let re_result ?opts s = 156 + match re ?opts s with 157 + | s -> Ok s 158 + | exception Not_supported -> Error `Not_supported 159 + | exception Parse_error -> Error `Parse_error 160 + ;; 161 + 162 + let compile re = Re.compile (Re.longest re) 163 + let compile_pat ?(opts = []) s = compile (re ~opts s)
+107
vendor/opam/re/lib/posix.mli
··· 1 + (* 2 + RE - A regular expression library 3 + 4 + Copyright (C) 2001 Jerome Vouillon 5 + email: Jerome.Vouillon@pps.jussieu.fr 6 + 7 + This library is free software; you can redistribute it and/or 8 + modify it under the terms of the GNU Lesser General Public 9 + License as published by the Free Software Foundation, with 10 + linking exception; either version 2.1 of the License, or (at 11 + your option) any later version. 12 + 13 + This library is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + Lesser General Public License for more details. 17 + 18 + You should have received a copy of the GNU Lesser General Public 19 + License along with this library; if not, write to the Free Software 20 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 + *) 22 + 23 + (** References: 24 + - {{:http://www.opengroup.org/onlinepubs/007908799/xbd/re.html} re} 25 + - {{:http://www.opengroup.org/onlinepubs/007908799/xsh/regcomp.html} regcomp} 26 + 27 + Example of how to use this module (to parse some IRC logs): 28 + 29 + {[ 30 + type msg = 31 + { time : string 32 + ; author : string 33 + ; content : string 34 + } 35 + 36 + let re = Core.compile (Re_posix.re "([^:].*:[^:]*:[^:]{2})<.([^>]+)> (.+)$") 37 + 38 + (* parse a line *) 39 + let match_line line = 40 + try 41 + let substrings = Core.exec re line in 42 + let groups = Core.get_all substrings in 43 + (* groups can be obtained directly by index within [substrings] *) 44 + Some { time = groups.(1); author = groups.(2); content = groups.(3) } 45 + with 46 + | Not_found -> None (* regex didn't match *) 47 + ;; 48 + ]} *) 49 + 50 + (* XXX Character classes *) 51 + 52 + exception Parse_error 53 + 54 + (** Errors that can be raised during the parsing of the regular expression *) 55 + exception Not_supported 56 + 57 + type opt = 58 + [ `ICase 59 + | `NoSub 60 + | `Newline 61 + ] 62 + 63 + (** Parsing of a Posix extended regular expression *) 64 + val re : ?opts:opt list -> string -> Core.t 65 + 66 + val re_result 67 + : ?opts:opt list 68 + -> string 69 + -> (Core.t, [ `Not_supported | `Parse_error ]) result 70 + 71 + (** [compile r] is defined as [Core.compile (Core.longest r)] *) 72 + val compile : Core.t -> Core.re 73 + 74 + (** [compile_pat ?opts regex] compiles the Posix extended regular expression [regexp] *) 75 + val compile_pat : ?opts:opt list -> string -> Core.re 76 + 77 + (* 78 + Deviation from the standard / ambiguities in the standard 79 + --------------------------------------------------------- 80 + We tested the behavior of the Linux library (glibc) and the Solaris 81 + library. 82 + 83 + (1) An expression [efg] should be parsed as [(ef)g]. 84 + All implementations parse it as [e(fg)]. 85 + (2) When matching the pattern "((a)|b)*" against the string "ab", 86 + the sub-expression "((a)|b)" should match "b", and the 87 + sub-expression "(a)" should not match anything. 88 + In both implementation, the sub-expression "(a)" matches "a". 89 + (3) When matching the pattern "(aa?)*" against the string "aaa", it is 90 + not clear whether the final match of the sub-expression "(aa?)" is 91 + the last "a" (all matches of the sub-expression are successively 92 + maximized), or "aa" (the final match is maximized). 93 + Both implementations implements the first case. 94 + (4) When matching the pattern "((a?)|b)*" against the string "ab", 95 + the sub-expression "((a?)|b)" should match the empty string at the 96 + end of the string (it is better to match the empty string than to 97 + match nothing). 98 + In both implementations, this sub-expression matches "b". 99 + (Strangely, in the Linux implementation, the sub-expression "(a?)" 100 + correctly matches the empty string at the end of the string) 101 + 102 + This library behaves the same way as the other libraries for all 103 + points, except for (2) and (4) where it follows the standard. 104 + 105 + The behavior of this library in theses four cases may change in future 106 + releases. 107 + *)
+53
vendor/opam/re/lib/posix_class.ml
··· 1 + module Re = Core 2 + 3 + let of_name = function 4 + | "alpha" -> Re.alpha 5 + | "alnum" -> Re.alnum 6 + | "ascii" -> Re.ascii 7 + | "blank" -> Re.blank 8 + | "cntrl" -> Re.cntrl 9 + | "digit" -> Re.digit 10 + | "lower" -> Re.lower 11 + | "print" -> Re.print 12 + | "space" -> Re.space 13 + | "upper" -> Re.upper 14 + | "word" -> Re.wordc 15 + | "punct" -> Re.punct 16 + | "graph" -> Re.graph 17 + | "xdigit" -> Re.xdigit 18 + | class_ -> invalid_arg ("Invalid pcre class: " ^ class_) 19 + ;; 20 + 21 + let names = 22 + [ "alpha" 23 + ; "alnum" 24 + ; "ascii" 25 + ; "blank" 26 + ; "cntrl" 27 + ; "digit" 28 + ; "lower" 29 + ; "print" 30 + ; "space" 31 + ; "upper" 32 + ; "word" 33 + ; "punct" 34 + ; "graph" 35 + ; "xdigit" 36 + ] 37 + ;; 38 + 39 + let parse buf = 40 + let accept = Parse_buffer.accept buf in 41 + let accept_s = Parse_buffer.accept_s buf in 42 + match accept ':' with 43 + | false -> None 44 + | true -> 45 + let compl = accept '^' in 46 + let cls = 47 + try List.find accept_s names with 48 + | Not_found -> raise Parse_buffer.Parse_error 49 + in 50 + if not (accept_s ":]") then raise Parse_buffer.Parse_error; 51 + let posix_class = of_name cls in 52 + Some (if compl then Re.compl [ posix_class ] else posix_class) 53 + ;;
+3
vendor/opam/re/lib/posix_class.mli
··· 1 + val names : string list 2 + val of_name : string -> Core.t 3 + val parse : Parse_buffer.t -> Core.t option
+9
vendor/opam/re/lib/re.ml
··· 1 + include Core 2 + include Replace 3 + module View = View 4 + module Emacs = Emacs 5 + module Glob = Glob 6 + module Perl = Perl 7 + module Pcre = Pcre 8 + module Posix = Posix 9 + module Str = Str
+53
vendor/opam/re/lib/replace.ml
··· 1 + let replace ?(pos = 0) ?len ?(all = true) re ~f s = 2 + if pos < 0 then invalid_arg "Re.replace"; 3 + let limit = 4 + match len with 5 + | None -> String.length s 6 + | Some l -> 7 + if l < 0 || pos + l > String.length s then invalid_arg "Re.replace"; 8 + pos + l 9 + in 10 + (* buffer into which we write the result *) 11 + let buf = Buffer.create (String.length s) in 12 + (* iterate on matched substrings. *) 13 + let rec iter pos on_match = 14 + if pos <= limit 15 + then ( 16 + match 17 + Compile.match_str ~groups:true ~partial:false re s ~pos ~len:(limit - pos) 18 + with 19 + | Match substr -> 20 + let p1 = Group.start_offset substr 0 |> Group.Offset.get_no_check in 21 + let p2 = Group.stop_offset substr 0 |> Group.Offset.get_no_check in 22 + if pos = p1 && p1 = p2 && on_match 23 + then ( 24 + (* if we matched an empty string right after a match, 25 + we must manually advance by 1 *) 26 + if p2 < limit then Buffer.add_char buf s.[p2]; 27 + iter (p2 + 1) false) 28 + else ( 29 + (* add string between previous match and current match *) 30 + Buffer.add_substring buf s pos (p1 - pos); 31 + (* what should we replace the matched group with? *) 32 + let replacing = f substr in 33 + Buffer.add_string buf replacing; 34 + if all 35 + then 36 + (* if we matched an empty string, we must manually advance by 1 *) 37 + iter 38 + (if p1 = p2 39 + then ( 40 + (* a non char could be past the end of string. e.g. $ *) 41 + if p2 < limit then Buffer.add_char buf s.[p2]; 42 + p2 + 1) 43 + else p2) 44 + (p1 <> p2) 45 + else Buffer.add_substring buf s p2 (limit - p2)) 46 + | Running _ -> () 47 + | Failed -> Buffer.add_substring buf s pos (limit - pos)) 48 + in 49 + iter pos false; 50 + Buffer.contents buf 51 + ;; 52 + 53 + let replace_string ?pos ?len ?all re ~by s = replace ?pos ?len ?all re s ~f:(fun _ -> by)
+35
vendor/opam/re/lib/replace.mli
··· 1 + (** [replace ~all re ~f s] iterates on [s], and replaces every occurrence 2 + of [re] with [f substring] where [substring] is the current match. 3 + If [all = false], then only the first occurrence of [re] is replaced. *) 4 + val replace 5 + : ?pos:int (** Default: 0 *) 6 + -> ?len:int 7 + -> ?all:bool (** Default: true. Otherwise only replace first occurrence *) 8 + -> Compile.re (** matched groups *) 9 + -> f:(Group.t -> string) (** how to replace *) 10 + -> string (** string to replace in *) 11 + -> string 12 + 13 + (** [replace_string ~all re ~by s] iterates on [s], and replaces every 14 + occurrence of [re] with [by]. If [all = false], then only the first 15 + occurrence of [re] is replaced. 16 + 17 + {5 Examples:} 18 + {[ 19 + # let regex = Re.compile (Re.char ',');; 20 + val regex : re = <abstr> 21 + 22 + # Re.replace_string regex ~by:";" "[1,2,3,4,5,6,7]";; 23 + - : string = "[1;2;3;4;5;6;7]" 24 + 25 + # Re.replace_string regex ~all:false ~by:";" "[1,2,3,4,5,6,7]";; 26 + - : string = "[1;2,3,4,5,6,7]" 27 + ]} *) 28 + val replace_string 29 + : ?pos:int (** Default: 0 *) 30 + -> ?len:int 31 + -> ?all:bool (** Default: true. Otherwise only replace first occurrence *) 32 + -> Compile.re (** matched groups *) 33 + -> by:string (** replacement string *) 34 + -> string (** string to replace in *) 35 + -> string
+114
vendor/opam/re/lib/search.ml
··· 1 + let all ?(pos = 0) ?len re s : _ Seq.t = 2 + if pos < 0 then invalid_arg "Re.all"; 3 + (* index of the first position we do not consider. 4 + !pos < limit is an invariant *) 5 + let limit = 6 + match len with 7 + | None -> String.length s 8 + | Some l -> 9 + if l < 0 || pos + l > String.length s then invalid_arg "Re.all"; 10 + pos + l 11 + in 12 + (* iterate on matches. When a match is found, search for the next 13 + one just after its end *) 14 + let rec aux pos on_match () = 15 + if pos > limit 16 + then Seq.Nil (* no more matches *) 17 + else ( 18 + match 19 + Compile.match_str ~groups:true ~partial:false re s ~pos ~len:(limit - pos) 20 + with 21 + | Match substr -> 22 + let p1 = Group.start_offset substr 0 |> Group.Offset.get_no_check in 23 + let p2 = Group.stop_offset substr 0 |> Group.Offset.get_no_check in 24 + if on_match && p1 = pos && p1 = p2 25 + then (* skip empty match right after a match *) 26 + aux (pos + 1) false () 27 + else ( 28 + let pos = if p1 = p2 then p2 + 1 else p2 in 29 + Seq.Cons (substr, aux pos (p1 <> p2))) 30 + | Running _ | Failed -> Seq.Nil) 31 + in 32 + aux pos false 33 + ;; 34 + 35 + let matches ?pos ?len re s : _ Seq.t = 36 + all ?pos ?len re s |> Seq.map (fun sub -> Group.get sub 0) 37 + ;; 38 + 39 + let split_full ?(pos = 0) ?len re s : _ Seq.t = 40 + if pos < 0 then invalid_arg "Re.split"; 41 + let limit = 42 + match len with 43 + | None -> String.length s 44 + | Some l -> 45 + if l < 0 || pos + l > String.length s then invalid_arg "Re.split"; 46 + pos + l 47 + in 48 + (* i: start of delimited string 49 + pos: first position after last match of [re] 50 + limit: first index we ignore (!pos < limit is an invariant) *) 51 + let pos0 = pos in 52 + let rec aux state i pos () = 53 + match state with 54 + | `Idle when pos > limit -> 55 + (* We had an empty match at the end of the string *) 56 + assert (i = limit); 57 + Seq.Nil 58 + | `Idle -> 59 + (match 60 + Compile.match_str ~groups:true ~partial:false re s ~pos ~len:(limit - pos) 61 + with 62 + | Match substr -> 63 + let p1 = Group.start_offset substr 0 |> Group.Offset.get_no_check in 64 + let p2 = Group.stop_offset substr 0 |> Group.Offset.get_no_check in 65 + let pos = if p1 = p2 then p2 + 1 else p2 in 66 + let old_i = i in 67 + let i = p2 in 68 + if old_i = p1 && p1 = p2 && p1 > pos0 69 + then (* Skip empty match right after a delimiter *) 70 + aux state i pos () 71 + else if p1 > pos0 72 + then ( 73 + (* string does not start by a delimiter *) 74 + let text = String.sub s old_i (p1 - old_i) in 75 + let state = `Yield (`Delim substr) in 76 + Seq.Cons (`Text text, aux state i pos)) 77 + else Seq.Cons (`Delim substr, aux state i pos) 78 + | Running _ -> Seq.Nil 79 + | Failed -> 80 + if i < limit 81 + then ( 82 + let text = String.sub s i (limit - i) in 83 + (* yield last string *) 84 + Seq.Cons (`Text text, aux state limit pos)) 85 + else Seq.Nil) 86 + | `Yield x -> Seq.Cons (x, aux `Idle i pos) 87 + in 88 + aux `Idle pos pos 89 + ;; 90 + 91 + let split ?pos ?len re s : _ Seq.t = 92 + let seq = split_full ?pos ?len re s in 93 + let rec filter seq () = 94 + match seq () with 95 + | Seq.Nil -> Seq.Nil 96 + | Seq.Cons (`Delim _, tl) -> filter tl () 97 + | Seq.Cons (`Text s, tl) -> Seq.Cons (s, filter tl) 98 + in 99 + filter seq 100 + ;; 101 + 102 + let split_delim ?pos ?len re s : _ Seq.t = 103 + let seq = split_full ?pos ?len re s in 104 + let rec filter ~delim seq () = 105 + match seq () with 106 + | Seq.Nil -> if delim then Seq.Cons ("", fun () -> Seq.Nil) else Seq.Nil 107 + | Seq.Cons (`Delim _, tl) -> 108 + if delim 109 + then Seq.Cons ("", fun () -> filter ~delim:true tl ()) 110 + else filter ~delim:true tl () 111 + | Seq.Cons (`Text s, tl) -> Seq.Cons (s, filter ~delim:false tl) 112 + in 113 + filter ~delim:true seq 114 + ;;
+70
vendor/opam/re/lib/slice.ml
··· 1 + open Import 2 + 3 + type t = 4 + { s : string 5 + ; pos : int 6 + ; len : int 7 + } 8 + 9 + module L = struct 10 + type nonrec t = t list 11 + 12 + let get_substring slices ~start ~stop = 13 + if stop = start 14 + then "" 15 + else ( 16 + let slices = 17 + let rec drop slices remains = 18 + if remains = 0 19 + then slices 20 + else ( 21 + match slices with 22 + | [] -> assert false 23 + | ({ s = _; pos; len } as slice) :: xs -> 24 + let remains' = remains - len in 25 + if remains' >= 0 26 + then drop xs remains' 27 + else ( 28 + let pos = pos + remains in 29 + let len = len - remains in 30 + { slice with pos; len } :: xs)) 31 + in 32 + drop slices start 33 + in 34 + let buf = Buffer.create (stop - start) in 35 + let rec take slices remains = 36 + if remains > 0 37 + then ( 38 + match slices with 39 + | [] -> assert false 40 + | { s; pos; len } :: xs -> 41 + let remains' = remains - len in 42 + if remains' > 0 43 + then ( 44 + Buffer.add_substring buf s pos len; 45 + take xs remains') 46 + else Buffer.add_substring buf s pos remains) 47 + in 48 + take slices (stop - start); 49 + Buffer.contents buf) 50 + ;; 51 + 52 + let rec drop t remains = 53 + if remains = 0 54 + then t 55 + else ( 56 + match t with 57 + | [] -> [] 58 + | ({ s = _; pos; len } as slice) :: t -> 59 + if remains >= len 60 + then drop t (remains - len) 61 + else ( 62 + let delta = len - remains in 63 + { slice with pos = pos + delta; len = len - delta } :: t)) 64 + ;; 65 + 66 + let drop_rev t remains = 67 + (* TODO Use a proper functional queue *) 68 + if remains = 0 then t else List.rev (drop (List.rev t) remains) 69 + ;; 70 + end
+12
vendor/opam/re/lib/slice.mli
··· 1 + type t = 2 + { s : string 3 + ; pos : int 4 + ; len : int 5 + } 6 + 7 + module L : sig 8 + type nonrec t = t list 9 + 10 + val get_substring : t -> start:int -> stop:int -> string 11 + val drop_rev : t -> int -> t 12 + end
+299
vendor/opam/re/lib/str.ml
··· 1 + (***********************************************************************) 2 + (* *) 3 + (* Objective Caml *) 4 + (* *) 5 + (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) 6 + (* *) 7 + (* Copyright 1996 Institut National de Recherche en Informatique et *) 8 + (* en Automatique. All rights reserved. This file is distributed *) 9 + (* under the terms of the GNU Library General Public License, with *) 10 + (* linking exception. *) 11 + (* *) 12 + (***********************************************************************) 13 + 14 + (* Modified by Jerome.Vouillon@pps.jussieu.fr for integration in RE *) 15 + 16 + (* $Id: re_str.ml,v 1.3 2002/07/03 15:47:54 vouillon Exp $ *) 17 + 18 + module Ast = Ast.Export 19 + 20 + include struct 21 + open Core 22 + 23 + let exec = exec 24 + let exec_partial = exec_partial 25 + end 26 + 27 + type regexp = 28 + { mtch : Compile.re Lazy.t 29 + ; srch : Compile.re Lazy.t 30 + } 31 + 32 + let compile_regexp s c = 33 + let re = Emacs.re_no_emacs ~case:(not c) s in 34 + { mtch = lazy (Compile.compile (Ast.seq [ Ast.start; re ])) 35 + ; srch = lazy (Compile.compile re) 36 + } 37 + ;; 38 + 39 + let state = Domain.DLS.new_key (fun () -> None) 40 + 41 + let string_match re s p = 42 + match exec ~pos:p (Lazy.force re.mtch) s with 43 + | res -> 44 + Domain.DLS.set state (Some res); 45 + true 46 + | exception Not_found -> 47 + Domain.DLS.set state None; 48 + false 49 + ;; 50 + 51 + let string_partial_match re s p = 52 + match exec_partial ~pos:p (Lazy.force re.mtch) s with 53 + | `Full -> string_match re s p 54 + | `Partial -> true 55 + | `Mismatch -> false 56 + ;; 57 + 58 + let search_forward re s p = 59 + match exec ~pos:p (Lazy.force re.srch) s with 60 + | res -> 61 + Domain.DLS.set state (Some res); 62 + fst (Group.offset res 0) 63 + | exception Not_found -> 64 + Domain.DLS.set state None; 65 + raise Not_found 66 + ;; 67 + 68 + let rec search_backward re s p = 69 + match exec ~pos:p (Lazy.force re.mtch) s with 70 + | res -> 71 + Domain.DLS.set state (Some res); 72 + p 73 + | exception Not_found -> 74 + Domain.DLS.set state None; 75 + if p = 0 then raise Not_found else search_backward re s (p - 1) 76 + ;; 77 + 78 + let valid_group n = 79 + n >= 0 80 + && n < 10 81 + && 82 + match Domain.DLS.get state with 83 + | None -> false 84 + | Some m -> n < Group.nb_groups m 85 + ;; 86 + 87 + let offset_group i = 88 + match Domain.DLS.get state with 89 + | Some m -> Group.offset m i 90 + | None -> raise Not_found 91 + ;; 92 + 93 + let group_len i = 94 + match offset_group i with 95 + | b, e -> e - b 96 + | exception Not_found -> 0 97 + ;; 98 + 99 + let rec repl_length repl p q len = 100 + if p < len 101 + then 102 + if repl.[p] <> '\\' 103 + then repl_length repl (p + 1) (q + 1) len 104 + else ( 105 + let p = p + 1 in 106 + if p = len then failwith "Str.replace: illegal backslash sequence"; 107 + let q = 108 + match repl.[p] with 109 + | '\\' -> q + 1 110 + | '0' .. '9' as c -> q + group_len (Char.code c - Char.code '0') 111 + | _ -> q + 2 112 + in 113 + repl_length repl (p + 1) q len) 114 + else q 115 + ;; 116 + 117 + let rec replace orig repl p res q len = 118 + if p < len 119 + then ( 120 + let c = repl.[p] in 121 + if c <> '\\' 122 + then ( 123 + Bytes.set res q c; 124 + replace orig repl (p + 1) res (q + 1) len) 125 + else ( 126 + match repl.[p + 1] with 127 + | '\\' -> 128 + Bytes.set res q '\\'; 129 + replace orig repl (p + 2) res (q + 1) len 130 + | '0' .. '9' as c -> 131 + let d = 132 + let group = Char.code c - Char.code '0' in 133 + match offset_group group with 134 + | exception Not_found -> 0 135 + | b, e -> 136 + let d = e - b in 137 + if d > 0 then String.blit orig b res q d; 138 + d 139 + in 140 + replace orig repl (p + 2) res (q + d) len 141 + | c -> 142 + Bytes.set res q '\\'; 143 + Bytes.set res (q + 1) c; 144 + replace orig repl (p + 2) res (q + 2) len)) 145 + ;; 146 + 147 + let replacement_text repl orig = 148 + let len = String.length repl in 149 + let res = Bytes.create (repl_length repl 0 0 len) in 150 + replace orig repl 0 res 0 (String.length repl); 151 + Bytes.unsafe_to_string res 152 + ;; 153 + 154 + let quote s = 155 + let len = String.length s in 156 + let buf = Buffer.create (2 * len) in 157 + for i = 0 to len - 1 do 158 + match s.[i] with 159 + | ('[' | ']' | '*' | '.' | '\\' | '?' | '+' | '^' | '$') as c -> 160 + Buffer.add_char buf '\\'; 161 + Buffer.add_char buf c 162 + | c -> Buffer.add_char buf c 163 + done; 164 + Buffer.contents buf 165 + ;; 166 + 167 + let string_before s n = String.sub s 0 n 168 + let string_after s n = String.sub s n (String.length s - n) 169 + let first_chars s n = String.sub s 0 n 170 + let last_chars s n = String.sub s (String.length s - n) n 171 + let regexp e = compile_regexp e false 172 + let regexp_case_fold e = compile_regexp e true 173 + let regexp_string s = compile_regexp (quote s) false 174 + let regexp_string_case_fold s = compile_regexp (quote s) true 175 + 176 + let group_beginning n = 177 + if not (valid_group n) then invalid_arg "Str.group_beginning"; 178 + let pos = fst (offset_group n) in 179 + if pos = -1 then raise Not_found else pos 180 + ;; 181 + 182 + let group_end n = 183 + if not (valid_group n) then invalid_arg "Str.group_end"; 184 + let pos = snd (offset_group n) in 185 + if pos = -1 then raise Not_found else pos 186 + ;; 187 + 188 + let matched_group n txt = 189 + let b, e = offset_group n in 190 + String.sub txt b (e - b) 191 + ;; 192 + 193 + let replace_matched repl matched = replacement_text repl matched 194 + 195 + let match_beginning () = group_beginning 0 196 + and match_end () = group_end 0 197 + and matched_string txt = matched_group 0 txt 198 + 199 + let substitute_first expr repl_fun text = 200 + try 201 + let pos = search_forward expr text 0 in 202 + String.concat 203 + "" 204 + [ string_before text pos; repl_fun text; string_after text (match_end ()) ] 205 + with 206 + | Not_found -> text 207 + ;; 208 + 209 + let global_substitute expr repl_fun text = 210 + let rec replace accu start last_was_empty = 211 + let startpos = if last_was_empty then start + 1 else start in 212 + if startpos > String.length text 213 + then string_after text start :: accu 214 + else ( 215 + match search_forward expr text startpos with 216 + | pos -> 217 + let end_pos = match_end () in 218 + let repl_text = repl_fun text in 219 + replace 220 + (repl_text :: String.sub text start (pos - start) :: accu) 221 + end_pos 222 + (end_pos = pos) 223 + | exception Not_found -> string_after text start :: accu) 224 + in 225 + String.concat "" (List.rev (replace [] 0 false)) 226 + ;; 227 + 228 + let global_replace expr repl text = global_substitute expr (replacement_text repl) text 229 + and replace_first expr repl text = substitute_first expr (replacement_text repl) text 230 + 231 + let search_forward_progress re s p = 232 + let pos = search_forward re s p in 233 + if match_end () > p 234 + then pos 235 + else if p < String.length s 236 + then search_forward re s (p + 1) 237 + else raise Not_found 238 + ;; 239 + 240 + let bounded_split expr text num = 241 + let start = if string_match expr text 0 then match_end () else 0 in 242 + let rec split accu start n = 243 + if start >= String.length text 244 + then accu 245 + else if n = 1 246 + then string_after text start :: accu 247 + else ( 248 + match search_forward_progress expr text start with 249 + | pos -> split (String.sub text start (pos - start) :: accu) (match_end ()) (n - 1) 250 + | exception Not_found -> string_after text start :: accu) 251 + in 252 + List.rev (split [] start num) 253 + ;; 254 + 255 + let split expr text = bounded_split expr text 0 256 + 257 + let bounded_split_delim expr text num = 258 + let rec split accu start n = 259 + if start > String.length text 260 + then accu 261 + else if n = 1 262 + then string_after text start :: accu 263 + else ( 264 + match search_forward_progress expr text start with 265 + | pos -> split (String.sub text start (pos - start) :: accu) (match_end ()) (n - 1) 266 + | exception Not_found -> string_after text start :: accu) 267 + in 268 + if text = "" then [] else List.rev (split [] 0 num) 269 + ;; 270 + 271 + let split_delim expr text = bounded_split_delim expr text 0 272 + 273 + type split_result = 274 + | Text of string 275 + | Delim of string 276 + 277 + let bounded_full_split expr text num = 278 + let rec split accu start n = 279 + if start >= String.length text 280 + then accu 281 + else if n = 1 282 + then Text (string_after text start) :: accu 283 + else ( 284 + match search_forward_progress expr text start with 285 + | pos -> 286 + let s = matched_string text in 287 + if pos > start 288 + then 289 + split 290 + (Delim s :: Text (String.sub text start (pos - start)) :: accu) 291 + (match_end ()) 292 + (n - 1) 293 + else split (Delim s :: accu) (match_end ()) (n - 1) 294 + | exception Not_found -> Text (string_after text start) :: accu) 295 + in 296 + List.rev (split [] 0 num) 297 + ;; 298 + 299 + let full_split expr text = bounded_full_split expr text 0
+220
vendor/opam/re/lib/str.mli
··· 1 + (***********************************************************************) 2 + (* *) 3 + (* Objective Caml *) 4 + (* *) 5 + (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) 6 + (* *) 7 + (* Copyright 1996 Institut National de Recherche en Informatique et *) 8 + (* en Automatique. All rights reserved. This file is distributed *) 9 + (* under the terms of the GNU Library General Public License, with *) 10 + (* linking exception. *) 11 + (* *) 12 + (***********************************************************************) 13 + 14 + (* $Id: re_str.mli,v 1.1 2002/01/16 14:16:04 vouillon Exp $ *) 15 + 16 + (** Module [Str]: regular expressions and high-level string processing *) 17 + 18 + (** {2 Regular expressions} *) 19 + 20 + (** The type of compiled regular expressions. *) 21 + type regexp 22 + 23 + (** Compile a regular expression. The syntax for regular expressions 24 + is the same as in Gnu Emacs. The special characters are 25 + [$^.*+?[]]. The following constructs are recognized: 26 + - [. ] matches any character except newline 27 + - [* ] (postfix) matches the previous expression zero, one or 28 + several times 29 + - [+ ] (postfix) matches the previous expression one or 30 + several times 31 + - [? ] (postfix) matches the previous expression once or 32 + not at all 33 + - [[..] ] character set; ranges are denoted with [-], as in [[a-z]]; 34 + an initial [^], as in [[^0-9]], complements the set 35 + - [^ ] matches at beginning of line 36 + - [$ ] matches at end of line 37 + - [\| ] (infix) alternative between two expressions 38 + - [\(..\)] grouping and naming of the enclosed expression 39 + - [\1 ] the text matched by the first [\(...\)] expression 40 + ([\2] for the second expression, etc) 41 + - [\b ] matches word boundaries 42 + - [\ ] quotes special characters. *) 43 + val regexp : string -> regexp 44 + 45 + (** Same as [regexp], but the compiled expression will match text 46 + in a case-insensitive way: uppercase and lowercase letters will 47 + be considered equivalent. *) 48 + val regexp_case_fold : string -> regexp 49 + 50 + (** [Str.quote s] returns a regexp string that matches exactly 51 + [s] and nothing else. *) 52 + val quote : string -> string 53 + 54 + (** [Str.regexp_string s] returns a regular expression 55 + that matches exactly [s] and nothing else. *) 56 + val regexp_string : string -> regexp 57 + 58 + (** [Str.regexp_string_case_fold] is similar to [Str.regexp_string], but the regexp 59 + matches in a case-insensitive way. *) 60 + val regexp_string_case_fold : string -> regexp 61 + 62 + (** {2 String matching and searching} *) 63 + 64 + (** [string_match r s start] tests whether the characters in [s] 65 + starting at position [start] match the regular expression [r]. 66 + The first character of a string has position [0], as usual. *) 67 + val string_match : regexp -> string -> int -> bool 68 + 69 + (** [search_forward r s start] searches the string [s] for a substring 70 + matching the regular expression [r]. The search starts at position 71 + [start] and proceeds towards the end of the string. 72 + Return the position of the first character of the matched 73 + substring, or raise [Not_found] if no substring matches. *) 74 + val search_forward : regexp -> string -> int -> int 75 + 76 + (** Same as [search_forward], but the search proceeds towards the 77 + beginning of the string. *) 78 + val search_backward : regexp -> string -> int -> int 79 + 80 + (** Similar to [string_match], but succeeds whenever the argument 81 + string is a prefix of a string that matches. This includes 82 + the case of a true complete match. *) 83 + val string_partial_match : regexp -> string -> int -> bool 84 + 85 + (** [matched_string s] returns the substring of [s] that was matched 86 + by the latest [string_match], [search_forward] or [search_backward]. 87 + The user must make sure that the parameter [s] is the same string 88 + that was passed to the matching or searching function. *) 89 + val matched_string : string -> string 90 + 91 + (** [match_beginning ()] returns the position of the first character 92 + of the substring that was matched by [string_match], 93 + [search_forward] or [search_backward]. *) 94 + val match_beginning : unit -> int 95 + 96 + (** [match_end ()] returns the position of the character following the 97 + last character of the substring that was matched by [string_match], 98 + [search_forward] or [search_backward]. *) 99 + val match_end : unit -> int 100 + 101 + (** [matched_group n s] returns the substring of [s] that was matched 102 + by the [n]th group [\(...\)] of the regular expression during 103 + the latest [string_match], [search_forward] or [search_backward]. 104 + The user must make sure that the parameter [s] is the same string 105 + that was passed to the matching or searching function. 106 + [matched_group n s] raises [Not_found] if the [n]th group 107 + of the regular expression was not matched. This can happen 108 + with groups inside alternatives [\|], options [?] 109 + or repetitions [*]. For instance, the empty string will match 110 + [\(a\)*], but [matched_group 1 ""] will raise [Not_found] 111 + because the first group itself was not matched. *) 112 + val matched_group : int -> string -> string 113 + 114 + (** [group_beginning n] returns the position of the first character 115 + of the substring that was matched by the [n]th group of the regular expression. 116 + Raises [Not_found] if the [n]th group of the regular expression was not matched. *) 117 + val group_beginning : int -> int 118 + 119 + (** [group_end n] returns the position of the character following 120 + the last character of the matched substring. 121 + Raises [Not_found] if the [n]th group of the regular expression was not matched. *) 122 + val group_end : int -> int 123 + 124 + (** {2 Replacement} *) 125 + 126 + (** [global_replace regexp templ s] returns a string identical to [s], 127 + except that all substrings of [s] that match [regexp] have been 128 + replaced by [templ]. The replacement template [templ] can contain 129 + [\1], [\2], etc; these sequences will be replaced by the text 130 + matched by the corresponding group in the regular expression. 131 + [\0] stands for the text matched by the whole regular expression. *) 132 + val global_replace : regexp -> string -> string -> string 133 + 134 + (** Same as [global_replace], except that only the first substring 135 + matching the regular expression is replaced. *) 136 + val replace_first : regexp -> string -> string -> string 137 + 138 + (** [global_substitute regexp subst s] returns a string identical 139 + to [s], except that all substrings of [s] that match [regexp] 140 + have been replaced by the result of function [subst]. The 141 + function [subst] is called once for each matching substring, 142 + and receives [s] (the whole text) as argument. *) 143 + val global_substitute : regexp -> (string -> string) -> string -> string 144 + 145 + (** Same as [global_substitute], except that only the first substring 146 + matching the regular expression is replaced. *) 147 + val substitute_first : regexp -> (string -> string) -> string -> string 148 + 149 + (** [replace_matched repl s] returns the replacement text [repl] 150 + in which [\1], [\2], etc. have been replaced by the text 151 + matched by the corresponding groups in the most recent matching 152 + operation. [s] must be the same string that was matched during 153 + this matching operation. *) 154 + val replace_matched : string -> string -> string 155 + 156 + (** {2 Splitting} *) 157 + 158 + (** [split r s] splits [s] into substrings, taking as delimiters 159 + the substrings that match [r], and returns the list of substrings. 160 + For instance, [split (regexp "[ \t]+") s] splits [s] into 161 + blank-separated words. An occurrence of the delimiter at the 162 + beginning and at the end of the string is ignored. *) 163 + val split : regexp -> string -> string list 164 + 165 + (** Same as [split], but splits into at most [n] substrings, 166 + where [n] is the extra integer parameter. *) 167 + val bounded_split : regexp -> string -> int -> string list 168 + 169 + (** Same as [split], but occurrences of the delimiter at the beginning 170 + and at the end of the string are recognized and returned as empty strings 171 + in the result. 172 + For instance, [split_delim (regexp " ") " abc "] returns [[""; "abc"; ""]], 173 + while [split] with the same arguments returns [["abc"]]. *) 174 + val split_delim : regexp -> string -> string list 175 + 176 + (** Same as [bounded_split] and [split_delim], but occurrences of 177 + the delimiter at the beginning and at the end of the string are recognized 178 + and returned as empty strings in the result. 179 + For instance, [split_delim (regexp " ") " abc "] returns [[""; "abc"; ""]], 180 + while [split] with the same arguments returns [["abc"]]. *) 181 + val bounded_split_delim : regexp -> string -> int -> string list 182 + 183 + type split_result = 184 + | Text of string 185 + | Delim of string 186 + 187 + (** Same as [split_delim], but returns the delimiters 188 + as well as the substrings contained between delimiters. 189 + The former are tagged [Delim] in the result list; 190 + the latter are tagged [Text]. 191 + For instance, [full_split (regexp "[{}]") "{ab}"] returns 192 + [[Delim "{"; Text "ab"; Delim "}"]]. *) 193 + val full_split : regexp -> string -> split_result list 194 + 195 + (** Same as [split_delim] and [bounded_split_delim], but returns 196 + the delimiters as well as the substrings contained between delimiters. 197 + The former are tagged [Delim] in the result list; 198 + the latter are tagged [Text]. 199 + For instance, [full_split (regexp "[{}]") "{ab}"] returns 200 + [[Delim "{"; Text "ab"; Delim "}"]]. *) 201 + val bounded_full_split : regexp -> string -> int -> split_result list 202 + 203 + (** {2 Extracting substrings} *) 204 + 205 + (** [string_before s n] returns the substring of all characters of [s] 206 + that precede position [n] (excluding the character at 207 + position [n]). *) 208 + val string_before : string -> int -> string 209 + 210 + (** [string_after s n] returns the substring of all characters of [s] 211 + that follow position [n] (including the character at 212 + position [n]). *) 213 + val string_after : string -> int -> string 214 + 215 + (** [first_chars s n] returns the first [n] characters of [s]. 216 + This is the same function as [string_before]. *) 217 + val first_chars : string -> int -> string 218 + 219 + (** [last_chars s n] returns the last [n] characters of [s]. *) 220 + val last_chars : string -> int -> string
+90
vendor/opam/re/lib/view.ml
··· 1 + open Import 2 + 3 + module Cset = struct 4 + include Cset 5 + 6 + module Range = struct 7 + type t = 8 + { first : Char.t 9 + ; last : Char.t 10 + } 11 + 12 + let first t = t.first 13 + let last t = t.last 14 + end 15 + 16 + let view t = 17 + fold_right t ~init:[] ~f:(fun first last acc -> 18 + let range = { Range.first = Cset.to_char first; last = Cset.to_char last } in 19 + range :: acc) 20 + ;; 21 + end 22 + 23 + module Sem = Automata.Sem 24 + module Rep_kind = Automata.Rep_kind 25 + 26 + type t = 27 + | Set of Cset.t 28 + | Sequence of Ast.t list 29 + | Alternative of Ast.t list 30 + | Repeat of Ast.t * int * int option 31 + | Beg_of_line 32 + | End_of_line 33 + | Beg_of_word 34 + | End_of_word 35 + | Not_bound 36 + | Beg_of_str 37 + | End_of_str 38 + | Last_end_of_line 39 + | Start 40 + | Stop 41 + | Sem of Automata.Sem.t * Ast.t 42 + | Sem_greedy of Automata.Rep_kind.t * Ast.t 43 + | Group of string option * Ast.t 44 + | No_group of Ast.t 45 + | Nest of Ast.t 46 + | Case of Ast.t 47 + | No_case of Ast.t 48 + | Intersection of Ast.t list 49 + | Complement of Ast.t list 50 + | Difference of Ast.t * Ast.t 51 + | Pmark of Pmark.t * Ast.t 52 + 53 + let view_ast f (t : _ Ast.ast) : t = 54 + match t with 55 + | Alternative a -> Alternative (List.map ~f a) 56 + | No_case a -> No_case (f a) 57 + | Case a -> Case (f a) 58 + ;; 59 + 60 + let view_set (cset : Ast.cset) : t = 61 + match cset with 62 + | Cset set -> Set set 63 + | Intersection sets -> Intersection (List.map sets ~f:Ast.t_of_cset) 64 + | Complement sets -> Complement (List.map sets ~f:Ast.t_of_cset) 65 + | Difference (x, y) -> Difference (Ast.t_of_cset x, Ast.t_of_cset y) 66 + | Cast ast -> view_ast Ast.t_of_cset ast 67 + ;; 68 + 69 + let view : Ast.t -> t = function 70 + | Set s -> view_set s 71 + | Ast s -> view_ast (fun x -> x) s 72 + | Sem (sem, a) -> Sem (sem, a) 73 + | Sem_greedy (sem, a) -> Sem_greedy (sem, a) 74 + | Sequence s -> Sequence s 75 + | Repeat (t, x, y) -> Repeat (t, x, y) 76 + | Beg_of_line -> Beg_of_line 77 + | End_of_line -> End_of_line 78 + | Beg_of_word -> Beg_of_word 79 + | End_of_word -> End_of_word 80 + | Not_bound -> Not_bound 81 + | Beg_of_str -> Beg_of_str 82 + | End_of_str -> End_of_str 83 + | Last_end_of_line -> Last_end_of_line 84 + | Start -> Start 85 + | Stop -> Stop 86 + | No_group a -> No_group a 87 + | Group (name, t) -> Group (name, t) 88 + | Nest t -> Nest t 89 + | Pmark (pmark, t) -> Pmark (pmark, t) 90 + ;;
+58
vendor/opam/re/lib/view.mli
··· 1 + (** A view of the top-level of a regex. This type is unstable and may change *) 2 + 3 + module Cset : sig 4 + type t = Cset.t 5 + 6 + module Range : sig 7 + type t 8 + 9 + val first : t -> Char.t 10 + val last : t -> Char.t 11 + end 12 + 13 + val view : t -> Range.t list 14 + end 15 + 16 + module Sem : sig 17 + type t = 18 + [ `Longest 19 + | `Shortest 20 + | `First 21 + ] 22 + end 23 + 24 + module Rep_kind : sig 25 + type t = 26 + [ `Greedy 27 + | `Non_greedy 28 + ] 29 + end 30 + 31 + type t = 32 + | Set of Cset.t 33 + | Sequence of Ast.t list 34 + | Alternative of Ast.t list 35 + | Repeat of Ast.t * int * int option 36 + | Beg_of_line 37 + | End_of_line 38 + | Beg_of_word 39 + | End_of_word 40 + | Not_bound 41 + | Beg_of_str 42 + | End_of_str 43 + | Last_end_of_line 44 + | Start 45 + | Stop 46 + | Sem of Sem.t * Ast.t 47 + | Sem_greedy of Rep_kind.t * Ast.t 48 + | Group of string option * Ast.t 49 + | No_group of Ast.t 50 + | Nest of Ast.t 51 + | Case of Ast.t 52 + | No_case of Ast.t 53 + | Intersection of Ast.t list 54 + | Complement of Ast.t list 55 + | Difference of Ast.t * Ast.t 56 + | Pmark of Pmark.t * Ast.t 57 + 58 + val view : Ast.t -> t
+9
vendor/opam/re/lib_test/.cvsignore
··· 1 + *.cmi 2 + *.cmx 3 + re_match 4 + pcre_match 5 + re_scan 6 + pcre_scan 7 + unison 8 + unison2 9 + unison3
+13
vendor/opam/re/lib_test/concurrency/dune
··· 1 + (test 2 + (name test) 3 + (build_if 4 + (>= %{ocaml_version} 5.0)) 5 + (action 6 + (pipe-outputs 7 + (setenv 8 + TSAN_OPTIONS 9 + suppressions=suppress.txt 10 + (run %{test})) 11 + (run cat))) 12 + (deps suppress.txt) 13 + (libraries re))
+22
vendor/opam/re/lib_test/concurrency/suppress.txt
··· 1 + 2 + # Data race between Compile.State.follow_transition (inlined in Compile.next) 3 + # and Compile.State.set_transition 4 + race_top:^camlRe__Compile.next 5 + 6 + # Data race within Compile.find_initial_state (read/write re.initial_states) 7 + race_top:^camlRe__Compile.find_initial_state 8 + 9 + # Spurious data race due to the two-step initialization in Compile.State.make 10 + # (between Compile.State.get_info and Compile.State.set_info, both inlined) 11 + race_top:^camlRe__Compile.loop 12 + 13 + # Race within Automata.Desc.status and Automata.Desc.status_no_mutex 14 + # (read/write s.status) 15 + race_top:^camlRe__Automata.status 16 + 17 + # Race within Compile.final 18 + race_top:^camlRe__Compile.final 19 + 20 + # Spurious data race due to the two-step initialization in Mark_info.make 21 + # (between Mark_info.make and other functions in module Mark_infos) 22 + race_top:^camlRe__Mark_infos.set
+2
vendor/opam/re/lib_test/concurrency/test.expected
··· 1 + Sequential 2 + Concurrent
+142
vendor/opam/re/lib_test/concurrency/test.ml
··· 1 + module Barrier = struct 2 + type t = 3 + { waiters : int Atomic.t 4 + ; size : int 5 + ; passed : int Atomic.t 6 + } 7 + 8 + let create n = { waiters = Atomic.make n; size = n; passed = Atomic.make 0 } 9 + 10 + let await { waiters; size; passed } = 11 + if Atomic.fetch_and_add passed 1 = size - 1 12 + then ( 13 + Atomic.set passed 0; 14 + Atomic.set waiters 0); 15 + while Atomic.get waiters = size do 16 + Domain.cpu_relax () 17 + done; 18 + Atomic.incr waiters; 19 + while Atomic.get waiters < size do 20 + Domain.cpu_relax () 21 + done 22 + ;; 23 + end 24 + 25 + let shuffle_array a = 26 + let n = Array.length a in 27 + let a' = Array.copy a in 28 + for i = n - 1 downto 1 do 29 + let j = Random.int (i + 1) in 30 + let temp = a'.(i) in 31 + a'.(i) <- a'.(j); 32 + a'.(j) <- temp 33 + done; 34 + a' 35 + ;; 36 + 37 + let inverse_permutation p = 38 + let n = Array.length p in 39 + let inv = Array.make n 0 in 40 + for i = 0 to n - 1 do 41 + inv.(p.(i)) <- i 42 + done; 43 + inv 44 + ;; 45 + 46 + let apply_permutation p a = 47 + let n = Array.length p in 48 + let b = Array.make n a.(0) in 49 + for i = 0 to n - 1 do 50 + b.(i) <- a.(p.(i)) 51 + done; 52 + b 53 + ;; 54 + 55 + (****) 56 + 57 + let re1 = Re.(alt [ group (char 'a'); char 'b' ]) 58 + let re2 = Re.(seq [ re1; re1 ]) 59 + let re3 = Re.(seq [ re2; re2 ]) 60 + let re4 = Re.(seq [ re3; re3 ]) 61 + 62 + let re5 = 63 + Re.( 64 + alt 65 + [ seq [ re4; re4 ] 66 + ; group (str "b") 67 + ; group (str "bb") 68 + ; group (str "bbb") 69 + ; group (str "bbbb") 70 + ]) 71 + ;; 72 + 73 + let size = 300 74 + 75 + let strings = 76 + Array.init size (fun _ -> String.init 30 (fun _ -> if Random.bool () then 'a' else 'b')) 77 + ;; 78 + 79 + let execute ~short re a = 80 + apply_permutation 81 + (inverse_permutation a) 82 + (Array.map 83 + (fun i -> 84 + try 85 + Some 86 + (Re.Group.all_offset 87 + @@ Re.exec ~pos:(if short then 30 - 7 else 0) re strings.(i)) 88 + with 89 + | Not_found -> None) 90 + a) 91 + ;; 92 + 93 + let compare_groups g g' = g = g' 94 + 95 + let concurrent f f' = 96 + let barrier = Barrier.create 2 in 97 + let domain = 98 + Domain.spawn 99 + @@ fun () -> 100 + Barrier.await barrier; 101 + f' () 102 + in 103 + Barrier.await barrier; 104 + let res = f () in 105 + let res' = Domain.join domain in 106 + res, res' 107 + ;; 108 + 109 + let sequential f f' = f (), f' () 110 + 111 + let test compose ~short n = 112 + let success = ref true in 113 + for _ = 1 to n do 114 + let re = Re.compile re5 in 115 + let a = shuffle_array (Array.init size Fun.id) in 116 + let a' = shuffle_array a in 117 + try 118 + let groups, groups' = 119 + compose (fun () -> execute ~short re a) (fun () -> execute ~short re a') 120 + in 121 + let ok = Array.for_all2 (Option.equal compare_groups) groups groups' in 122 + success := !success && ok; 123 + if not ok then prerr_endline "Bad group" 124 + with 125 + | Invalid_argument msg -> 126 + prerr_endline ("Invalid_argument " ^ msg); 127 + success := false 128 + | Division_by_zero -> 129 + prerr_endline "Division_by_zero"; 130 + success := false 131 + done; 132 + if not !success then exit 1 133 + ;; 134 + 135 + let () = 136 + prerr_endline "Sequential"; 137 + test sequential ~short:false 20; 138 + test sequential ~short:true 10; 139 + prerr_endline "Concurrent"; 140 + test ~short:false concurrent 750; 141 + test ~short:true concurrent 250 142 + ;;
+4
vendor/opam/re/lib_test/dune
··· 1 + (env 2 + (_ 3 + (flags 4 + (:standard -w -58))))
+39
vendor/opam/re/lib_test/expect/dune
··· 1 + (library 2 + (name re_tests) 3 + (libraries 4 + re_private 5 + ;; This is because of the (implicit_transitive_deps false) 6 + ;; in dune-project 7 + ppx_expect.config 8 + ppx_expect.config_types 9 + ppx_expect 10 + ppx_expect_common 11 + base 12 + str 13 + ppx_inline_test.config) 14 + (inline_tests 15 + (modes native js)) 16 + (preprocess 17 + (pps ppx_expect))) 18 + 19 + ;; ppx_expect v16 depends on ppx_expect.common 20 + (subdir 21 + ppx_expect_common 22 + (library 23 + (name ppx_expect_common) 24 + (enabled_if 25 + (< %{ocaml_version} 5.0)) 26 + (libraries (re_export ppx_expect.common))) 27 + (library 28 + (name ppx_expect_common) 29 + (enabled_if 30 + (>= %{ocaml_version} 5.0)))) 31 + 32 + ;; this hackery is needed because ppx_expect itself uses re, therefore we need to mangle 33 + ;; the library name 34 + 35 + (subdir 36 + private_re 37 + (library 38 + (name re_private)) 39 + (copy_files %{project_root}/lib/*.{ml,mli}))
+85
vendor/opam/re/lib_test/expect/import.ml
··· 1 + module Re = Re_private.Re 2 + include Re_private.Import 3 + module Fmt = Re_private.Fmt 4 + module Dyn = Re_private.Dyn 5 + 6 + let printf = Printf.printf 7 + 8 + let t re s = 9 + let group = Re.exec_opt (Re.compile re) s in 10 + Format.printf "%a@." (Fmt.opt Re.Group.pp) group 11 + ;; 12 + 13 + let re_whitespace = Re.Pcre.regexp "[\t ]+" 14 + let re_eol = Re.compile Re.eol 15 + let re_bow = Re.compile Re.bow 16 + let re_eow = Re.compile Re.eow 17 + let strings = Format.printf "[%a]@." Fmt.(list ~pp_sep:(Fmt.lit "; ") Fmt.quoted_string) 18 + let re_empty = Re.Posix.compile_pat "" 19 + 20 + let invalid_argument f = 21 + match f () with 22 + | s -> ignore s 23 + | exception Invalid_argument s -> Format.printf "Invalid_argument %S@." s 24 + ;; 25 + 26 + let exec_partial_detailed ?pos re s = 27 + let re = Re.compile re in 28 + let res = Re.exec_partial_detailed ?pos re s in 29 + match res with 30 + | `Mismatch -> Format.printf "`Mismatch@." 31 + | `Partial position -> Format.printf "`Partial %d@." position 32 + | `Full groups -> 33 + Re.Group.all_offset groups 34 + |> Array.to_list 35 + |> List.map ~f:(fun (a, b) -> 36 + Printf.sprintf 37 + "%d,%d,%s" 38 + a 39 + b 40 + (match String.sub s a (b - a) with 41 + | exception Invalid_argument _ -> "<No match>" 42 + | s -> Printf.sprintf "%S" s)) 43 + |> String.concat ";" 44 + |> Format.printf "`Full [|%s|]@." 45 + ;; 46 + 47 + let or_not_found f fmt v = 48 + match v () with 49 + | exception Not_found -> Format.fprintf fmt "Not_found" 50 + | s -> f fmt s 51 + ;; 52 + 53 + let array f fmt v = 54 + Format.fprintf fmt "[| %a |]" (Fmt.list ~pp_sep:(Fmt.lit "; ") f) (Array.to_list v) 55 + ;; 56 + 57 + let offset fmt (x, y) = Format.fprintf fmt "(%d, %d)" x y 58 + 59 + let test_re ?pos ?len r s = 60 + let offsets () = Re.Group.all_offset (Re.exec ?pos ?len (Re.compile r) s) in 61 + Format.printf "%a@." (or_not_found (array offset)) offsets 62 + ;; 63 + 64 + let rec sexp_of_dyn (t : Re_private.Dyn.t) : Base.Sexp.t = 65 + match t with 66 + | Int i -> Atom (Int.to_string i) 67 + | String s -> Atom s 68 + | Tuple xs -> List (List.map xs ~f:sexp_of_dyn) 69 + | Enum s -> Atom s 70 + | List xs -> List (List.map ~f:sexp_of_dyn xs) 71 + | Variant (name, []) -> Atom name 72 + | Variant (name, xs) -> 73 + let xs = List.map xs ~f:sexp_of_dyn in 74 + (match xs with 75 + | [] -> List [] 76 + | xs -> List (Atom name :: xs)) 77 + | Record fields -> 78 + List 79 + (List.filter_map fields ~f:(fun (name, v) -> 80 + match sexp_of_dyn v with 81 + | List [] -> None 82 + | sexp -> Some (Base.Sexp.List [ Atom name; sexp ]))) 83 + ;; 84 + 85 + let print_dyn dyn = sexp_of_dyn dyn |> Base.Sexp.to_string_hum |> print_endline
+76
vendor/opam/re/lib_test/expect/test_186.ml
··· 1 + open Import 2 + 3 + let print re result = 4 + Printf.printf 5 + "%s: %s\n" 6 + re 7 + (match result with 8 + | Ok _ -> "backward range parsed" 9 + | Error `Parse_error -> "parse error" 10 + | Error `Not_supported -> "not supported") 11 + ;; 12 + 13 + let cases = [ "[1-0]"; "[5-1]"; "[6-6]"; "[z-a]"; "[b-b]" ] 14 + 15 + let test f = 16 + List.iter cases ~f:(fun re -> 17 + let result = f re in 18 + print re result) 19 + ;; 20 + 21 + let%expect_test "perl" = 22 + test Re.Perl.re_result; 23 + [%expect 24 + {| 25 + [1-0]: backward range parsed 26 + [5-1]: backward range parsed 27 + [6-6]: backward range parsed 28 + [z-a]: backward range parsed 29 + [b-b]: backward range parsed 30 + |}] 31 + ;; 32 + 33 + let%expect_test "pcre" = 34 + test Re.Pcre.re_result; 35 + [%expect 36 + {| 37 + [1-0]: backward range parsed 38 + [5-1]: backward range parsed 39 + [6-6]: backward range parsed 40 + [z-a]: backward range parsed 41 + [b-b]: backward range parsed 42 + |}] 43 + ;; 44 + 45 + let%expect_test "posix" = 46 + test Re.Posix.re_result; 47 + [%expect 48 + {| 49 + [1-0]: backward range parsed 50 + [5-1]: backward range parsed 51 + [6-6]: backward range parsed 52 + [z-a]: backward range parsed 53 + [b-b]: backward range parsed 54 + |}] 55 + ;; 56 + 57 + (* CR-someday rgrinberg: is this correct? *) 58 + let%expect_test "emacs" = 59 + test Re.Emacs.re_result; 60 + [%expect 61 + {| 62 + [1-0]: backward range parsed 63 + [5-1]: backward range parsed 64 + [6-6]: backward range parsed 65 + [z-a]: backward range parsed 66 + [b-b]: backward range parsed 67 + |}] 68 + ;; 69 + 70 + (* We allow backward ranges in re. We could forbid them? *) 71 + let%expect_test "re" = 72 + Format.printf "%a@." Re.pp (Re.rg '5' '0'); 73 + [%expect {| (Set 48-53) |}]; 74 + Format.printf "%a@." Re.pp (Re.rg '0' '5'); 75 + [%expect {| (Set 48-53) |}] 76 + ;;
+28
vendor/opam/re/lib_test/expect/test_alternation.ml
··· 1 + open Import 2 + module Ast = Re_private.Ast 3 + 4 + let test f string = 5 + match f string with 6 + | Ok res -> print_dyn (Ast.to_dyn res) 7 + | Error _ -> assert false 8 + ;; 9 + 10 + let%expect_test "pcre" = 11 + test Re.Pcre.re_result "(a|b|c)"; 12 + [%expect {| (Group (Set (Cast (Alternative (Cset 97) (Cset 98) (Cset 99))))) |}] 13 + ;; 14 + 15 + let%expect_test "emacs" = 16 + test Re.Emacs.re_result {|\(a\|b\|c\)|}; 17 + [%expect {| (Group (Set (Cast (Alternative (Cset 97) (Cset 98) (Cset 99))))) |}] 18 + ;; 19 + 20 + let%expect_test "perl" = 21 + test Re.Perl.re_result "(a|b|c)"; 22 + [%expect {| (Group (Set (Cast (Alternative (Cset 97) (Cset 98) (Cset 99))))) |}] 23 + ;; 24 + 25 + let%expect_test "posix" = 26 + test Re.Posix.re_result "(a|b|c)"; 27 + [%expect {| (Group (Set (Cast (Alternative (Cset 97) (Cset 98) (Cset 99))))) |}] 28 + ;;
+218
vendor/opam/re/lib_test/expect/test_automata.ml
··· 1 + open! Import 2 + module Cset = Re_private.Cset 3 + module Category = Re_private.Category 4 + module Automata = Re_private.Automata 5 + 6 + include struct 7 + open Automata 8 + module Ids = Ids 9 + module Working_area = Working_area 10 + module State = State 11 + 12 + let empty = empty 13 + let eps = eps 14 + let cst = cst 15 + let seq = seq 16 + let rep = rep 17 + end 18 + 19 + let pp_state state = print_dyn (State.to_dyn state) 20 + let pp_expr fmt expr = Automata.pp fmt expr 21 + let cat = Category.dummy 22 + 23 + let str ids sem str = 24 + let rec loop (s : Char.t Seq.t) = 25 + match (s () : _ Seq.node) with 26 + | Nil -> eps ids 27 + | Cons (c, rest) -> 28 + let c = cst ids (Cset.csingle c) in 29 + seq ids sem c (loop rest) 30 + in 31 + loop (String.to_seq str) 32 + ;; 33 + 34 + let loop ?(max = 100) wa d c = 35 + let cset = Cset.of_char c in 36 + let rec loop d n = 37 + if n > 0 38 + then ( 39 + print_dyn (State.to_dyn d); 40 + match State.status_no_mutex d with 41 + | Failed -> Format.printf "> failed@." 42 + | Match _ -> Format.printf "> matched@." 43 + | Running -> 44 + let d = Automata.delta wa cat cset d in 45 + loop d (n - 1)) 46 + in 47 + loop d max 48 + ;; 49 + 50 + let%expect_test "string" = 51 + let re = 52 + let n = 4 in 53 + let s = 54 + let c = 'a' in 55 + String.make n c 56 + in 57 + let ids = Ids.create () in 58 + str ids `First s 59 + in 60 + let wa = Working_area.create () in 61 + loop wa (State.create cat re) 'a'; 62 + [%expect 63 + {| 64 + ((TExp (first (Seq 97 97 97 97)))) 65 + ((TExp (first (Seq 97 97 97)))) 66 + ((TExp (first (Seq 97 97)))) 67 + ((TExp 97)) 68 + ((TExp Eps)) 69 + ((TMarks ())) 70 + > matched 71 + |}]; 72 + loop wa (State.create cat re) 'b'; 73 + [%expect {| 74 + ((TExp (first (Seq 97 97 97 97)))) 75 + () 76 + > failed 77 + |}] 78 + ;; 79 + 80 + let%expect_test "alternation" = 81 + let re = 82 + let ids = Ids.create () in 83 + let n = 4 in 84 + let s = 85 + let c = 'a' in 86 + String.make n c 87 + in 88 + List.init ~len:n ~f:(fun i -> 89 + let prefix = str ids `First s in 90 + let suffix = 91 + let c = Char.chr (Char.code 'b' + i) in 92 + cst ids (Cset.csingle c) 93 + in 94 + seq ids `First prefix suffix) 95 + |> Automata.alt ids 96 + in 97 + let wa = Working_area.create () in 98 + loop wa (State.create cat re) 'a'; 99 + [%expect 100 + {| 101 + ((TExp 102 + (Alt (first (Seq (Seq 97 97 97 97) 98)) (first (Seq (Seq 97 97 97 97) 99)) 103 + (first (Seq (Seq 97 97 97 97) 100)) (first (Seq (Seq 97 97 97 97) 101))))) 104 + ((first (TSeq ((TExp (Seq 97 97 97))) 98)) 105 + (first (TSeq ((TExp (Seq 97 97 97))) 99)) 106 + (first (TSeq ((TExp (Seq 97 97 97))) 100)) 107 + (first (TSeq ((TExp (Seq 97 97 97))) 101))) 108 + ((first (TSeq ((TExp (Seq 97 97))) 98)) 109 + (first (TSeq ((TExp (Seq 97 97))) 99)) 110 + (first (TSeq ((TExp (Seq 97 97))) 100)) 111 + (first (TSeq ((TExp (Seq 97 97))) 101))) 112 + ((first (TSeq ((TExp 97)) 98)) (first (TSeq ((TExp 97)) 99)) 113 + (first (TSeq ((TExp 97)) 100)) (first (TSeq ((TExp 97)) 101))) 114 + ((TExp 98) (TExp 99) (TExp 100) (TExp 101)) 115 + () 116 + > failed 117 + |}] 118 + ;; 119 + 120 + let%expect_test "alternation shared prefix" = 121 + let n = 4 in 122 + let re = 123 + let ids = Ids.create () in 124 + let prefix = 125 + let s = 126 + let c = 'a' in 127 + String.make n c 128 + in 129 + str ids `First s 130 + in 131 + let suffix = 132 + List.init ~len:n ~f:(fun i -> 133 + let c = Char.chr (Char.code 'b' + i) in 134 + cst ids (Cset.csingle c)) 135 + |> Automata.alt ids 136 + in 137 + seq ids `First prefix suffix 138 + in 139 + let wa = Working_area.create () in 140 + loop wa (State.create cat re) 'a'; 141 + [%expect 142 + {| 143 + ((TExp (first (Seq (Seq 97 97 97 97) (Alt 98 99 100 101))))) 144 + ((first (TSeq ((TExp (Seq 97 97 97))) (Alt 98 99 100 101)))) 145 + ((first (TSeq ((TExp (Seq 97 97))) (Alt 98 99 100 101)))) 146 + ((first (TSeq ((TExp 97)) (Alt 98 99 100 101)))) 147 + ((TExp (Alt 98 99 100 101))) 148 + () 149 + > failed 150 + |}] 151 + ;; 152 + 153 + let%expect_test "kleene star" = 154 + let re = 155 + let ids = Ids.create () in 156 + rep ids `Greedy `First (cst ids (Cset.csingle 'z')) 157 + in 158 + let wa = Working_area.create () in 159 + loop ~max:4 wa (State.create cat re) 'z'; 160 + [%expect 161 + {| 162 + ((TExp (first (Rep 122)))) 163 + ((TExp (first (Rep 122))) (TMarks ())) 164 + ((TExp (first (Rep 122))) (TMarks ())) 165 + ((TExp (first (Rep 122))) (TMarks ())) 166 + |}]; 167 + loop ~max:3 wa (State.create cat re) 'a'; 168 + [%expect {| 169 + ((TExp (first (Rep 122)))) 170 + ((TMarks ())) 171 + > matched 172 + |}] 173 + ;; 174 + 175 + let%expect_test "derivative recomputation" = 176 + let sem = `Longest in 177 + let re = 178 + let ids = Ids.create () in 179 + let lhs = rep ids `Non_greedy sem (cst ids Cset.cany) in 180 + let rhs = 181 + seq 182 + ids 183 + sem 184 + (Automata.mark ids Automata.Mark.start) 185 + (Automata.alt ids [ cst ids (Cset.csingle 'z'); cst ids (Cset.csingle 'b') ]) 186 + in 187 + seq ids sem lhs rhs 188 + in 189 + let wa = Working_area.create () in 190 + loop ~max:7 wa (State.create cat re) 'z'; 191 + [%expect 192 + {| 193 + ((TExp (long (Seq (Rep ((0 255))) (Seq (Mark 0) (Alt 122 98)))))) 194 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98)))) 195 + (TExp ((marks ((0 0)))) Eps)) 196 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98)))) 197 + (TExp ((marks ((0 1)))) Eps) (TMarks ((marks ((0 0)))))) 198 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98)))) 199 + (TExp ((marks ((0 0)))) Eps) (TMarks ((marks ((0 1)))))) 200 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98)))) 201 + (TExp ((marks ((0 1)))) Eps) (TMarks ((marks ((0 0)))))) 202 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98)))) 203 + (TExp ((marks ((0 0)))) Eps) (TMarks ((marks ((0 1)))))) 204 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98)))) 205 + (TExp ((marks ((0 1)))) Eps) (TMarks ((marks ((0 0)))))) 206 + |}]; 207 + loop ~max:7 wa (State.create cat re) 'a'; 208 + [%expect 209 + {| 210 + ((TExp (long (Seq (Rep ((0 255))) (Seq (Mark 0) (Alt 122 98)))))) 211 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98))))) 212 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98))))) 213 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98))))) 214 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98))))) 215 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98))))) 216 + ((long (TSeq ((TExp (Rep ((0 255))))) (Seq (Mark 0) (Alt 122 98))))) 217 + |}] 218 + ;;
+26
vendor/opam/re/lib_test/expect/test_bit_vector.ml
··· 1 + open! Import 2 + module Bit_vector = Re_private.Bit_vector 3 + 4 + let%expect_test "reset_zero" = 5 + let n = Bit_vector.create_zero 10 in 6 + let print () = Format.printf "%a@." Bit_vector.pp n in 7 + print (); 8 + [%expect {| 9 + (len 10) 10 + (bits "\000\000") |}]; 11 + Bit_vector.reset_zero n; 12 + print (); 13 + [%expect {| 14 + (len 10) 15 + (bits "\000\000") |}]; 16 + Bit_vector.set n 1 true; 17 + print (); 18 + [%expect {| 19 + (len 10) 20 + (bits "\002\000") |}]; 21 + Bit_vector.reset_zero n; 22 + print (); 23 + [%expect {| 24 + (len 10) 25 + (bits "\000\000") |}] 26 + ;;
+16
vendor/opam/re/lib_test/expect/test_category.ml
··· 1 + module Category = Re_private.Category 2 + module Cset = Re_private.Cset 3 + 4 + let%expect_test "Category.from_char" = 5 + for i = 0 to 255 do 6 + let char = Char.chr i in 7 + let cat = Category.from_char char in 8 + if Cset.(mem (of_char char) cword) then assert (Category.(intersect letter cat)) 9 + done 10 + ;; 11 + 12 + let%expect_test "newline" = 13 + let cat = Category.from_char '\n' in 14 + assert (Category.(intersect cat newline)); 15 + assert (Category.(intersect cat not_letter)) 16 + ;;
+13
vendor/opam/re/lib_test/expect/test_color.ml
··· 1 + open Import 2 + 3 + let all_chars = String.init 256 Char.chr 4 + 5 + let%expect_test "match an re that distinguishes every single char" = 6 + let re = 7 + let open Re in 8 + set all_chars |> whole_string |> compile 9 + in 10 + for i = 0 to String.length all_chars - 1 do 11 + assert (Re.execp re (String.make 1 all_chars.[i])) 12 + done 13 + ;;
+163
vendor/opam/re/lib_test/expect/test_csets.ml
··· 1 + open! Import 2 + module Fmt = Re_private.Fmt 3 + module Cset = Re_private.Cset 4 + 5 + let%expect_test "empty" = 6 + Format.printf "%a@." Cset.pp Cset.empty; 7 + [%expect {| |}] 8 + ;; 9 + 10 + let%expect_test "ascii" = 11 + Format.printf "%a@." Cset.pp Cset.ascii; 12 + [%expect {| 0-127 |}] 13 + ;; 14 + 15 + let%expect_test "cdigit" = 16 + Format.printf "%a@." Cset.pp Cset.cdigit; 17 + [%expect {| 48-57 |}] 18 + ;; 19 + 20 + let%expect_test "calpha" = 21 + Format.printf "%a@." Cset.pp Cset.calpha; 22 + [%expect {| 23 + 65-90, 97-122, 170, 181, 186, 192-214, 216-246, 248-255 |}] 24 + ;; 25 + 26 + let%expect_test "cword" = 27 + Format.printf "%a@." Cset.pp Cset.cword; 28 + [%expect {| 29 + 48-57, 65-90, 95, 97-122, 170, 181, 186, 192-214, 216-246, 248-255 |}] 30 + ;; 31 + 32 + let%expect_test "notnl" = 33 + Format.printf "%a@." Cset.pp Cset.notnl; 34 + [%expect {| 35 + 0-9, 11-255 |}] 36 + ;; 37 + 38 + let%expect_test "nl" = 39 + Format.printf "%a@." Cset.pp Cset.nl; 40 + [%expect {| 10 |}] 41 + ;; 42 + 43 + let%expect_test "blank" = 44 + Format.printf "%a@." Cset.pp Cset.nl; 45 + [%expect {| 10 |}] 46 + ;; 47 + 48 + let%expect_test "space" = 49 + Format.printf "%a@." Cset.pp Cset.space; 50 + [%expect {| 51 + 9-13, 32 |}] 52 + ;; 53 + 54 + let%expect_test "xdigit" = 55 + Format.printf "%a@." Cset.pp Cset.xdigit; 56 + [%expect {| 57 + 48-57, 65-70, 97-102 |}] 58 + ;; 59 + 60 + let%expect_test "lower" = 61 + Format.printf "%a@." Cset.pp Cset.lower; 62 + [%expect {| 63 + 97-122, 181, 223-246, 248-255 |}] 64 + ;; 65 + 66 + let%expect_test "upper" = 67 + Format.printf "%a@." Cset.pp Cset.upper; 68 + [%expect {| 69 + 65-90, 192-214, 216-222 |}] 70 + ;; 71 + 72 + let%expect_test "alpha" = 73 + Format.printf "%a@." Cset.pp Cset.alpha; 74 + [%expect {| 75 + 65-90, 97-122, 170, 181, 186, 192-214, 216-246, 248-255 |}] 76 + ;; 77 + 78 + let%expect_test "alnum" = 79 + Format.printf "%a@." Cset.pp Cset.alnum; 80 + [%expect {| 81 + 48-57, 65-90, 97-122, 170, 181, 186, 192-214, 216-246, 248-255 |}] 82 + ;; 83 + 84 + let%expect_test "wordc" = 85 + Format.printf "%a@." Cset.pp Cset.wordc; 86 + [%expect {| 87 + 48-57, 65-90, 95, 97-122, 170, 181, 186, 192-214, 216-246, 248-255 |}] 88 + ;; 89 + 90 + let%expect_test "cntrl" = 91 + Format.printf "%a@." Cset.pp Cset.cntrl; 92 + [%expect {| 93 + 0-31, 127-159 |}] 94 + ;; 95 + 96 + let%expect_test "graph" = 97 + Format.printf "%a@." Cset.pp Cset.graph; 98 + [%expect {| 99 + 33-126, 160-255 |}] 100 + ;; 101 + 102 + let%expect_test "print" = 103 + Format.printf "%a@." Cset.pp Cset.print; 104 + [%expect {| 105 + 32-126, 160-255 |}] 106 + ;; 107 + 108 + let%expect_test "punct" = 109 + Format.printf "%a@." Cset.pp Cset.punct; 110 + [%expect 111 + {| 112 + 33-47, 58-64, 91-96, 123-126, 160-169, 171-180, 182-185, 187-191, 215, 247 |}] 113 + ;; 114 + 115 + let%expect_test "cany" = 116 + Format.printf "%a@." Cset.pp Cset.cany; 117 + [%expect {| 0-255 |}] 118 + ;; 119 + 120 + let%expect_test "case_insens" = 121 + let cset = Cset.diff (Cset.case_insens Cset.lower) (Cset.case_insens Cset.upper) in 122 + Format.printf "%a@." Cset.pp cset; 123 + [%expect {| 181, 223, 255 |}] 124 + ;; 125 + 126 + let%expect_test "one_char" = 127 + let test set = 128 + let pp fmt c = 129 + let c = Option.map Cset.to_char c in 130 + Fmt.(opt char) fmt c 131 + in 132 + Format.printf "%a@." pp (Cset.one_char set) 133 + in 134 + test Cset.empty; 135 + [%expect {| <None> |}]; 136 + test (Cset.csingle 'c'); 137 + [%expect {| c |}]; 138 + test Cset.cany; 139 + [%expect {| <None> |}] 140 + ;; 141 + 142 + let%expect_test "is_empty" = 143 + let test set = Format.printf "%a@." Fmt.bool (Cset.is_empty set) in 144 + test Cset.empty; 145 + [%expect {| true |}]; 146 + test (Cset.csingle 'c'); 147 + [%expect {| false |}]; 148 + test Cset.cany; 149 + [%expect {| false |}] 150 + ;; 151 + 152 + let%expect_test "Cset mem" = 153 + let test set c = Format.printf "%a@." Fmt.bool (Cset.mem c set) in 154 + test Cset.cany Cset.null_char; 155 + [%expect {| false |}]; 156 + test Cset.cany (Cset.of_char 'a'); 157 + [%expect {| true |}]; 158 + let c = Cset.csingle 'c' in 159 + test c (Cset.of_char 'c'); 160 + [%expect {| true |}]; 161 + test c (Cset.of_char '.'); 162 + [%expect {| false |}] 163 + ;;
+132
vendor/opam/re/lib_test/expect/test_emacs.ml
··· 1 + open Import 2 + 3 + (* 4 + * Tests based on description of emacs regular expressions given at 5 + * http://www.gnu.org/manual/elisp-manual-20-2.5/html_chapter/elisp_34.html 6 + *) 7 + 8 + let re re = Format.printf "%a@." Re.pp (Re.Emacs.re re) 9 + 10 + let%expect_test "not supported" = 11 + let re s = 12 + try ignore (Re.Emacs.re s) with 13 + | Re.Emacs.Parse_error -> print_endline "Parse error" 14 + | Re.Emacs.Not_supported -> print_endline "Not supported" 15 + in 16 + re "*ab"; 17 + [%expect {| Parse error |}]; 18 + re "+ab"; 19 + [%expect {| Parse error |}]; 20 + re "?ab"; 21 + [%expect {| Parse error |}]; 22 + re "\\0"; 23 + [%expect {| Not supported |}] 24 + ;; 25 + 26 + let%expect_test "escaping special characters" = 27 + re "\\."; 28 + [%expect {| (Set 46) |}]; 29 + re "\\*"; 30 + [%expect {| (Set 42) |}]; 31 + re "\\+"; 32 + [%expect {| (Set 43) |}]; 33 + re "\\?"; 34 + [%expect {| (Set 63) |}]; 35 + re "\\["; 36 + [%expect {| (Set 91) |}]; 37 + re "\\]"; 38 + [%expect {| (Set 93) |}]; 39 + re "\\^"; 40 + [%expect {| (Set 94) |}]; 41 + re "\\$"; 42 + [%expect {| (Set 36) |}]; 43 + re "\\\\"; 44 + [%expect {| (Set 92) |}] 45 + ;; 46 + 47 + let%expect_test "special characeters" = 48 + re "."; 49 + [%expect {| (Set 0-9, 11-255) |}]; 50 + re "a*"; 51 + [%expect {| (Repeat (Set 97) 0) |}]; 52 + re "a+"; 53 + [%expect {| (Repeat (Set 97) 1) |}]; 54 + re "a?"; 55 + [%expect {| (Repeat (Set 97) 0 1) |}]; 56 + re "[ab]"; 57 + [%expect {| (Alternative (Set 98)(Set 97)) |}]; 58 + re "[a-z]"; 59 + [%expect {| (Set 97-122) |}]; 60 + re "[a-z$%.]"; 61 + [%expect {| (Alternative (Set 46)(Set 37)(Set 36)(Set 97-122)) |}]; 62 + re "[]a]"; 63 + [%expect {| (Alternative (Set 97)(Set 93)) |}]; 64 + re "[]-]"; 65 + [%expect {| (Alternative (Set 93)(Set 45)) |}]; 66 + re "[a^]"; 67 + [%expect {| (Alternative (Set 94)(Set 97)) |}]; 68 + re "[^a-z]"; 69 + [%expect {| (Complement (Set 97-122)) |}]; 70 + re "[^a-z$]"; 71 + [%expect {| (Complement (Set 36)(Set 97-122)) |}]; 72 + re "^"; 73 + [%expect {| Beg_of_line |}]; 74 + re "$"; 75 + [%expect {| End_of_line |}] 76 + ;; 77 + 78 + let%expect_test "alternatives" = 79 + re "a\\|b"; 80 + [%expect {| (Alternative (Set 97)(Set 98)) |}]; 81 + re "aa\\|bb"; 82 + [%expect {| (Alternative (Sequence (Set 97)(Set 97))(Sequence (Set 98)(Set 98))) |}] 83 + ;; 84 + 85 + let%expect_test "contexts" = 86 + re "\\`"; 87 + [%expect {| Beg_of_str |}]; 88 + re "\\'"; 89 + [%expect {| End_of_str |}]; 90 + re "\\="; 91 + [%expect {| Start |}]; 92 + re "\\b"; 93 + [%expect {| (Alternative Beg_of_wordEnd_of_word) |}]; 94 + re "\\B"; 95 + [%expect {| Not_bound |}]; 96 + re "\\<"; 97 + [%expect {| Beg_of_word |}]; 98 + re "\\>"; 99 + [%expect {| End_of_word |}] 100 + ;; 101 + 102 + let%expect_test "word-constituent" = 103 + re "\\w"; 104 + [%expect 105 + {| 106 + (Alternative 107 + (Set 48-57, 65-90, 97-122, 170, 181, 186, 192-214, 216-246, 248-255) 108 + (Set 95)) |}]; 109 + re "\\W"; 110 + [%expect 111 + {| 112 + (Complement 113 + (Set 48-57, 65-90, 97-122, 170, 181, 186, 192-214, 216-246, 248-255) 114 + (Set 95)) |}] 115 + ;; 116 + 117 + let%expect_test "grouping" = 118 + re "\\(a\\)"; 119 + [%expect {| (Group (Set 97)) |}]; 120 + re "\\(a\\|b\\)c"; 121 + [%expect {| (Sequence (Group (Alternative (Set 97)(Set 98)))(Set 99)) |}] 122 + ;; 123 + 124 + let%expect_test "concatenation" = 125 + re "ab"; 126 + [%expect {| (Sequence (Set 97)(Set 98)) |}] 127 + ;; 128 + 129 + let%expect_test "ordinary characters" = 130 + re "a"; 131 + [%expect {| (Set 97) |}] 132 + ;;
+258
vendor/opam/re/lib_test/expect/test_glob.ml
··· 1 + open Import 2 + 3 + let glob ?match_backslashes ?expand_braces ?anchored ?pathname ?period re s = 4 + let re = 5 + Re.Glob.glob ?match_backslashes ?expand_braces ?anchored ?pathname ?period re 6 + |> Re.compile 7 + in 8 + Format.printf "%b@." (Re.execp re s) 9 + ;; 10 + 11 + let%expect_test "glob" = 12 + glob "foo*" "foobar"; 13 + [%expect {| true |}]; 14 + glob "fo?bar" "fobar"; 15 + [%expect {| false |}]; 16 + glob "fo?bar" "foobar"; 17 + [%expect {| true |}]; 18 + glob "fo?bar" "foo0bar"; 19 + [%expect {| false |}]; 20 + glob "?oobar" "foobar"; 21 + [%expect {| true |}]; 22 + glob "*bar" "foobar"; 23 + [%expect {| true |}]; 24 + glob "\\*bar" "foobar"; 25 + [%expect {| false |}]; 26 + glob "\\*bar" "*bar"; 27 + [%expect {| true |}]; 28 + glob "[ab]foo" "afoo"; 29 + [%expect {| true |}]; 30 + glob "[ab]foo" "bfoo"; 31 + [%expect {| true |}]; 32 + glob "[ab]foo" "cfoo"; 33 + [%expect {| false |}]; 34 + glob "c[ab]foo" "cabfoo"; 35 + [%expect {| false |}]; 36 + glob ".foo" ".foo"; 37 + [%expect {| true |}]; 38 + glob ".foo" "afoo"; 39 + [%expect {| false |}]; 40 + glob "*[.]foo" "a.foo"; 41 + [%expect {| true |}]; 42 + glob "*[.]foo" "ba.foo"; 43 + [%expect {| true |}]; 44 + glob "*.foo" ".foo"; 45 + [%expect {| false |}]; 46 + glob "*[.]foo" ".foo"; 47 + [%expect {| false |}]; 48 + glob ~anchored:true "*/foo" "/foo"; 49 + [%expect {| true |}]; 50 + glob ~anchored:true "foo/*" "foo/"; 51 + [%expect {| true |}]; 52 + glob "/[^f]" "/foo"; 53 + [%expect {| false |}]; 54 + glob "/[^f]" "/bar"; 55 + [%expect {| true |}]; 56 + glob ~anchored:true "/[^f]" "/bar"; 57 + [%expect {| false |}]; 58 + glob ~anchored:true "*" ".bar"; 59 + [%expect {| false |}]; 60 + glob "foo[.]bar" "foo.bar"; 61 + [%expect {| true |}]; 62 + glob "[.]foo" ".foo"; 63 + [%expect {| false |}]; 64 + glob "foo[/]bar" "foo/bar"; 65 + [%expect {| false |}]; 66 + glob ~anchored:true "*bar" "foobar"; 67 + [%expect {| true |}]; 68 + glob "foo" "foobar"; 69 + [%expect {| true |}]; 70 + glob "bar" "foobar"; 71 + [%expect {| true |}]; 72 + glob ~anchored:true "foo" "foobar"; 73 + [%expect {| false |}]; 74 + glob ~anchored:true "bar" "foobar"; 75 + [%expect {| false |}]; 76 + glob "{foo,bar}bar" "foobar"; 77 + [%expect {| false |}]; 78 + glob "{foo,bar}bar" "{foo,bar}bar"; 79 + [%expect {| true |}]; 80 + glob "foo?bar" "foo/bar"; 81 + [%expect {| false |}]; 82 + let pathname = true in 83 + let period = true in 84 + glob ~pathname ~period "?oobar" ".oobar"; 85 + [%expect {| false |}]; 86 + glob ~pathname ~period "?oobar" "/oobar"; 87 + [%expect {| false |}]; 88 + glob ~pathname ~period "f?obar" "f/obar"; 89 + [%expect {| false |}]; 90 + glob ~pathname ~period "f?obar" "f.obar"; 91 + [%expect {| true |}]; 92 + glob ~pathname ~period "f*.bar" "f.bar"; 93 + [%expect {| true |}]; 94 + glob ~pathname ~period "f?.bar" "fo.bar"; 95 + [%expect {| true |}]; 96 + glob ~pathname ~period "/.bar" "/.bar"; 97 + [%expect {| true |}]; 98 + glob ~pathname ~period "*.bar" ".bar"; 99 + [%expect {| false |}]; 100 + glob ~pathname ~period "?" "."; 101 + [%expect {| false |}]; 102 + glob ~pathname ~period "/*bar" "/.bar"; 103 + [%expect {| false |}]; 104 + glob "?oobar" ".oobar"; 105 + [%expect {| false |}]; 106 + glob "?oobar" "/oobar"; 107 + [%expect {| false |}]; 108 + let pathname = true in 109 + let period = false in 110 + glob ~pathname ~period "?oobar" "/oobar"; 111 + [%expect {| false |}]; 112 + glob ~pathname ~period "?oobar" ".oobar"; 113 + [%expect {| true |}]; 114 + glob ~pathname ~period "f?obar" "f/obar"; 115 + [%expect {| false |}]; 116 + glob ~pathname ~period "f?obar" "f.obar"; 117 + [%expect {| true |}]; 118 + let pathname = false in 119 + let period = false in 120 + glob ~pathname ~period "?oobar" ".oobar"; 121 + [%expect {| true |}]; 122 + glob ~pathname ~period "?oobar" "/oobar"; 123 + [%expect {| true |}]; 124 + glob ~expand_braces:true "{foo,far}bar" "foobar"; 125 + [%expect {| true |}]; 126 + glob ~expand_braces:true "{foo,far}bar" "farbar"; 127 + [%expect {| true |}]; 128 + glob ~expand_braces:true "{foo,far}bar" "{foo,far}bar"; 129 + [%expect {| false |}] 130 + ;; 131 + 132 + let%expect_test "double asterisk" = 133 + let glob = glob ~anchored:true in 134 + glob "**" "foobar"; 135 + [%expect {| true |}]; 136 + glob "**" "foo/bar"; 137 + [%expect {| true |}]; 138 + glob "**/bar" "foo/bar"; 139 + [%expect {| true |}]; 140 + glob "**/bar" "foo/far/bar"; 141 + [%expect {| true |}]; 142 + glob "foo/**" "foo"; 143 + [%expect {| false |}]; 144 + glob "foo/**" "foo/bar"; 145 + [%expect {| true |}]; 146 + glob "foo/**" "foo/far/bar"; 147 + [%expect {| true |}]; 148 + glob "foo/**/bar" "foo/far/bar"; 149 + [%expect {| true |}]; 150 + glob "foo/**/bar" "foo/far/oof/bar"; 151 + [%expect {| true |}]; 152 + glob "foo/**bar" "foo/far/oofbar"; 153 + [%expect {| true |}]; 154 + glob "foo/**bar" "foo/bar"; 155 + [%expect {| true |}]; 156 + glob "foo/**bar" "foo/foobar"; 157 + [%expect {| true |}]; 158 + glob "/**" "//foo"; 159 + [%expect {| true |}]; 160 + glob "/**" "/"; 161 + [%expect {| true |}]; 162 + glob "/**" "/x"; 163 + [%expect {| true |}]; 164 + glob "**" "foo//bar"; 165 + [%expect {| true |}]; 166 + glob "foo/bar/**/*.ml" "foo/bar/baz/foobar.ml"; 167 + [%expect {| true |}]; 168 + glob "foo/bar/**/*.ml" "foo/bar/foobar.ml"; 169 + [%expect {| true |}]; 170 + glob "foo/**/bar/**/baz" "foo/bar/baz"; 171 + [%expect {| true |}]; 172 + glob "foo/**/bar/**/baz" "foo/bar/x/y/z/baz"; 173 + [%expect {| true |}]; 174 + glob "foo/**/bar/**/baz" "foo/x/y/z/bar/baz"; 175 + [%expect {| true |}]; 176 + glob "foo/**/bar/**/baz" "foo/bar/x/bar/x/baz"; 177 + [%expect {| true |}]; 178 + glob "foo/**/bar/**/baz" "foo/bar/../x/baz"; 179 + [%expect {| false |}]; 180 + glob "foo/**/bar/**/baz" "foo/bar/./x/baz"; 181 + [%expect {| false |}]; 182 + ((* Interaction with [~period] *) 183 + let glob = glob ~period:true in 184 + glob "**" ".foobar"; 185 + [%expect {| false |}]; 186 + glob "**" ".foo/bar"; 187 + [%expect {| false |}]; 188 + glob "foo/**" "foo/.bar"; 189 + [%expect {| false |}]; 190 + glob "**" "foo/.bar/bat"; 191 + [%expect {| false |}]; 192 + glob "foo/**/bat" "foo/.bar/bat"; 193 + [%expect {| false |}]; 194 + glob "/**/bat" "/foo/.bar/bat"; 195 + [%expect {| false |}]; 196 + glob "/**/bat" "/.bar/bat"; 197 + [%expect {| false |}]; 198 + glob "/**bat" "/bar/.bat"; 199 + [%expect {| false |}]; 200 + glob ".**" ".foobar"; 201 + [%expect {| true |}]; 202 + glob ".**" ".foo/bar"; 203 + [%expect {| true |}]; 204 + glob "foo/.**" "foo/.bar"; 205 + [%expect {| true |}]); 206 + let glob = glob ~period:false in 207 + glob "**" ".foobar"; 208 + [%expect {| true |}]; 209 + glob "**" ".foo/bar"; 210 + [%expect {| true |}]; 211 + glob "foo/**" "foo/.bar"; 212 + [%expect {| true |}]; 213 + glob "**" "foo/.bar/bat"; 214 + [%expect {| true |}]; 215 + glob "foo/**/bat" "foo/.bar/bat"; 216 + [%expect {| true |}]; 217 + glob "/**/bat" "/foo/.bar/bat"; 218 + [%expect {| true |}]; 219 + glob "/**/bat" "/.bar/bat"; 220 + [%expect {| true |}]; 221 + glob "/**bat" "/bar/.bat"; 222 + [%expect {| true |}] 223 + ;; 224 + 225 + let%expect_test "backslash handling" = 226 + let anchored = true in 227 + let glob = glob ~anchored in 228 + (let glob = glob ~match_backslashes:false in 229 + glob "a/b/c" "a\\b/c"; 230 + [%expect {| false |}]; 231 + glob "a\\b" "ab"; 232 + [%expect {| true |}]; 233 + glob "a/*.ml" "a/b\\c.ml"; 234 + [%expect {| true |}]; 235 + glob "a/b/*.ml" "a\\b\\c.ml"; 236 + [%expect {| false |}]; 237 + glob "/" "\\"; 238 + [%expect {| false |}]; 239 + glob "/?" "\\a"; 240 + [%expect {| false |}]; 241 + glob "a/**.ml" "a\\c\\.b.ml"; 242 + [%expect {| true |}]); 243 + let glob = glob ~match_backslashes:true in 244 + glob "a/b/c" "a\\b/c"; 245 + [%expect {| true |}]; 246 + glob "a\\b" "ab"; 247 + [%expect {| true |}]; 248 + glob "a/*.ml" "a/b\\c.ml"; 249 + [%expect {| false |}]; 250 + glob "a/b/*.ml" "a\\b\\c.ml"; 251 + [%expect {| true |}]; 252 + glob "/" "\\"; 253 + [%expect {| true |}]; 254 + glob "/?" "\\a"; 255 + [%expect {| true |}]; 256 + glob "a/**.ml" "a\\c\\.b.ml"; 257 + [%expect {| false |}] 258 + ;;
+143
vendor/opam/re/lib_test/expect/test_group.ml
··· 1 + open Import 2 + open Re 3 + 4 + let%expect_test "empty group" = 5 + let empty = group empty in 6 + t empty ""; 7 + [%expect {| <None> |}]; 8 + t empty "x"; 9 + [%expect {| <None> |}] 10 + ;; 11 + 12 + let%expect_test "zero length group" = 13 + let empty = group bos in 14 + t empty ""; 15 + [%expect {| (Group ( (0 0))( (0 0))) |}]; 16 + t empty "x"; 17 + [%expect {| (Group ( (0 0))( (0 0))) |}] 18 + ;; 19 + 20 + let%expect_test "no group" = 21 + let re = any in 22 + t re ""; 23 + [%expect {| <None> |}]; 24 + t re "."; 25 + [%expect {| (Group (. (0 1))) |}] 26 + ;; 27 + 28 + let%expect_test "two groups" = 29 + let re = seq [ group any; group any ] in 30 + t re "a"; 31 + [%expect {| <None> |}]; 32 + t re "ab"; 33 + [%expect {| (Group (ab (0 2))(a (0 1))(b (1 2))) |}]; 34 + t re "abc"; 35 + [%expect {| (Group (ab (0 2))(a (0 1))(b (1 2))) |}] 36 + ;; 37 + 38 + let%expect_test "maybe group" = 39 + let twoany = seq [ any; any ] in 40 + let re = alt [ twoany; group twoany ] in 41 + t re "aa"; 42 + [%expect {| (Group (aa (0 2))( (-1 -1))) |}]; 43 + t re "a"; 44 + [%expect {| <None> |}] 45 + ;; 46 + 47 + let%expect_test "nesting of groups" = 48 + let re = group (seq [ group (char 'a'); char 'b' ]) in 49 + t re "ab"; 50 + [%expect {| (Group (ab (0 2))(ab (0 2))(a (0 1))) |}] 51 + ;; 52 + 53 + let%expect_test "group choice" = 54 + let t = Import.exec_partial_detailed in 55 + (* Alternation of character sets isn't flattened *) 56 + let lhs_group = 57 + let open Re in 58 + alt [ group (char 'a'); char 'b' ] 59 + in 60 + t lhs_group "a"; 61 + [%expect {| `Full [|0,1,"a";0,1,"a"|] |}]; 62 + t lhs_group "b"; 63 + [%expect {| `Full [|0,1,"b";-1,-1,<No match>|] |}]; 64 + t 65 + (let open Re in 66 + alt [ group (char 'a'); group (char 'b') ]) 67 + "b"; 68 + [%expect {| `Full [|0,1,"b";-1,-1,<No match>;0,1,"b"|] |}]; 69 + (* No_group inside char set: *) 70 + let no_group_charset = 71 + let a = Re.group (Re.char 'a') in 72 + let b = Re.char 'b' in 73 + Re.no_group (Re.alt [ a; b ]) 74 + in 75 + t no_group_charset "a"; 76 + [%expect {| `Full [|0,1,"a"|] |}]; 77 + t no_group_charset "b"; 78 + [%expect {| `Full [|0,1,"b"|] |}]; 79 + (* No_group outside char set *) 80 + let no_group_string = 81 + let aa = Re.group (Re.str "aa") in 82 + let bb = Re.str "bb" in 83 + Re.no_group (Re.alt [ aa; bb ]) 84 + in 85 + t no_group_string "aa"; 86 + [%expect {| `Full [|0,2,"aa"|] |}]; 87 + t no_group_string "bb"; 88 + [%expect {| `Full [|0,2,"bb"|] |}] 89 + ;; 90 + 91 + let%expect_test "Group.{get,get_opt,offset,test}" = 92 + let r = seq [ group (char 'a'); opt (group (char 'a')); group (char 'b') ] in 93 + let m = exec (compile r) "ab" in 94 + let test idx = 95 + Format.printf "get_opt = %a@." (Fmt.opt Fmt.str) (Group.get_opt m idx); 96 + Format.printf "get = %a@." (or_not_found Fmt.str) (fun () -> Group.get m idx); 97 + Format.printf "test = %b@." (Group.test m idx); 98 + Format.printf "offset = %a@." (or_not_found offset) (fun () -> Group.offset m idx) 99 + in 100 + test 0; 101 + [%expect {| 102 + get_opt = ab 103 + get = ab 104 + test = true 105 + offset = (0, 2) |}]; 106 + test 1; 107 + [%expect {| 108 + get_opt = a 109 + get = a 110 + test = true 111 + offset = (0, 1) |}]; 112 + test 2; 113 + [%expect 114 + {| 115 + get_opt = <None> 116 + get = Not_found 117 + test = false 118 + offset = Not_found |}]; 119 + test 3; 120 + [%expect {| 121 + get_opt = b 122 + get = b 123 + test = true 124 + offset = (1, 2) |}]; 125 + Format.printf "%a@." (array offset) (Group.all_offset m); 126 + [%expect {| [| (0, 2); (0, 1); (-1, -1); (1, 2) |] |}] 127 + ;; 128 + 129 + let%expect_test "nest" = 130 + let r = rep (nest (alt [ group (char 'a'); char 'b' ])) in 131 + test_re r "ab"; 132 + [%expect {| [| (0, 2); (-1, -1) |] |}]; 133 + test_re r "ba"; 134 + [%expect {| [| (0, 2); (1, 2) |] |}] 135 + ;; 136 + 137 + let%expect_test "group/no_group" = 138 + let r = seq [ group (char 'a'); opt (group (char 'a')); group (char 'b') ] in 139 + test_re r "ab"; 140 + [%expect {| [| (0, 2); (0, 1); (-1, -1); (1, 2) |] |}]; 141 + test_re (no_group r) "ab"; 142 + [%expect {| [| (0, 2) |] |}] 143 + ;;
+49
vendor/opam/re/lib_test/expect/test_hashset.ml
··· 1 + open Import 2 + 3 + let () = Printexc.record_backtrace true 4 + 5 + module Hash_set = Re_private.Hash_set 6 + 7 + let id1 = 1 8 + let id2 = 2 9 + let id3 = 3 10 + 11 + let test table f = 12 + if f table 13 + then print_endline "[PASS]" 14 + else ( 15 + print_endline "[FAIL]"; 16 + Format.printf "%a@." Hash_set.pp table) 17 + ;; 18 + 19 + let%expect_test "basic set" = 20 + let set = Hash_set.create () in 21 + test set Hash_set.is_empty; 22 + [%expect {| [PASS] |}]; 23 + test set (fun set -> not (Hash_set.mem set id1)); 24 + [%expect {| 25 + [PASS] |}] 26 + ;; 27 + 28 + let%expect_test "add 1 element" = 29 + let set = Hash_set.create () in 30 + Hash_set.add set id1; 31 + test set (fun set -> not (Hash_set.is_empty set)); 32 + [%expect {| 33 + [PASS] |}]; 34 + test set (fun set -> Hash_set.mem set id1); 35 + [%expect {| 36 + [PASS] |}]; 37 + Hash_set.add set id1; 38 + test set (fun set -> Hash_set.mem set id1); 39 + [%expect {| [PASS] |}]; 40 + Hash_set.add set id2; 41 + test set (fun set -> Hash_set.mem set id2); 42 + [%expect {| [PASS] |}]; 43 + Hash_set.add set id3; 44 + test set (fun set -> Hash_set.mem set id3); 45 + [%expect {| 46 + [PASS] |}]; 47 + test set (fun set -> List.for_all [ id1; id2; id3 ] ~f:(fun id -> Hash_set.mem set id)); 48 + [%expect {| [PASS] |}] 49 + ;;
+13
vendor/opam/re/lib_test/expect/test_iter.ml
··· 1 + open Import 2 + 3 + let%expect_test "iter" = 4 + let re = Re.Posix.compile_pat "(ab)+" in 5 + strings (Re.matches re "aabab aaabba dab "); 6 + [%expect {| ["abab"; "ab"; "ab"] |}]; 7 + strings (Re.matches ~pos:2 ~len:7 re "abab ababab"); 8 + [%expect {| ["ab"; "abab"] |}]; 9 + strings (Re.matches re_empty "ab"); 10 + [%expect {| [""; ""; ""] |}]; 11 + strings (Re.matches (Re.compile (Re.rep (Re.char 'a'))) "cat"); 12 + [%expect {| [""; "a"; ""] |}] 13 + ;;
+53
vendor/opam/re/lib_test/expect/test_mark.ml
··· 1 + open Import 2 + open Re 3 + 4 + let test_mark ?pos ?len r s il1 il2 = 5 + let subs = exec ?pos ?len (compile r) s in 6 + Format.printf 7 + "%b@." 8 + (List.for_all ~f:(Mark.test subs) il1 9 + && List.for_all ~f:(fun x -> not (Mark.test subs x)) il2) 10 + ;; 11 + 12 + let%expect_test "mark" = 13 + let i, r = mark digit in 14 + test_mark r "0" [ i ] []; 15 + [%expect {| true |}] 16 + ;; 17 + 18 + let%expect_test "mark seq" = 19 + let i, r = mark digit in 20 + let r = seq [ r; r ] in 21 + test_mark r "02" [ i ] []; 22 + [%expect {| true |}] 23 + ;; 24 + 25 + let%expect_test "mark rep" = 26 + let i, r = mark digit in 27 + let r = rep r in 28 + test_mark r "02" [ i ] []; 29 + [%expect {| true |}] 30 + ;; 31 + 32 + let%expect_test "mark alt" = 33 + let ia, ra = mark (char 'a') in 34 + let ib, rb = mark (char 'b') in 35 + let r = alt [ ra; rb ] in 36 + test_mark r "a" [ ia ] [ ib ]; 37 + test_mark r "b" [ ib ] [ ia ]; 38 + [%expect {| 39 + true 40 + true |}]; 41 + let r = rep r in 42 + test_mark r "ab" [ ia; ib ] []; 43 + [%expect {| true |}] 44 + ;; 45 + 46 + let%expect_test "mark prefers lhs" = 47 + let two_chars = seq [ any; any ] in 48 + let lhs, x = mark two_chars in 49 + let rhs, x' = mark two_chars in 50 + let r = alt [ x; x' ] in 51 + test_mark r "aa" [ lhs ] [ rhs ]; 52 + [%expect {| true |}] 53 + ;;
+69
vendor/opam/re/lib_test/expect/test_partial.ml
··· 1 + open Import 2 + 3 + let t re s = 4 + let re = Re.compile re in 5 + let res = Re.exec_partial re s in 6 + Format.printf 7 + "`%s@." 8 + (match res with 9 + | `Partial -> "Partial" 10 + | `Full -> "Full" 11 + | `Mismatch -> "Mismatch") 12 + ;; 13 + 14 + let%expect_test "partial matches" = 15 + let open Re in 16 + t (str "hello") "he"; 17 + [%expect {| `Partial |}]; 18 + t (str "hello") "goodbye"; 19 + [%expect {| `Partial |}]; 20 + (* exec_partial 3 should be `Full *) 21 + t (str "hello") "hello"; 22 + [%expect {| `Partial |}]; 23 + t (whole_string (str "hello")) "hello"; 24 + [%expect {| `Partial |}]; 25 + t (whole_string (str "hello")) "goodbye"; 26 + [%expect {| `Mismatch |}]; 27 + t (str "hello") ""; 28 + [%expect {| `Partial |}]; 29 + t (str "") "hello"; 30 + [%expect {| `Full |}]; 31 + t (whole_string (str "hello")) ""; 32 + [%expect {| `Partial |}] 33 + ;; 34 + 35 + let t = exec_partial_detailed 36 + 37 + let%expect_test "partial detailed" = 38 + let open Re in 39 + t (str "hello") "he"; 40 + [%expect {| `Partial 0 |}]; 41 + (* Because of how the matching engine currently works, situations where 42 + the entirety of the input string cannot be a match like the test below 43 + actually return the last character as a potential start instead of just 44 + return `Partial (String.length input). This is still fine however as 45 + it still respects the mli contract, as no match could start before 46 + the given position, and is fine in practice as testing an extra 47 + character on extra input doesn't add much more in terms of workload. 48 + *) 49 + t (str "hello") "goodbye"; 50 + [%expect {| `Partial 6 |}]; 51 + t (str "hello") "hello"; 52 + [%expect {| `Full [|0,5,"hello"|] |}]; 53 + t (whole_string (str "hello")) "hello"; 54 + [%expect {| `Full [|0,5,"hello"|] |}]; 55 + t (whole_string (str "hello")) "goodbye"; 56 + [%expect {| `Mismatch |}]; 57 + t (str "hello") ""; 58 + [%expect {| `Partial 0 |}]; 59 + t (str "") "hello"; 60 + [%expect {| `Full [|0,0,""|] |}]; 61 + t (whole_string (str "hello")) ""; 62 + [%expect {| `Partial 0 |}]; 63 + t (str "abc") ".ab.ab"; 64 + [%expect {| `Partial 4 |}]; 65 + t ~pos:1 (seq [ not_boundary; str "b" ]) "ab"; 66 + [%expect {| `Full [|1,2,"b"|] |}]; 67 + t (seq [ group (str "a"); rep any; group (str "b") ]) ".acb."; 68 + [%expect {| `Full [|1,4,"acb";1,2,"a";3,4,"b"|] |}] 69 + ;;
+105
vendor/opam/re/lib_test/expect/test_pcre.ml
··· 1 + open Import 2 + module Pcre = Re_private.Pcre 3 + 4 + let test re s = 5 + match Pcre.re re with 6 + | exception _ -> Format.printf "failed to parse@." 7 + | re -> t re s 8 + ;; 9 + 10 + let%expect_test "quoted strings" = 11 + test {|\Qfoo\E|} "foo"; 12 + [%expect {| (Group (foo (0 3))) |}]; 13 + test {|\Qbar|} ""; 14 + [%expect {| failed to parse |}]; 15 + test {|\Qbaz\|} ""; 16 + [%expect {| failed to parse |}]; 17 + test {|\Qba\Xz\E|} {|ba\Xz|}; 18 + [%expect {| (Group (ba\Xz (0 5))) |}] 19 + ;; 20 + 21 + let%expect_test "octal" = 22 + test {|\025|} (String.make 1 '\o025'); 23 + [%expect {| (Group ( (0 1))) |}]; 24 + test {|\999|} ""; 25 + [%expect {| failed to parse |}]; 26 + test {|\111|} (String.make 1 '\o111'); 27 + [%expect {| (Group (I (0 1))) |}] 28 + ;; 29 + 30 + let%expect_test "\\x and \\o form" = 31 + test {|\o{111}|} (String.make 1 '\o111'); 32 + [%expect {| <None> |}]; 33 + test {|\o{111|} ""; 34 + [%expect {| failed to parse |}]; 35 + test {|\x{ff}|} (String.make 1 '\xff'); 36 + [%expect {| (Group (� (0 1))) |}]; 37 + test {|\x{ff|} ""; 38 + [%expect {| failed to parse |}] 39 + ;; 40 + 41 + let%expect_test "substitute" = 42 + let open Pcre in 43 + let substitute ~rex ~subst s = substitute ~rex ~subst s |> print_endline in 44 + let rex = regexp "[a-zA-Z]+" in 45 + let subst = String.capitalize_ascii in 46 + substitute ~rex ~subst " hello world; I love chips!"; 47 + [%expect {| Hello World; I Love Chips! |}]; 48 + substitute ~rex:re_empty ~subst:(fun _ -> "a") ""; 49 + [%expect {| a |}]; 50 + substitute ~rex:(regexp "a*") ~subst:(fun _ -> "*") "cat"; 51 + [%expect {| *c*t* |}]; 52 + let rex = regexp "^ *" in 53 + substitute ~rex ~subst:(fun _ -> "A ") "test"; 54 + [%expect {| A test |}] 55 + ;; 56 + 57 + let%expect_test "test_blank_class" = 58 + let re = Re.Perl.compile_pat "\\d[[:blank:]]\\d[[:blank:]]+[a-z]" in 59 + let successes = [ "1 2 a"; "2\t3 z"; "9\t0 \t a" ] in 60 + let failures = [ ""; "123"; " "; "1 3z" ] in 61 + List.iter successes ~f:(fun s -> printf "String %S should match %b\n" s (Re.execp re s)); 62 + [%expect 63 + {| 64 + String "1 2 a" should match true 65 + String "2\t3 z" should match true 66 + String "9\t0 \t a" should match true |}]; 67 + List.iter failures ~f:(fun s -> 68 + printf "String %S should not match %b\n" s (Re.execp re s)); 69 + [%expect 70 + {| 71 + String "" should not match false 72 + String "123" should not match false 73 + String " " should not match false 74 + String "1 3z" should not match false |}] 75 + ;; 76 + 77 + let%expect_test "named groups" = 78 + let open Pcre in 79 + let rex = regexp "(?<many_x>x+)" in 80 + let s = exec ~rex "testxxxyyy" in 81 + print_endline (get_named_substring rex "many_x" s); 82 + [%expect {| xxx |}] 83 + ;; 84 + 85 + let%expect_test "quote" = 86 + let test s = Printf.printf "%S\n" (Re.Pcre.quote s) in 87 + test ""; 88 + [%expect {| "" |}]; 89 + test "\000"; 90 + [%expect {| "\000" |}]; 91 + test ""; 92 + [%expect {| "" |}]; 93 + test (String.init (126 - 32) (fun x -> Char.chr (x + 32))); 94 + [%expect 95 + {xxx| " !\"#\\$%&'\\(\\)\\*\\+,-\\./0123456789:;<=>\\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\[\\\\]\\^_`abcdefghijklmnopqrstuvwxyz\\{\\|}" |xxx}]; 96 + let b = Buffer.create 100 in 97 + for i = 0 to 255 do 98 + let c = Char.chr i in 99 + let s = Pcre.quote (String.make 1 c) in 100 + if String.length s > 1 then Buffer.add_char b c 101 + done; 102 + let b = Buffer.contents b in 103 + Printf.printf "%S\n" b; 104 + [%expect {xxx| "$()*+.?[\\^{|" |xxx}] 105 + ;;
+15
vendor/opam/re/lib_test/expect/test_pcre_288.ml
··· 1 + open Import 2 + module Pcre = Re_private.Pcre 3 + 4 + let whitespace_re = Pcre.regexp "\\s+" 5 + 6 + let%expect_test "split1" = 7 + strings (Pcre.split ~rex:whitespace_re ""); 8 + [%expect {| [] |}] 9 + ;; 10 + 11 + let%expect_test "split2" = 12 + strings (Pcre.split ~rex:whitespace_re " "); 13 + [%expect {| 14 + [] |}] 15 + ;;
+48
vendor/opam/re/lib_test/expect/test_pcre_split.ml
··· 1 + open Import 2 + 3 + let split ~rex s = Re.Pcre.split ~rex s |> strings 4 + 5 + let%expect_test "split" = 6 + split ~rex:re_whitespace "aa bb c d "; 7 + [%expect {| ["aa"; "bb"; "c"; "d"] |}]; 8 + split ~rex:re_whitespace " a full_word bc "; 9 + [%expect {| ["a"; "full_word"; "bc"] |}]; 10 + split ~rex:re_empty "abcd"; 11 + [%expect {| ["a"; "b"; "c"; "d"] |}]; 12 + split ~rex:re_eol "a\nb"; 13 + [%expect {| ["a"; "\nb"] |}]; 14 + split ~rex:re_bow "a b"; 15 + [%expect {| ["a "; "b"] |}]; 16 + split ~rex:re_eow "a b"; 17 + [%expect {| ["a"; " b"] |}]; 18 + let rex = Re.Pcre.regexp "" in 19 + split ~rex "xx"; 20 + [%expect {| ["x"; "x"] |}] 21 + ;; 22 + 23 + let full_split ?max ~rex s = 24 + let res = Re.Pcre.full_split ?max ~rex s in 25 + Format.printf 26 + "[%a]@." 27 + Fmt.( 28 + list ~pp_sep:(Fmt.lit "; ") (fun fmt what -> 29 + match (what : Re.Pcre.split_result) with 30 + | Text s -> Format.fprintf fmt "Text %S" s 31 + | Delim s -> Format.fprintf fmt "Delim %S" s 32 + | NoGroup -> Format.fprintf fmt "NoGroup" 33 + | Group (x, s) -> Format.fprintf fmt "Group (%d, %S)" x s)) 34 + res 35 + ;; 36 + 37 + let%expect_test "full split" = 38 + (let full_split = full_split ~rex:(Re.Pcre.regexp "x(x)?") in 39 + full_split "testxxyyy"; 40 + [%expect {| [Text "test"; Delim "xx"; Group (1, "x"); Text "yyy"] |}]; 41 + full_split "testxyyy"; 42 + [%expect {| [Text "test"; Delim "x"; NoGroup; Text "yyy"] |}]); 43 + let full_split = full_split ~rex:(Re.Pcre.regexp "[:_]") in 44 + full_split ""; 45 + [%expect {| [] |}]; 46 + full_split ~max:1 "xxx:yyy"; 47 + [%expect {| [Text "xxx:yyy"] |}] 48 + ;;
+212
vendor/opam/re/lib_test/expect/test_perl.ml
··· 1 + open Import 2 + 3 + (* Tests based on description of Perl regular expressions given at 4 + http://www.perl.com/CPAN-local/doc/manual/html/pod/perlre.html *) 5 + 6 + let re ?opts s = Format.printf "%a@." Re.pp (Re.Perl.re ?opts s) 7 + 8 + let try_parse ?opts s = 9 + try 10 + ignore (Re.Perl.re ?opts s); 11 + print_endline "Prased successfully" 12 + with 13 + | Re.Perl.Parse_error -> print_endline "Parse error" 14 + | Re.Perl.Not_supported -> print_endline "Not supported" 15 + ;; 16 + 17 + let%expect_test "escaping meta characters" = 18 + re "\\^"; 19 + [%expect {| (Set 94) |}]; 20 + re "\\."; 21 + [%expect {| (Set 46) |}]; 22 + re "\\$"; 23 + [%expect {| (Set 36) |}]; 24 + re "\\|"; 25 + [%expect {| (Set 124) |}]; 26 + re "\\("; 27 + [%expect {| (Set 40) |}]; 28 + re "\\)"; 29 + [%expect {| (Set 41) |}]; 30 + re "\\["; 31 + [%expect {| (Set 91) |}]; 32 + re "\\]"; 33 + [%expect {| (Set 93) |}]; 34 + re "\\*"; 35 + [%expect {| (Set 42) |}]; 36 + re "\\+"; 37 + [%expect {| (Set 43) |}]; 38 + re "\\?"; 39 + [%expect {| (Set 63) |}]; 40 + re "\\\\"; 41 + [%expect {| (Set 92) |}] 42 + ;; 43 + 44 + let%expect_test "basic metacharacters" = 45 + re "^"; 46 + [%expect {| Beg_of_str |}]; 47 + re "."; 48 + [%expect {| (Set 0-9, 11-255) |}]; 49 + re "$"; 50 + [%expect {| End_of_str |}]; 51 + re "a|b"; 52 + [%expect {| (Alternative (Set 97)(Set 98)) |}]; 53 + re "aa|bb"; 54 + [%expect {| (Alternative (Sequence (Set 97)(Set 97))(Sequence (Set 98)(Set 98))) |}]; 55 + re "(a)"; 56 + [%expect {| (Group (Set 97)) |}]; 57 + re "(a|b)c"; 58 + [%expect {| (Sequence (Group (Alternative (Set 97)(Set 98)))(Set 99)) |}]; 59 + re "[ab]"; 60 + [%expect {| (Alternative (Set 98)(Set 97)) |}]; 61 + re "[a-z]"; 62 + [%expect {| (Set 97-122) |}]; 63 + re "[a-z$%.]"; 64 + [%expect {| (Alternative (Set 46)(Set 37)(Set 36)(Set 97-122)) |}]; 65 + re "[-az]"; 66 + [%expect {| (Alternative (Set 122)(Set 97)(Set 45)) |}]; 67 + re "[az-]"; 68 + [%expect {| (Alternative (Set 122)(Set 45)(Set 97)) |}]; 69 + re "[a\\-z]"; 70 + [%expect {| (Alternative (Set 122)(Set 45)(Set 97)) |}]; 71 + re "[]a]"; 72 + [%expect {| (Alternative (Set 97)(Set 93)) |}]; 73 + re "[]-]"; 74 + [%expect {| (Alternative (Set 93)(Set 45)) |}]; 75 + re "[a^]"; 76 + [%expect {| (Alternative (Set 94)(Set 97)) |}]; 77 + re "[^a-z]"; 78 + [%expect {| (Complement (Set 97-122)) |}]; 79 + re "[^a-z$]"; 80 + [%expect {| (Complement (Set 36)(Set 97-122)) |}]; 81 + re "[a-\\sz]"; 82 + [%expect {| (Alternative (Set 122)(Set 97)(Set 45)(Set 9-13, 32)) |}] 83 + ;; 84 + 85 + let%expect_test "greedy quantifiers" = 86 + re "a*"; 87 + [%expect {| (Sem_greedy Greedy (Repeat (Set 97) 0)) |}]; 88 + re "a+"; 89 + [%expect {| (Sem_greedy Greedy (Repeat (Set 97) 1)) |}]; 90 + re "a?"; 91 + [%expect {| (Sem_greedy Greedy (Repeat (Set 97) 0 1)) |}]; 92 + re "a{10}"; 93 + [%expect {| (Sem_greedy Greedy (Repeat (Set 97) 10 10)) |}]; 94 + re "a{10,}"; 95 + [%expect {| (Sem_greedy Greedy (Repeat (Set 97) 10)) |}]; 96 + re "a{10,12}"; 97 + [%expect {| (Sem_greedy Greedy (Repeat (Set 97) 10 12)) |}] 98 + ;; 99 + 100 + let%expect_test "non-greedy quantifiers" = 101 + re "a*?"; 102 + [%expect {| (Sem_greedy Non_greedy (Repeat (Set 97) 0)) |}]; 103 + re "a+?"; 104 + [%expect {| (Sem_greedy Non_greedy (Repeat (Set 97) 1)) |}]; 105 + re "a??"; 106 + [%expect {| (Sem_greedy Non_greedy (Repeat (Set 97) 0 1)) |}]; 107 + re "a{10}?"; 108 + [%expect {| (Sem_greedy Non_greedy (Repeat (Set 97) 10 10)) |}]; 109 + re "a{10,}?"; 110 + [%expect {| (Sem_greedy Non_greedy (Repeat (Set 97) 10)) |}]; 111 + re "a{10,12}?"; 112 + [%expect {| (Sem_greedy Non_greedy (Repeat (Set 97) 10 12)) |}] 113 + ;; 114 + 115 + let%expect_test "character sets" = 116 + re "\\w"; 117 + [%expect 118 + {| 119 + (Alternative 120 + (Set 48-57, 65-90, 97-122, 170, 181, 186, 192-214, 216-246, 248-255) 121 + (Set 95)) |}]; 122 + re "\\W"; 123 + [%expect 124 + {| 125 + (Complement 126 + (Set 48-57, 65-90, 97-122, 170, 181, 186, 192-214, 216-246, 248-255) 127 + (Set 95)) |}]; 128 + re "\\s"; 129 + [%expect {| (Set 9-13, 32) |}]; 130 + re "\\S"; 131 + [%expect {| (Complement (Set 9-13, 32)) |}]; 132 + re "\\d"; 133 + [%expect {| (Set 48-57) |}]; 134 + re "\\D"; 135 + [%expect {| (Complement (Set 48-57)) |}] 136 + ;; 137 + 138 + let%expect_test "zero-width assertions" = 139 + re "\\b"; 140 + [%expect {| (Alternative Beg_of_wordEnd_of_word) |}]; 141 + re "\\B"; 142 + [%expect {| Not_bound |}]; 143 + re "\\A"; 144 + [%expect {| Beg_of_str |}]; 145 + re "\\Z"; 146 + [%expect {| Last_end_of_line |}]; 147 + re "\\z"; 148 + [%expect {| End_of_str |}]; 149 + re "\\G"; 150 + [%expect {| Start |}] 151 + ;; 152 + 153 + let%expect_test "options" = 154 + re ~opts:[ `Anchored ] "a"; 155 + [%expect {| (Sequence Start(Set 97)) |}]; 156 + re ~opts:[ `Caseless ] "b"; 157 + [%expect {| (No_case (Set 98)) |}]; 158 + re ~opts:[ `Dollar_endonly ] "$"; 159 + [%expect {| Last_end_of_line |}]; 160 + re ~opts:[ `Dollar_endonly; `Multiline ] "$"; 161 + [%expect {| End_of_line |}]; 162 + re ~opts:[ `Dotall ] "."; 163 + [%expect {| (Set 0-255) |}]; 164 + re ~opts:[ `Multiline ] "^"; 165 + [%expect {| Beg_of_line |}]; 166 + re ~opts:[ `Multiline ] "$"; 167 + [%expect {| End_of_line |}]; 168 + re ~opts:[ `Ungreedy ] "a*"; 169 + [%expect {| (Sem_greedy Non_greedy (Repeat (Set 97) 0)) |}]; 170 + re ~opts:[ `Ungreedy ] "a*?"; 171 + [%expect {| (Sem_greedy Greedy (Repeat (Set 97) 0)) |}] 172 + ;; 173 + 174 + let%expect_test "clustering" = 175 + re "(?:a)"; 176 + [%expect {| (Set 97) |}]; 177 + re "(?:a|b)c"; 178 + [%expect {| (Sequence (Alternative (Set 97)(Set 98))(Set 99)) |}] 179 + ;; 180 + 181 + let%expect_test "comment" = 182 + re "a(?#comment)b"; 183 + [%expect {| (Sequence (Set 97)(Sequence )(Set 98)) |}]; 184 + try_parse "(?#"; 185 + [%expect {| Parse error |}] 186 + ;; 187 + 188 + let%expect_test "backrefs" = 189 + try_parse "\\0"; 190 + [%expect {| Not supported |}] 191 + ;; 192 + 193 + let%expect_test "ordinary characters" = 194 + re "a"; 195 + [%expect {| (Set 97) |}] 196 + ;; 197 + 198 + let%expect_test "concacentation" = 199 + re "ab"; 200 + [%expect {| (Sequence (Set 97)(Set 98)) |}] 201 + ;; 202 + 203 + let%expect_test "sets in classes" = 204 + re "[a\\s]"; 205 + [%expect {| (Alternative (Set 9-13, 32)(Set 97)) |}] 206 + ;; 207 + 208 + let%expect_test "fixed bug" = 209 + (try ignore (Re.compile (Re.Perl.re "(.*?)(\\WPl|\\Bpl)(.*)")) with 210 + | _ -> failwith "bug in Re.handle_case"); 211 + [%expect {||}] 212 + ;;
+10
vendor/opam/re/lib_test/expect/test_posix.ml
··· 1 + open Import 2 + 3 + let%expect_test "class space" = 4 + let re = Re.Posix.compile_pat {|a[[:space:]]b|} in 5 + let exec = Re.execp re in 6 + assert (exec "a b"); 7 + assert (not (exec "ab")); 8 + assert (not (exec "a_b")); 9 + [%expect {||}] 10 + ;;
+330
vendor/opam/re/lib_test/expect/test_re.ml
··· 1 + open Import 2 + open Re 3 + 4 + let%expect_test "str" = 5 + test_re (str "a") "a"; 6 + [%expect {| [| (0, 1) |] |}]; 7 + test_re (str "a") "b"; 8 + [%expect {| Not_found |}] 9 + ;; 10 + 11 + let%expect_test "char" = 12 + test_re (alt [ char 'a'; char 'b' ]) "a"; 13 + [%expect {| [| (0, 1) |] |}]; 14 + test_re (alt [ char 'a'; char 'b' ]) "b"; 15 + [%expect {| [| (0, 1) |] |}]; 16 + test_re (alt [ char 'a'; char 'b' ]) "c"; 17 + [%expect {| Not_found |}] 18 + ;; 19 + 20 + let%expect_test "alt" = 21 + test_re (alt [ char 'a'; char 'b' ]) "a"; 22 + [%expect {| [| (0, 1) |] |}]; 23 + test_re (alt [ char 'a'; char 'b' ]) "b"; 24 + [%expect {| [| (0, 1) |] |}]; 25 + test_re (alt [ char 'a'; char 'b' ]) "c"; 26 + [%expect {| Not_found |}] 27 + ;; 28 + 29 + let%expect_test "seq" = 30 + test_re (seq [ char 'a'; char 'b' ]) "ab"; 31 + [%expect {| [| (0, 2) |] |}]; 32 + test_re (seq [ char 'a'; char 'b' ]) "ac"; 33 + [%expect {| Not_found |}] 34 + ;; 35 + 36 + let%expect_test "empty" = 37 + test_re empty ""; 38 + [%expect {| Not_found |}]; 39 + test_re empty "a"; 40 + [%expect {| Not_found |}] 41 + ;; 42 + 43 + let%expect_test "epsilon" = 44 + test_re epsilon ""; 45 + [%expect {| [| (0, 0) |] |}]; 46 + test_re epsilon "a"; 47 + [%expect {| [| (0, 0) |] |}] 48 + ;; 49 + 50 + let%expect_test "rep" = 51 + test_re (rep (char 'a')) ""; 52 + [%expect {| [| (0, 0) |] |}]; 53 + test_re (rep (char 'a')) "a"; 54 + [%expect {| [| (0, 1) |] |}]; 55 + test_re (rep (char 'a')) "aa"; 56 + [%expect {| [| (0, 2) |] |}]; 57 + test_re (rep (char 'a')) "b"; 58 + [%expect {| [| (0, 0) |] |}] 59 + ;; 60 + 61 + let%expect_test "bol" = 62 + test_re (seq [ bol; char 'a' ]) "ab"; 63 + [%expect {| [| (0, 1) |] |}]; 64 + test_re (seq [ bol; char 'a' ]) "b\na"; 65 + [%expect {| [| (2, 3) |] |}]; 66 + test_re (seq [ bol; char 'a' ]) "ba"; 67 + [%expect {| Not_found |}] 68 + ;; 69 + 70 + let%expect_test "eol" = 71 + test_re (seq [ char 'a'; eol ]) "ba"; 72 + [%expect {| [| (1, 2) |] |}]; 73 + test_re (seq [ char 'a'; eol ]) "a\nb"; 74 + [%expect {| [| (0, 1) |] |}]; 75 + test_re (seq [ char 'a'; eol ]) "ba\n"; 76 + [%expect {| [| (1, 2) |] |}]; 77 + test_re (seq [ char 'a'; eol ]) "ab"; 78 + [%expect {| Not_found |}] 79 + ;; 80 + 81 + let%expect_test "bow" = 82 + test_re (seq [ bow; char 'a' ]) "a"; 83 + [%expect {| [| (0, 1) |] |}]; 84 + test_re (seq [ bow; char 'a' ]) "bb aa"; 85 + [%expect {| [| (3, 4) |] |}]; 86 + test_re (seq [ bow; char 'a' ]) "ba ba"; 87 + [%expect {| Not_found |}]; 88 + test_re bow ";"; 89 + [%expect {| Not_found |}]; 90 + test_re bow ""; 91 + [%expect {| Not_found |}] 92 + ;; 93 + 94 + let%expect_test "eow" = 95 + test_re (seq [ char 'a'; eow ]) "a"; 96 + [%expect {| [| (0, 1) |] |}]; 97 + test_re (seq [ char 'a'; eow ]) "bb aa"; 98 + [%expect {| [| (4, 5) |] |}]; 99 + test_re (seq [ char 'a'; eow ]) "ab ab"; 100 + [%expect {| Not_found |}]; 101 + test_re eow ";"; 102 + [%expect {| Not_found |}]; 103 + test_re eow ""; 104 + [%expect {| Not_found |}] 105 + ;; 106 + 107 + let%expect_test "bos" = 108 + test_re (seq [ bos; char 'a' ]) "ab"; 109 + [%expect {| [| (0, 1) |] |}]; 110 + test_re (seq [ bos; char 'a' ]) "b\na"; 111 + [%expect {| Not_found |}]; 112 + test_re (seq [ bos; char 'a' ]) "ba"; 113 + [%expect {| Not_found |}] 114 + ;; 115 + 116 + let%expect_test "eos" = 117 + test_re (seq [ char 'a'; eos ]) "ba"; 118 + [%expect {| [| (1, 2) |] |}]; 119 + test_re (seq [ char 'a'; eos ]) "a\nb"; 120 + [%expect {| Not_found |}]; 121 + test_re (seq [ char 'a'; eos ]) "ba\n"; 122 + [%expect {| Not_found |}]; 123 + test_re (seq [ char 'a'; eos ]) "ab"; 124 + [%expect {| Not_found |}] 125 + ;; 126 + 127 + let%expect_test "leol" = 128 + test_re (seq [ char 'a'; leol ]) "ba"; 129 + [%expect {| [| (1, 2) |] |}]; 130 + test_re (seq [ char 'a'; leol ]) "a\nb"; 131 + [%expect {| Not_found |}]; 132 + test_re (seq [ char 'a'; leol ]) "ba\n"; 133 + [%expect {| [| (1, 2) |] |}]; 134 + test_re (seq [ char 'a'; leol ]) "ab"; 135 + [%expect {| Not_found |}]; 136 + test_re (alt [ str "b\n"; seq [ char 'a'; leol ] ]) "ab\n"; 137 + [%expect {| [| (1, 3) |] |}] 138 + ;; 139 + 140 + let%expect_test "start" = 141 + test_re ~pos:1 (seq [ start; char 'a' ]) "xab"; 142 + [%expect {| [| (1, 2) |] |}]; 143 + test_re ~pos:1 (seq [ start; char 'a' ]) "xb\na"; 144 + [%expect {| Not_found |}]; 145 + test_re ~pos:1 (seq [ start; char 'a' ]) "xba"; 146 + [%expect {| Not_found |}] 147 + ;; 148 + 149 + let%expect_test "stop" = 150 + test_re ~len:2 (seq [ char 'a'; stop ]) "bax"; 151 + [%expect {| [| (1, 2) |] |}]; 152 + test_re ~len:3 (seq [ char 'a'; stop ]) "a\nbx"; 153 + [%expect {| Not_found |}]; 154 + test_re ~len:3 (seq [ char 'a'; stop ]) "ba\nx"; 155 + [%expect {| Not_found |}]; 156 + test_re ~len:2 (seq [ char 'a'; stop ]) "abx"; 157 + [%expect {| Not_found |}] 158 + ;; 159 + 160 + let%expect_test "word" = 161 + test_re (word (str "aa")) "aa"; 162 + [%expect {| [| (0, 2) |] |}]; 163 + test_re (word (str "aa")) "bb aa"; 164 + [%expect {| [| (3, 5) |] |}]; 165 + test_re (word (str "aa")) "aaa"; 166 + [%expect {| Not_found |}]; 167 + test_re (word (str "")) ""; 168 + [%expect {| Not_found |}] 169 + ;; 170 + 171 + let%expect_test "not_boundary" = 172 + test_re (seq [ not_boundary; char 'b'; not_boundary ]) "abc"; 173 + [%expect {| [| (1, 2) |] |}]; 174 + test_re (seq [ char ';'; not_boundary; char ';' ]) ";;"; 175 + [%expect {| [| (0, 2) |] |}]; 176 + test_re (seq [ not_boundary; char ';'; not_boundary ]) ";"; 177 + [%expect {| [| (0, 1) |] |}]; 178 + test_re (seq [ not_boundary; char 'a' ]) "abc"; 179 + [%expect {| Not_found |}]; 180 + test_re (seq [ char 'c'; not_boundary ]) "abc"; 181 + [%expect {| Not_found |}] 182 + ;; 183 + 184 + let%expect_test "default match semantics" = 185 + test_re (seq [ rep (alt [ char 'a'; char 'b' ]); char 'b' ]) "aabaab"; 186 + [%expect {| [| (0, 6) |] |}]; 187 + test_re (alt [ str "aa"; str "aaa" ]) "aaaa"; 188 + [%expect {| [| (0, 2) |] |}]; 189 + test_re (alt [ str "aaa"; str "aa" ]) "aaaa"; 190 + [%expect {| [| (0, 3) |] |}] 191 + ;; 192 + 193 + let%expect_test "shortest match" = 194 + test_re (shortest (seq [ rep (alt [ char 'a'; char 'b' ]); char 'b' ])) "aabaab"; 195 + [%expect {| [| (0, 3) |] |}]; 196 + test_re (shortest (alt [ str "aa"; str "aaa" ])) "aaaa"; 197 + [%expect {| [| (0, 2) |] |}]; 198 + test_re (shortest (alt [ str "aaa"; str "aa" ])) "aaaa"; 199 + [%expect {| [| (0, 2) |] |}] 200 + ;; 201 + 202 + let%expect_test "longest match" = 203 + test_re (longest (seq [ rep (alt [ char 'a'; char 'b' ]); char 'b' ])) "aabaab"; 204 + [%expect {| [| (0, 6) |] |}]; 205 + test_re (longest (alt [ str "aa"; str "aaa" ])) "aaaa"; 206 + [%expect {| [| (0, 3) |] |}]; 207 + test_re (longest (alt [ str "aaa"; str "aa" ])) "aaaa"; 208 + [%expect {| [| (0, 3) |] |}] 209 + ;; 210 + 211 + let%expect_test "first match" = 212 + test_re (first (seq [ rep (alt [ char 'a'; char 'b' ]); char 'b' ])) "aabaab"; 213 + [%expect {| [| (0, 6) |] |}]; 214 + test_re (first (alt [ str "aa"; str "aaa" ])) "aaaa"; 215 + [%expect {| [| (0, 2) |] |}]; 216 + test_re (first (alt [ str "aaa"; str "aa" ])) "aaaa"; 217 + [%expect {| [| (0, 3) |] |}] 218 + ;; 219 + 220 + let%expect_test "match_semantics" = 221 + let r = rep (group (alt [ str "aaa"; str "aa" ])) in 222 + test_re (longest r) "aaaaaaa"; 223 + [%expect {| [| (0, 7); (5, 7) |] |}]; 224 + test_re (first r) "aaaaaaa"; 225 + [%expect {| [| (0, 6); (3, 6) |] |}]; 226 + test_re (first (non_greedy r)) "aaaaaaa"; 227 + [%expect {| [| (0, 0); (-1, -1) |] |}]; 228 + test_re (shortest r) "aaaaaaa"; 229 + [%expect {| [| (0, 0); (-1, -1) |] |}]; 230 + let r' = rep (group (shortest (alt [ str "aaa"; str "aa" ]))) in 231 + test_re (longest r') "aaaaaaa"; 232 + [%expect {| [| (0, 7); (4, 7) |] |}]; 233 + test_re (first r') "aaaaaaa"; 234 + [%expect {| [| (0, 6); (4, 6) |] |}] 235 + ;; 236 + 237 + let%expect_test "greedy" = 238 + test_re (greedy (seq [ rep (alt [ char 'a'; char 'b' ]); char 'b' ])) "aabaab"; 239 + [%expect {| [| (0, 6) |] |}]; 240 + test_re (greedy (rep (group (opt (char 'a'))))) "aa"; 241 + [%expect {| [| (0, 2); (2, 2) |] |}] 242 + ;; 243 + 244 + let%expect_test "non_greedy" = 245 + test_re 246 + (non_greedy (longest (seq [ rep (alt [ char 'a'; char 'b' ]); char 'b' ]))) 247 + "aabaab"; 248 + [%expect {| [| (0, 6) |] |}]; 249 + test_re 250 + (non_greedy (first (seq [ rep (alt [ char 'a'; char 'b' ]); char 'b' ]))) 251 + "aabaab"; 252 + [%expect {| [| (0, 3) |] |}]; 253 + test_re (non_greedy (longest (rep (group (opt (char 'a')))))) "aa"; 254 + [%expect {| [| (0, 2); (1, 2) |] |}] 255 + ;; 256 + 257 + let%expect_test "set" = 258 + test_re (rep1 (set "abcd")) "bcbadbabcdba"; 259 + [%expect {| [| (0, 12) |] |}]; 260 + test_re (set "abcd") "e"; 261 + [%expect {| Not_found |}] 262 + ;; 263 + 264 + let%expect_test "rg" = 265 + test_re (rep1 (rg '0' '9')) "0123456789"; 266 + [%expect {| [| (0, 10) |] |}]; 267 + test_re (rep1 (rg '0' '9')) "a"; 268 + [%expect {| Not_found |}] 269 + ;; 270 + 271 + let%expect_test "inter" = 272 + test_re (rep1 (inter [ rg '0' '9'; rg '4' '6' ])) "456"; 273 + [%expect {| [| (0, 3) |] |}]; 274 + test_re (rep1 (inter [ rg '0' '9'; rg '4' '6' ])) "7"; 275 + [%expect {| Not_found |}]; 276 + test_re (inter [ alt [ char 'a'; char 'b' ]; char 'b' ]) "b"; 277 + [%expect {| [| (0, 1) |] |}] 278 + ;; 279 + 280 + let%expect_test "diff" = 281 + test_re (rep1 (diff (rg '0' '9') (rg '4' '6'))) "0123789"; 282 + [%expect {| [| (0, 7) |] |}]; 283 + test_re (rep1 (diff (rg '0' '9') (rg '4' '6'))) "4"; 284 + [%expect {| Not_found |}] 285 + ;; 286 + 287 + let%expect_test "compl" = 288 + test_re (rep1 (compl [ rg '0' '9'; rg 'a' 'z' ])) "A:Z+"; 289 + [%expect {| [| (0, 4) |] |}]; 290 + test_re (rep1 (compl [ rg '0' '9'; rg 'a' 'z' ])) "0"; 291 + [%expect {| Not_found |}]; 292 + test_re (rep1 (compl [ rg '0' '9'; rg 'a' 'z' ])) "a"; 293 + [%expect {| Not_found |}] 294 + ;; 295 + 296 + let%expect_test "case" = 297 + test_re (case (str "abc")) "abc"; 298 + [%expect {| [| (0, 3) |] |}]; 299 + test_re (no_case (case (str "abc"))) "abc"; 300 + [%expect {| [| (0, 3) |] |}]; 301 + test_re (case (str "abc")) "ABC"; 302 + [%expect {| Not_found |}]; 303 + test_re (no_case (case (str "abc"))) "ABC"; 304 + [%expect {| Not_found |}] 305 + ;; 306 + 307 + let%expect_test "no_case" = 308 + test_re (no_case (str "abc")) "abc"; 309 + [%expect {| [| (0, 3) |] |}]; 310 + test_re (no_case (str "abc")) "ABC"; 311 + [%expect {| [| (0, 3) |] |}]; 312 + test_re (case (no_case (str "abc"))) "abc"; 313 + [%expect {| [| (0, 3) |] |}]; 314 + test_re (case (no_case (str "abc"))) "ABC"; 315 + [%expect {| [| (0, 3) |] |}] 316 + ;; 317 + 318 + let%expect_test "witness" = 319 + let t re = print_endline (witness re) in 320 + t (set "ac"); 321 + [%expect {| a |}]; 322 + t (repn (str "foo") 3 None); 323 + [%expect {| foofoofoo |}]; 324 + t (alt [ char 'c'; char 'd' ]); 325 + [%expect {| c |}]; 326 + t (no_case (str "test")); 327 + [%expect {| TEST |}]; 328 + t eol; 329 + [%expect {| |}] 330 + ;;
+33
vendor/opam/re/lib_test/expect/test_replace.ml
··· 1 + open Import 2 + 3 + let%expect_test "test_replace" = 4 + let re = Re.Posix.compile_pat "[a-zA-Z]+" in 5 + let f sub = String.capitalize_ascii (Re.Group.get sub 0) in 6 + print_endline (Re.replace re ~f " hello world; I love chips!"); 7 + [%expect {| Hello World; I Love Chips! |}]; 8 + print_endline (Re.replace ~all:false re ~f " allo maman, bobo"); 9 + [%expect {| Allo maman, bobo |}]; 10 + print_endline (Re.replace re_empty ~f:(fun _ -> "a") ""); 11 + [%expect {| a |}]; 12 + print_endline (Re.replace (Re.compile (Re.rep (Re.char 'a'))) ~f:(fun _ -> "*") "cat"); 13 + [%expect {| *c*t* |}] 14 + ;; 15 + 16 + let%expect_test "test_replace_string" = 17 + let re = Re.Posix.compile_pat "_[a-zA-Z]+_" in 18 + print_endline (Re.replace_string re ~by:"goodbye" "_hello_ world"); 19 + [%expect {| goodbye world |}]; 20 + print_endline (Re.replace_string ~all:false re ~by:"brown" "The quick _XXX_ fox"); 21 + [%expect {| The quick brown fox |}] 22 + ;; 23 + 24 + let%expect_test "test_bug_55" = 25 + let re = Re.(compile bol) in 26 + let res = Re.replace_string re ~by:"z" "abc" in 27 + print_endline res; 28 + [%expect {| zabc |}]; 29 + let re = Re.(compile eow) in 30 + let res = Re.replace_string re ~by:"X" "one two three" in 31 + print_endline res; 32 + [%expect {| oneX twoX threeX |}] 33 + ;;
+78
vendor/opam/re/lib_test/expect/test_repn.ml
··· 1 + open Import 2 + open Re 3 + 4 + let%expect_test "fixed repetition" = 5 + let re = Re.compile @@ Re.(repn (char 'a') 3 (Some 3)) in 6 + let test s = printf "%b\n" (Re.execp re s) in 7 + test ""; 8 + [%expect {| false |}]; 9 + test "aa"; 10 + [%expect {| false |}]; 11 + test "aaa"; 12 + [%expect {| true |}]; 13 + test "aaaa"; 14 + [%expect {| true |}] 15 + ;; 16 + 17 + let%expect_test "repn" = 18 + let a = char 'a' in 19 + test_re (repn a 0 None) ""; 20 + [%expect {| [| (0, 0) |] |}]; 21 + test_re (repn a 2 None) "a"; 22 + [%expect {| Not_found |}]; 23 + test_re (repn a 2 None) "aa"; 24 + [%expect {| [| (0, 2) |] |}]; 25 + test_re (repn a 0 (Some 0)) ""; 26 + [%expect {| [| (0, 0) |] |}]; 27 + test_re (repn a 1 (Some 2)) "a"; 28 + [%expect {| [| (0, 1) |] |}]; 29 + test_re (repn a 1 (Some 2)) "aa"; 30 + [%expect {| [| (0, 2) |] |}]; 31 + test_re (repn a 1 (Some 2)) ""; 32 + [%expect {| Not_found |}]; 33 + test_re (repn a 1 (Some 2)) "aaa"; 34 + [%expect {| [| (0, 2) |] |}]; 35 + invalid_argument (fun () -> repn empty (-1) None); 36 + [%expect {| Invalid_argument "Re.repn" |}]; 37 + invalid_argument (fun () -> repn empty 1 (Some 0)); 38 + [%expect {| Invalid_argument "Re.repn" |}]; 39 + invalid_argument (fun () -> repn empty 4 (Some 3)); 40 + [%expect {| Invalid_argument "Re.repn" |}] 41 + ;; 42 + 43 + let%expect_test "rep1" = 44 + test_re (rep1 (char 'a')) "a"; 45 + [%expect {| [| (0, 1) |] |}]; 46 + test_re (rep1 (char 'a')) "aa"; 47 + [%expect {| [| (0, 2) |] |}]; 48 + test_re (rep1 (char 'a')) ""; 49 + [%expect {| Not_found |}]; 50 + test_re (rep1 (char 'a')) "b"; 51 + [%expect {| Not_found |}] 52 + ;; 53 + 54 + let%expect_test "opt" = 55 + test_re (opt (char 'a')) ""; 56 + [%expect {| [| (0, 0) |] |}]; 57 + test_re (opt (char 'a')) "a"; 58 + [%expect {| [| (0, 1) |] |}] 59 + ;; 60 + 61 + let copy s n = 62 + let len = String.length s in 63 + let b = Bytes.make (len * n) '\000' in 64 + for i = 0 to n - 1 do 65 + Bytes.blit_string s 0 b (i * len) len 66 + done; 67 + Bytes.to_string b 68 + ;; 69 + 70 + let%expect_test "repeat sequence" = 71 + let s = "abcde" in 72 + let re = str s |> rep |> whole_string |> compile in 73 + for i = 0 to 3 do 74 + let r = copy s i in 75 + assert (Re.execp re r) 76 + done; 77 + [%expect {||}] 78 + ;;
+76
vendor/opam/re/lib_test/expect/test_split.ml
··· 1 + open Import 2 + 3 + let re_whitespace = Re.Posix.compile_pat "[\t ]+" 4 + let re_eol = Re.compile Re.eol 5 + let re_bow = Re.compile Re.bow 6 + let re_eow = Re.compile Re.eow 7 + 8 + let%expect_test "split" = 9 + let split ?pos ?len re s = strings (Re.split ?pos ?len re s) in 10 + split re_whitespace "aa bb c d "; 11 + [%expect {| ["aa"; "bb"; "c"; "d"] |}]; 12 + split ~pos:1 ~len:4 re_whitespace "aa b c d"; 13 + [%expect {| ["a"; "b"] |}]; 14 + split re_whitespace " a full_word bc "; 15 + [%expect {| ["a"; "full_word"; "bc"] |}]; 16 + split re_empty "abcd"; 17 + [%expect {| ["a"; "b"; "c"; "d"] |}]; 18 + split re_eol "a\nb"; 19 + [%expect {| 20 + ["a"; "\nb"] |}]; 21 + split re_bow "a b"; 22 + [%expect {| ["a "; "b"] |}]; 23 + split re_eow "a b"; 24 + [%expect {| ["a"; " b"] |}]; 25 + split re_whitespace ""; 26 + [%expect {| [] |}]; 27 + split re_empty ""; 28 + [%expect {| [] |}] 29 + ;; 30 + 31 + let%expect_test "split_delim" = 32 + let split_delim ?pos ?len re s = strings (Re.split_delim ?pos ?len re s) in 33 + split_delim re_whitespace "aa bb c d "; 34 + [%expect {| ["aa"; "bb"; "c"; "d"; ""] |}]; 35 + split_delim ~pos:1 ~len:4 re_whitespace "aa b c d"; 36 + [%expect {| ["a"; "b"; ""] |}]; 37 + split_delim re_whitespace " a full_word bc "; 38 + [%expect {| [""; "a"; "full_word"; "bc"; ""] |}]; 39 + split_delim re_empty "abcd"; 40 + [%expect {| [""; "a"; "b"; "c"; "d"; ""] |}]; 41 + split_delim re_eol "a\nb"; 42 + [%expect {| ["a"; "\nb"; ""] |}]; 43 + split_delim re_bow "a b"; 44 + [%expect {| [""; "a "; "b"] |}]; 45 + split_delim re_eow "a b"; 46 + [%expect {| ["a"; " b"; ""] |}]; 47 + split_delim re_whitespace ""; 48 + [%expect {| [""] |}]; 49 + split_delim re_empty ""; 50 + [%expect {| [""; ""] |}] 51 + ;; 52 + 53 + let%expect_test "split_full" = 54 + let split_full ?pos ?len re s = 55 + let res = Re.split_full ?pos ?len re s in 56 + Format.printf 57 + "[%a]@." 58 + Fmt.( 59 + list ~pp_sep:(Fmt.lit "; ") (fun fmt what -> 60 + match what with 61 + | `Text s -> Format.fprintf fmt "`T %S" s 62 + | `Delim s -> Format.fprintf fmt "`D %S" (Re.Group.get s 0))) 63 + res 64 + in 65 + split_full re_whitespace "aa bb c d "; 66 + [%expect {| [`T "aa"; `D " "; `T "bb"; `D " "; `T "c"; `D " "; `T "d"; `D " "] |}]; 67 + split_full ~pos:1 ~len:5 re_whitespace "aa \tb c d"; 68 + [%expect {| [`T "a"; `D " \t"; `T "b"; `D " "] |}]; 69 + split_full re_whitespace " a full_word bc "; 70 + [%expect {| [`D " "; `T "a"; `D " "; `T "full_word"; `D " "; `T "bc"; `D " "] |}]; 71 + split_full re_empty "ab"; 72 + [%expect {| [`D ""; `T "a"; `D ""; `T "b"; `D ""] |}]; 73 + split_full Re.(compile (rep (char 'a'))) "cat"; 74 + [%expect {| [`D ""; `T "c"; `D "a"; `T "t"; `D ""] |}]; 75 + () 76 + ;;
+330
vendor/opam/re/lib_test/expect/test_str.ml
··· 1 + open Import 2 + 3 + module type Str_intf = module type of Str 4 + 5 + module Test_matches (R : Str_intf) = struct 6 + let groups () = 7 + let group i = 8 + try `Found (R.group_beginning i) with 9 + | Not_found -> `Not_found 10 + | Invalid_argument _ -> `Not_exists 11 + in 12 + let rec loop acc i = 13 + match group i with 14 + | `Found p -> loop ((p, R.group_end i) :: acc) (i + 1) 15 + | `Not_found -> loop ((-1, -1) :: acc) (i + 1) 16 + | `Not_exists -> List.rev acc 17 + in 18 + loop [] 0 19 + ;; 20 + 21 + let eq_match ?(pos = 0) ?(case = true) r s = 22 + let pat = if case then R.regexp r else R.regexp_case_fold r in 23 + try 24 + ignore (R.search_forward pat s pos); 25 + Some (groups ()) 26 + with 27 + | Not_found -> None 28 + ;; 29 + 30 + let eq_match' ?(pos = 0) ?(case = true) r s = 31 + let pat = if case then R.regexp r else R.regexp_case_fold r in 32 + try 33 + ignore (R.string_match pat s pos); 34 + Some (groups ()) 35 + with 36 + | Not_found -> None 37 + ;; 38 + end 39 + 40 + module T_str = Test_matches (Str) 41 + module T_re = Test_matches (Re.Str) 42 + 43 + let test dyn_of_ok str re args = 44 + let run f = 45 + match f () with 46 + | s -> Ok s 47 + | exception exn -> Error exn 48 + in 49 + let str = run (fun () -> str args) in 50 + let re = run (fun () -> re args) in 51 + if not (Poly.equal str re) 52 + then ( 53 + let printer x = 54 + let dyn = 55 + let open Dyn in 56 + result dyn_of_ok (fun x -> string (Printexc.to_string x)) x 57 + in 58 + sexp_of_dyn dyn |> Base.Sexp.to_string_hum 59 + in 60 + Printf.printf "str: %s\n" (printer str); 61 + Printf.printf "re: %s\n" (printer re)) 62 + ;; 63 + 64 + let dyn_of_pairs x = 65 + Dyn.option 66 + (fun x -> 67 + List.map x ~f:(fun (start, stop) -> 68 + let open Dyn in 69 + pair (int start) (int stop)) 70 + |> Dyn.list) 71 + x 72 + ;; 73 + 74 + let split_result_conv = 75 + List.map ~f:(function 76 + | Str.Delim x -> Re.Str.Delim x 77 + | Str.Text x -> Re.Str.Text x) 78 + ;; 79 + 80 + let dyn_split_result_list list = 81 + List.map 82 + list 83 + ~f: 84 + (let open Dyn in 85 + function 86 + | Re.Str.Delim x -> variant "Delim" [ string x ] 87 + | Text s -> variant "Text" [ string s ]) 88 + |> Dyn.list 89 + ;; 90 + 91 + type ('a, 'b) test = 92 + { name : string 93 + ; dyn_of_ok : 'b -> Dyn.t 94 + ; re_str : Re.Str.regexp -> 'a -> 'b 95 + ; str : Str.regexp -> 'a -> 'b 96 + } 97 + 98 + let bounded_split_t = 99 + { name = "bounded_split" 100 + ; dyn_of_ok = (fun x -> Dyn.list (List.map x ~f:Dyn.string)) 101 + ; re_str = (fun re (s, n) -> Re.Str.bounded_split re s n) 102 + ; str = (fun re (s, n) -> Str.bounded_split re s n) 103 + } 104 + ;; 105 + 106 + let bounded_full_split_t = 107 + { name = "bounded_full_split" 108 + ; dyn_of_ok = dyn_split_result_list 109 + ; re_str = (fun re (s, n) -> Re.Str.bounded_full_split re s n) 110 + ; str = (fun re (s, n) -> split_result_conv (Str.bounded_full_split re s n)) 111 + } 112 + ;; 113 + 114 + let full_split_t = 115 + { bounded_full_split_t with 116 + name = "full_split" 117 + ; re_str = (fun re s -> Re.Str.full_split re s) 118 + ; str = (fun re s -> split_result_conv (Str.full_split re s)) 119 + } 120 + ;; 121 + 122 + let split_delim_t = 123 + { name = "split_delim" 124 + ; dyn_of_ok = (fun x -> Dyn.list (List.map x ~f:Dyn.string)) 125 + ; re_str = Re.Str.split_delim 126 + ; str = Str.split_delim 127 + } 128 + ;; 129 + 130 + let split_t = 131 + { name = "split" 132 + ; dyn_of_ok = (fun x -> Dyn.list (List.map x ~f:Dyn.string)) 133 + ; re_str = Re.Str.split 134 + ; str = Str.split 135 + } 136 + ;; 137 + 138 + let global_replace_t = 139 + { name = "global_replace" 140 + ; dyn_of_ok = Dyn.string 141 + ; re_str = (fun re (r, s) -> Re.Str.global_replace re r s) 142 + ; str = (fun re (r, s) -> Str.global_replace re r s) 143 + } 144 + ;; 145 + 146 + let eq_match ?pos ?case re = 147 + test dyn_of_pairs (T_str.eq_match ?pos ?case re) (T_re.eq_match ?pos ?case re) 148 + ;; 149 + 150 + let eq_match' ?pos ?case re = 151 + test dyn_of_pairs (T_str.eq_match' ?pos ?case re) (T_re.eq_match' ?pos ?case re) 152 + ;; 153 + 154 + let test t re args = 155 + test t.dyn_of_ok (t.re_str (Re.Str.regexp re)) (t.str (Str.regexp re)) args 156 + ;; 157 + 158 + let split_delim re s = test split_delim_t re s 159 + let split re s = test split_t re s 160 + let full_split re s = test full_split_t re s 161 + let bounded_split re s n = test bounded_split_t re (s, n) 162 + let bounded_full_split re s n = test bounded_full_split_t re (s, n) 163 + let global_replace re r s = test global_replace_t re (r, s) 164 + 165 + let%expect_test "literal match" = 166 + eq_match "a" "a"; 167 + eq_match "a" "b"; 168 + [%expect {||}] 169 + ;; 170 + 171 + let%expect_test "alt" = 172 + eq_match "a\\|b" "a"; 173 + eq_match "a\\|b" "b"; 174 + eq_match "a\\|b" "c"; 175 + [%expect {||}] 176 + ;; 177 + 178 + let%expect_test "seq" = 179 + eq_match "ab" "ab"; 180 + eq_match "ab" "ac"; 181 + [%expect {||}] 182 + ;; 183 + 184 + let%expect_test "epsilon" = 185 + eq_match "" ""; 186 + eq_match "" "a"; 187 + [%expect {||}] 188 + ;; 189 + 190 + let%expect_test "rep" = 191 + eq_match "a*" ""; 192 + eq_match "a*" "a"; 193 + eq_match "a*" "aa"; 194 + eq_match "a*" "b"; 195 + [%expect {||}] 196 + ;; 197 + 198 + let%expect_test "rep1" = 199 + eq_match "a+" "a"; 200 + eq_match "a+" "aa"; 201 + eq_match "a+" ""; 202 + eq_match "a+" "b"; 203 + [%expect {| |}] 204 + ;; 205 + 206 + let%expect_test "opt" = 207 + eq_match "a?" ""; 208 + eq_match "a?" "a"; 209 + [%expect {| |}] 210 + ;; 211 + 212 + let%expect_test "bol" = 213 + eq_match "^a" "ab"; 214 + eq_match "^a" "b\na"; 215 + eq_match "^a" "ba"; 216 + [%expect {| |}] 217 + ;; 218 + 219 + let%expect_test "eol" = 220 + eq_match "a$" "ba"; 221 + eq_match "a$" "a\nb"; 222 + eq_match "a$" "ba\n"; 223 + eq_match "a$" "ab"; 224 + [%expect {| |}] 225 + ;; 226 + 227 + let%expect_test "start" = 228 + eq_match ~pos:1 "Za" "xab"; 229 + eq_match ~pos:1 "Za" "xb\na"; 230 + eq_match ~pos:1 "Za" "xba"; 231 + [%expect {||}] 232 + ;; 233 + 234 + let%expect_test "match semantics" = 235 + eq_match "\\(a\\|b\\)*b" "aabaab"; 236 + eq_match "aa\\|aaa" "aaaa"; 237 + eq_match "aaa\\|aa" "aaaa"; 238 + [%expect {||}] 239 + ;; 240 + 241 + let%expect_test "Group (or submatch)" = 242 + eq_match "\\(a\\)\\(a\\)?\\(b\\)" "ab"; 243 + [%expect {| |}]; 244 + eq_match "\\(foo" "foo"; 245 + [%expect {| 246 + str: (Error "Failure(\"\\\\( group not closed by \\\\)\")") 247 + re: (Error Re_private.Emacs.Parse_error) 248 + |}] 249 + ;; 250 + 251 + let%expect_test "Character set" = 252 + eq_match "[0-9]+" "0123456789"; 253 + eq_match "[0-9]+" "a"; 254 + eq_match "[9-0]+" "2"; 255 + eq_match "[5-5]" "5"; 256 + eq_match "[5-4]" "1"; 257 + eq_match' "[]]" "]"; 258 + eq_match' "[a-]" "-"; 259 + eq_match' "[-a]" "-"; 260 + eq_match' "]" "]"; 261 + eq_match' "[^b-f]" "z"; 262 + eq_match' "[^b-f]" "a"; 263 + [%expect {||}]; 264 + (* These errors aren't correct *) 265 + eq_match' "[]" "x"; 266 + eq_match' "[" "["; 267 + [%expect 268 + {| 269 + str: (Error "Failure(\"[ class not closed by ]\")") 270 + re: (Error Re_private.Emacs.Parse_error) 271 + str: (Error "Failure(\"[ class not closed by ]\")") 272 + re: (Error Re_private.Emacs.Parse_error) 273 + |}] 274 + ;; 275 + 276 + let%expect_test "compl" = 277 + eq_match "[^0-9a-z]+" "A:Z+"; 278 + eq_match "[^0-9a-z]+" "0"; 279 + eq_match "[^0-9a-z]+" "a"; 280 + [%expect {||}] 281 + ;; 282 + 283 + let%expect_test "Word modifiers" = 284 + eq_match' "\\bfoo" "foo"; 285 + eq_match' "\\<foo" "foo"; 286 + eq_match' "foo\\>" "foo"; 287 + eq_match' "z\\Bfoo" "zfoo"; 288 + eq_match' "\\`foo" "foo"; 289 + eq_match' "foo\\'" "foo"; 290 + [%expect {||}] 291 + ;; 292 + 293 + let%expect_test "Case modifiers" = 294 + eq_match ~case:false "abc" "abc"; 295 + eq_match ~case:false "abc" "ABC"; 296 + [%expect {| |}] 297 + ;; 298 + 299 + let%expect_test "global_replace" = 300 + global_replace "needle" "test" "needlehaystack"; 301 + global_replace "needle" "" ""; 302 + global_replace "needle" "" "needle"; 303 + global_replace "xxx" "yyy" "zzz"; 304 + global_replace "test\\([0-9]*\\)" "\\1-foo-\\1" "test100 test200 test"; 305 + global_replace "test\\([0-9]*\\)" "'\\-0'" "test100 test200 test"; 306 + (* Regrssion test for #129 *) 307 + global_replace "\\(X+\\)" "A\\1YY" "XXXXXXZZZZ"; 308 + [%expect {||}] 309 + ;; 310 + 311 + let%expect_test "bounded_split, bounded_full_split" = 312 + [ ",", "foo,bar,baz", 5 313 + ; ",", "foo,bar,baz", 1 314 + ; ",", "foo,bar,baz", 0 315 + ; ",\\|", "foo,bar|baz", 4 316 + ] 317 + |> List.iter ~f:(fun (re, s, n) -> 318 + bounded_full_split re s n; 319 + bounded_split re s n); 320 + [%expect {||}] 321 + ;; 322 + 323 + let%expect_test "split, full_split, split_delim" = 324 + [ "re", ""; " ", "foo bar"; "\b", "one-two three"; "[0-9]", "One3TwoFive" ] 325 + |> List.iter ~f:(fun (re, s) -> 326 + split re s; 327 + full_split re s; 328 + split_delim re s); 329 + [%expect {||}] 330 + ;;
+203
vendor/opam/re/lib_test/expect/test_stream.ml
··· 1 + open Import 2 + module Stream = Re.Stream 3 + 4 + let feed t str = 5 + let res = Stream.feed t str ~pos:0 ~len:(String.length str) in 6 + let () = 7 + match res with 8 + | No_match -> Printf.printf "%S did not match\n" str 9 + | Ok s -> 10 + let status = 11 + match Stream.finalize s "" ~pos:0 ~len:0 with 12 + | true -> "matched" 13 + | false -> "unmatched" 14 + in 15 + Printf.printf "%S not matched (status = %s)\n" str status 16 + in 17 + res 18 + ;; 19 + 20 + let%expect_test "out out of bounds" = 21 + let stream = Re.any |> Re.compile |> Stream.create in 22 + invalid_argument (fun () -> ignore (Stream.feed stream "foo" ~pos:2 ~len:3)); 23 + [%expect {| Invalid_argument "index out of bounds" |}]; 24 + invalid_argument (fun () -> ignore (Stream.finalize stream "foo" ~pos:2 ~len:3)); 25 + [%expect {| Invalid_argument "index out of bounds" |}]; 26 + let stream = Stream.Group.create stream in 27 + invalid_argument (fun () -> ignore (Stream.Group.feed stream "foo" ~pos:2 ~len:3)); 28 + [%expect {| Invalid_argument "index out of bounds" |}]; 29 + invalid_argument (fun () -> ignore (Stream.Group.finalize stream "foo" ~pos:2 ~len:3)); 30 + [%expect {| Invalid_argument "index out of bounds" |}] 31 + ;; 32 + 33 + let%expect_test "basic" = 34 + let s = [ Re.bos; Re.str "abab" ] |> Re.seq |> Re.compile |> Stream.create in 35 + ignore (feed s "x"); 36 + [%expect {| "x" did not match |}]; 37 + let suffix = "ab" in 38 + let s = 39 + match feed s suffix with 40 + | Ok s -> s 41 + | No_match -> assert false 42 + in 43 + [%expect {| 44 + "ab" not matched (status = unmatched) |}]; 45 + (let (_ : _ Stream.feed) = feed s "ab" in 46 + [%expect {| 47 + "ab" not matched (status = matched) |}]); 48 + let (_ : _ Stream.feed) = feed s "xy" in 49 + [%expect {| 50 + "xy" did not match |}] 51 + ;; 52 + 53 + let%expect_test "eos" = 54 + let s = [ Re.str "zzz"; Re.eos ] |> Re.seq |> Re.compile |> Stream.create in 55 + ignore (feed s "zzz"); 56 + [%expect {| "zzz" not matched (status = matched) |}]; 57 + let s = 58 + match feed s "z" with 59 + | Ok s -> s 60 + | No_match -> assert false 61 + in 62 + [%expect {| "z" not matched (status = unmatched) |}]; 63 + (let str = "zz" in 64 + match Stream.finalize s str ~pos:0 ~len:(String.length str) with 65 + | true -> () 66 + | false -> assert false); 67 + [%expect {||}] 68 + ;; 69 + 70 + let%expect_test "finalize empty" = 71 + let s = "abde" in 72 + let stream = 73 + let stream = Re.str s |> Re.whole_string |> Re.compile |> Stream.create in 74 + match feed stream s with 75 + | Ok s -> s 76 + | No_match -> assert false 77 + in 78 + assert (Stream.finalize stream "" ~pos:0 ~len:0); 79 + [%expect {| "abde" not matched (status = matched) |}] 80 + ;; 81 + 82 + let%expect_test "group - basic" = 83 + let s = 84 + let open Re in 85 + str "foo" |> whole_string |> group |> compile |> Stream.create 86 + in 87 + let g = Stream.Group.create s in 88 + let g = 89 + match Stream.Group.feed g "f" ~pos:0 ~len:1 with 90 + | No_match -> assert false 91 + | Ok s -> s 92 + in 93 + (match Stream.Group.finalize g "oo" ~pos:0 ~len:2 with 94 + | Ok _ -> () 95 + | No_match -> assert false); 96 + [%expect {| |}] 97 + ;; 98 + 99 + let pmarks set m = 100 + Printf.printf "mark present %b\n" (Re.Stream.Group.Match.test_mark set m) 101 + ;; 102 + 103 + let%expect_test "group - mark entire string must match" = 104 + let m1, f = Re.(mark (char 'f')) in 105 + let m2, oo = Re.(mark (str "oo")) in 106 + let re = 107 + let open Re in 108 + [ f; oo ] |> seq |> compile 109 + in 110 + let s = Stream.create re in 111 + let g = Stream.Group.create s in 112 + let g = 113 + match Stream.Group.feed g "f" ~pos:0 ~len:1 with 114 + | No_match -> assert false 115 + | Ok s -> s 116 + in 117 + let g = 118 + match Stream.Group.finalize g "oo" ~pos:0 ~len:2 with 119 + | Ok g -> g 120 + | No_match -> assert false 121 + in 122 + pmarks g m1; 123 + [%expect {| mark present true |}]; 124 + pmarks g m2; 125 + [%expect {| mark present true |}] 126 + ;; 127 + 128 + let%expect_test "group - partial mark match" = 129 + let m, foo = Re.(mark (str "foo")) in 130 + let re = Re.compile foo in 131 + let s = Stream.create re in 132 + let g = Stream.Group.create s in 133 + let g = 134 + match Stream.Group.feed g "xx" ~pos:0 ~len:2 with 135 + | No_match -> assert false 136 + | Ok g -> g 137 + in 138 + let g = 139 + match Stream.Group.feed g "foo" ~pos:0 ~len:3 with 140 + | Ok g -> g 141 + | No_match -> assert false 142 + in 143 + let g = 144 + match Stream.Group.finalize g "garb" ~pos:0 ~len:4 with 145 + | Ok g -> g 146 + | No_match -> assert false 147 + in 148 + pmarks g m; 149 + [%expect {| mark present true |}] 150 + ;; 151 + 152 + let print_match match_ n = 153 + match Stream.Group.Match.get match_ n with 154 + | None -> Printf.printf "match %d: <not found>\n" n 155 + | Some s -> Printf.printf "match %d: %s\n" n s 156 + ;; 157 + 158 + let%expect_test "group - match group" = 159 + let stream = 160 + let re = Re.Pcre.re "_([a-z]+)_" |> Re.whole_string |> Re.compile in 161 + Stream.Group.create (Stream.create re) 162 + in 163 + let s = "_abc_" in 164 + let () = 165 + match Stream.Group.finalize stream s ~pos:0 ~len:(String.length s) with 166 + | No_match -> assert false 167 + | Ok m -> 168 + for i = 0 to 1 do 169 + print_match m i 170 + done 171 + in 172 + [%expect {| 173 + match 0: _abc_ 174 + match 1: abc 175 + |}] 176 + ;; 177 + 178 + let%expect_test "group - match group" = 179 + let stream = 180 + let re = Re.Pcre.re "_([a-z]+)__([a-z]+)_" |> Re.whole_string |> Re.compile in 181 + Stream.Group.create (Stream.create re) 182 + in 183 + let s = "_abc_" in 184 + let stream = 185 + match Stream.Group.feed stream s ~pos:0 ~len:(String.length s) with 186 + | No_match -> assert false 187 + | Ok m -> m 188 + in 189 + let s = "_de_" in 190 + let () = 191 + match Stream.Group.finalize stream s ~pos:0 ~len:(String.length s) with 192 + | No_match -> assert false 193 + | Ok m -> 194 + for i = 0 to 2 do 195 + print_match m i 196 + done 197 + in 198 + [%expect {| 199 + match 0: _abc__de_ 200 + match 1: abc 201 + match 2: de 202 + |}] 203 + ;;
+12
vendor/opam/re/lib_test/expect/test_validation.ml
··· 1 + open Import 2 + 3 + let () = Printexc.record_backtrace false 4 + let any = Re.(compile (rep any)) 5 + 6 + let%expect_test "bound errors" = 7 + let (_ : bool) = Re.execp any ~pos:4 "foo" in 8 + [%expect {| |}]; 9 + let (_ : bool) = Re.execp any ~pos:1 ~len:3 "foo" in 10 + [%expect.unreachable] 11 + [@@expect.uncaught_exn {| (Invalid_argument "Re.exec: out of bounds") |}] 12 + ;;
+6
vendor/opam/re/lib_test/expect/test_view.ml
··· 1 + open Import 2 + 3 + let%expect_test "view" = 4 + let view = Re.View.view (Re.str "foo") in 5 + ignore view 6 + ;;
+46
vendor/opam/re/re.opam
··· 1 + # This file is generated by dune, edit dune-project instead 2 + opam-version: "2.0" 3 + synopsis: "RE is a regular expression library for OCaml" 4 + description: """ 5 + 6 + Pure OCaml regular expressions with: 7 + * Perl-style regular expressions (module Re.Perl) 8 + * Posix extended regular expressions (module Re.Posix) 9 + * Emacs-style regular expressions (module Re.Emacs) 10 + * Shell-style file globbing (module Re.Glob) 11 + * Compatibility layer for OCaml's built-in Str module (module Re.Str) 12 + """ 13 + maintainer: ["Rudi Grinberg <me@rgrinberg.com>"] 14 + authors: [ 15 + "Jerome Vouillon" 16 + "Thomas Gazagnaire" 17 + "Anil Madhavapeddy" 18 + "Rudi Grinberg" 19 + "Gabriel Radanne" 20 + ] 21 + license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" 22 + homepage: "https://github.com/ocaml/ocaml-re" 23 + bug-reports: "https://github.com/ocaml/ocaml-re/issues" 24 + depends: [ 25 + "dune" {>= "3.15"} 26 + "ocaml" {>= "4.08.0"} 27 + "ppx_expect" {with-test} 28 + "ounit2" {with-test} 29 + "js_of_ocaml" {with-test} 30 + "odoc" {with-doc} 31 + ] 32 + build: [ 33 + ["dune" "subst"] {dev} 34 + [ 35 + "dune" 36 + "build" 37 + "-p" 38 + name 39 + "-j" 40 + jobs 41 + "@install" 42 + "@runtest" {with-test} 43 + "@doc" {with-doc} 44 + ] 45 + ] 46 + dev-repo: "git+https://github.com/ocaml/ocaml-re.git"