@chatopera/ms-parser
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40789
10
399
+ Added@chatopera/bot-lang@^1.1.1
+ Added@chatopera/bot-lang@1.1.1(transitive)
- Removedbot-lang@^1.1.1
- Removedbot-lang@1.1.1(transitive)