Parsing
John Aycock
aycock at csc.uvic.ca
Tue May 4 02:28:50 EDT 1999
Paul Prescod (paul at prescod.net) wrote:
: I am using Aycock's package to handle some parsing but I am having trouble
: because the language I am parsing is highly context sensitive. I don't
: have any trouble dealing with the context-sensitivity in the so-called
: "context free grammar" part of the package (the parser) but in the scanner
: it is killing me.
..
Element ::= <URL> urlcontent </URL>
urlcontent = (([^<>\/:]* ("\<"|"\>"|":"|"/"|"\\"))*
Element ::= <NOT-A-URL> anychar* </NOT-A-URL>
..
: I could handle it if I could switch scanners mid-stream (for URL elements)
: but Aycock's scanner finishes up before the parser even gets under way!
True. The framework's design deliberately excluded lexical feedback. When
I needed to do a similar context-sensitive job with the framework, I had a
kludge in the scanner class which guessed the context.
In your particular case, my thought is that the correct form of "urlcontent"
is more of a semantic issue, and so I'd want to handle it *after* scanning and
parsing; you would likely be able to print a better diagnostic message
that way too. Maybe I've misunderstood the problem you described?
John
More information about the Python-list
mailing list