Skip to content

Commit 3b4f441

Browse files
committed
initial dump: first pass at expression grammar and naive js port of @rsc's regexp.go
1 parent 215db6e commit 3b4f441

11 files changed

+1096
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
dist
3+
node_modules

Gruntfile.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module.exports = function(grunt) {
2+
grunt.initConfig({
3+
pkg: grunt.file.readJSON('package.json'),
4+
browserify: {
5+
dist: {
6+
src: [ 'src/<%= pkg.name %>.js' ],
7+
dest: 'dist/<%= pkg.name %>.js',
8+
options: {
9+
standalone: '<%= pkg.name %>'
10+
}
11+
},
12+
dist_min: {
13+
src: [ 'src/<%= pkg.name %>.js' ],
14+
dest: 'dist/<%= pkg.name %>.min.js',
15+
options: {
16+
standalone: '<%= pkg.name %>',
17+
transform: ['uglifyify']
18+
}
19+
}
20+
},
21+
clean: ["build", "dist"],
22+
jshint: {
23+
all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
24+
},
25+
nodeunit: {
26+
all: ['test/**/*_test.js']
27+
},
28+
peg: {
29+
options: { trackLineAndColumn: true },
30+
regex : {
31+
src: "src/regex.peg",
32+
dest: "build/regex-peg.js"
33+
}
34+
}
35+
});
36+
37+
grunt.loadNpmTasks('grunt-browserify');
38+
grunt.loadNpmTasks('grunt-contrib-clean');
39+
grunt.loadNpmTasks('grunt-contrib-jshint');
40+
grunt.loadNpmTasks('grunt-contrib-nodeunit');
41+
grunt.loadNpmTasks('grunt-contrib-uglify');
42+
grunt.loadNpmTasks('grunt-peg');
43+
44+
grunt.registerTask('build', ['clean', 'peg', 'browserify']);
45+
46+
grunt.registerTask('test', ['build', 'jshint', 'nodeunit']);
47+
48+
grunt.registerTask('default', ['test']);
49+
};

LICENSE

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Copyright (c) 2014, Bright Fulton
2+
All rights reserved.
3+
4+
Portions of this library are based on Code Search, which is available under the
5+
New BSD License and copyright by The Go Authors. Code Search can be found at
6+
https://code.google.com/p/codesearch/ with background and usage details provided
7+
by Russ Cox at http://swtch.com/~rsc/regexp/regexp4.html.
8+
9+
Redistribution and use in source and binary forms, with or without
10+
modification, are permitted provided that the following conditions are met:
11+
12+
* Redistributions of source code must retain the above copyright notice, this
13+
list of conditions and the following disclaimer.
14+
15+
* Redistributions in binary form must reproduce the above copyright notice,
16+
this list of conditions and the following disclaimer in the documentation
17+
and/or other materials provided with the distribution.
18+
19+
* Neither the name of [project] nor the names of its
20+
contributors may be used to endorse or promote products derived from
21+
this software without specific prior written permission.
22+
23+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

NOTICE

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
regex-trigram (including the regex-trigram.js and regex-trigram.min.js files) is
2+
licensed under the terms of the New BSD License, which is reproduced in the
3+
LICENSE file and online at:
4+
5+
https://github.com/bfulton/regex-trigram-js/blob/master/LICENSE
6+
7+
regex-trigram is distributed along with the third-party software that it depends
8+
on. Those dependencies are listed below along with their licensing terms. By
9+
installing and using regex-trigram, you are agreeing to the licensing terms
10+
that it is released under, as well as the licensing terms of the included
11+
third-party works.
12+
13+
#######################################################################
14+
## stringset 0.2.1
15+
## The MIT License (MIT)
16+
#######################################################################
17+
18+
Dependencies:
19+
"stringset": "~0.2.1"
20+
21+
URLs:
22+
https://github.com/olov/stringset
23+
24+
Local files:
25+
lib/ext/aws-java-sdk-1.7.7.jar
26+
27+
License URL:
28+
https://raw.githubusercontent.com/olov/stringset/master/LICENSE
29+
30+
License Text:
31+
Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
32+
33+
Permission is hereby granted, free of charge, to any person obtaining a copy
34+
of this software and associated documentation files (the "Software"), to deal
35+
in the Software without restriction, including without limitation the rights
36+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37+
copies of the Software, and to permit persons to whom the Software is
38+
furnished to do so, subject to the following conditions:
39+
40+
The above copyright notice and this permission notice shall be included in
41+
all copies or substantial portions of the Software.
42+
43+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
49+
THE SOFTWARE.
50+
51+
#######################################################################
52+

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
regex-trigram-js
2+
================
3+
4+
This project ports some ideas [Russ Cox](http://swtch.com/~rsc/) shared on
5+
[how Google Code Search works](http://swtch.com/~rsc/regexp/regexp4.html) — in
6+
particular the [`RegexpQuery` and related functions](https://code.google.com/p/codesearch/source/browse/index/regexp.go)
7+
from Go to JavaScript. Since JavaScript doesn't have an equivalent to Go's [`regexp/syntax`](http://golang.org/pkg/regexp/syntax/),
8+
we also use [PEG.js](http://pegjs.majda.cz/) to introduce a simplified regular
9+
expression grammar to obtain parse trees for a subset of valid [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
10+
patterns. The goal of this work is to enable JS clients an effective way to
11+
query Trigram indexes for candidate documents.

package.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "regex-trigram",
3+
"version": "0.0.1",
4+
"description": "JavaScript port of portions of Google Code Search",
5+
"author": "Bright Fulton",
6+
"main": "lib/regex.js",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/bfultonx/regex-trigram-js"
10+
},
11+
"bugs": {
12+
"url": "https://github.com/bfultonx/regex-trigram-js/issues"
13+
},
14+
"keywords": [
15+
"regex",
16+
"regexp",
17+
"trigram"
18+
],
19+
"dependencies": {
20+
"stringset": "~0.2.1"
21+
},
22+
"devDependencies": {
23+
"grunt": "~0.4.5",
24+
"grunt-browserify": "~3.0.1",
25+
"grunt-contrib-clean": "~0.6.0",
26+
"grunt-contrib-jshint": "~0.10.0",
27+
"grunt-contrib-nodeunit": "~0.4.1",
28+
"grunt-peg": "~1.5.0",
29+
"uglifyify": "~2.5.0"
30+
},
31+
"license": "BSD New"
32+
}

0 commit comments

Comments
 (0)