Stack machines = context free languages = primitive recursive functions. (?)
Turingmachines = context sensitive languages = total recursive functions. (?)
Or something like that.
Primitive recursive functions alone are able to recognize formal languages: https://en.wikipedia.org/wiki/PR_(complexity) PR is the complexity class of all primitive recursive functions—or, equivalently, the set of all formal languages that can be decided by such a function.
In this analogy G is the 'universal Turing machine'
The Algol-68 was specified using two level grammar and if I understand it correctly, the declaration part constrained parsing of the statement part so that only valid expressions can be parsed. Parsed statements are valid in the semantic sense, i.e., the subscription can be applied only to array values and parser will reject subscription for scalar values.
To generate the grammar you need to execute some function. And this function depends on the part of input.