Comprobación de Tipos
Especificación de la etapa de comprobación de tipos (perteneciente a la fase de análisis semántico) utilizando como metalenguaje una gramática atribuida:
Attributes
| Symbol | Atribute Name | Java Type | Syn/Inh | Description |
| expression | type | Type | Synthetized | Type of the expression |
| expression | lvalue | boolean | Synthetized | True if the expression can appear to the left of an assignment |
Auxiliary Functions
| Name | Description |
| sameType(type_a, type_b) | True if the params are equal |
Rules
| Node | Predicates | Functions |
| program → varDefinition* statement* | ||
| varDefinition → type name:string | ||
| intType:type → ε | ||
| floatType:type → ε | ||
| print:statement → expression | ||
| assignment:statement → left:expression right:expression | sameType(left.type, right.type) left.lvalue == true | |
| arithmetic:expression → left:expression operator:string right:expression | sameType(left.type, right.type) | arithmetic.type = left.type arithmetic.lvalue = false |
| variable:expression → name:string | variable.type = variable.varDefinition.type variable.lvalue = true | |
| intLiteral:expression → intValue:int | intLiteral.type = intType intLiteral.lvalue = false | |
| floatLiteral:expression → floatValue:float | floatLiteral.type = floatType floatLiteral.lvalue = false |