Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

good-enough-parser

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

good-enough-parser - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

4

dist/cjs/query/matchers/abstract-matcher.d.ts

@@ -5,4 +5,4 @@ import type { Cursor, Node } from '../../parser';

canSkip(node: Node): boolean;
seek(cursor: Cursor): Cursor;
seekRight(cursor: Cursor): Cursor;
seekNext(cursor: Cursor): Cursor;
moveRight(cursor: Cursor): Cursor;
abstract match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;

@@ -9,0 +9,0 @@ nextMatch(): Checkpoint<Ctx> | null;

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

}
seek(cursor) {
seekNext(cursor) {
let node = cursor.node;

@@ -26,3 +26,3 @@ while (this.canSkip(node)) {

}
seekRight(cursor) {
moveRight(cursor) {
const result = cursor.right;

@@ -29,0 +29,0 @@ if (result) {

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

const context = checkpoint.context;
const cursor = this.seek(checkpoint.cursor);
const cursor = this.seekNext(checkpoint.cursor);
const node = cursor.node;

@@ -22,0 +22,0 @@ if ((node === null || node === void 0 ? void 0 : node.type) === 'comment') {

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

let context = checkpoint.context;
let cursor = this.seek(checkpoint.cursor);
let cursor = this.seekNext(checkpoint.cursor);
const node = cursor.node;

@@ -27,3 +27,3 @@ if ((node === null || node === void 0 ? void 0 : node.type) === 'number') {

context = this.handler(context, node);
cursor = this.seekRight(cursor);
cursor = this.moveRight(cursor);
return { cursor, context };

@@ -30,0 +30,0 @@ }

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

let context = checkpoint.context;
let cursor = this.seek(checkpoint.cursor);
let cursor = this.seekNext(checkpoint.cursor);
const node = cursor.node;

@@ -27,3 +27,3 @@ if ((node === null || node === void 0 ? void 0 : node.type) === 'operator') {

context = this.handler(context, node);
cursor = this.seekRight(cursor);
cursor = this.moveRight(cursor);
return { cursor, context };

@@ -30,0 +30,0 @@ }

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

context = this.handler(context, node);
cursor = this.seekRight(cursor);
cursor = this.moveRight(cursor);
return { cursor, context };

@@ -49,10 +49,10 @@ }

let context = this.preHandler(tplContext, rootNode);
cursor = this.matcher.seek(cursor);
cursor = this.matcher.seekNext(cursor);
const match = this.matcher.match({ context, cursor });
if (match) {
({ cursor, context } = match);
cursor = this.seek(cursor);
cursor = this.seekNext(cursor);
if (((_a = cursor.node) === null || _a === void 0 ? void 0 : _a.type) === '_end') {
context = this.postHandler(context, rootNode);
cursor = this.seekRight(tplCursor);
cursor = this.moveRight(tplCursor);
return { context, cursor };

@@ -76,6 +76,7 @@ }

match(checkpoint) {
const rootNode = checkpoint.cursor.node;
const rootCursor = this.seekNext(checkpoint.cursor);
const rootNode = rootCursor.node;
if ((rootNode === null || rootNode === void 0 ? void 0 : rootNode.type) === 'string-tree') {
let context = this.preHandler(checkpoint.context, rootNode);
let cursor = checkpoint.cursor;
let cursor = rootCursor;
if (this.matchers) {

@@ -87,3 +88,3 @@ const tokensCount = cursor.children.length - 2;

if (tokensCount > 0) {
cursor = this.seekRight(cursor.down);
cursor = this.moveRight(cursor.down);
for (const matcher of this.matchers) {

@@ -99,3 +100,3 @@ const match = matcher.match({ context, cursor });

context = this.postHandler(context, rootNode);
cursor = this.seekRight(checkpoint.cursor);
cursor = this.moveRight(rootCursor);
return { context, cursor };

@@ -102,0 +103,0 @@ }

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

let context = checkpoint.context;
let cursor = this.seek(checkpoint.cursor);
let cursor = this.seekNext(checkpoint.cursor);
const node = cursor.node;

@@ -27,3 +27,3 @@ if ((node === null || node === void 0 ? void 0 : node.type) === 'symbol') {

context = this.handler(context, node);
cursor = this.seekRight(cursor);
cursor = this.moveRight(cursor);
return { cursor, context };

@@ -30,0 +30,0 @@ }

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

rightCursor = this.matcher
? this.matcher.seek(rightCursor)
: this.seek(rightCursor);
? this.matcher.seekNext(rightCursor)
: this.seekNext(rightCursor);
if (rightCursor) {

@@ -47,4 +47,4 @@ return rightCursor;

rightCursor = this.matcher
? this.matcher.seek(rightCursor)
: this.seek(rightCursor);
? this.matcher.seekNext(rightCursor)
: this.seekNext(rightCursor);
if (rightCursor) {

@@ -104,3 +104,3 @@ upperCursor = rightCursor;

? checkpoint.cursor
: this.seekRight(checkpoint.cursor);
: this.moveRight(checkpoint.cursor);
return { context, cursor };

@@ -107,0 +107,0 @@ }

@@ -45,3 +45,3 @@ import type { CommentToken, MinorToken, NumberToken, OperatorToken, SymbolToken } from '../lexer/types';

export interface Matcher<Ctx> {
seek(cursor: Cursor): Cursor;
seekNext(cursor: Cursor): Cursor;
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;

@@ -48,0 +48,0 @@ nextMatch(): Checkpoint<Ctx> | null;

@@ -5,4 +5,4 @@ import type { Cursor, Node } from '../../parser';

canSkip(node: Node): boolean;
seek(cursor: Cursor): Cursor;
seekRight(cursor: Cursor): Cursor;
seekNext(cursor: Cursor): Cursor;
moveRight(cursor: Cursor): Cursor;
abstract match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;

@@ -9,0 +9,0 @@ nextMatch(): Checkpoint<Ctx> | null;

@@ -11,3 +11,3 @@ const skipByDefault = [

}
seek(cursor) {
seekNext(cursor) {
let node = cursor.node;

@@ -23,3 +23,3 @@ while (this.canSkip(node)) {

}
seekRight(cursor) {
moveRight(cursor) {
const result = cursor.right;

@@ -26,0 +26,0 @@ if (result) {

@@ -16,3 +16,3 @@ import { coerceHandler } from '../util';

const context = checkpoint.context;
const cursor = this.seek(checkpoint.cursor);
const cursor = this.seekNext(checkpoint.cursor);
const node = cursor.node;

@@ -19,0 +19,0 @@ if ((node === null || node === void 0 ? void 0 : node.type) === 'comment') {

@@ -11,3 +11,3 @@ import { coerceHandler } from '../util';

let context = checkpoint.context;
let cursor = this.seek(checkpoint.cursor);
let cursor = this.seekNext(checkpoint.cursor);
const node = cursor.node;

@@ -24,3 +24,3 @@ if ((node === null || node === void 0 ? void 0 : node.type) === 'number') {

context = this.handler(context, node);
cursor = this.seekRight(cursor);
cursor = this.moveRight(cursor);
return { cursor, context };

@@ -27,0 +27,0 @@ }

@@ -11,3 +11,3 @@ import { coerceHandler } from '../util';

let context = checkpoint.context;
let cursor = this.seek(checkpoint.cursor);
let cursor = this.seekNext(checkpoint.cursor);
const node = cursor.node;

@@ -24,3 +24,3 @@ if ((node === null || node === void 0 ? void 0 : node.type) === 'operator') {

context = this.handler(context, node);
cursor = this.seekRight(cursor);
cursor = this.moveRight(cursor);
return { cursor, context };

@@ -27,0 +27,0 @@ }

@@ -22,3 +22,3 @@ import { coerceHandler } from '../util';

context = this.handler(context, node);
cursor = this.seekRight(cursor);
cursor = this.moveRight(cursor);
return { cursor, context };

@@ -45,10 +45,10 @@ }

let context = this.preHandler(tplContext, rootNode);
cursor = this.matcher.seek(cursor);
cursor = this.matcher.seekNext(cursor);
const match = this.matcher.match({ context, cursor });
if (match) {
({ cursor, context } = match);
cursor = this.seek(cursor);
cursor = this.seekNext(cursor);
if (((_a = cursor.node) === null || _a === void 0 ? void 0 : _a.type) === '_end') {
context = this.postHandler(context, rootNode);
cursor = this.seekRight(tplCursor);
cursor = this.moveRight(tplCursor);
return { context, cursor };

@@ -71,6 +71,7 @@ }

match(checkpoint) {
const rootNode = checkpoint.cursor.node;
const rootCursor = this.seekNext(checkpoint.cursor);
const rootNode = rootCursor.node;
if ((rootNode === null || rootNode === void 0 ? void 0 : rootNode.type) === 'string-tree') {
let context = this.preHandler(checkpoint.context, rootNode);
let cursor = checkpoint.cursor;
let cursor = rootCursor;
if (this.matchers) {

@@ -82,3 +83,3 @@ const tokensCount = cursor.children.length - 2;

if (tokensCount > 0) {
cursor = this.seekRight(cursor.down);
cursor = this.moveRight(cursor.down);
for (const matcher of this.matchers) {

@@ -94,3 +95,3 @@ const match = matcher.match({ context, cursor });

context = this.postHandler(context, rootNode);
cursor = this.seekRight(checkpoint.cursor);
cursor = this.moveRight(rootCursor);
return { context, cursor };

@@ -97,0 +98,0 @@ }

@@ -11,3 +11,3 @@ import { coerceHandler } from '../util';

let context = checkpoint.context;
let cursor = this.seek(checkpoint.cursor);
let cursor = this.seekNext(checkpoint.cursor);
const node = cursor.node;

@@ -24,3 +24,3 @@ if ((node === null || node === void 0 ? void 0 : node.type) === 'symbol') {

context = this.handler(context, node);
cursor = this.seekRight(cursor);
cursor = this.moveRight(cursor);
return { cursor, context };

@@ -27,0 +27,0 @@ }

@@ -32,4 +32,4 @@ import { isTree } from '../../parser';

rightCursor = this.matcher
? this.matcher.seek(rightCursor)
: this.seek(rightCursor);
? this.matcher.seekNext(rightCursor)
: this.seekNext(rightCursor);
if (rightCursor) {

@@ -44,4 +44,4 @@ return rightCursor;

rightCursor = this.matcher
? this.matcher.seek(rightCursor)
: this.seek(rightCursor);
? this.matcher.seekNext(rightCursor)
: this.seekNext(rightCursor);
if (rightCursor) {

@@ -101,3 +101,3 @@ upperCursor = rightCursor;

? checkpoint.cursor
: this.seekRight(checkpoint.cursor);
: this.moveRight(checkpoint.cursor);
return { context, cursor };

@@ -104,0 +104,0 @@ }

@@ -45,3 +45,3 @@ import type { CommentToken, MinorToken, NumberToken, OperatorToken, SymbolToken } from '../lexer/types';

export interface Matcher<Ctx> {
seek(cursor: Cursor): Cursor;
seekNext(cursor: Cursor): Cursor;
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;

@@ -48,0 +48,0 @@ nextMatch(): Checkpoint<Ctx> | null;

{
"name": "good-enough-parser",
"description": "Parse and query computer programs source code",
"version": "1.1.0",
"version": "1.1.1",
"repository": "git@github.com:zharinov/good-enough-parser.git",

@@ -6,0 +6,0 @@ "author": "Sergei Zharinov",

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