you might want to bite off the gaps that are between other bites.
in this language, you can bite off "pasta", then "gang". but this time, you can leave a gap between them, if you want.
TRANSLATED:
it's easy. it's just a REGULAR EXPRESSION term that matches any number ofspaces or tabs.
class GapTerm extends RegExpTerm {
constructor() {
super(/[\s\t]+/)
}
}
give it a name though. no one wants to see your filthy REGULAR EXPRESSION.
class GapTerm extends RegExpTerm {
//...
name() {
return "gap"
}
}
then use it in your list.
const listTerm = new ListTerm([
new StringTerm("pasta"),
new MaybeTerm(new GapTerm()),
new StringTerm("gang"),
])
function translate(text) {
return listTerm.translate(text)
}
back to the dream