Next: Tracking Locations, Previous: Rules, Up: Grammar File [Contents][Index]
The grammar rules for a language determine only the syntax. The semantics are determined by the semantic values associated with various tokens and groupings, and by the actions taken when various groupings are recognized.
For example, the calculator calculates properly because the value associated with each expression is the proper number; it adds properly because the action for the grouping ‘x + y’ is to add the numbers associated with x and y.
• Value Type: | Specifying one data type for all semantic values. | |
• Multiple Types: | Specifying several alternative data types. | |
• Type Generation: | Generating the semantic value type. | |
• Union Decl: | Declaring the set of all semantic value types. | |
• Structured Value Type: | Providing a structured semantic value type. | |
• Actions: | An action is the semantic definition of a grammar rule. | |
• Action Types: | Specifying data types for actions to operate on. | |
• Mid-Rule Actions: | Most actions go at the end of a rule. This says when, why and how to use the exceptional action in the middle of a rule. |