New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clarity-pattern-parser

Package Overview
Dependencies
Maintainers
1
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clarity-pattern-parser - npm Package Compare versions

Comparing version 2.0.6 to 2.0.7

index.d.ts

6

lib/ast/CompositeNode.js

@@ -59,3 +59,3 @@ "use strict";

key: "filter",
value: function filter(isMatch) {
value: function filter(shouldKeep) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

@@ -66,5 +66,5 @@ var childrenContext = context.slice();

var matches = this.children.reduce(function (acc, child) {
return acc.concat(child.filter(isMatch, childrenContext));
return acc.concat(child.filter(shouldKeep, childrenContext));
}, []);
var match = isMatch(this, context);
var match = shouldKeep(this, context);

@@ -71,0 +71,0 @@ if (match) {

@@ -55,4 +55,4 @@ "use strict";

key: "filter",
value: function filter(isMatch, context) {
var match = isMatch(this, context);
value: function filter(shouldKeep, context) {
var match = shouldKeep(this, context);

@@ -59,0 +59,0 @@ if (match) {

@@ -8,3 +8,3 @@ "use strict";

var _CursorHistory = _interopRequireDefault(require("./CursorHistory"));
var _CursorHistory = _interopRequireDefault(require("./CursorHistory.js"));

@@ -11,0 +11,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -6,8 +6,2 @@ "use strict";

});
Object.defineProperty(exports, "Mark", {
enumerable: true,
get: function get() {
return _Mark.default;
}
});
Object.defineProperty(exports, "Node", {

@@ -146,4 +140,2 @@ enumerable: true,

var _Mark = _interopRequireDefault(require("./Mark.js"));
var _Node = _interopRequireDefault(require("./ast/Node.js"));

@@ -191,5 +183,5 @@

var _ParseInspector = _interopRequireDefault(require("./ParseInspector"));
var _ParseInspector = _interopRequireDefault(require("./ParseInspector.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

@@ -48,2 +48,4 @@ "use strict";

return {
pattern: null,
astNode: null,
match: null,

@@ -50,0 +52,0 @@ error: null,

@@ -178,7 +178,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -185,0 +180,0 @@ value: function getPossibilities(rootPattern) {

@@ -56,8 +56,3 @@ "use strict";

throw new Error("Invalid Argument: All patterns need to be an instance of Pattern.");
} // if (this._children.length < 2) {
// throw new Error(
// "Invalid Argument: Composite Patterns need to have more than one value pattern."
// );
// }
}
}

@@ -64,0 +59,0 @@ }, {

@@ -78,7 +78,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -85,0 +80,0 @@ value: function getPossibilities(rootPattern) {

@@ -126,7 +126,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -133,0 +128,0 @@ value: function getPossibilities(rootPattern) {

@@ -145,7 +145,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -152,0 +147,0 @@ value: function getPossibilities(rootPattern) {

@@ -17,3 +17,2 @@ "use strict";

this.pattern = pattern;
this.stack = [];
};

@@ -20,0 +19,0 @@

@@ -102,7 +102,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.pattern.getCurrentMark();
}
}, {
key: "getPossibilities",

@@ -109,0 +104,0 @@ value: function getPossibilities() {

@@ -177,7 +177,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -184,0 +179,0 @@ value: function getPossibilities(rootPattern) {

@@ -115,7 +115,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -122,0 +117,0 @@ value: function getPossibilities(rootPattern) {

@@ -113,7 +113,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -120,0 +115,0 @@ value: function getPossibilities() {

@@ -117,7 +117,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -124,0 +119,0 @@ value: function getPossibilities() {

@@ -77,7 +77,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -84,0 +79,0 @@ value: function getPossibilities(rootPattern) {

@@ -120,7 +120,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -127,0 +122,0 @@ value: function getPossibilities(rootPattern) {

@@ -123,7 +123,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.cursor.getIndex();
}
}, {
key: "getPossibilities",

@@ -130,0 +125,0 @@ value: function getPossibilities() {

@@ -148,7 +148,2 @@ "use strict";

}, {
key: "getCurrentMark",
value: function getCurrentMark() {
return this.mark;
}
}, {
key: "getPossibilities",

@@ -155,0 +150,0 @@ value: function getPossibilities(rootPattern) {

@@ -71,7 +71,2 @@ "use strict";

}
}, {
key: "getCurrentMark",
value: function getCurrentMark() {
throw new Error("Not Yet Implemented");
}
}]);

@@ -78,0 +73,0 @@

@@ -35,2 +35,19 @@ "use strict";

exports["Literal: exec."] = function () {
var john = new _Literal.default("john", "John");
var result = john.exec("John");
var result2 = john.exec("Jane");
var expectedValue = {
type: "literal",
name: "john",
startIndex: 0,
endIndex: 3,
value: "John"
};
_assert.default.equal(JSON.stringify(result), JSON.stringify(expectedValue));
_assert.default.equal(result2, null);
};
exports["Literal: Match."] = function () {

@@ -37,0 +54,0 @@ var variable = new _Literal.default("variable", "var");

@@ -13,4 +13,4 @@ "use strict";

var text = "Pat ";
var parseStatusGenerator = new _ParseInspector.default();
var inspection = parseStatusGenerator.inspectParse(text, _sentence.default);
var parseInspector = new _ParseInspector.default();
var inspection = parseInspector.inspectParse(text, _sentence.default);

@@ -34,4 +34,4 @@ _assert.default.equal(inspection.match.text, "Pat ");

var text = "Pat wzoo";
var parseStatusGenerator = new _ParseInspector.default();
var inspection = parseStatusGenerator.inspectParse(text, _sentence.default);
var parseInspector = new _ParseInspector.default();
var inspection = parseInspector.inspectParse(text, _sentence.default);

@@ -55,4 +55,4 @@ _assert.default.equal(inspection.possibilities, null);

var text = "bank";
var parseStatusGenerator = new _ParseInspector.default();
var inspection = parseStatusGenerator.inspectParse(text, _sentence.default);
var parseInspector = new _ParseInspector.default();
var inspection = parseInspector.inspectParse(text, _sentence.default);

@@ -72,4 +72,4 @@ _assert.default.equal(inspection.possibilities.options.length, 16);

var text = "store bank";
var parseStatusGenerator = new _ParseInspector.default();
var inspection = parseStatusGenerator.inspectParse(text, _sentence.default);
var parseInspector = new _ParseInspector.default();
var inspection = parseInspector.inspectParse(text, _sentence.default);

@@ -89,4 +89,4 @@ _assert.default.equal(inspection.possibilities.options.length, 32);

var text = "Pat wen";
var parseStatusGenerator = new _ParseInspector.default();
var inspection = parseStatusGenerator.inspectParse(text, _sentence.default);
var parseInspector = new _ParseInspector.default();
var inspection = parseInspector.inspectParse(text, _sentence.default);

@@ -110,4 +110,4 @@ _assert.default.equal(inspection.match.text, "Pat wen");

var text = "";
var parseStatusGenerator = new _ParseInspector.default();
var inspection = parseStatusGenerator.inspectParse(text, _sentence.default);
var parseInspector = new _ParseInspector.default();
var inspection = parseInspector.inspectParse(text, _sentence.default);

@@ -127,4 +127,4 @@ _assert.default.equal(inspection.match, null);

var text = "Jared left ";
var parseStatusGenerator = new _ParseInspector.default();
var inspection = parseStatusGenerator.inspectParse(text, _sentence.default);
var parseInspector = new _ParseInspector.default();
var inspection = parseInspector.inspectParse(text, _sentence.default);

@@ -144,4 +144,4 @@ _assert.default.equal(inspection.match, null);

var text = "Pat went to a big store";
var parseStatusGenerator = new _ParseInspector.default();
var inspection = parseStatusGenerator.inspectParse(text, _sentence.default);
var parseInspector = new _ParseInspector.default();
var inspection = parseInspector.inspectParse(text, _sentence.default);

@@ -148,0 +148,0 @@ _assert.default.equal(inspection.match.text, "Pat went to a big store");

@@ -28,4 +28,12 @@ "use strict";

_assert.default.equal(JSON.stringify(node), '{"type":"and-value","name":"line-ending-comment","startIndex":0,"endIndex":20,"value":"// This is a comment\\n"}'); // --> true
var expectedValue = {
type: "and-value",
name: "line-ending-comment",
startIndex: 0,
endIndex: 20,
value: "// This is a comment\n"
};
_assert.default.equal(JSON.stringify(node), JSON.stringify(expectedValue)); // --> true
};

@@ -60,4 +68,31 @@

_assert.default.equal(JSON.stringify(node), '{"type":"and-composite","name":"line-ending-comment","startIndex":0,"endIndex":20,"children":[{"type":"literal","name":"forward-slashes","startIndex":0,"endIndex":1,"value":"//"},{"type":"repeat-value","name":"comment","startIndex":2,"endIndex":19,"value":" This is a comment"},{"type":"or-value","name":"line-end","startIndex":20,"endIndex":20,"value":"\\n"}]}');
var expectedValue = {
type: "and-composite",
name: "line-ending-comment",
startIndex: 0,
endIndex: 20,
children: [{
type: "literal",
name: "forward-slashes",
startIndex: 0,
endIndex: 1,
value: "//"
}, {
type: "repeat-value",
name: "comment",
startIndex: 2,
endIndex: 19,
value: " This is a comment"
}, {
type: "or-value",
name: "line-end",
startIndex: 20,
endIndex: 20,
value: "\n"
}]
};
_assert.default.equal(JSON.stringify(node), JSON.stringify(expectedValue)); // --> true
};
//# sourceMappingURL=readmeDemo.js.map
{
"name": "clarity-pattern-parser",
"type": "module",
"version": "2.0.6",
"version": "2.0.7",
"description": "",

@@ -6,0 +6,0 @@ "main": "./lib/index.js",

@@ -8,88 +8,192 @@ ## Installation

## How to use
There are two constructs within clarity pattern parser. The first is value based patterns. The second is composite based patterns.
Value patterns can be composed, however, they are reduced to a single value even if they are composed of many parts.
There are two constructs within clarity pattern parser. The first is value based patterns. The second is composite based patterns.
Composite patterns can also be composed, however, they are left with their parts. The best way to understand this is by an example.
Value patterns can be composed, however, they are reduced to a single value even if they are composed of many parts.
We will create a pattern for line ending comments, first with value based patterns, and second with some composite based patterns.
Composite patterns can also be composed, however, they are left with their parts. The best way to understand this is by an example.
We will create a pattern for line ending comments, first with value based patterns, and second with some composite based patterns.
### Value based comment
```javascript
import {
Cursor,
Literal,
AndValue,
OrValue,
RepeatValue,
NotValue
} from 'clarity-pattern-parser';
import assert from "assert";
Cursor,
Literal,
AndValue,
OrValue,
RepeatValue,
NotValue,
AndComposite
} from "clarity-pattern-parser";
import assert from "assert";
const forwardSlashes = new Literal("forward-slashes", "//");
const newLine = new Literal("new-line", "\n");
const returnCarriage = new Literal("return-carriage", "\r");
const windowsNewLine = new AndValue("windows-new-line", [returnCarriage, newLine]);
const lineEnd = new OrValue("line-end", [newLine, windowNewLine]);
const character = new NotValue("character", lineEnd);
const comment = new RepeatValue("comment", character);
exports["readme.md: value"] = () => {
const forwardSlashes = new Literal("forward-slashes", "//");
const newLine = new Literal("new-line", "\n");
const returnCarriage = new Literal("return-carriage", "\r");
const windowsNewLine = new AndValue("windows-new-line", [
returnCarriage,
newLine
]);
const lineEnd = new OrValue("line-end", [newLine, windowsNewLine]);
const character = new NotValue("character", lineEnd);
const comment = new RepeatValue("comment", character);
const lineEndingComment = AndValue("line-ending-comment", [
const lineEndingComment = new AndValue("line-ending-comment", [
forwardSlashes,
comment,
lineEnd
]);
]);
const string = "// This is a comment\n";
const cursor = new Cursor(string);
const node = lineEndingComment.parse(cursor);
const string = "// This is a comment\n";
const cursor = new Cursor(string);
const node = lineEndingComment.parse(cursor);
assert.equal(node.name, "line-ending-comment"); // --> true
assert.equal(node.value, string); // --> true
assert.equal(node.name, "line-ending-comment"); // --> true
assert.equal(node.value, string); // --> true
const expectedValue = {
type: "and-value",
name: "line-ending-comment",
startIndex: 0,
endIndex: 20,
value: "// This is a comment\n"
};
assert.equal(JSON.stringify(node), JSON.stringify(expectedValue)); // --> true
};
```
### Composite based comment
```javascript
import {
Cursor,
Literal,
AndValue,
OrValue,
RepeatValue,
NotValue,
AndComposite
} from 'clarity-pattern-parser';
import assert from "assert";
Cursor,
Literal,
AndValue,
OrValue,
RepeatValue,
NotValue,
AndComposite
} from "clarity-pattern-parser";
import assert from "assert";
const forwardSlashes = new Literal("forward-slashes", "//");
const newLine = new Literal("new-line", "\n");
const returnCarriage = new Literal("return-carriage", "\r");
const windowsNewLine = new AndValue("windows-new-line", [returnCarriage, newLine]);
const lineEnd = new OrValue("line-end", [newLine, windowNewLine]);
const character = new NotValue("character", lineEnd);
const comment = new RepeatValue("comment", character);
exports["readme.md: composite"] = () => {
const forwardSlashes = new Literal("forward-slashes", "//");
const newLine = new Literal("new-line", "\n");
const returnCarriage = new Literal("return-carriage", "\r");
const windowsNewLine = new AndValue("windows-new-line", [
returnCarriage,
newLine
]);
const lineEnd = new OrValue("line-end", [newLine, windowsNewLine]);
const character = new NotValue("character", lineEnd);
const comment = new RepeatValue("comment", character);
const lineEndingComment = AndComposite("line-ending-comment", [
const lineEndingComment = new AndComposite("line-ending-comment", [
forwardSlashes,
comment,
lineEnd
]);
]);
const string = "// This is a comment\n";
const cursor = new Cursor(string);
const node = lineEndingComment.parse(cursor);
const string = "// This is a comment\n";
const cursor = new Cursor(string);
const node = lineEndingComment.parse(cursor);
assert.equal(node.name, "line-ending-comment");
assert.equal(node.name, "line-ending-comment");
assert.equal(node.children[0].name, "forward-slashes");
assert.equal(node.children[0].value, "//");
assert.equal(node.children[0].name, "forward-slashes");
assert.equal(node.children[0].value, "//");
assert.equal(node.children[1].name, "comment");
assert.equal(node.children[1].value, " This is a comment");
assert.equal(node.children[1].name, "comment");
assert.equal(node.children[1].value, " This is a comment");
assert.equal(node.children[2].name, "line-end");
assert.equal(node.children[2].value, "\n");
assert.equal(node.children[2].name, "line-end");
assert.equal(node.children[2].value, "\n");
const expectedValue = {
type: "and-composite",
name: "line-ending-comment",
startIndex: 0,
endIndex: 20,
children: [
{
type: "literal",
name: "forward-slashes",
startIndex: 0,
endIndex: 1,
value: "//"
},
{
type: "repeat-value",
name: "comment",
startIndex: 2,
endIndex: 19,
value: " This is a comment"
},
{
type: "or-value",
name: "line-end",
startIndex: 20,
endIndex: 20,
value: "\n"
}
]
};
assert.equal(JSON.stringify(node), JSON.stringify(expectedValue)); // --> true
};
```
## Notes
### Literal
```javascript
import { Literal } from "clarity-pattern-parser";
import assert from "assert";
// The first parameter is the name of the pattern, the second is the string you are matching.
const john = new Literal("john", "John");
const result = john.exec("John");
const result2 = john.exec("Jane");
const expectedValue = {
type: "literal",
name: "john",
startIndex: 0,
endIndex: 3,
value: "John"
};
assert.equal(JSON.stringify(result), JSON.stringify(expectedValue));
assert.equal(result2, null);
```
### RegexValue
```javascript
import { RegexValue } from "clarity-pattern-parser";
import assert from "assert";
// Notice this isn't a regex literal /[^a]+/
// This is because we need to modify the expression to use it in the middle of a parse.
// This also means we shouldn't use things like the start "^" character or the end "$" character.
// There are several gotchas with RegexValue, however the speed gains are undeniable.
const notA = new RegexValue("not-a", "[^a]+");
const result = notA.exec("John");
const result2 = notA.exec("a");
const expectedValue = {
type: "regex-value",
name: "not-a",
startIndex: 0,
endIndex: 3,
value: "John"
};
assert.equal(JSON.stringify(result), JSON.stringify(expectedValue));
assert.equal(result2, null);
```

@@ -23,3 +23,3 @@ import Node from "./Node.js";

filter(isMatch, context = []) {
filter(shouldKeep, context = []) {
const childrenContext = context.slice();

@@ -31,6 +31,6 @@ childrenContext.push(this);

const matches = this.children.reduce((acc, child) => {
return acc.concat(child.filter(isMatch, childrenContext));
return acc.concat(child.filter(shouldKeep, childrenContext));
}, []);
const match = isMatch(this, context);
const match = shouldKeep(this, context);

@@ -37,0 +37,0 @@ if (match) {

@@ -13,4 +13,4 @@ import Node from "./Node.js";

filter(isMatch, context){
const match = isMatch(this, context);
filter(shouldKeep, context){
const match = shouldKeep(this, context);

@@ -17,0 +17,0 @@ if (match){

@@ -1,2 +0,2 @@

import CursorHistory from "./CursorHistory";
import CursorHistory from "./CursorHistory.js";

@@ -3,0 +3,0 @@ export default class Cursor {

@@ -1,2 +0,1 @@

import Mark from "./Mark.js";
import Node from "./ast/Node.js";

@@ -23,6 +22,5 @@ import CompositeNode from "./ast/CompositeNode.js";

import RecursivePattern from "./patterns/RecursivePattern.js";
import ParseInspector from "./ParseInspector";
import ParseInspector from "./ParseInspector.js";
export {
Mark,
Node,

@@ -29,0 +27,0 @@ CompositeNode,

@@ -25,2 +25,4 @@ import { Cursor } from "./index.js";

return {
pattern: null,
astNode: null,
match: null,

@@ -27,0 +29,0 @@ error: null,

@@ -135,6 +135,2 @@ import CompositePattern from "./CompositePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities(rootPattern) {

@@ -141,0 +137,0 @@ if (rootPattern == null || !(rootPattern instanceof Pattern)){

@@ -25,8 +25,2 @@ import Pattern from "../Pattern.js";

// if (this._children.length < 2) {
// throw new Error(
// "Invalid Argument: Composite Patterns need to have more than one value pattern."
// );
// }
}

@@ -33,0 +27,0 @@

@@ -36,6 +36,2 @@ import CompositePattern from "./CompositePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities(rootPattern) {

@@ -42,0 +38,0 @@ if (rootPattern == null || !(rootPattern instanceof Pattern)) {

@@ -81,6 +81,2 @@ import CompositePattern from "./CompositePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities(rootPattern) {

@@ -87,0 +83,0 @@ if (rootPattern == null || !(rootPattern instanceof Pattern)){

@@ -108,6 +108,2 @@ import CompositePattern from "./CompositePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities(rootPattern) {

@@ -114,0 +110,0 @@ if (rootPattern == null || !(rootPattern instanceof Pattern)) {

@@ -7,4 +7,3 @@ export default class ParseError {

this.pattern = pattern;
this.stack = [];
}
}

@@ -62,6 +62,2 @@ import Pattern from "./Pattern.js";

getCurrentMark() {
return this.pattern.getCurrentMark();
}
getPossibilities() {

@@ -68,0 +64,0 @@ if (!this.isGettingPossibilities) {

@@ -130,6 +130,2 @@ import ValuePattern from "./ValuePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities(rootPattern) {

@@ -136,0 +132,0 @@ if (rootPattern == null || !(rootPattern instanceof Pattern)) {

@@ -72,6 +72,2 @@ import ValuePattern from "./ValuePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities(rootPattern) {

@@ -78,0 +74,0 @@ if (rootPattern == null || !(rootPattern instanceof Pattern)) {

@@ -78,6 +78,2 @@ import ParseError from "../ParseError.js";

getCurrentMark() {
return this.mark;
}
getPossibilities() {

@@ -84,0 +80,0 @@ return [this.literal];

@@ -85,6 +85,2 @@ import ValuePattern from "./ValuePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities() {

@@ -91,0 +87,0 @@ return [];

@@ -35,6 +35,2 @@ import ValuePattern from "./ValuePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities(rootPattern) {

@@ -41,0 +37,0 @@ if (rootPattern == null || !(rootPattern instanceof Pattern)) {

@@ -81,6 +81,2 @@ import ValuePattern from "./ValuePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities(rootPattern) {

@@ -87,0 +83,0 @@ if (rootPattern == null || !(rootPattern instanceof Pattern)) {

@@ -90,6 +90,2 @@ import ParseError from "../ParseError.js";

getCurrentMark() {
return this.cursor.getIndex();
}
getPossibilities() {

@@ -96,0 +92,0 @@ return [this.name];

@@ -110,6 +110,2 @@ import ValuePattern from "./ValuePattern.js";

getCurrentMark() {
return this.mark;
}
getPossibilities(rootPattern) {

@@ -116,0 +112,0 @@ if (rootPattern == null || !(rootPattern instanceof Pattern)) {

@@ -42,5 +42,2 @@ import Pattern from "../Pattern.js";

getCurrentMark() {
throw new Error("Not Yet Implemented");
}
}

@@ -29,2 +29,20 @@ import Literal from "../patterns/value/Literal.js";

exports["Literal: exec."] = () => {
const john = new Literal("john", "John");
const result = john.exec("John");
const result2 = john.exec("Jane");
const expectedValue = {
type: "literal",
name: "john",
startIndex: 0,
endIndex: 3,
value: "John"
};
assert.equal(JSON.stringify(result), JSON.stringify(expectedValue));
assert.equal(result2, null);
};
exports["Literal: Match."] = () => {

@@ -31,0 +49,0 @@ const variable = new Literal("variable", "var");

@@ -7,5 +7,5 @@ import ParseInspector from "../ParseInspector.js";

const text = "Pat ";
const parseStatusGenerator = new ParseInspector();
const parseInspector = new ParseInspector();
const inspection = parseStatusGenerator.inspectParse(text, sentence);
const inspection = parseInspector.inspectParse(text, sentence);

@@ -23,5 +23,5 @@ assert.equal(inspection.match.text, "Pat ");

const text = "Pat wzoo";
const parseStatusGenerator = new ParseInspector();
const parseInspector = new ParseInspector();
const inspection = parseStatusGenerator.inspectParse(text, sentence);
const inspection = parseInspector.inspectParse(text, sentence);
assert.equal(inspection.possibilities, null);

@@ -38,5 +38,5 @@ assert.equal(inspection.match.startIndex, 0);

const text = "bank";
const parseStatusGenerator = new ParseInspector();
const parseInspector = new ParseInspector();
const inspection = parseStatusGenerator.inspectParse(text, sentence);
const inspection = parseInspector.inspectParse(text, sentence);

@@ -54,5 +54,5 @@ assert.equal(inspection.possibilities.options.length, 16);

const text = "store bank";
const parseStatusGenerator = new ParseInspector();
const parseInspector = new ParseInspector();
const inspection = parseStatusGenerator.inspectParse(text, sentence);
const inspection = parseInspector.inspectParse(text, sentence);

@@ -68,5 +68,5 @@ assert.equal(inspection.possibilities.options.length, 32);

const text = "Pat wen";
const parseStatusGenerator = new ParseInspector();
const parseInspector = new ParseInspector();
const inspection = parseStatusGenerator.inspectParse(text, sentence);
const inspection = parseInspector.inspectParse(text, sentence);

@@ -84,5 +84,5 @@ assert.equal(inspection.match.text, "Pat wen");

const text = "";
const parseStatusGenerator = new ParseInspector();
const parseInspector = new ParseInspector();
const inspection = parseStatusGenerator.inspectParse(text, sentence);
const inspection = parseInspector.inspectParse(text, sentence);

@@ -98,5 +98,5 @@ assert.equal(inspection.match, null);

const text = "Jared left ";
const parseStatusGenerator = new ParseInspector();
const parseInspector = new ParseInspector();
const inspection = parseStatusGenerator.inspectParse(text, sentence);
const inspection = parseInspector.inspectParse(text, sentence);
assert.equal(inspection.match, null);

@@ -111,5 +111,5 @@ assert.equal(inspection.isComplete, false);

const text = "Pat went to a big store";
const parseStatusGenerator = new ParseInspector();
const parseInspector = new ParseInspector();
const inspection = parseStatusGenerator.inspectParse(text, sentence);
const inspection = parseInspector.inspectParse(text, sentence);

@@ -116,0 +116,0 @@ assert.equal(inspection.match.text, "Pat went to a big store");

@@ -36,6 +36,12 @@ import {

assert.equal(node.value, string); // --> true
assert.equal(
JSON.stringify(node),
'{"type":"and-value","name":"line-ending-comment","startIndex":0,"endIndex":20,"value":"// This is a comment\\n"}'
); // --> true
const expectedValue = {
type: "and-value",
name: "line-ending-comment",
startIndex: 0,
endIndex: 20,
value: "// This is a comment\n"
};
assert.equal(JSON.stringify(node), JSON.stringify(expectedValue)); // --> true
};

@@ -76,6 +82,33 @@

assert.equal(
JSON.stringify(node),
'{"type":"and-composite","name":"line-ending-comment","startIndex":0,"endIndex":20,"children":[{"type":"literal","name":"forward-slashes","startIndex":0,"endIndex":1,"value":"//"},{"type":"repeat-value","name":"comment","startIndex":2,"endIndex":19,"value":" This is a comment"},{"type":"or-value","name":"line-end","startIndex":20,"endIndex":20,"value":"\\n"}]}'
);
const expectedValue = {
type: "and-composite",
name: "line-ending-comment",
startIndex: 0,
endIndex: 20,
children: [
{
type: "literal",
name: "forward-slashes",
startIndex: 0,
endIndex: 1,
value: "//"
},
{
type: "repeat-value",
name: "comment",
startIndex: 2,
endIndex: 19,
value: " This is a comment"
},
{
type: "or-value",
name: "line-end",
startIndex: 20,
endIndex: 20,
value: "\n"
}
]
};
assert.equal(JSON.stringify(node), JSON.stringify(expectedValue)); // --> true
};

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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc