1. Declaration and Unicity. Review for uniqueness and that the variable has been declared before its usage. 2. Types. Review that the types of variables match the values assigned to them. 3. Array’s indexes. Review that the indexes are integers. 4. Conditions. Review that all expressions on the conditons return a boolean value. 5. Return type. Review that the value returned by a method match the type of the method. 6. Parameters. Review that the parameters in a method match in type and number with the declaration of the method.
Declaration and Unicity. Review for uniqueness and that the variable has been declared before its usage. Type Matching. Review that the types of variables match the values assigned to them. Array’s indexes. Review that the indexes are integers. Conditions. Review that all expressions on the conditions return a boolean value. Return type. Review that the value returned by a method matches the type of the method. Parameters. Review that the parameters in a method match in type and number with the declaration of the method.
Work 1. Functions: Grammar and Semantic Validation 2. Arrays: Grammar and Semantic Validation 3. Switch, For, and Do/While: Grammar and Semantic Validation 4. CallToMethod: Grammar and Semantic Validation
1 1.Line 2: variable <boo> is already defined 2.Line 4: variable <k> is already defined 3.Line 8: incompatible types: type mismatch 4.Line 10: variable <hello> not found 5.Line 10: incompatible types: type mismatch 6.Line 18: boolean expression expected 7.Line 30: incompatible types: type mismatch 8.Line 34: incompatible types: type mismatch
slides can only be used as study material for the Compilers course at Universidad Panamericana. They cannot be distributed or used for another purpose.