[antlr-interest] Progressive Slowdown in Parsing

A. Saake asaake at hotmail.de
Mon Dec 22 01:54:20 PST 2008


Hi,

I'm new to ANTLR, but with support of the "The Definitive Reference ...", the great tool ANTRLWorks and much optimism I got all problems solved, so far. 
ANTLR is a very impressive tool and probably will help me to migrate legacy 4GL code to C#, as I hope.

But now I'm facing a problem, where help would be very appreciated !

I'm converting a 4GL "local function" with 3500 lines of code, mainly constisting of assignments (SET ... TO ...), simple IF's and embedded SQL Selects. This means, there are many flat, not deep statements.

The first 2000 lines can be processed in under 1 min. If I parse the whole script, time increases to 15 minutes. For a correct migration of this script (it's an include file), I would have to embed it into another 3500 lines code script, and I'm afraid that it will need a very long time. Because of the variable system of the 4GL (declaration of variables is not necessary, so there's no scope, I have to estimate it from context), I will have to run it many times.

To find out, if the slowdown is from my grammar, I tried lot's of syntactic predicates and so on, until I used a profiler, which names GetKindOfOps as responsible for nearly 80% of the runtime. 

My grammar is a combined lexer and parser, output is template and I use the token rewrite mechanism.

Can you give me a hint, what I can do for more speed? 
Would building an output tree and then generating templates be faster?

Many thanks in advance !

Andreas 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081222/160861e6/attachment.html 


More information about the antlr-interest mailing list