I am doing a program for my automaton class. But now they have asked us for a somewhat complicated program and I would like them to help me with some detail (I do not want them to do my homework, but I am looking for ideas) The problem is, that in the following grammar:
program > begin statementlist end
statementlist > statement statementtail
statementtail > statement statementtail
statementtail >
statement > ip dosp igual expresion pcoma
statement > read pari exprlist pard pcoma
statement > write pari exprlist pard pcoma
idlist > id idtail
idtail > coma id idtail
idtail >
exprlist > expresion exprtail
exprtail > coma expresion exprtail
exprtail >
expresion > primary primarytail
primarytail > addop primary primarytail
primarytail >
primary > pari expresion pard
primary > id
primary > intliteral
addop > mas
addop > menos
systemgoal > program
I have terminal and non-terminal symbols. Until then everything clear. The activity proposes to carry out a program capable of reading from a txt the grammar shown and also separating the terminal symbols from the nonterminals. (Basically separate the left side of the right). All this I tried to do with lists, but it did not work for me. An important detail is that I HAVE NOT ALLOWED TO USE SPLIT (). Any ideas? Any contribution will be appreciated.