Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
gkz committed Nov 2, 2013
0 parents commit ff0c722
Show file tree
Hide file tree
Showing 17 changed files with 1,108 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
*.swp
node_modules
coverage
*.t
3 changes: 3 additions & 0 deletions .travis.yml
@@ -0,0 +1,3 @@
language: node_js
node_js:
- 0.8
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
Copyright (c) George Zahariev

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
42 changes: 42 additions & 0 deletions Makefile
@@ -0,0 +1,42 @@
default: all

SRC = $(shell find src -name "*.ls" -type f | sort)
LIB = $(SRC:src/%.ls=lib/%.js)

LS = node_modules/LiveScript
LSC = node_modules/.bin/lsc
MOCHA = node_modules/.bin/mocha
MOCHA2 = node_modules/.bin/_mocha
ISTANBUL = node_modules/.bin/istanbul

package.json: package.json.ls
$(LSC) --compile package.json.ls

lib:
mkdir lib/

lib/%.js: src/%.ls lib
$(LSC) --compile --output lib "$<"

.PHONY: build test coverage dev-install loc clean

all: build

build: $(LIB) package.json

test: build
$(MOCHA) --reporter dot --ui tdd --compilers ls:$(LS)

coverage: build
$(ISTANBUL) cover $(MOCHA2) -- --reporter dot --ui tdd --compilers ls:$(LS)

install: package.json
npm install .

loc:
wc -l $(SRC)

clean:
rm -f package.json
rm -rf lib
rm -rf coverage
22 changes: 22 additions & 0 deletions README.md
@@ -0,0 +1,22 @@
# grasp equery
A query engine for [grasp](http://graspjs.com) - use JavaScript code examples with wildcards.

For documentation on the selector format, see [the grasp page on equery](http://graspjs.com/docs/equery).

See also the other query engine for grasp: [squery](https://github.com/gkz/grasp-squery).

## Usage

Add `grasp-equery` to your `package.json`, and then require it: `var equery = require('grasp-equery);`.

The `squery` object exposes four properties: three functions, `parse`, `queryParsed`, `query`, and the version string as `VERSION`.

Use `parse(selector)` to parse a string selector into a parsed selector.

Use `queryParsed(parsedSelector, ast)` to query your parsed selector.

`query(selector, ast)` is shorthand for doing `queryParsed(parse(selector), ast)`.

The AST must be in the [Mozilla SpiderMonkey AST format](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API) - you can use [acorn](https://github.com/marijnh/acorn) to parse a JavaScript file into the format.

If you are using one selector for multiple ASTs, parse it first, and then feed the parsed version to `queryParsed`. If you are only using the selector once, just use `query`.
20 changes: 20 additions & 0 deletions lib/common.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

136 changes: 136 additions & 0 deletions lib/match.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ff0c722

Please sign in to comment.