Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[api] Overloaded kyuri.compile to take an AST or source Gherkin text

  • Loading branch information...
commit 414f1840a9e0a2f1b1212acd6a0082c0fab713e4 1 parent 4f8a52c
@indexzero indexzero authored
Showing with 6 additions and 7 deletions.
  1. +0 −1  lib/kyuri.js
  2. +6 −6 lib/kyuri/core.js
View
1  lib/kyuri.js
@@ -13,7 +13,6 @@ var kyuri = exports;
kyuri.version = '0.0.1';
kyuri.compile = require('kyuri/core').compile;
kyuri.parse = require('kyuri/core').parse;
-kyuri.parseAST = require('kyuri/core').parseAST;
kyuri.tokens = require('kyuri/core').tokens;
kyuri.nodes = require('kyuri/core').nodes;
kyuri.setLanguage = require('kyuri/core').setLanguage;
View
12 lib/kyuri/core.js
@@ -11,16 +11,20 @@
var i18n = require('./i18n').i18n,
Lexer = require('./lexer').Lexer,
- Parser = require('./parser').Parser;
+ Parser = require('./parser').Parser,
+ Generator = require('./generator').Generator;
var core = exports,
parser = new Parser(),
lexer = new Lexer('en', i18n);
exports.compile = function (code, options) {
+ var isText = typeof code === 'string', generator;
options = options || {};
+
try {
- return (parser.parse(lexer.tokenize(code))).compile(options);
+ generator = isText ? parser.parse(lexer.tokenize(code)) : new (Generator)(code);
+ return generator.compile(options);
}
catch (err) {
if (options.fileName) {
@@ -30,10 +34,6 @@ exports.compile = function (code, options) {
}
};
-exports.parseAST = function (ast) {
- return parser.parse(ast);
-};
-
exports.parse = function (code) {
return parser.parse(lexer.tokenize(code));
};
Please sign in to comment.
Something went wrong with that request. Please try again.