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

apg-js

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apg-js - npm Package Compare versions

Comparing version 4.2.1 to 4.3.0

2

package.json
{
"name": "apg-js",
"version": "4.2.1",
"version": "4.3.0",
"description": "JavaScript APG, an ABNF Parser Generator",

@@ -5,0 +5,0 @@ "main": "index.js",

# JavaScript APG
## 4.3.0 Release Notes
Version 4.3.0 adds support for [apg-lite](https://github.com/ldthomas/apg-lite),
a new, light-weight version of the parsers built from this library.
The parser generator (`src/apg/apg.js`) has a new option, `--lite`, that will
generate grammar objects for the `apg-lite` parsers.
See the documentation for `apg-lite` for a complete description.
Version 4.3.0 makes no other changes to the previous version other than adding the new `apg-lite` feature.
## 4.2.1 Release Notes

@@ -8,4 +18,4 @@

> char = %d33-127
> empty1 = 0char
> char = %d33-127
> empty1 = 0char
> empty2 = 0"x"

@@ -12,0 +22,0 @@

@@ -350,7 +350,7 @@ /* *************************************************************************************

// Error detection and reporting is now fairly robust and tracing should be unnecessary. Use at your own peril.</i>
this.parse = function parse(strict, trace) {
this.parse = function parse(strict, lite, trace) {
if (!isScanned) {
throw new Error(`${thisFileName}grammar not scanned`);
}
parser.syntax(this.chars, this.lines, this.errors, strict, trace);
parser.syntax(this.chars, this.lines, this.errors, strict, lite, trace);
isParsed = true;

@@ -452,3 +452,3 @@ };

// This object can then be used to construct a parser.
this.toSource = function toSource(name) {
this.toSource = function toSource(lite, name) {
if (!haveAttributes) {

@@ -460,3 +460,3 @@ throw new Error(`${thisFileName}can't generate parser source - must be preceeded by call to attributes()`);

}
return parser.generateSource(this.chars, this.lines, this.rules, this.udts, name);
return parser.generateSource(this.chars, this.lines, this.rules, this.udts, lite, name);
};

@@ -463,0 +463,0 @@ // Returns a parser grammar object.

@@ -85,3 +85,3 @@ /* *************************************************************************************

/* SABNF grammar syntax errors are caught and reported here. */
this.syntax = function syntax(chars, lines, errors, strict, trace) {
this.syntax = function syntax(chars, lines, errors, strict, lite, trace) {
if (trace) {

@@ -96,2 +96,3 @@ if (trace.traceObject !== 'traceObject') {

data.strict = !!strict;
data.lite = !!lite;
data.lines = lines;

@@ -135,3 +136,3 @@ data.findLine = findLine;

// An object instantiated from this constructor is used with the `apg-lib` `parser()` function.
this.generateSource = function generateSource(chars, lines, rules, udts, name) {
this.generateSource = function generateSource(chars, lines, rules, udts, lite, name) {
let source = '';

@@ -245,11 +246,13 @@ let i;

}
let funcname = 'module.exports';
if (name && typeof name === 'string') {
funcname = `let ${name}`;
}
source += '// copyright: Copyright (c) 2023 Lowell D. Thomas, all rights reserved<br>\n';
source += '// license: BSD-2-Clause (https://opensource.org/licenses/BSD-2-Clause)<br>\n';
source += '//\n';
source += '// Generated by apg-js, Version 4.2.1 [apg-js](https://github.com/ldthomas/apg-js)\n';
source += `${funcname} = function grammar(){\n`;
source += '// Generated by apg-js, Version 4.3.0 [apg-js](https://github.com/ldthomas/apg-js)\n';
if (name && typeof name === 'string') {
source += `const ${name} = function grammar(){\n`;
} else if (lite) {
source += 'export default function grammar(){\n';
} else {
source += `module.exports = function grammar(){\n`;
}
source += ' // ```\n';

@@ -272,7 +275,9 @@ source += ' // SUMMARY\n';

source += ` // NOT = ${not}\n`;
source += ` // BKA = ${bka}\n`;
source += ` // BKN = ${bkn}\n`;
source += ` // BKR = ${bkr}\n`;
source += ` // ABG = ${abg}\n`;
source += ` // AEN = ${aen}\n`;
if (!lite) {
source += ` // BKA = ${bka}\n`;
source += ` // BKN = ${bkn}\n`;
source += ` // BKR = ${bkr}\n`;
source += ` // ABG = ${abg}\n`;
source += ` // AEN = ${aen}\n`;
}
source += ' // characters = [';

@@ -289,4 +294,6 @@ if (tls + tbs + trg === 0) {

source += ' // ```\n';
source += ' /* OBJECT IDENTIFIER (for internal parser use) */\n';
source += " this.grammarObject = 'grammarObject';\n";
if (!lite) {
source += ' /* OBJECT IDENTIFIER (for internal parser use) */\n';
source += " this.grammarObject = 'grammarObject';\n";
}
source += '\n';

@@ -293,0 +300,0 @@ source += ' /* RULES */\n';

@@ -186,2 +186,8 @@ /* eslint-disable func-names */

});
} else if (data.lite) {
data.errors.push({
line: data.findLine(data.lines, phraseIndex, data.charsLength),
char: phraseIndex,
msg: 'Positive look-behind operator(&&) found - apg-lite specified.',
});
}

@@ -208,2 +214,8 @@ break;

});
} else if (data.lite) {
data.errors.push({
line: data.findLine(data.lines, phraseIndex, data.charsLength),
char: phraseIndex,
msg: 'Negative look-behind operator(!!) found - apg-lite specified.',
});
}

@@ -230,2 +242,8 @@ break;

});
} else if (data.lite) {
data.errors.push({
line: data.findLine(data.lines, phraseIndex, data.charsLength),
char: phraseIndex,
msg: 'Beginning of string anchor(%^) found - apg-lite specified.',
});
}

