Re: [Pyparsing] Slow parsing with indentedBlock()
Brought to you by:
ptmcg
From: spir <den...@fr...> - 2009-11-15 19:38:13
|
Le Sun, 15 Nov 2009 17:51:00 +0100, Philipp Reichmuth <phi...@gm...> s'exprima ainsi: > I have a problem with indentedBlock() and a relatively simple grammar that > relies on indentation and recursion. I'm seeing extremely long execution > times. On one example that I've attached it doesn't terminate within an > hour. 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 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). So, 1 1 2 2 3 2 ==> 1 1 { 2 2 { 3 } 2 } or 1 1 { 2 2 { 3 } 2 } Just need to find delimiters that cannot clash against possible content. (I chose to have delimiters on their own line for this reason and also cause it's easier to check visually, maybe also to parse, I guess.) But think that your performance issues may come in great part from recursive patterns, not only from indented structure. Denis -------------------------------- * la vita e estrany * http://spir.wikidot.com/ |