I'm finally making progress in this project.
Working on predictive LL(*) style parsers which will provide a prediction mechanism any time there is a non LL(1) compliant choice to be made.
Let's say you have a grammar which describes a class member declaration:
ClassMemberDeclaration ::=> ConstantDeclaration | FieldDeclaration | MethodDeclaration | LanguageDeclaration | PropertyDeclaration | EventDeclaration | IndexerDeclaration | OperatorDeclaration | ConstructorDeclaration | DestructorDeclaration | StaticConstructorDeclaration | TypeDeclaration ;
All of these members are allowed 'Attributes' which begin with a '['. Typically this would cause an LL(1) parser generator to halt, but here OILexer does the work to guess which path is valid:
// State 298 requires prediction: Predict298OnClassMemberDeclaration.
The look-ahead table is symbolic in nature, so be it a token or a rule, it'll go into the stream.
The results of the 'predict' method are the target state that the deterministic machine generated for a given rule would have gone into could it guess properly in one token. So it not only tells it which rule to call, but where to go next.
The state machines are heavily reduced for now, but as I learn the viability of the process, it'll be better decidable. There is a caveat, there might be possible incorrect guesses for now, and here's why:
- Edge states which overlap the owning rule's tokens, the prediction might guess incorrectly.
No comments:
Post a Comment