When a new language is designed, generally an interpreter is built and offered to the users so that they can experiment and give comments/feedback.
The designer of the interpreter goes through the source language, makes a list of the operations/task required to implement the language. For each identified operation/task, the designer writes a function. The main function of the interpreter reads the source program line by line, checks its syntax/semantics. The parsed statement is got executed through an appropriate function.
For instance:
Consider the following program segment :
Read A
Read B
C= A + B
Print C
The above statements can be executed through the functions given below:
int Read ()
{
int val;
cin >> val;
return val;
}
int Add ( int op1, int op2)
{
return op1 + op2;
}
void Print ( int val)
{
cout << val;
}
main ()
{
Step1. open the file.
2. Read a statement
3. Parse the statement
4. get the statement executed through corresponding function
5. repeat steps 2 to 4 till the file
}
A. K. Sharma
Thought to Ponder:
How to control the worldly thoughts:
In order to control the worldly thoughts, one has to reach the level of super mind. Super mind is nothing but superior mind, that which transcends the ordinary mind
Cultivate good thoughts. Good thoughts lead to good actions. Good actions lead to Satsang.
(Bhagwan Sri Satya Sai Baba)
The designer of the interpreter goes through the source language, makes a list of the operations/task required to implement the language. For each identified operation/task, the designer writes a function. The main function of the interpreter reads the source program line by line, checks its syntax/semantics. The parsed statement is got executed through an appropriate function.
For instance:
Consider the following program segment :
Read A
Read B
C= A + B
Print C
The above statements can be executed through the functions given below:
int Read ()
{
int val;
cin >> val;
return val;
}
int Add ( int op1, int op2)
{
return op1 + op2;
}
void Print ( int val)
{
cout << val;
}
main ()
{
Step1. open the file.
2. Read a statement
3. Parse the statement
4. get the statement executed through corresponding function
5. repeat steps 2 to 4 till the file
}
A. K. Sharma
Thought to Ponder:
How to control the worldly thoughts:
In order to control the worldly thoughts, one has to reach the level of super mind. Super mind is nothing but superior mind, that which transcends the ordinary mind
Cultivate good thoughts. Good thoughts lead to good actions. Good actions lead to Satsang.
(Bhagwan Sri Satya Sai Baba)
I am sure no text book would provide such a clear and comrehensive description. Thanks you very much.
ReplyDeleteBest Regards
Dear Sir
ReplyDeleteI read this post, realy it is awesome, most of the book do not give such an elaborative discripption, for this we all thanks you whole heartely and request you to keep on posting such topics in future.
Regards
manjeet singh