Comparing version 1.4.2 to 1.4.3
{ | ||
"name": "astq", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "Abstract Syntax Tree (AST) Query Engine", | ||
@@ -5,0 +5,0 @@ "main": "lib/astq.browser.js", |
@@ -31,2 +31,3 @@ /* | ||
grunt.loadNpmTasks("grunt-mocha-test"); | ||
grunt.loadNpmTasks("grunt-eslint"); | ||
grunt.loadNpmTasks("grunt-jscs"); | ||
@@ -43,2 +44,8 @@ | ||
}, | ||
eslint: { | ||
options: { | ||
config: "eslint.json" | ||
}, | ||
"astq": [ "src/**/*.js", "tst/**/*.js" ] | ||
}, | ||
jscs: { | ||
@@ -128,5 +135,5 @@ "astq": { | ||
grunt.registerTask("default", [ "jshint", "jscs", "browserify", "mochaTest" ]); | ||
grunt.registerTask("default", [ "jshint", "eslint", "jscs", "browserify", "mochaTest" ]); | ||
grunt.registerTask("test", [ "jshint:astq", "browserify:astq-node", "mochaTest" ]); | ||
}; | ||
{ | ||
"name": "astq", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "Abstract Syntax Tree (AST) Query Engine", | ||
@@ -26,3 +26,3 @@ "keywords": [ "abstract", "syntax", "tree", "query", "engine", "adaptable" ], | ||
"pegjs-util": "~1.0.3", | ||
"asty": "~1.1.2", | ||
"asty": "~1.1.3", | ||
"cache-lru": "~1.0.5" | ||
@@ -38,2 +38,4 @@ }, | ||
"grunt-mocha-test": "~0.12.7", | ||
"grunt-eslint": "~12.0.0", | ||
"babel-eslint": "~3.0.1", | ||
"mocha": "~2.2.4", | ||
@@ -40,0 +42,0 @@ "chai": "~2.2.0", |
@@ -31,22 +31,17 @@ | ||
ASTq is a Abstract Syntax Tree (AST) query engine library for | ||
ASTq is an Abstract Syntax Tree (AST) query engine library for | ||
JavaScript, i.e., it allows you to query nodes of an arbitary AST-style | ||
hierarchical data structure with the help of a powerful XPath-inspired | ||
query language. | ||
query language. ASTq can operate on arbitrary AST-style data structures | ||
through the help of pluggable access adapters. | ||
Usage | ||
----- | ||
Query Language | ||
-------------- | ||
The ASTq API, here assumed to be exposed through the variable `ASTQ`, | ||
provides the following methods (in a notation somewhat resembling | ||
TypeScript type definitions) is: | ||
### Selector/Query Domain Specific Language | ||
ASTq uses an XPath-inspired Domain Specific Language (DSL) | ||
for querying the supplied AST-style hierarchical data structure. | ||
#### By Example | ||
### By Example | ||
At its simplest form it looks like a POSIX filesystem path: | ||
At its simplest form, a query looks like a POSIX filesystem path: | ||
@@ -57,5 +52,6 @@ Foo/Bar/Quux | ||
are childs of nodes of type `Bar`, which in turn are childs of nodes of | ||
type `Foo`, which in turn has to be start node. | ||
type `Foo`, which in turn has to be the start node. | ||
A little bit sophisticated query, showing more of axis and a filter: | ||
A little bit more sophisticated query, showing more features, | ||
like axis, filter and optional whitespaces for padding: | ||
@@ -69,7 +65,10 @@ // Foo [ /Bar [ @bar == 'baz1' || @bar == 'baz2' ] && /Quux ] | ||
#### By Grammar | ||
### By Grammar | ||
In general a query consists of one or more individual query paths, | ||
In general, a query consists of one or more individual query paths, | ||
separated by comma. A path consists of a mandatory initial query step | ||
and optionally zero or more subsequent query steps: | ||
and optionally zero or more subsequent query steps. The difference | ||
between initial and subsequent query steps is | ||
that an initial query step does not need an axis while all subsequent | ||
query steps require it. | ||
@@ -81,5 +80,5 @@ query ::= path (, path)* | ||
A query step consists of an (optional) axis (direct/any child, | ||
direct/any left/right sibling or direct/any parent), a (mandatory) type | ||
match and an (optional) filter expression: | ||
A query step consists of an (optional) AST node search axis (direct/any child, | ||
direct/any left/right sibling or direct/any parent), a (mandatory) AST node type | ||
match and an (optional) AST node filter expression: | ||
@@ -90,9 +89,11 @@ axis ::= ("//" | "/" | "+//" | "+/" | "-//" | "-/" | "../" | "..//") (":" id)? | ||
The power comes through the optional filter expression: it can be | ||
applied to each query step and it recursively(!) can contain sub-queries! | ||
A combined example is: | ||
The real power comes through the optional filter expression: it can be | ||
applied to each query step and it recursively(!) can contain sub-queries | ||
with the help of embedded query paths! | ||
An illustrating combined example is: | ||
// Foo / Bar [ / Baz [ @bar == 'baz' ] && / Quux ], // Foo2 | ||
+------------------------------------------------+ +-----+ query | ||
+----+ +-----------------------------------------+ +-----+ path | ||
+---------------------------------------------------------+ query | ||
+------------------------------------------------+ +-----+ path | ||
+---------------------+ +-----+ path | ||
+----+ +-----------------------------------------+ +-----+ step | ||
@@ -147,2 +148,9 @@ ++ + + + ++ axis | ||
Application Programming Interface (API) | ||
--------------------------------------- | ||
The ASTq API, here assumed to be exposed through the variable `ASTQ`, | ||
provides the following methods (in a notation somewhat resembling | ||
TypeScript type definitions): | ||
### ASTQ API | ||
@@ -158,3 +166,3 @@ | ||
By default ASTq has built-in adapters for ASTy, XML DOM and Mozilla AST. | ||
Calling `adapter()` causes these to be removed with the custom adapter. | ||
Calling `adapter()` causes these three to be replaced with a single custom adapter. | ||
@@ -161,0 +169,0 @@ /* the built-in implementation for supporting ASTy */ |
@@ -177,3 +177,3 @@ /* | ||
let node = T | ||
while (true) { | ||
for (;;) { | ||
let parent = this.adapter.getParentNode(node, t) | ||
@@ -180,0 +180,0 @@ if (parent === null) |
@@ -25,2 +25,4 @@ /* | ||
/* eslint no-console: 0 */ | ||
import util from "./astq-util.js" | ||
@@ -27,0 +29,0 @@ |
@@ -27,2 +27,3 @@ /* | ||
/* global console: true */ | ||
/* eslint no-console: 0 */ | ||
@@ -29,0 +30,0 @@ /* load external dependencies */ |
@@ -28,2 +28,3 @@ /* | ||
/* jshint -W030 */ | ||
/* eslint no-unused-expressions: 0 */ | ||
@@ -30,0 +31,0 @@ var chai = require("chai") |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
497598
27
6957
276
16
Updatedasty@~1.1.3