Aug 10, 2012 at 8:46 AM
Edited Aug 10, 2012 at 11:18 AM
I implemented some grammar and managed to get rid of all conflicts. However, up to now it seems that one problem remains (I try to narrow it down as much as possible to keep focus on the problem):
My grammar supports characterliterals, such as 'c', and attributes, such as variableName'AttributeName. The problem now is two-fold, although I think solving one also solves the other... Consider the following simple line of code:
assert c='a' and c'OldVal='b'
(1) Whenever I want to declare an attribute (OldVal), the parser complains of a malformed string. Of course it does, There is a missing ' and OldVal is longer than one character.
(2) Before the assignment operator "=", the Grammar allows a simple identifier ("c" in the example) or an identifier's attribute ("c'OldVal"):
| identifier + "'" + identifier;
By looking only at the next token, the parser sees a valid identifier and reduces it to name. How can I implement a more sophisticated preview mechanism that, e.g., also takes into account the token after the preview token. An identifier followed by ' would
unmistakably specify an attribute.
Note: The complete grammar is relatively complex, and ShiftIf() or ReduceIf() cannot be used - at least I wouldn't know how...
Any help or hint in the right direction is appreciated!