@@ -252,2 +270,8 @@ break;

});
} else if (data.lite) {
data.errors.push({
line: data.findLine(data.lines, phraseIndex, data.charsLength),
char: phraseIndex,
msg: 'End of string anchor(%$) found - apg-lite specified.',
});
}

@@ -275,2 +299,9 @@ break;

});
} else if (data.lite) {
const name = apglib.utils.charsToString(chars, phraseIndex, result.phraseLength);
data.errors.push({
line: data.findLine(data.lines, phraseIndex, data.charsLength),
char: phraseIndex,
msg: `Back reference operator(${name}) found - apg-lite specified.`,
});
}

@@ -277,0 +308,0 @@ break;

@@ -68,3 +68,3 @@ /* *************************************************************************************

/* parse the grammar - the syntax phase */
api.parse(config.strict);
api.parse(config.strict, config.lite);
if (api.errors.length) {

@@ -110,4 +110,8 @@ logErrors(api, 'GRAMMAR SYNTAX ERRORS');

if (config.outfd) {
fs.writeSync(config.outfd, api.toSource(config.funcName));
console.log(`\nJavaScript parser generated: ${config.outFilename}`);
fs.writeSync(config.outfd, api.toSource(config.lite, config.funcName));
if (config.lite) {
console.log(`\napg-lite grammar object generated: ${config.outFilename}`);
} else {
console.log(`\napg-js grammar object generated: ${config.outFilename}`);
}
}

@@ -114,0 +118,0 @@ } catch (e) {

@@ -30,2 +30,3 @@ /* *************************************************************************************

help += '-s, --strict : only ABNF grammar (RFC 5234 & 7405) allowed, no Superset features\n';
help += '-l, --lite : generate an apg-lite ESM grammar object\n';
help += '-i <path>[,<path>[,...]] : input file(s)*\n';

@@ -51,13 +52,14 @@ help += '--in=<path>[,<path>[,...]] : input file(s)*\n';

help += '*** Grammar function name is optional.\n';
help += ' If absent, use module.exports for node.js application usage.\n';
help += ' If present, must be a valid JavaScript function name for web page usage.\n';
help += " No testing is done (it's complicated). If the name is not valid\n";
help += ' you will find out when you try to use it.\n';
help += ' If present, must be a valid JavaScript function name\n';
help += ' If absent, uses "module.exports" for apg-js application\n';
help += ' or "export default" for apg-lite application.\n';
return help;
};
const version = function version() {
return 'JavaScript APG, version 4.2.1\nCopyright (C) 2023 Lowell D. Thomas, all rights reserved\n';
return 'JavaScript APG, version 4.3.0\nCopyright (C) 2023 Lowell D. Thomas, all rights reserved\n';
};
const STRICTL = '--strict';
const STRICTS = '-s';
const LITEL = '--lite';
const LITES = '-l';
const HELPL = '--help';

@@ -82,2 +84,3 @@ const HELPS = '-h';

strict: false,
lite: false,
noAttrs: false,

@@ -134,2 +137,7 @@ displayRules: false,

break;
case LITEL:
case LITES:
config.lite = true;
i += 1;
break;
case INL:

@@ -136,0 +144,0 @@ case INS:

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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