Is it valid (in the sense of formal grammars or formal language theory) to refer to outside of the grammar in attribute grammars?

What I mean is that since attribute grammars can contain semantic functions e.g.

E1 → E2+T { E1.val := sum(E2.val, T.val) }

then could there (in the place of the sum function) be a function that does e.g. a SQL query?

Should add that this is technically feasible, but I want to know that if it's reasonable and in accord to the theory of attribute grammars and the practice of semantic analysis.


1 Answer 1


The sum function of your example itself is already stepping out of the strict scope of the grammar. Or you'd have to to explicitly include all the machinery used in your attributed grammar into it, in which case nothing forbids adding (some formalization of) SQL and a database to it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.