CMSC 435: Assignment 9
Overview
Create a SemanticAnalysisVisitor class that makes one or
more passes over the AST to detect a larger set of semantic errors.
Detect and report the following errors, including location information.
Subscripting non-arrays.
Operators being applied to non-integer types.
Assigning to array or function names.
Calling non-functions.
Types of arguments and parameters not being compatible.
Too few or too many function arguments.
Returning a value from a void function.
Not having at least one return expression for a non-void function.
Declaring variables or parameters as void.
Not declaring
mainlast.
Input Specification
Take the name of a C- program as a command-line argument. If no
argument is specified read from standard input (this is NECESSARY for
the grading scripts). Use .cm as the extension for C-
source files. You may add zero or more optional flags.
> ./CMinus [ --flag ]* [ <Program.cm> ]
Output Specification
Output “Valid!” if the program is a valid sentence in C- AND it has no semantic errors. Output the AST to a text file if and only if there are no errors. Output errors as in previous assignments.
If the program is syntactically valid and has no symbol errors,
perform a semantic analysis pass with your
SemanticAnalysisVisitor. Accumulate and print all errors
before aborting.
Use PRECISELY the format below with the EXACT same SPACING and SPELLING.
> ./CMinus Gcd.cm
Valid!
AST output: Gcd.ast
> ./CMinus NoReturn.cm
Compilation Error
Semantic Error [Line 7, Col 1]
No return expression found for non-void function 'gcd'
Logistics
You may work with a partner. Only ONE team member should submit. Ensure each team member’s name is listed in all submitted files.
Submission
Submit ALL necessary source files and a Makefile. ENSURE
your Makefile is named Makefile, properly builds your
program, and that make clean removes all generated
files.
ALSO, submit a text file Team.txt listing your team
members (even if you’re the only member), each member’s contributions,
what functionality works, what doesn’t, and the areas with which you
struggled.
NOTE: NO submissions will be accepted after the due date.
Gary M. Zoppetti, Ph.D.