TinyCStr
Compiler Design Lab
JNTUGV CEV
18-07-2026
TinyCStr features
TinyCStr program structure
Every TinyC program has an optional global declarations followed by one or more functions and one function must be main.
Every TinyC function has zero or more TinyC statements
Every TinyC statement is any of the following, an assignment statement, a control flow statement, a return statement, a declaration statement, a TinyC print statement
1
2
3
TinyCStr examples: Example 1
int main(){
int a,b,c;
a=5;
b=5;
c=a+b; // all statements are similar to C, except print
print c; // print is predefined operator in TinyCStr which prints the value of c
}
TinyCStr example Example2
int main(){
int a=30;
Int b =40;
c=a+b*a+a*a;
print a;
}
TinyCStr examples: Example 3
int a=40,b=50;
double c;
int main(){
if(a>b)
c=(double)a/b;
else
c=(double)b/a;
print c;
}
TinyCStr examples: Example4
int a,b,c;
double d,e,f,;
int add(int,int); //declaration of function
double mult(double,double);
int main(){
c=add(30,40);
d=mult(40.8,50.2);
a=-5;
b=-45;
c= add(a,b);
print c;
}
Int add(int a1, int a2){
return a+b;
}
Implementation of TinyCStr
Compilation:
Lexical analysis -> Syntax Analysis -> Semantic Analysis -> Intermediate code generation -> Code Optimization -> Code generation
Interpretation:
Lexical analysis -> Syntax Analysis -> Semantic Analysis -> Evaluate statements
Translation vs Evaluation: Example
int main(){
int a,b,c;
a=5;
b=25;
c=a*a+b-20; // all statements are similar to C, except print
print c; // print is predefined operator in TinyC which prints the value of c
}
Evaluation gives :