Example of synthesized attribute:
Cross-using rules from each other, different typing (example itself is meaningless by design)
Naive/manual implementation of visiting pattern on grammar:
In a language like C# you implement IJsonVisitor and execute calculation on parse result (int array). Extensions can potentially be implemented using C# extension methods syntax on interface. The problem is their discovery, otherwise they are just static functions which gets interface and node data.
Such visitor can be generated with syntactic sugar: