ariatemplates/editor-backend — pull request #61 by ymeine (2014-01-08 18:29:21+00:00)
Title: Optimized a lot the parsers.

# Line and column removal

No more call to line() and column() PEG.js methods are made from the parsers: they were detected as being too expensive.

This implied changing some things in the implementation:

- in the Node class and more generally node module, use of lines and columns have been commented
- in the web application, the annotations put to the editors for validation were using the line and column information: we now use the Ace API to compute them from the index information instead

Tests have also been updated, since the resulting graph doesn't contain anymore the line and column information, so they must be removed from the expected results specifications.

# Node optimization

The Node class is defined using the OOP library, which can provide nice features in terms of API. Unfortunately, one of these features was really expensive, and impacted the construction of the nodes: when you build an average of 20,000 nodes for a HTML file of 1500 lines, the overhead becomes monstruous. However there is a gain even for smaller files, and for every parser since it's related to Node only.

There is now a ligther Node implementation, which modifies only a few things: mainly for node creation, but also for node insertion.

In order not to copy code, a full refactoring has been made:

- there is now a dedicated folder for the whole `node` module
- class definitions have been split into files
- the two nodes implementations share a common base definition for their classes

Finally, and this is something important for this to be used: the NodeInstancier now gets an options at its creation, to choose which node implementation to use.

So now, the grammars use a NodeInstancier instance configured to use the light Node implementation.

# IMPORTANT change in the AT-HTML parser build

Now the AT-HTML parser is built using the PEG.js option `cache` set to `true`. It can make the parser slower as written in the documentation, but it resolved the issue of the parser never finishing parsing some inputs (so what they say in the documentation is true).

Thus I:

- enabled more inputs for benchmarks as now they work, and in acceptable time
- changed a timeout limit in the test of a rule for AT-HTML (maybe slower because if the activated option)