...

/

Implementation of Gherkin Comments

Implementation of Gherkin Comments

Learn about the implementation of the parser and Gherkin comments.

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:

Press + to interact
Funksjonalitet: Gjett et ord
Eksempel: Ordmaker starter et spill
Når Ordmaker starter et spill
Så må Ordmaker vente på at Gjetter blir med
Eksempel: Gjetter blir med
Gitt at Ordmaker har startet et spill med ordet "bløtt"
Når Gjetter blir med på Ordmakers spill
Så 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.

Parser implementation

...