mapnik/mapnik — pull request #2314 by springmeyer (2014-07-24 21:51:06+00:00)
Title: Grammar refactor

This reworks all the spirit grammars.

The goal was to make sure that none of the grammars are needlessly compiled into `libmapnik.so` unless absolutely required by the core library. So, this means that grammars for things like wkt and geojson parsing/generation are now not linked into the core library and rather only compiled into the specific parts of the python bindings and the input plugins that need them. The decreases the libmapnik.so final size by > 2MB at the cost of slightly longer overall compile times if you build both the python bindings and the csv and geojson plugins. This does not directly speed up overall compile times but offers a basis for only paying for what you use in terms of compile time. So, this should speed up the compile of the core library if that is all you are after at the cost of the python bindings and plugins taking a bit longer to compile.

The sub-goal was to make sure that all grammars were split into definition (aka `grammar.hpp`) and implementation (aka `_impl.hpp`) files. Theoretically the `grammar.hpp` should take less time and memory to compile and might therefore benefit other files that include it but do not need an instanciation. In reality karma alone and the `grammar.hpp` is hard enough on the compiler that this does not help much. But this is still a good organization scheme so I've made it consistently used.

### other notes:
- Declaring grammars in cpp files like: `template struct mapnik::wkt::wkt_collection_grammar;` is not worth it (for compile time savings) unless they are used from at least >= 2 cpp files (so, I removed this usage in the topojson plugin). The only case where I have maintained this usage is with the `css_color_grammar` since it is used twice: for general color parsing in `src/color_factory.cpp` and as a sub-grammar in the `image_filters_grammar`.
- In terms of compile memory peaks I also did not see a huge problem with just directly include the `*grammar_impl.hpp` in the same file as the `grammar.hpp` because it does not add much memory on top of what is already needed for the `grammar.hpp`.