-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
286 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
const { AstBuilder, GherkinClassicTokenMatcher, Parser } = require('@cucumber/gherkin'); | ||
|
||
function createGherkinParser(options) | ||
{ | ||
const builder = new AstBuilder(String); | ||
const tokenMatcher = new GherkinClassicTokenMatcher(options.defaultDialectName); | ||
const parser = new Parser(builder, tokenMatcher); | ||
return parser; | ||
} | ||
|
||
module.exports = | ||
{ | ||
parse(text, options) | ||
{ | ||
const parser = createGherkinParser(options); | ||
try | ||
{ | ||
const ast = parser.parse(text); | ||
ast.body = []; | ||
ast.loc = { }; | ||
ast.range = [,,]; | ||
ast.tokens = []; | ||
ast.type = 'Program'; | ||
return ast; | ||
} | ||
catch (error) | ||
{ | ||
const [subError] = error.errors; | ||
if (subError) | ||
{ | ||
const { location } = subError; | ||
error.lineNumber = location.line; | ||
error.column = location.column; | ||
} | ||
throw error; | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.