Implementation of Gherkin Comments
Learn about the implementation of the parser and Gherkin comments.
We'll cover the following...
Our existing IndentationManager class will help us quite a bit to implement our Gherkin parser, but there is still a lot for us to do. Don’t worry; like with the data modeling, we will work through each section one at a time and discuss what we are doing along the way. We should first address the hidden complexity of Gherkin’s keywords.
Previously, we briefly mentioned that Gherkin can be localized in several different languages. Gherkin has been translated into over seventy languages, including English and Norwegian. We can find the following example from their documentation:
This presents a particularly interesting challenge to us working to implement a parser; we cannot rely on the keywords directly when looking for different Gherkin features. Instead, we will have to rely on an internal mapping of localized keywords to a known set of keywords our parser can use. Sometimes it can be challenging to determine where we should start implementing a parser, but this seems like an excellent place to start.
Parser implementation
Let’s examine the code below where we begin our parser implementation:
Between lines 16 and 26, we are ...