# Copyright (C) Mohammad Hasanzadeh Mofrad - All Rights Reserved # Course: CS 2210 - Compiler Design (Spring 2016) # Project: Mini Java - part 3 - Semantic Analyser # File: Readme # Author: Mohammad Hasanzadeh Mofrad # Email: hasanzadeh@cs.pitt.edu # Date: March 2016; Last revision 03-29-2016 # Mini Java - semantic Analyzer ## Compatible GCC version # gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ## Compatible file character encoding # text/x-c; charset=us-ascii ## Successful run on arsenic.cs.pitt.edu ## Project structure This project consists of the following key files: * Makefile that build the program * parser.y contains grammars for YACC tool * driver.c runs the parser * lexer.l contains regular expressions for LEX tool * proj2.c and proj2.h contain procedures to print syntax tree * proj3.c and proj3.h contain procedures to print semantic tree * traverstree.c contains procedures to perform semantic checks * tokens.h contains token numbers of reserved words for lexical analyser * lexer0.c (lexical analysis only) contains regular expressions for LEX tool * driver0.c (lexical analysis only) runs the lexer ## Building the project For help building the parser: * make help For building the parser: * make parser For using the parser: * ./parser PATH_TO_TEST_FILE For storing the output of parser: * ./parser PATH_TO_TEST_FILE > PATH_TO_OUT_FILE ## Semantic Analyser specifications Semantic analyser consists of a two passes process for creation of attribute syntax tree with parser.y and traversetree.c for attribute syntax tree * Concise linking between parser.y (syntax analyser) and traversetree.c (semantic analyser) with zero changing in parser.y * Integrating the semantic analyser with lexical analyser by adding loc_str() in lexer.l and attaching it to proj3.c ## Main Semantic Checks # ERR1: Array dimensions mismatch # ERR2: Number of arguments mismatch # ERR3: Multiple mains ## Additional Semantic Checks * Symbol redeclaration * Undeclared Symbol * Adding undeclared symbols to the symbol table * Undeclared class methods