[antlr-interest] Parsing CSS accurately and fast

Bart Kiers bkiers at gmail.com
Mon Sep 19 00:11:40 PDT 2011


Hi Vivek,


On Mon, Sep 19, 2011 at 4:04 AM, Vivek Jhaveri <vivekjhaveri at hotmail.com>wrote:

> ...
>
> To date, our efforts have yielded accuracy, but not performance.
>

Hard to comment without seeing the grammar(s).
Do you by any chance have `backtrack=true;` in the options-section of your
parser? If so, you could try to add `memoize=true;` to it: that might
increase the parse-time (most probably will). However, it would be better to
remove `backtrack=true;` and only add predicates to rules where needed.


...
>
> However, this double parsing creates a new instance of the CSS2.1 parser
> for
> each successfully parsed piece of the core grammar. This results in
> extremely slow parse times.
>
>
I would imagine things would go faster if you just parse once (core CSS),
which would result in a proper AST, and then manipulate the AST according
some other spec of CSS.

Regards,

Bart.


More information about the antlr-interest mailing list