|
/*
Author : Shakti Misra
All are welcome to use these files, distribute, modify and release. But This notice should be included.
*/
#include "Interpreter.h"
void Interpreter::interpreteScript()//Main routine to start script interpretation. this is semantic analysis or meaning findout method.
{
while(eTokenOver != m_lex.getNextToken())
{
switch(m_lex.getCurrentToken())
{//Based on the tokens choose the path.
case eRdAndStrVal:
m_tapeVirtualMachine.getCharAndStore();break;
case eDspCurVal:
m_tapeVirtualMachine.displayChar();break;
case eIncrContent:
m_tapeVirtualMachine.incrementContent();break;
case eDecrContent:
m_tapeVirtualMachine.decrementContent();break;
case eAddWithNext:
m_tapeVirtualMachine.addWithNext();break;
case eSubNext:
m_tapeVirtualMachine.substractFromNext();break;
case eIncrHead:
m_tapeVirtualMachine.moveHeadForeward();break;
case eDecrHead:
m_tapeVirtualMachine.moveHeadBackward();break;
case eExclaimationMark:
intDisplayContent();break;
}
}
}
void Interpreter::intDisplayContent()
{//When we are in this function we know that it was due to ![eExclaimationMark] that this function is called.
//So check for eLeftSqrParen eIntNumber eRightSqrParen structure.
switch(m_lex.getNextToken())//The tokens group eExclaimationMark eLeftSqrParen eIntNumber eRightSqrParen is a valid token.
{
case eLeftSqrParen:
int len = 0;
if(eIntNumber == m_lex.getNextToken())
{
len = m_lex.getAttribVal();
}
if(eRightSqrParen == m_lex.getNextToken())
{
m_tapeVirtualMachine.displayMultiChar(len);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I like to explore different aspects of technology. Try new things, and get delighted. My interests are programming language, and Imaging. But its not hard to work on other things also. Algorithms delight me over a coffee break.
I basically code in C++, but JAVA is not so alien for me. I know few scripting languages also. Basically I feel that knowing a programing language is just a matter of getting introduced to it.
For my other articles check my blog on homepage:
http://brainlesslabs.com/
https://github.com/BrainlessLabsInc
http://www.luxrender.net/en_GB/authors_contributors - SMISRA