Closed bentorkington closed 1 year ago
The side effects should be reset after each grammar run, so the rules only persist for that single evaluation pass.
From the original docs:
Dynamically Constructing Rules
Template expansions can be dynamically constructed at runtime by passing a context map of rules to the
#generate
method:class AppGreeting < Calyx::Grammar start 'Hi {username}!', 'Welcome back {username}!', 'Hola {username}!' end context = { username: UserModel.username } greeting = AppGreeting.new greeting.generate(context)
This method seems like it's intended to be like a static method, but has the effect of adding the built rules to the registry. This might be surprising, given the method name suggests it wouldn't do this.
Is this (and it's caller,
Grammar.Generate(string, Dictionary<string, string>
) intended to be part of the API?