I am writing a language specification, and I need the following rudimentary question resolved. Suppose I have the (admittedly contrived) abstract syntax:
<A> ::= <B> | <C>
<B> ::= 1 | 2 | 3
<C> ::= 4 | 5 | 6
What does the denotational semantics for this language look like? Non-terminals are enclosed in '<' and '>' and terminals are not. I want to map 1
... 6
to the domain of natural numbers. The thing that is not at all clear to me is whether I need to provide mappings for non-terminals. It seems like I should not need to since, e.g., <A> ::= <B> | <C>
has no meaning; it is simply a bit of structure. Ignore, for the moment that we could eliminate this rule entirely.
So, as it stands, this is what I think the complete denotational definition should look like, where the right-hand side (in italics) represents the corresponding value from the natural numbers:
[[1]] =
one
[[2]] =
two
[[3]] =
three
[[4]] =
four
[[5]] =
five
[[6]] =
six
Aesthetically, it seems odd not to mention A
, B
, or C
at all, but I suppose that those symbols will never appear in an actual program (like: 4
), so maybe this suffices. All of the materials I have on this subject omit this very simple, nuts and bolts, aspect of the language definition process from their discussions.