re2 1.19.2 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/actions/linux-alpine-node-16/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-18/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-20/Dockerfile +1 -1
- package/.gitmodules +5 -2
- package/README.md +1 -0
- package/binding.gyp +82 -25
- package/lib/replace.cc +4 -4
- package/package.json +1 -1
- package/tsconfig.json +2 -1
- package/vendor/re2/.bazelrc +16 -0
- package/vendor/re2/.github/bazel.sh +24 -0
- package/vendor/re2/.github/cmake.sh +12 -0
- package/vendor/re2/.github/workflows/ci-bazel.yml +17 -0
- package/vendor/re2/.github/workflows/ci-cmake.yml +108 -0
- package/vendor/re2/.github/workflows/ci.yml +89 -0
- package/vendor/re2/.github/workflows/pr.yml +26 -0
- package/vendor/re2/.github/workflows/python.yml +185 -0
- package/vendor/re2/AUTHORS +13 -0
- package/vendor/re2/BUILD.bazel +280 -0
- package/vendor/re2/CMakeLists.txt +268 -0
- package/vendor/re2/CONTRIBUTING.md +2 -0
- package/vendor/re2/CONTRIBUTORS +41 -0
- package/vendor/re2/Makefile +400 -0
- package/vendor/{README → re2/README} +5 -0
- package/vendor/re2/SECURITY.md +4 -0
- package/vendor/re2/WORKSPACE.bazel +62 -0
- package/vendor/re2/app/BUILD.bazel +19 -0
- package/vendor/re2/app/_re2.cc +94 -0
- package/vendor/re2/app/_re2.d.ts +23 -0
- package/vendor/re2/app/app.ts +111 -0
- package/vendor/re2/app/build.sh +50 -0
- package/vendor/re2/app/index.html +5 -0
- package/vendor/re2/app/package.json +14 -0
- package/vendor/re2/app/rollup.config.js +28 -0
- package/vendor/re2/app/tsconfig.json +17 -0
- package/vendor/re2/benchlog/benchplot.py +98 -0
- package/vendor/re2/benchlog/mktable +155 -0
- package/vendor/re2/doc/mksyntaxgo +42 -0
- package/vendor/re2/doc/mksyntaxhtml +42 -0
- package/vendor/re2/doc/mksyntaxwiki +36 -0
- package/vendor/re2/doc/syntax.html +477 -0
- package/vendor/re2/doc/syntax.txt +463 -0
- package/vendor/re2/lib/git/commit-msg.hook +104 -0
- package/vendor/re2/libre2.symbols +19 -0
- package/vendor/re2/libre2.symbols.darwin +15 -0
- package/vendor/re2/python/BUILD.bazel +36 -0
- package/vendor/re2/python/README +1 -0
- package/vendor/re2/python/_re2.cc +338 -0
- package/vendor/re2/python/re2.py +582 -0
- package/vendor/re2/python/re2_test.py +482 -0
- package/vendor/re2/python/setup.py +105 -0
- package/vendor/re2/{bitmap256.cc → re2/bitmap256.cc} +4 -4
- package/vendor/re2/{bitstate.cc → re2/bitstate.cc} +21 -25
- package/vendor/re2/{compile.cc → re2/compile.cc} +5 -4
- package/vendor/re2/{dfa.cc → re2/dfa.cc} +120 -101
- package/vendor/re2/{filtered_re2.cc → re2/filtered_re2.cc} +8 -11
- package/vendor/re2/{filtered_re2.h → re2/filtered_re2.h} +5 -4
- package/vendor/re2/{fuzzing → re2/fuzzing}/re2_fuzzer.cc +4 -6
- package/vendor/re2/{mimics_pcre.cc → re2/mimics_pcre.cc} +0 -1
- package/vendor/re2/{nfa.cc → re2/nfa.cc} +34 -37
- package/vendor/re2/{onepass.cc → re2/onepass.cc} +25 -27
- package/vendor/re2/{parse.cc → re2/parse.cc} +118 -121
- package/vendor/re2/{prefilter.cc → re2/prefilter.cc} +2 -3
- package/vendor/re2/{prefilter.h → re2/prefilter.h} +0 -1
- package/vendor/re2/{prefilter_tree.cc → re2/prefilter_tree.cc} +4 -5
- package/vendor/re2/{prefilter_tree.h → re2/prefilter_tree.h} +1 -2
- package/vendor/re2/{prog.cc → re2/prog.cc} +20 -21
- package/vendor/re2/{prog.h → re2/prog.h} +21 -22
- package/vendor/re2/{re2.cc → re2/re2.cc} +51 -62
- package/vendor/re2/{re2.h → re2/re2.h} +78 -40
- package/vendor/re2/{regexp.cc → re2/regexp.cc} +11 -12
- package/vendor/re2/{regexp.h → re2/regexp.h} +9 -10
- package/vendor/re2/{set.cc → re2/set.cc} +3 -5
- package/vendor/re2/{set.h → re2/set.h} +4 -3
- package/vendor/re2/{simplify.cc → re2/simplify.cc} +1 -2
- package/vendor/re2/re2/stringpiece.h +24 -0
- package/vendor/re2/{testing → re2/testing}/backtrack.cc +22 -25
- package/vendor/re2/{testing → re2/testing}/charclass_test.cc +23 -21
- package/vendor/re2/{testing → re2/testing}/compile_test.cc +5 -4
- package/vendor/re2/{testing → re2/testing}/dfa_test.cc +36 -30
- package/vendor/re2/{testing → re2/testing}/dump.cc +8 -8
- package/vendor/re2/{testing → re2/testing}/exhaustive1_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive2_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive3_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive_tester.cc +36 -32
- package/vendor/re2/{testing → re2/testing}/exhaustive_tester.h +0 -1
- package/vendor/re2/{testing → re2/testing}/filtered_re2_test.cc +9 -8
- package/vendor/re2/{testing → re2/testing}/mimics_pcre_test.cc +3 -2
- package/vendor/re2/{testing → re2/testing}/null_walker.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/parse_test.cc +13 -12
- package/vendor/re2/{testing → re2/testing}/possible_match_test.cc +15 -14
- package/vendor/re2/{testing → re2/testing}/random_test.cc +13 -12
- package/vendor/re2/{testing → re2/testing}/re2_arg_test.cc +25 -2
- package/vendor/re2/{testing → re2/testing}/re2_test.cc +49 -47
- package/vendor/re2/{testing → re2/testing}/regexp_benchmark.cc +144 -145
- package/vendor/re2/{testing → re2/testing}/regexp_generator.cc +18 -14
- package/vendor/re2/{testing → re2/testing}/regexp_generator.h +3 -4
- package/vendor/re2/{testing → re2/testing}/regexp_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/required_prefix_test.cc +5 -4
- package/vendor/re2/{testing → re2/testing}/search_test.cc +3 -2
- package/vendor/re2/{testing → re2/testing}/set_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/simplify_test.cc +3 -2
- package/vendor/re2/{testing → re2/testing}/string_generator.cc +3 -3
- package/vendor/re2/{testing → re2/testing}/string_generator.h +5 -6
- package/vendor/re2/{testing → re2/testing}/string_generator_test.cc +2 -2
- package/vendor/re2/{testing → re2/testing}/tester.cc +77 -78
- package/vendor/re2/{testing → re2/testing}/tester.h +13 -15
- package/vendor/re2/{tostring.cc → re2/tostring.cc} +7 -8
- package/vendor/re2/{unicode_casefold.h → re2/unicode_casefold.h} +0 -1
- package/vendor/re2/{unicode_groups.h → re2/unicode_groups.h} +0 -1
- package/vendor/re2/{walker-inl.h → re2/walker-inl.h} +2 -1
- package/vendor/re2/re2.pc.in +9 -0
- package/vendor/re2/re2Config.cmake.in +28 -0
- package/vendor/re2/runtests +33 -0
- package/vendor/re2/testinstall.cc +27 -0
- package/vendor/re2/ucs2.diff +567 -0
- package/vendor/{util → re2/util}/logging.h +2 -2
- package/vendor/{util → re2/util}/pcre.cc +47 -116
- package/vendor/{util → re2/util}/pcre.h +53 -63
- package/vendor/re2/util/strutil.cc +26 -0
- package/vendor/{util → re2/util}/strutil.h +0 -5
- package/vendor/re2/stringpiece.cc +0 -65
- package/vendor/re2/stringpiece.h +0 -213
- package/vendor/util/benchmark.cc +0 -131
- package/vendor/util/benchmark.h +0 -156
- package/vendor/util/flags.h +0 -26
- package/vendor/util/mix.h +0 -41
- package/vendor/util/mutex.h +0 -164
- package/vendor/util/strutil.cc +0 -149
- package/vendor/util/test.cc +0 -34
- package/vendor/util/test.h +0 -50
- package/vendor/util/util.h +0 -42
- /package/vendor/{LICENSE → re2/LICENSE} +0 -0
- /package/vendor/re2/{bitmap256.h → re2/bitmap256.h} +0 -0
- /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/LICENSE +0 -0
- /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/include/fuzzer/FuzzedDataProvider.h +0 -0
- /package/vendor/re2/{make_perl_groups.pl → re2/make_perl_groups.pl} +0 -0
- /package/vendor/re2/{make_unicode_casefold.py → re2/make_unicode_casefold.py} +0 -0
- /package/vendor/re2/{make_unicode_groups.py → re2/make_unicode_groups.py} +0 -0
- /package/vendor/re2/{perl_groups.cc → re2/perl_groups.cc} +0 -0
- /package/vendor/re2/{pod_array.h → re2/pod_array.h} +0 -0
- /package/vendor/re2/{sparse_array.h → re2/sparse_array.h} +0 -0
- /package/vendor/re2/{sparse_set.h → re2/sparse_set.h} +0 -0
- /package/vendor/re2/{unicode.py → re2/unicode.py} +0 -0
- /package/vendor/re2/{unicode_casefold.cc → re2/unicode_casefold.cc} +0 -0
- /package/vendor/re2/{unicode_groups.cc → re2/unicode_groups.cc} +0 -0
- /package/vendor/{util → re2/util}/fuzz.cc +0 -0
- /package/vendor/{util → re2/util}/malloc_counter.h +0 -0
- /package/vendor/{util → re2/util}/rune.cc +0 -0
- /package/vendor/{util → re2/util}/utf.h +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright 2022 The RE2 Authors. All Rights Reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import {css, html, LitElement, render} from 'lit';
|
|
6
|
+
import {customElement} from 'lit/decorators.js';
|
|
7
|
+
|
|
8
|
+
import /*default*/ loadModule from './_re2';
|
|
9
|
+
import {Info, MainModule} from './_re2';
|
|
10
|
+
|
|
11
|
+
var _re2: MainModule;
|
|
12
|
+
loadModule().then((module: MainModule) => {
|
|
13
|
+
_re2 = module;
|
|
14
|
+
render(html`<title>re2-dev</title><re2-dev></re2-dev>`, document.body);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
@customElement('re2-dev')
|
|
18
|
+
export class RE2Dev extends LitElement {
|
|
19
|
+
private _pattern: string = '';
|
|
20
|
+
private _info: Info|null = null;
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this._pattern = decodeURIComponent(window.location.hash.slice(1));
|
|
25
|
+
this._info = this._pattern ? _re2.getInfo(this._pattern) : null;
|
|
26
|
+
this.requestUpdate();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private _onChange = (e: Event) => {
|
|
30
|
+
this._pattern = (e.target as HTMLInputElement).value;
|
|
31
|
+
this._info = this._pattern ? _re2.getInfo(this._pattern) : null;
|
|
32
|
+
this.requestUpdate();
|
|
33
|
+
window.location.hash = '#' + encodeURIComponent(this._pattern);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
static override styles = css`
|
|
37
|
+
.code {
|
|
38
|
+
font-family: monospace;
|
|
39
|
+
white-space: pre-line;
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
override render() {
|
|
44
|
+
var fragments = [];
|
|
45
|
+
fragments.push(html`
|
|
46
|
+
<div>
|
|
47
|
+
<input type="text" size="48" @change=${this._onChange} .value=${this._pattern}>
|
|
48
|
+
</div>
|
|
49
|
+
`);
|
|
50
|
+
|
|
51
|
+
if (this._info === null) {
|
|
52
|
+
return html`${fragments}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this._info.error) {
|
|
56
|
+
fragments.push(html`
|
|
57
|
+
<br>
|
|
58
|
+
<div>
|
|
59
|
+
error:
|
|
60
|
+
<span class="code">${this._info.error}</span>
|
|
61
|
+
</div>
|
|
62
|
+
`);
|
|
63
|
+
return html`${fragments}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fragments.push(html`
|
|
67
|
+
<br>
|
|
68
|
+
<div>
|
|
69
|
+
pattern:
|
|
70
|
+
<span class="code">${this._info.pattern}</span>
|
|
71
|
+
<br>
|
|
72
|
+
prefix:
|
|
73
|
+
<span class="code">${this._info.prefix}</span>
|
|
74
|
+
·
|
|
75
|
+
_foldcase:
|
|
76
|
+
<span class="code">${this._info.prefix_foldcase}</span>
|
|
77
|
+
<br>
|
|
78
|
+
accel_prefix:
|
|
79
|
+
<span class="code">${this._info.accel_prefix}</span>
|
|
80
|
+
·
|
|
81
|
+
_foldcase:
|
|
82
|
+
<span class="code">${this._info.accel_prefix_foldcase}</span>
|
|
83
|
+
<br>
|
|
84
|
+
num_captures:
|
|
85
|
+
<span class="code">${this._info.num_captures}</span>
|
|
86
|
+
<br>
|
|
87
|
+
is_one_pass:
|
|
88
|
+
<span class="code">${this._info.is_one_pass}</span>
|
|
89
|
+
<br>
|
|
90
|
+
can_bit_state:
|
|
91
|
+
<span class="code">${this._info.can_bit_state}</span>
|
|
92
|
+
<br>
|
|
93
|
+
<br>
|
|
94
|
+
bytecode:
|
|
95
|
+
<br>
|
|
96
|
+
<span class="code">${this._info.bytecode}</span>
|
|
97
|
+
<br>
|
|
98
|
+
bytemap:
|
|
99
|
+
<br>
|
|
100
|
+
<span class="code">${this._info.bytemap}</span>
|
|
101
|
+
</div>
|
|
102
|
+
`);
|
|
103
|
+
return html`${fragments}`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare global {
|
|
108
|
+
interface HTMLElementTagNameMap {
|
|
109
|
+
're2-dev': RE2Dev;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -eux
|
|
3
|
+
|
|
4
|
+
SRCDIR=$(readlink --canonicalize $(dirname $0))
|
|
5
|
+
DSTDIR=$(mktemp --directory --tmpdir $(basename $0).XXXXXXXXXX)
|
|
6
|
+
|
|
7
|
+
BAZEL=/tmp/bazel
|
|
8
|
+
BAZELISK_RELEASE=v1.16.0
|
|
9
|
+
|
|
10
|
+
if [[ ${UID} -ne 0 ]]; then
|
|
11
|
+
if [[ -d deploy ]]; then
|
|
12
|
+
echo -e '\033[1;31m' "** The ${PWD}/deploy directory exists! Refusing to clobber it! **" '\033[0m'
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
mkdir deploy
|
|
16
|
+
sudo docker run -i -t --pull always --rm -v ${SRCDIR}/..:/src -v ${PWD}:/dst emscripten/emsdk /src/app/$(basename $0)
|
|
17
|
+
ls -l deploy
|
|
18
|
+
else
|
|
19
|
+
wget -O ${BAZEL} https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_RELEASE}/bazelisk-linux-amd64
|
|
20
|
+
chmod +x ${BAZEL}
|
|
21
|
+
|
|
22
|
+
cd ${SRCDIR}
|
|
23
|
+
# Emscripten doesn't support `-fstack-protector`.
|
|
24
|
+
AR=emar CC=emcc \
|
|
25
|
+
${BAZEL} build --compilation_mode=opt \
|
|
26
|
+
--copt=-fno-stack-protector \
|
|
27
|
+
-- :all
|
|
28
|
+
# Bazel doesn't retain the `_re2.wasm` artifact;
|
|
29
|
+
# we have to redo the link command to obtain it.
|
|
30
|
+
pushd ..
|
|
31
|
+
emcc @bazel-bin/app/_re2.js-2.params
|
|
32
|
+
cd bazel-bin/app
|
|
33
|
+
cp _re2.js _re2.wasm ${DSTDIR}
|
|
34
|
+
popd
|
|
35
|
+
# Clean up the sundry Bazel output directories.
|
|
36
|
+
${BAZEL} clean --expunge
|
|
37
|
+
cp app.ts index.html _re2.d.ts ${DSTDIR}
|
|
38
|
+
cp package.json rollup.config.js tsconfig.json ${DSTDIR}
|
|
39
|
+
|
|
40
|
+
cd ${DSTDIR}
|
|
41
|
+
npm install
|
|
42
|
+
npx tsc
|
|
43
|
+
npx rollup -c rollup.config.js -d deploy
|
|
44
|
+
mv deploy/* /dst/deploy
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
cd ${SRCDIR}
|
|
48
|
+
rm -rf ${DSTDIR}
|
|
49
|
+
|
|
50
|
+
exit 0
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"lit": "*"
|
|
4
|
+
},
|
|
5
|
+
"devDependencies": {
|
|
6
|
+
"@rollup/plugin-node-resolve": "*",
|
|
7
|
+
"@rollup/plugin-terser": "*",
|
|
8
|
+
"@web/rollup-plugin-html": "*",
|
|
9
|
+
"@web/rollup-plugin-import-meta-assets": "*",
|
|
10
|
+
"rollup": "~2",
|
|
11
|
+
"tslib": "*",
|
|
12
|
+
"typescript": "*"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2022 The RE2 Authors. All Rights Reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
6
|
+
import terser from '@rollup/plugin-terser';
|
|
7
|
+
import html from '@web/rollup-plugin-html';
|
|
8
|
+
import {importMetaAssets} from '@web/rollup-plugin-import-meta-assets';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
input: 'index.html',
|
|
12
|
+
output: {
|
|
13
|
+
entryFileNames: '[hash].js',
|
|
14
|
+
chunkFileNames: '[hash].js',
|
|
15
|
+
assetFileNames: '[hash][extname]',
|
|
16
|
+
format: 'es',
|
|
17
|
+
},
|
|
18
|
+
preserveEntrySignatures: false,
|
|
19
|
+
plugins:
|
|
20
|
+
[
|
|
21
|
+
html({
|
|
22
|
+
minify: true,
|
|
23
|
+
}),
|
|
24
|
+
nodeResolve(),
|
|
25
|
+
terser(),
|
|
26
|
+
importMetaAssets(),
|
|
27
|
+
],
|
|
28
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"noEmitOnError": true,
|
|
7
|
+
"lib": ["esnext", "dom"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": false,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"importHelpers": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"inlineSources": true,
|
|
15
|
+
"incremental": true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
import argparse # for ArgumentParser
|
|
4
|
+
import subprocess # for Popen
|
|
5
|
+
import tempfile # for NamedTemporaryFile
|
|
6
|
+
import os # for remove
|
|
7
|
+
|
|
8
|
+
class gnuplot(object):
|
|
9
|
+
|
|
10
|
+
output = "result.png"
|
|
11
|
+
|
|
12
|
+
script = """
|
|
13
|
+
set terminal png size 1024, 768
|
|
14
|
+
set output "{}.png"
|
|
15
|
+
set title "re2 benchlog"
|
|
16
|
+
set datafile separator ";"
|
|
17
|
+
set grid x y
|
|
18
|
+
set ylabel "MB/s"
|
|
19
|
+
set autoscale
|
|
20
|
+
plot """
|
|
21
|
+
|
|
22
|
+
template = """'{}' using 1:5:xticlabels(2) with linespoints linewidth 3 title "{}",\\\n"""
|
|
23
|
+
|
|
24
|
+
benchdata = dict()
|
|
25
|
+
tempfiles = []
|
|
26
|
+
|
|
27
|
+
def __enter__(self):
|
|
28
|
+
return self
|
|
29
|
+
|
|
30
|
+
def __exit__(self, type, value, traceback):
|
|
31
|
+
"""
|
|
32
|
+
remove all temporary files
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
for filename in self.tempfiles:
|
|
36
|
+
os.remove(filename)
|
|
37
|
+
|
|
38
|
+
def parse_re2_benchlog(self, filename):
|
|
39
|
+
"""
|
|
40
|
+
parse the input benchlog and return a dictionary contain bench data
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
benchdata = self.benchdata
|
|
44
|
+
|
|
45
|
+
with open(filename) as f:
|
|
46
|
+
|
|
47
|
+
for raw in f.readlines():
|
|
48
|
+
|
|
49
|
+
data = raw.split('\t')
|
|
50
|
+
|
|
51
|
+
if len(data) == 4:
|
|
52
|
+
|
|
53
|
+
data = data[0].split('/') + data[1:]
|
|
54
|
+
data = list(map(str.strip, data))
|
|
55
|
+
|
|
56
|
+
if not benchdata.get(data[0]):
|
|
57
|
+
benchdata[data[0]] = [ data[1:] ]
|
|
58
|
+
else:
|
|
59
|
+
benchdata[data[0]].append(data[1:])
|
|
60
|
+
|
|
61
|
+
def gen_csv(self):
|
|
62
|
+
"""
|
|
63
|
+
generate temporary csv files
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
for name, data in self.benchdata.items():
|
|
67
|
+
|
|
68
|
+
with tempfile.NamedTemporaryFile(delete=False) as f:
|
|
69
|
+
|
|
70
|
+
for index, line in enumerate(data):
|
|
71
|
+
f.write('{};{}\n'.format(index, ';'.join(line)).encode())
|
|
72
|
+
|
|
73
|
+
self.tempfiles.append(f.name)
|
|
74
|
+
self.script = self.script + self.template.format(f.name, name)
|
|
75
|
+
|
|
76
|
+
def run(self):
|
|
77
|
+
self.gen_csv()
|
|
78
|
+
script = self.script[:-3].format(self.output)
|
|
79
|
+
command = subprocess.Popen(['gnuplot'], stdin=subprocess.PIPE)
|
|
80
|
+
command.communicate(script.encode())
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if __name__ == '__main__':
|
|
84
|
+
|
|
85
|
+
parser = argparse.ArgumentParser(description='generate plots for benchlog')
|
|
86
|
+
parser.add_argument('benchlog', type=str, help='benchlog generated by re2')
|
|
87
|
+
args = parser.parse_args()
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
subprocess.Popen(['gnuplot'], stdin=subprocess.PIPE)
|
|
91
|
+
except FileNotFoundError:
|
|
92
|
+
print('you can install "gnuplot" to generate plots automatically')
|
|
93
|
+
exit(1)
|
|
94
|
+
|
|
95
|
+
with gnuplot() as plot:
|
|
96
|
+
plot.output = args.benchlog
|
|
97
|
+
plot.parse_re2_benchlog(args.benchlog)
|
|
98
|
+
plot.run()
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/perl
|
|
2
|
+
# XXX
|
|
3
|
+
|
|
4
|
+
sub table() {
|
|
5
|
+
my ($name) = @_;
|
|
6
|
+
print <<'EOF';
|
|
7
|
+
<table border=0>
|
|
8
|
+
<tr><th>System</th><th>PCRE</th><th>RE2</th></tr>
|
|
9
|
+
EOF
|
|
10
|
+
foreach my $sys (@sys) {
|
|
11
|
+
my $ns_pcre = $data{$sys}->{sprintf($name, "PCRE")}->{'ns/op'};
|
|
12
|
+
my $ns_re2 = $data{$sys}->{sprintf($name, "RE2")}->{'ns/op'};
|
|
13
|
+
printf "<tr><td>%s</td><td>%.1f µs</td><td>%.1f µs</td></tr>\n", $sysname{$sys}, $ns_pcre/1000., $ns_re2/1000.;
|
|
14
|
+
}
|
|
15
|
+
print <<'EOF';
|
|
16
|
+
<tr height=5><td colspan=3></td></tr>
|
|
17
|
+
</table>
|
|
18
|
+
EOF
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@sizes = (
|
|
22
|
+
"8", "16", "32", "64", "128", "256", "512",
|
|
23
|
+
"1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K",
|
|
24
|
+
"1M", "2M", "4M", "8M", "16M"
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
%color = (
|
|
28
|
+
"PCRE" => "0.7 0 0",
|
|
29
|
+
"RE2" => "0 0 1",
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
$ngraph = 0;
|
|
33
|
+
|
|
34
|
+
sub graph() {
|
|
35
|
+
my ($name) = @_;
|
|
36
|
+
|
|
37
|
+
my $sys = "wreck";
|
|
38
|
+
my $base = sprintf("regexp3g%d", ++$ngraph);
|
|
39
|
+
|
|
40
|
+
open(JGR, ">$base.jgr") || die "open >$base.jgr: $!";
|
|
41
|
+
printf JGR "bbox -20 -12 392 95\n";
|
|
42
|
+
printf JGR "newgraph clip x_translate 0.25 y_translate 0.25\n";
|
|
43
|
+
$ymax = 0;
|
|
44
|
+
%lastx = ();
|
|
45
|
+
%lasty = ();
|
|
46
|
+
foreach my $who ("PCRE", "RE2") {
|
|
47
|
+
printf JGR "newcurve pts\n";
|
|
48
|
+
for(my $i=0; $i<@sizes; $i++) {
|
|
49
|
+
my $key = sprintf("%s%s/%s", $name, $who, $sizes[$i]);
|
|
50
|
+
my $val = $data{$sys}->{$key}->{'MB/s'};
|
|
51
|
+
next if !defined($val);
|
|
52
|
+
if($val > $ymax) {
|
|
53
|
+
$ymax = $val;
|
|
54
|
+
}
|
|
55
|
+
$lastx{$who} = $i;
|
|
56
|
+
$lasty{$who} = $val;
|
|
57
|
+
printf JGR "$i %f (* %s *)\n", $val, $key;
|
|
58
|
+
}
|
|
59
|
+
my $color = $color{$who};
|
|
60
|
+
printf JGR "marktype none color $color linethickness 2 linetype solid label : $who\n";
|
|
61
|
+
}
|
|
62
|
+
my $n = @sizes;
|
|
63
|
+
printf JGR "xaxis min -1 max $n size 5 label : text size (bytes)\n";
|
|
64
|
+
printf JGR " no_auto_hash_marks hash_labels fontsize 9\n";
|
|
65
|
+
for($i=0; $i<@sizes; $i+=3) {
|
|
66
|
+
printf JGR " hash_at $i hash_label at $i : $sizes[$i]\n";
|
|
67
|
+
}
|
|
68
|
+
my $y = 1;
|
|
69
|
+
while(10*$y <= $ymax) {
|
|
70
|
+
$y = 10*$y;
|
|
71
|
+
}
|
|
72
|
+
for($i=2; $i<=10; $i++) {
|
|
73
|
+
if($i*$y > $ymax) {
|
|
74
|
+
$y = $i*$y;
|
|
75
|
+
last;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
foreach my $who ("PCRE", "RE2") {
|
|
79
|
+
$x1 = $lastx{$who};
|
|
80
|
+
$y1 = $lasty{$who};
|
|
81
|
+
$x1 *= 1.01;
|
|
82
|
+
my $v = "vjc";
|
|
83
|
+
if($y1 < 0.05 * $y) {
|
|
84
|
+
$v = "vjb";
|
|
85
|
+
$y1 = 0.05 * $y;
|
|
86
|
+
}
|
|
87
|
+
printf JGR "newstring x $x1 y $y1 hjl $v : $who\n";
|
|
88
|
+
}
|
|
89
|
+
printf JGR "yaxis min 0 max $y size 1 label : speed (MB/s)\n";
|
|
90
|
+
printf JGR " hash_labels fontsize 9\n";
|
|
91
|
+
# printf JGR "legend defaults font Times-Roman fontsize 10 x 0 y $y hjl vjt\n";
|
|
92
|
+
|
|
93
|
+
system("jgraph $base.jgr >$base.eps"); # die "system: $!";
|
|
94
|
+
system("gs -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dEPSCrop -sDEVICE=png16m -r100 -sOutputFile=$base.png -dBATCH -dQUIT -dQUIET -dNOPAUSE $base.eps");
|
|
95
|
+
|
|
96
|
+
printf "<img src=$base.png>\n"
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
sub skip() {
|
|
101
|
+
while(<>) {
|
|
102
|
+
if(/^<!-- -->/) {
|
|
103
|
+
print;
|
|
104
|
+
last;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@sys = ("r70", "c2", "wreck", "mini");
|
|
110
|
+
%sysname = (
|
|
111
|
+
"r70" => "AMD Opteron 8214 HE, 2.2 GHz",
|
|
112
|
+
"c2" => "Intel Core2 Duo E7200, 2.53 GHz",
|
|
113
|
+
"wreck" => "Intel Xeon 5150, 2.66 GHz (Mac Pro)",
|
|
114
|
+
"mini" => "Intel Core2 T5600, 1.83 GHz (Mac Mini)",
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
%func = (
|
|
118
|
+
"table" => \&table,
|
|
119
|
+
"graph" => \&graph,
|
|
120
|
+
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
foreach my $sys (@sys) {
|
|
124
|
+
open(F, "benchlog.$sys") || die "open benchlog.$sys: $!";
|
|
125
|
+
my %sysdat;
|
|
126
|
+
while(<F>) {
|
|
127
|
+
if(/^([A-Za-z0-9_\/]+)\s+(\d+)\s+(\d+) ns\/op/) {
|
|
128
|
+
my %row;
|
|
129
|
+
$row{"name"} = $1;
|
|
130
|
+
$row{"iter"} = $2;
|
|
131
|
+
$row{"ns/op"} = $3;
|
|
132
|
+
if(/([\d.]+) MB\/s/){
|
|
133
|
+
$row{"MB/s"} = $1;
|
|
134
|
+
}
|
|
135
|
+
$sysdat{$row{"name"}} = \%row;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
close F;
|
|
139
|
+
$data{$sys} = \%sysdat;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
while(<>) {
|
|
143
|
+
print;
|
|
144
|
+
if(/^<!-- benchlog (\w+) -->/) {
|
|
145
|
+
$func{$1}();
|
|
146
|
+
skip();
|
|
147
|
+
next;
|
|
148
|
+
}
|
|
149
|
+
if(/^<!-- benchlog (\w+) ([%\w]+) -->/) {
|
|
150
|
+
$func{$1}($2);
|
|
151
|
+
skip();
|
|
152
|
+
next;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
out=$GOROOT/src/regexp/syntax/doc.go
|
|
5
|
+
cp syntax.txt $out
|
|
6
|
+
sam -d $out <<'!'
|
|
7
|
+
,x g/NOT SUPPORTED/d
|
|
8
|
+
/^Unicode character class/,$d
|
|
9
|
+
,s/[«»]//g
|
|
10
|
+
,x g/^Possessive repetitions:/d
|
|
11
|
+
,x g/\\C/d
|
|
12
|
+
,x g/Flag syntax/d
|
|
13
|
+
,s/.=(true|false)/flag &/g
|
|
14
|
+
,s/^Flags:/ Flag syntax is xyz (set) or -xyz (clear) or xy-z (set xy, clear z). The flags are:\n/
|
|
15
|
+
,s/\n\n\n+/\n\n/g
|
|
16
|
+
,x/(^.* .*\n)+/ | awk -F' ' '{printf(" %-14s %s\n", $1, $2)}'
|
|
17
|
+
1,2c
|
|
18
|
+
// Copyright 2012 The Go Authors. All rights reserved.
|
|
19
|
+
// Use of this source code is governed by a BSD-style
|
|
20
|
+
// license that can be found in the LICENSE file.
|
|
21
|
+
|
|
22
|
+
// DO NOT EDIT. This file is generated by mksyntaxgo from the RE2 distribution.
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
Package syntax parses regular expressions into parse trees and compiles
|
|
26
|
+
parse trees into programs. Most clients of regular expressions will use the
|
|
27
|
+
facilities of package regexp (such as Compile and Match) instead of this package.
|
|
28
|
+
|
|
29
|
+
Syntax
|
|
30
|
+
|
|
31
|
+
The regular expression syntax understood by this package when parsing with the Perl flag is as follows.
|
|
32
|
+
Parts of the syntax can be disabled by passing alternate flags to Parse.
|
|
33
|
+
|
|
34
|
+
.
|
|
35
|
+
$a
|
|
36
|
+
Unicode character classes are those in unicode.Categories and unicode.Scripts.
|
|
37
|
+
*/
|
|
38
|
+
package syntax
|
|
39
|
+
.
|
|
40
|
+
w
|
|
41
|
+
q
|
|
42
|
+
!
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
cp syntax.txt syntax.html
|
|
4
|
+
sam -d syntax.html <<'!'
|
|
5
|
+
,s/\&/\&/g
|
|
6
|
+
,s/</\</g
|
|
7
|
+
,s/>/\>/g
|
|
8
|
+
,s!== (([^()]|\([^()]*\))*)!≡ <code>\1</code>!g
|
|
9
|
+
,s!«!<code>!g
|
|
10
|
+
,s!»!</code>!g
|
|
11
|
+
,s! vim$! <font size=-2>VIM</font>!g
|
|
12
|
+
,s! pcre$! <font size=-2>PCRE</font>!g
|
|
13
|
+
,s! perl$! <font size=-2>PERL</font>!g
|
|
14
|
+
,x g/NOT SUPPORTED/ s!^[^ ]+!<font color=#808080>&</font>!
|
|
15
|
+
,s!NOT SUPPORTED!!g
|
|
16
|
+
,s!(^[^ ]+) (.*)\n!<tr><td><code>\1</code></td><td>\2</td></tr>\n!g
|
|
17
|
+
,s!.*:$!<b>&</b>!g
|
|
18
|
+
,s!^$!<tr><td></td></tr>!g
|
|
19
|
+
,x v/<tr>/ s!.*!<tr><td colspan=2>&</td></tr>!
|
|
20
|
+
1,2c
|
|
21
|
+
<html>
|
|
22
|
+
<!-- AUTOMATICALLY GENERATED by mksyntaxhtml -->
|
|
23
|
+
<head>
|
|
24
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
25
|
+
<title>RE2 regular expression syntax reference</title>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<h1>RE2 regular expression syntax reference</h1>
|
|
29
|
+
|
|
30
|
+
<table border=0 cellpadding=2 cellspacing=2>
|
|
31
|
+
<tr><td colspan=2>This page lists the regular expression syntax accepted by RE2.</td></tr>
|
|
32
|
+
<tr><td colspan=2>It also lists syntax accepted by PCRE, PERL, and VIM.</td></tr>
|
|
33
|
+
<tr><td colspan=2>Grayed out expressions are not supported by RE2.</td></tr>
|
|
34
|
+
.
|
|
35
|
+
$a
|
|
36
|
+
</table>
|
|
37
|
+
</body>
|
|
38
|
+
</html>
|
|
39
|
+
.
|
|
40
|
+
w
|
|
41
|
+
q
|
|
42
|
+
!
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
cp syntax.txt syntax.wiki
|
|
4
|
+
sam -d syntax.wiki <<'!'
|
|
5
|
+
,s!`!`````!g
|
|
6
|
+
,s!== (([^()]|\([^()]*\))*)!≡ `\1`!g
|
|
7
|
+
,s!«!`!g
|
|
8
|
+
,s!»!`!g
|
|
9
|
+
,s! vim$! <font size="1">VIM</font>!g
|
|
10
|
+
,s! pcre$! <font size="1">PCRE</font>!g
|
|
11
|
+
,s! perl$! <font size="1">PERL</font>!g
|
|
12
|
+
,s!(^[^ ]+) (.*)\n!`\1` \2\n!g
|
|
13
|
+
,x g/NOT SUPPORTED/ s!^[^ ]+!<font color="#808080">&</font>!
|
|
14
|
+
,s!NOT SUPPORTED!<font size="1">(&)</font>!g
|
|
15
|
+
,s!(^[^ ]+) (.*)\n!<tr><td>\1</td><td>\2</td></tr>\n!g
|
|
16
|
+
,s!.*:$!<b>&</b>!g
|
|
17
|
+
,s!^$!<tr><td></td></tr>!g
|
|
18
|
+
,x v/<tr>/ s!.*!<tr><td colspan="2">&</td></tr>!
|
|
19
|
+
1,2c
|
|
20
|
+
#summary I define UNIX as “30 definitions of regular expressions living under one roof.” —Don Knuth
|
|
21
|
+
|
|
22
|
+
<wiki:comment>
|
|
23
|
+
GENERATED BY mksyntaxwiki. DO NOT EDIT
|
|
24
|
+
</wiki:comment>
|
|
25
|
+
|
|
26
|
+
<table border="0" cellpadding="2" cellspacing="2">
|
|
27
|
+
<tr><td colspan="2">This page lists the regular expression syntax accepted by RE2.</td></tr>
|
|
28
|
+
<tr><td colspan="2">It also lists syntax accepted by PCRE, PERL, and VIM.</td></tr>
|
|
29
|
+
<tr><td colspan="2">Grayed out expressions are not supported by RE2.</td></tr>
|
|
30
|
+
.
|
|
31
|
+
$a
|
|
32
|
+
</table>
|
|
33
|
+
.
|
|
34
|
+
w
|
|
35
|
+
q
|
|
36
|
+
!
|