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:
Funksjonalitet: Gjett et ordEksempel: Ordmaker starter et spillNår Ordmaker starter et spillSå må Ordmaker vente på at Gjetter blir medEksempel: Gjetter blir medGitt at Ordmaker har startet et spill med ordet "bløtt"Når Gjetter blir med på Ordmakers spillSå må Gjetter gjette et ord på 5 bokstaver
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.