C-- Interpretor Documentation
////////////////////////////////////////////////////////////////
Programmer : kejian Jin
Date : 2/00
Project : C-- interpretor
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
User Documentation
//////////////////////////////////////////////////////////////////
Manual
How to compile and run program:
This software has been tested under Borland C++ ,and Visual C++
Add every files into project environment, then compile and Make
then make a cmm.dat file as input file, write a small c-- program
in that file, then run the program in same directory
Program Purpose
This is program is to inteprete a language specified by CS32 intructors
which called C-- program language. We may call this software C-- interpretor
even though we need implement a visual interface in order to market it.
The language C-- specification could get from web or intructors
Program Capabilities
My program could do all functions and error checking of specification except
the things written in Limitation part. It could have cin, cout, if, for
return, assignment in the input file. All functionality for C-- is implemented
according to the specification of the project.
(1) declarations of int data types
(2) cin and cout input and output
(3) assignments
(4) single-selection if (i.e., with only a “then-clause” and no “else-clause”)
(5) counter-controlled for loops
(6) int main () and return 0
program Limitation
1. The assignment could not handle negative value
for example : t = -44 * 5 would give you an error
2. In any lines in input file body, if "return 0 ;" appear, it would ignore
the rest lines, program will be terminated.
3. It does not have line number to trace where error occurs,
but it would always be the last line to be executed
since the program will be terminated if error occurs.
4. In For loop, we could have declaration type, and return statement besides
the regular statement specified in project specification
5. Maximum input file is 1024 bytes. you could change the maximum size in
source code.
6. Do not catch error input for cin
Input data
Input file shall be specified as : cmm.dat
1. Sample input data:
int main ()
{
int num ;
int fact ;
cin >> num ;
fact = 1 ;
int i ;
for ( i = 1 ; i <= 5 ; i ++ ) {
fact = fact * i ;
}
cout << fact ;
return 0 ;
}
2. Expected Output:
valid: int main () {
Declare sucess..
Declare sucess..
Exec: cin...
please enter an integer: 5
Assignment expression : 1
Declare sucess..
Exec: for loop ....
Assignment expression : 1*1
Assignment expression : 1*2
Assignment expression : 2*3
Assignment expression : 6*4
Assignment expression : 24*5
Exec: cout : 120
Exec: return 0
|