#include <iostream>
#include <string>
#include "scanner.h"
using namespace std;
void program(string &sym);
void body(string &sym);
void stmt(string &sym);
string sym;
int main()
{
openfile();
sym = getsym();
program(sym);
return 0;
}
void program(string &sym)
{
stmt(sym);
//cout << sym;
if(sym!="$")
{
cout << "Parser failed" << endl;
}
else
{
cout << "PARSE COMPLETED" << endl;
return;
}
}
void stmt(string &sym)
{
//cout << sym;
if(sym == "RWread" || sym == "RWwrite")
{
sym = getsym();
if(sym == ";")
{
//cout << sym;
cout << "end of that expression" << endl;
sym = getsym();
program(sym);
}
}
else
return;
}
in the text file from what its reading is as follows:
read ;
$
i get the output "end of that expression" which is fine, but then I get 2 "PARSER COMPLTED" , but I only want one of them. I can't understand why I get two and not one? :sad: