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

@chatopera/ms-parser

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chatopera/ms-parser - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

lib/ss-grammar-zh_CN.pegjs

7

lib/index.js

@@ -35,3 +35,3 @@ 'use strict';

const parseFile = function parseFile(path, factSystem, callback) {
const parseFile = function parseFile(path, factSystem, lang, callback) {
const startTime = Date.now();

@@ -42,3 +42,3 @@ _fs2.default.readFile(path, 'utf-8', (err, contents) => {

}
return (0, _parseContents.parseContents)(contents, factSystem, (err, parsed) => {
return (0, _parseContents.parseContents)(contents, factSystem, lang, (err, parsed) => {
if (err) {

@@ -95,2 +95,3 @@ return callback(`Error whilst processing file: ${path}\n${err}`);

const factSystem = options.factSystem;
const lang = options.lang;
const cache = options.cache || {};

@@ -106,3 +107,3 @@

return _async2.default.map(files, (fileName, callback) => {
parseFile(fileName, factSystem, callback);
parseFile(fileName, factSystem, lang, callback);
}, (err, res) => {

@@ -109,0 +110,0 @@ if (err) {

@@ -24,3 +24,3 @@ 'use strict';

var _botLang = require('bot-lang');
var _botLang = require('@chatopera/bot-lang');

@@ -49,2 +49,11 @@ var _botLang2 = _interopRequireDefault(_botLang);

const getGrammarParser = lang => {
if (!lang || lang === 'en_US') {
return parser;
} else if (lang == 'zh_CN') {
let grammar = _fs2.default.readFileSync(`${__dirname}/ss-grammar-${lang}.pegjs`, 'utf-8');
return _pegjs2.default.generate(grammar, { trace: false });
} else throw new Error('unsupported language');
};
const triggerGrammar = _fs2.default.readFileSync(`${__dirname}/trigger-grammar.pegjs`, 'utf-8');

@@ -240,3 +249,3 @@ const triggerParser = _pegjs2.default.generate(triggerGrammar, { trace: false });

const parseContents = function parseContents(code, factSystem, callback) {
const parseContents = function parseContents(code, factSystem, lang, callback) {
// Maintain backward compat.

@@ -254,3 +263,3 @@ if (arguments.length === 2) {

try {
const parsed = parser.parse(preprocessed);
const parsed = getGrammarParser(lang).parse(preprocessed);
postprocess(parsed, factSystem, (err, postprocessed) => {

@@ -257,0 +266,0 @@ // Uncomment to debug the output of parseContents

{
"name": "@chatopera/ms-parser",
"version": "1.0.3",
"version": "1.1.0",
"description": "The parser interface for SuperScript",

@@ -28,3 +28,3 @@ "main": "./lib/index.js",

"async-replace": "^1.0.1",
"bot-lang": "^1.1.1",
"@chatopera/bot-lang": "^1.1.1",
"checksum": "^0.1.1",

@@ -31,0 +31,0 @@ "debug": "^2.6.3",

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