Comparing version 3.0.0 to 3.1.0
@@ -13,3 +13,3 @@ Please read [CONTRIBUTING](https://github.com/cucumber/gherkin3/blob/master/CONTRIBUTING.md) first. | ||
Just run `npm test` from this directory (you need to `npm test` first). | ||
Just run `npm test` from this directory (you need to `npm install` first). | ||
@@ -25,4 +25,6 @@ Keep in mind that this will only run unit tests. The acceptance tests are only | ||
# Do not manually change the version in package.json - this | ||
# happens during npm version. | ||
npm outdated --depth 0 # See if you can upgrade anything | ||
npm version NEW_VERSION -m | ||
npm version NEW_VERSION | ||
npm publish |
@@ -9,2 +9,7 @@ var AstNode = require('./ast_node'); | ||
this.reset = function () { | ||
stack = [new AstNode('None')]; | ||
comments = []; | ||
}; | ||
this.startRule = function (ruleType) { | ||
@@ -11,0 +16,0 @@ stack.push(new AstNode(ruleType)); |
@@ -1,12 +0,25 @@ | ||
var error = require('tea-error'); | ||
var Errors = {}; | ||
var Errors = { | ||
ParserException: error('ParserException'), | ||
CompositeParserException: error('CompositeParserException'), | ||
UnexpectedTokenException: error('UnexpectedTokenException'), | ||
UnexpectedEOFException: error('UnexpectedEOFException'), | ||
AstBuilderException: error('AstBuilderException'), | ||
NoSuchLanguageException: error('NoSuchLanguageException') | ||
}; | ||
[ | ||
'ParserException', | ||
'CompositeParserException', | ||
'UnexpectedTokenException', | ||
'UnexpectedEOFException', | ||
'AstBuilderException', | ||
'NoSuchLanguageException' | ||
].forEach(function (name) { | ||
function ErrorProto (message) { | ||
this.message = message || ('Unspecified ' + name); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, arguments.callee); | ||
} | ||
} | ||
ErrorProto.prototype = Object.create(Error.prototype); | ||
ErrorProto.prototype.name = name; | ||
ErrorProto.prototype.constructor = ErrorProto; | ||
Errors[name] = ErrorProto; | ||
}); | ||
Errors.CompositeParserException.create = function(errors) { | ||
@@ -13,0 +26,0 @@ var message = "Parser errors:\n" + errors.map(function (e) { return e.message; }).join("\n"); |
module.exports = function TokenFormatterBuilder() { | ||
var tokensText = ''; | ||
this.reset = function () { | ||
tokensText = ''; | ||
}; | ||
this.startRule = function(ruleType) {}; | ||
@@ -5,0 +9,0 @@ |
var dialects = require('./gherkin-languages.json'); | ||
var Errors = require('./errors'); | ||
var LANGUAGE_PATTERN = /^\s*#\s*language\s*:\s*([a-zA-Z\-_]+)\s*$/; | ||
module.exports = function TokenMatcher() { | ||
var LANGUAGE_PATTERN = /^\s*#\s*language\s*:\s*([a-zA-Z\-_]+)\s*$/; | ||
changeDialect('en'); | ||
module.exports = function TokenMatcher(defaultDialectName) { | ||
defaultDialectName = defaultDialectName || 'en'; | ||
var dialect; | ||
var dialectName; | ||
var activeDocStringSeparator; | ||
var indentToRemove; | ||
function changeDialect(newDialectName, location) { | ||
var newDialect = dialects[newDialectName]; | ||
if(!newDialect) { | ||
throw Errors.NoSuchLanguageException.create(newDialectName, location); | ||
} | ||
dialectName = newDialectName; | ||
dialect = newDialect; | ||
} | ||
this.reset = function () { | ||
if(dialectName != defaultDialectName) changeDialect(defaultDialectName); | ||
activeDocStringSeparator = null; | ||
indentToRemove = 0; | ||
}; | ||
this.reset(); | ||
this.match_TagLine = function match_TagLine(token) { | ||
@@ -65,3 +88,3 @@ if(token.line.startsWith('@')) { | ||
if(match = token.line.trimmedLineText.match(LANGUAGE_PATTERN)) { | ||
newDialectName = match[1]; | ||
var newDialectName = match[1]; | ||
setTokenMatched(token, 'Language', newDialectName); | ||
@@ -75,15 +98,2 @@ | ||
function changeDialect(newDialectName, location) { | ||
newDialect = dialects[newDialectName]; | ||
if(!newDialect) { | ||
throw Errors.NoSuchLanguageException.create(newDialectName, location); | ||
} | ||
dialectName = newDialectName; | ||
dialect = newDialect; | ||
} | ||
var activeDocStringSeparator = null; | ||
var indentToRemove = null; | ||
this.match_DocStringSeparator = function match_DocStringSeparator(token) { | ||
@@ -90,0 +100,0 @@ return activeDocStringSeparator == null |
{ | ||
"name": "gherkin", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Gherkin parser", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/cucumber/gherkin3" | ||
"url": "https://github.com/cucumber/gherkin-javascript" | ||
}, | ||
@@ -26,10 +26,7 @@ "keywords": [ | ||
"bower": "^1.4.1", | ||
"browserify": "^10.2.6", | ||
"browserify": "^11.0.1", | ||
"mocha": "^2.2.5", | ||
"mversion": "^1.10.0", | ||
"uglify-js": "^2.4.23" | ||
}, | ||
"dependencies": { | ||
"tea-error": "^0.1.0" | ||
"uglify-js": "^2.4.24" | ||
} | ||
} |
@@ -6,6 +6,6 @@ var assert = require('assert'); | ||
it("parses a simple feature", function () { | ||
var parser = new Gherkin.Parser(); | ||
var parser = new Gherkin.Parser(new Gherkin.AstBuilder()); | ||
var scanner = new Gherkin.TokenScanner("Feature: hello"); | ||
var builder = new Gherkin.AstBuilder(); | ||
var ast = parser.parse(scanner, builder, new Gherkin.TokenMatcher()); | ||
var matcher = new Gherkin.TokenMatcher(); | ||
var ast = parser.parse(scanner, matcher); | ||
assert.deepEqual(ast, { | ||
@@ -24,2 +24,84 @@ type: 'Feature', | ||
}); | ||
it("parses multiple features", function () { | ||
var parser = new Gherkin.Parser(new Gherkin.AstBuilder()); | ||
var matcher = new Gherkin.TokenMatcher(); | ||
var ast1 = parser.parse(new Gherkin.TokenScanner("Feature: hello"), matcher); | ||
var ast2 = parser.parse(new Gherkin.TokenScanner("Feature: hello again"), matcher); | ||
assert.deepEqual(ast1, { | ||
type: 'Feature', | ||
tags: [], | ||
location: { line: 1, column: 1 }, | ||
language: 'en', | ||
keyword: 'Feature', | ||
name: 'hello', | ||
description: undefined, | ||
background: undefined, | ||
scenarioDefinitions: [], | ||
comments: [] | ||
}); | ||
assert.deepEqual(ast2, { | ||
type: 'Feature', | ||
tags: [], | ||
location: { line: 1, column: 1 }, | ||
language: 'en', | ||
keyword: 'Feature', | ||
name: 'hello again', | ||
description: undefined, | ||
background: undefined, | ||
scenarioDefinitions: [], | ||
comments: [] | ||
}); | ||
}); | ||
it("parses feature after parse error", function () { | ||
var parser = new Gherkin.Parser(new Gherkin.AstBuilder()); | ||
var matcher = new Gherkin.TokenMatcher(); | ||
assert.throws(function() { parser.parse(new Gherkin.TokenScanner("# a comment\n" + | ||
"Feature: Foo\n" + | ||
" Scenario: Bar\n" + | ||
" Given x\n" + | ||
" ```\n" + | ||
" unclosed docstring\n"), | ||
matcher) }, | ||
Gherkin.ParserException); | ||
var ast = parser.parse(new Gherkin.TokenScanner("Feature: Foo\n" + | ||
" Scenario: Bar\n" + | ||
" Given x\n" + | ||
" \"\"\"\n" + | ||
" closed docstring\n" + | ||
" \"\"\""), | ||
matcher); | ||
assert.deepEqual(ast, { | ||
type: 'Feature', | ||
tags: [], | ||
location: { line: 1, column: 1 }, | ||
language: 'en', | ||
keyword: 'Feature', | ||
name: 'Foo', | ||
description: undefined, | ||
background: undefined, | ||
scenarioDefinitions: [{ | ||
description: undefined, | ||
keyword: 'Scenario', | ||
location: { line: 2, column: 3 }, | ||
name: 'Bar', | ||
steps: [{ | ||
argument: { | ||
content: 'closed docstring', | ||
contentType: '', | ||
location: { line: 4, column: 7 }, | ||
type: 'DocString', | ||
}, | ||
keyword: 'Given ', | ||
location: { line: 3, column: 5 }, | ||
text: 'x', | ||
type: 'Step' }], | ||
tags: [], | ||
type: 'Scenario' }], | ||
comments: [] | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
147982
0
5456
0
- Removedtea-error@^0.1.0
- Removedtea-error@0.1.0(transitive)
- Removedtea-extend@0.2.0(transitive)