Re: [Pyparsing] Slow parsing with indentedBlock()
Brought to you by:
ptmcg
From: Philipp R. <phi...@gm...> - 2009-11-16 14:59:14
|
Am Sun, 15 Nov 2009 20:37:59 +0100 schrieb spir: > May be useful: I do not parse anymore indented structure, instead > systematically preprocess to transform it into delimited structure (say, > C style). The reason is complication of the grammar and > state-dependance. I see the point. I'll think if I can preprocess the source text to avoid using indentedBlock(). > I have a pair of tool funcs that "transcode" in both directions (can send > if you like). It's easy as long as you can rely on indentation to be > consistent (which is not necessary true in eg python code). If you could send me those, I'd be grateful. From what I've seen so far, indentation seems to be fairly consistent. I have some cases that look like this: entity 1... @relation 1... entity 2... @relation 3... @relation 4... @relation 5... But those should be easy to catch. The problem seems indeed to be the combination of indentedBlock() and recursion - indentedBlock() currently uses a lookahead mechanism that seems to lead to exponential branching in the parse tree under some conditions. Philipp |