Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "apg-exp", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Pattern-matching tool similar to RegExp, except uses ABNF grammar instead of regular expressions.", | ||
@@ -5,0 +5,0 @@ "main": "./src/apg-exp.js", |
# apg-exp - APG Expressions | ||
`apg-exp` is a regex-like pattern-matching engine that uses an [ABNF syntax](https://tools.ietf.org/html/rfc5234) for the pattern definitions and [**APG**](https://github.com/ldthomas/apg-js2) to create and apply the pattern-matching parser. By way of introduction, the [regex Wikipedia article](https://en.wikipedia.org/wiki/Regular_expression) would be a good start and Jeffrey Friedl's book, [*Mastering Regular Expressions*](http://www.amazon.com/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124) would be a lot better and more complete. This introduction is will just mention features, a little on motivation and try to point out some possible advantages to `apg-exp`. | ||
`apg-exp` is a regex-like pattern-matching engine that uses a superset of the [ABNF syntax](https://tools.ietf.org/html/rfc5234) for the pattern definitions and [**APG**](https://github.com/ldthomas/apg-js2) to create and apply the pattern-matching parser. By way of introduction, the [regex Wikipedia article](https://en.wikipedia.org/wiki/Regular_expression) would be a good start and Jeffrey Friedl's book, [*Mastering Regular Expressions*](http://www.amazon.com/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124) would be a lot better and more complete. This introduction will just mention features, a little on motivation and try to point out some possible advantages to `apg-exp`. | ||
@@ -7,3 +7,3 @@ **Features:** | ||
<li> | ||
The pattern syntax is a superset of ABNF (<a href="https://github.com/ldthomas/apg-js2-exp/SABNF.md">SABNF</a>.) The ABNF syntax is standardized for and used to describe most Internet technical specifications. | ||
The pattern syntax is a superset of ABNF (<a href="https://github.com/ldthomas/apg-js2/blob/master/SABNF.md">SABNF</a>.) The ABNF syntax is standardized for and used to describe most Internet technical specifications. | ||
</li> | ||
@@ -29,3 +29,3 @@ <li> | ||
<li> | ||
Global and “sticky” flags operate nearly identically to the same-named <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp">JavaScript RegExp</a> flags. | ||
Global and "sticky" flags operate nearly identically to the same-named <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp">JavaScript RegExp</a> flags. | ||
</li> | ||
@@ -36,6 +36,8 @@ <li> | ||
<li> | ||
Fully implemented lookaround – positive and negative forms of both look-ahead and infinite-length look-behind. | ||
Fully implemented lookaround – positive and negative forms of both look-ahead and infinite-length look-behind. | ||
</li> | ||
<li> | ||
Back referencing – two modes, universal and parent. See the definitions in the <a href="https://github.com/ldthomas/apg-js2-exp/SABNF.md">SABNF documentation</a>. For example, parent mode used with recursion can match not only the opening and closing tags of HTML but also the tag names in them. (See the <a href="https://github.com/ldthomas/apg-js2-examples/back-reference">back reference example</a>.) | ||
Back referencing – two modes, universal and parent. See the definitions in the | ||
<a href="https://github.com/ldthomas/apg-js2/blob/master/SABNF.md">SABNF documentation</a>. | ||
For example, parent mode used with recursion can match not only the opening and closing tags of HTML but also the tag names in them. (See the <a href="https://github.com/ldthomas/apg-js2-examples/tree/master/back-reference">back reference example</a>.) | ||
</li> | ||
@@ -49,6 +51,7 @@ <li> | ||
<li> | ||
The syntax allows <b>APG</b>'s User-Defined Terminals (UDTs) – arbitrary code for special phrase matching requirements. They make the phrase matching power of <code>apg-exp</code> essentially Turing complete. | ||
The syntax allows <b>APG</b>'s User-Defined Terminals (UDTs) – arbitrary code for special phrase matching requirements. They make the phrase matching power of <code>apg-exp</code> essentially Turing complete. | ||
</li> | ||
<li> | ||
Provides the user with access to the <a href="https://en.wikipedia.org/wiki/Abstract_syntax_tree">Abstract Syntax Tree</a> (AST) of the pattern match. The AST can be used for complex translations of the matched phrase. | ||
(See the <a href="https://github.com/ldthomas/apg-js2-examples/blob/master/apg-exp/dangling-else.js">dangling-else</a> example.) | ||
</li> | ||
@@ -68,3 +71,3 @@ <li> | ||
<li> | ||
Tree depth and parser step controls to limit or “put the brakes on” an exponential or "catastrophic backtracking" syntax. | ||
Tree depth and parser step controls to limit or "put the brakes on" an exponential or "catastrophic backtracking" syntax. | ||
</li> | ||
@@ -89,5 +92,7 @@ <li> | ||
At the outset I naively thought that the regular expressions of regexes were just that – the Chomsky hierarchy variety. Therefore, I thought that using an **APG** parser for the pattern matching would add a great deal of parsing power to the problem. I soon discovered that not only were the “regular expressions” of many regexes full-blown recursive-descent parsers, they were loaded up with features that went well beyond that of **APG**. I had to play a little catch up to add look behind, back referencing and anchors. That being done, however, I think there is still a case for claiming some added power. I'm not a regex expert and I won't be making any big claims here, but there are a couple of points I will mention. I think the way that `apg-exp` gives the user nearly full control over the input, output and interpretation of the character codes goes a long way to address a number of the cautions mentioned in Jeffrey Friedl's book, for example on pages 92 and 106. I also think it addresses a number of the things Larry Wall finds wrong with the regex culture in his [Apocalypse 5](http://perl6.org/archive/doc/design/apo/A05.html) page. For example, back referencing, support for named capture, nested patterns (recursive rules), capture of all matches to a sub-phrase and others. | ||
At the outset I naively thought that the regular expressions of regexes were just that – the Chomsky hierarchy variety. Therefore, I thought that using an **APG** parser for the pattern matching would add a great deal of parsing power to the problem. I soon discovered that not only were the "regular expressions" of many regexes full-blown recursive-descent parsers, they were loaded up with features that went well beyond that of **APG**. I had to play a little catch up to add look behind, back referencing and anchors. That being done, however, I think there is still a case for claiming some added power. I'm not a regex expert and I won't be making any big claims here, but there are a couple of points I will mention. I think the way that `apg-exp` gives the user nearly full control over the input, output and interpretation of the character codes goes a long way to address a number of the cautions mentioned in Jeffrey Friedl's book, for example on pages 92 and 106. I also think it addresses a number of the things Larry Wall finds wrong with the regex culture in his [Apocalypse 5](http://perl6.org/archive/doc/design/apo/A05.html) page. For example, back referencing, support for named capture, nested patterns (recursive rules), capture of all matches to a sub-phrase and others. | ||
But the best thing to do, probably, is to head over to the [examples](https://github.com/ldthomas/apg-js2-examples/) and take a look. See and compare for yourself. I would suggest starting with the `flags`, `display` and `rules` examples to get your bearings and go from there. | ||
But the best thing to do, probably, is to head over to the | ||
[examples](https://github.com/ldthomas/apg-js2-examples/tree/master/apg-exp) and take a look. | ||
See and compare for yourself. I would suggest starting with the `flags`, `display` and `rules` examples to get your bearings and go from there. | ||
@@ -106,3 +111,3 @@ **Installation:** | ||
**Examples:** | ||
See <a href="https://github.com/ldthomas/apg-js2-examples">apg-js2-examples/apg-exp</a> for many examples of using | ||
See <a href="https://github.com/ldthomas/apg-js2-examples/tree/master/apg-exp">apg-js2-examples</a> for many examples of using | ||
`apg-exp`. | ||
@@ -109,0 +114,0 @@ |
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
80610
124