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

bnf-parser

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bnf-parser - npm Package Compare versions

Comparing version 4.0.2 to 4.0.3

6

bin/cli.js

@@ -44,5 +44,9 @@ #!/usr/bin/env node

const root = process.argv[2] || "./";
if (!existsSync(root)) {
console.error(`Unknown path ${root}`);
process.exit(1);
}
const isFile = statSync(root).isFile();
const root_dir = isFile ? dirname(root) : root.slice(0, -1);
if (!existsSync(root)) {
if (!existsSync(root_dir)) {
console.error(`Unknown path ${root}`);

@@ -49,0 +53,0 @@ process.exit(1);

16

bin/types.js

@@ -54,3 +54,3 @@ import { Sequence } from './legacy/parser.js';

function CompileGather() {
return TemplateNode(`'literal'`, 'string');
return "_Literal";
}

@@ -71,6 +71,6 @@ function CompileTerm(expr) {

function CompileNot() {
return TemplateNode(`'literal'`, 'string');
return "_Literal";
}
function CompileRange() {
return TemplateNode(`'literal'`, 'string');
return "_Literal";
}

@@ -88,3 +88,3 @@ function CompileLiteral(expr) {

let safe = expr.value.replace(/[^a-zA-Z0-9]/g, (char) => '\\x' + char.charCodeAt(0).toString(16).padStart(2, '0'));
return TemplateNode(`'literal'`, `'${safe}'`);
return `_Literal & {value: "${safe}"}`;
}

@@ -129,5 +129,7 @@ function CompileRepeat(innerType, repetitions) {

export function CompileTypes(lang) {
return `import type _Shared from './shared.js';\n` + [...lang.terms.keys()]
.map(x => CompileRule(lang.terms.get(x))) // hush Typescript it's okay
.join('\n');
return `import type _Shared from './shared.js';\n` +
`export type _Literal = { type: "literal", value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange };\n` +
[...lang.terms.keys()]
.map(x => CompileRule(lang.terms.get(x))) // hush Typescript it's okay
.join('\n');
}
import type _Shared from './shared.js';
export type _Literal = { type: "literal", value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange };
export type Term_Program = {

@@ -26,3 +27,3 @@ type: 'program',

value: [
(Term_Comment | { type: 'literal', value: '\x20', start: number, end: number, count: number, ref: _Shared.ReferenceRange } | { type: 'literal', value: '\x09', start: number, end: number, count: number, ref: _Shared.ReferenceRange } | { type: 'literal', value: '\x0a', start: number, end: number, count: number, ref: _Shared.ReferenceRange } | { type: 'literal', value: '\x0d\x0a', start: number, end: number, count: number, ref: _Shared.ReferenceRange })
(Term_Comment | _Literal & {value: "\x20"} | _Literal & {value: "\x09"} | _Literal & {value: "\x0a"} | _Literal & {value: "\x0d\x0a"})
]

@@ -44,5 +45,5 @@ }

value: [
{ type: 'literal', value: '\x23', start: number, end: number, count: number, ref: _Shared.ReferenceRange },
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange },
{ type: 'literal', value: '\x0a', start: number, end: number, count: number, ref: _Shared.ReferenceRange }
_Literal & {value: "\x23"},
_Literal,
_Literal & {value: "\x0a"}
]

@@ -65,3 +66,3 @@ }

Term_Letter,
{ type: '(...)*', value: Array<(Term_Letter | Term_Digit | { type: 'literal', value: '\x5f', start: number, end: number, count: number, ref: _Shared.ReferenceRange })>, start: number, end: number, count: number, ref: _Shared.ReferenceRange }
{ type: '(...)*', value: Array<(Term_Letter | Term_Digit | _Literal & {value: "\x5f"})>, start: number, end: number, count: number, ref: _Shared.ReferenceRange }
]

@@ -83,3 +84,3 @@ }

value: [
({ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange } | { type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange })
(_Literal | _Literal)
]

@@ -101,3 +102,3 @@ }

value: [
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange }
_Literal
]

@@ -119,3 +120,3 @@ }

value: [
({ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange } | { type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange } | { type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange })
(_Literal | _Literal | _Literal)
]

@@ -154,3 +155,3 @@ }

value: [
(Term_Escape | Term_Byte | { type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange })
(Term_Escape | Term_Byte | _Literal)
]

@@ -172,3 +173,3 @@ }

value: [
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange }
_Literal
]

@@ -190,3 +191,3 @@ }

value: [
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange }
_Literal
]

@@ -208,3 +209,3 @@ }

value: [
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange },
_Literal,
Term_Expr

@@ -235,3 +236,3 @@ ]

value: [
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange },
_Literal,
Term_Expr_arg

@@ -257,4 +258,4 @@ ]

Term_Expr_prefix,
(Term_Constant | Term_Expr_brackets | { type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange }),
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange }
(Term_Constant | Term_Expr_brackets | _Literal),
_Literal
]

@@ -276,5 +277,5 @@ }

value: [
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange },
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange },
{ type: 'literal', value: string, start: number, end: number, count: number, ref: _Shared.ReferenceRange }
_Literal,
_Literal,
_Literal
]

@@ -296,3 +297,3 @@ }

value: [
({ type: 'literal', value: '\x2d\x3e', start: number, end: number, count: number, ref: _Shared.ReferenceRange } | { type: 'literal', value: '\x7c', start: number, end: number, count: number, ref: _Shared.ReferenceRange })
(_Literal & {value: "\x2d\x3e"} | _Literal & {value: "\x7c"})
]

@@ -314,3 +315,3 @@ }

value: [
({ type: 'literal', value: '\x2a', start: number, end: number, count: number, ref: _Shared.ReferenceRange } | { type: 'literal', value: '\x3f', start: number, end: number, count: number, ref: _Shared.ReferenceRange } | { type: 'literal', value: '\x2b', start: number, end: number, count: number, ref: _Shared.ReferenceRange })
(_Literal & {value: "\x2a"} | _Literal & {value: "\x3f"} | _Literal & {value: "\x2b"})
]

@@ -317,0 +318,0 @@ }

{
"name": "bnf-parser",
"version": "4.0.2",
"version": "4.0.3",
"description": "Deterministic BNF compiler/parser",

@@ -5,0 +5,0 @@ "homepage": "https://bnf-parser.ajanibilby.com",

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