[Pyparsing] RE: python indentation grammar
Brought to you by:
ptmcg
From: Michel P. <mi...@di...> - 2005-08-18 17:30:42
|
On Thu, 2005-08-18 at 06:35 -0500, Paul McGuire wrote: > Michel - > > Glad the sparql parsing is proceeding well. > > I'm not sure pyparsing is going to go much better than your current parser, > given the warts that you cite: > - pyparsing is not very good in multi-thread code, for the same reasons you > mention, mostly use of globals. I don't see any vars declared global in pyparsing unless you've added them recently. I don't see any of the other usual thread-killing warts either, like mutable default arguments or module level vars. I've no experience with any other kind of global state in python, by my eyes pyparsing should be pretty threadsafe, but hey, you're the author. ;) I'd be more than willing to try and fix and/or verify pyparsing with multiple threads. Really the thread issue is just a minor concern, I don't think they're be much concurrent parsing as much as generation, so I can get a way with locks for now if it's totally necessary. > - pyparsing's asXML() output for parsed results is somewhat hit-or-miss. I > really should remove that code for now, or at least label it as "shaky". I'm just using it for visual verification for now, so it's shakyness is ok for me. > > To do indentation-based parsing, you will need a parse action to do the > indentation work, and a stack to keep track of the current indentation > levels, so that you can unwind to previous indent levels. Here's one > suggestion if you haven't thought of it already: use pyparsing's > col(loc,strg) built-in inside the parse action, to compute the column of the > starting text. Great, that's what I imagined, but the col() trick will be usefull, thanks Paul! -Michel |