I have the following entry in a file .txt
:
var a;
var b; var c;
a = (10+2)/2;
b = a*2;
c = a*b;
print a; print b; print c;
Where the getToken () function will return me the current token, containing the type and its value. For example:
1st method call getToken()
:
will return an object of type Token
, containing keywordChave and var
2nd method call getToken()
:
will return an object of type Token
, containing ID and a
3rd call of method getToken()
:
will return an object of type Token
, containing delimiter and ;
and so on.
In other words, I need to analyze the file in such a way that it is possible to control where I got the last token . The code below is impractical because I can not control which part of the file I captured the last symbol:
if(entrada.is_open()){
while(getline(entrada, linha)){
int tam_linha = linha.size();
for(int i=0; i<=tam_linha-1; i++){
}
}
}
So, how do I get the file to be read "interrupt" by calling the getToken()
function and return the next symbol?
Appendix: