I've been stuck with this since a while now. I want to parse something as simple as:
LIKES: word1 word2 .. wordN HATES: word1 word2 .. wordN
I am using Lemon+Flex. At the moment my Grammar looks something like this :
%left LIKES MOODS FROM HATES INFO.
%syntax_error {
std::cout << "Syntax error!" << std::endl;
}
final ::= likes_stmt.
final ::= hates_stmt.
likes_stmt ::= LIKES list(A). { Data *data=Data::getInstance();data->likes.push_back(A);}
hates_stmt ::= HATES list(A). { Data *data=Data::getInstance();data->hates.push_back(A);}
list ::= likes_stmt VALUE(A). { Data *data=Data::getInstance();data->likes.push_back(A);}
list ::= hates_stmt VALUE(A). { Data *data=Data::getInstance();data->hates.push_back(A); }
list(A) ::= VALUE(B). {A=B;}
But this only works for first 2 words. Clearly I am doing something wrong , probably in the recursive definition ? Any heads up is appreciated :)