Hey guys,
I was wondering if there were possiblities to ignore certain errors during
parsing. I tried using the error token, but that didn't seem to work. I
looked at the following topic
http://haskell.1045720.n5.nabble.com/Error-detection-in-GLR-Happy-grammar-td3083740.html
For my parser I
I'd join comments in with tokens so each token has a comment -
possibly the empty string, then the parser can decide what to do with
the comment part of token - e.g retaining it for functions, ignoring
it for everything else.
You may have to write a two-pass lexer to do this.
By the way - my last answer was for the second part of the question.
For error handling - Doaitse Swierstra's UU-Parsing is a combinator
parsing library with some flexibility for error recovery. For an LR
parser like Happy adding extra error handling cases to the productions
in your grammar is
That two-pass lexer sounds like a good idea. I actually want to keep the
happy parser if possible, can you elaborate on adding extra error handling
cases for production rules? Do you mean I have to add a line for comments on
possible places where they can occur?
Thanks
Hi Tom
Here's how I'd do comment annotation in the Parser:
type Comment = String
type Identifier = String
I suspect data carrying tokens need to pair the data and the comment
so Happy can treat them as a positional reference e.g. $1
data Token =
TK_identifier (Identifier,Comment)
|
Alright thanks for your comprehensive answer! I think I got something to
work with :)
Cheers,
Tom
On Tue, Mar 8, 2011 at 8:09 PM, Stephen Tetley stephen.tet...@gmail.comwrote:
Hi Tom
Here's how I'd do comment annotation in the Parser:
type Comment = String
type Identifier = String