Preprocessor for style files

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Preprocessor for style files

toc-rox
My style file are becoming more and more complex.
IMHO a (simple) preprocessor would be very helpful.

Important features (analogue C preprocessor):
- ##include (includes a text file)
- ##define (defines a preprocessor var; also as command line option)
- ##ifdef (checks if a preprocessor var is defined)
-   ##else (else for ##ifdef)
- ##endif (end of ##ifdef)

A simple example (for polygons):

##define BASECAMP
...
##include "indexrules.txt"
...
##ifdef BASECAMP
  # draw buildings
  building = * [0x13 resolution 20]
##endif
...

Questions:
- What do think of this proposal ?
- Does anyone already uses an external preprocessor for the style files ?

Regards Klaus
Reply | Threaded
Open this post in threaded view
|

Re: Preprocessor for style files

Thorsten Kukuk
On Wed, Jan 04, toc-rox wrote:

> My style file are becoming more and more complex.
> IMHO a (simple) preprocessor would be very helpful.

At least on UNIX, there a preprocessor which would solve
this problems: cpp

But I don't know if there is something similar for windows.

> Questions:
> - What do think of this proposal ?

I would like to see the "include" statement, but not as preporocessor.
Wanted to implemented it already, but didn't found the time to learn
enough java and understand the mkgmap code.

> - Does anyone already uses an external preprocessor for the style files ?

I use a script which uses some standard UNIX commands to workaround
the missing "include" statement.

  Thorsten

--
Thorsten Kukuk, Project Manager/Release Manager SLES
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nuernberg
GF: Jeff Hawn, Jennifer Guild, Felix Imend├Ârffer, HRB 16746 (AG N├╝rnberg)
_______________________________________________
mkgmap-dev mailing list
[hidden email]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Reply | Threaded
Open this post in threaded view
|

Re: Preprocessor for style files

Steve Ratcliffe
In reply to this post by toc-rox
On 04/01/12 14:53, toc-rox wrote:
> Questions:
> - What do think of this proposal ?

I have a vague plan to implement some kind of include functionality, not
so sure about the rest though.

..Steve
_______________________________________________
mkgmap-dev mailing list
[hidden email]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Reply | Threaded
Open this post in threaded view
|

Re: Preprocessor for style files

toc-rox
In reply to this post by toc-rox
This looks (very) interesting: http://www.synesys.com/Downloads/ppp.html
...
ppp is yet another preprocessor for Perl, written in Perl.
So why use it?
Because it offers one feature that makes all the difference:
Like all preprocessors, it provides the effects of conditional compilation, but it does so offline.
Under normal usage, the code runs without the preprocessor.
The preprocessor need only run when one of the conditional compilation variables changes.

ppp's provides the functionality of conditional compilation in-place.
That is, the .pl file is directly modified, but no information is discarded.
Instead, both sides of all #ifdefs remain in the run-time code,
but with their 'inactive' sides commented out. For example:

#ifdef FOO
    FooIsDefined();
#else /* !FOO */
#   FooIsNOTDefined();
#endif /* FOO */

The 'false' side code and the #ifdef structure are seen as comments, and thus ignored by the perl compiler.
If the value of 'FOO' changed in the above example, say from 'true' to 'false',
then when the ppp preprocessor is rerun, the code becomes:

#ifdef FOO
#   FooIsDefined();
#else /* !FOO */
    FooIsNOTDefined();
#endif /* FOO */

The code is still all there.
Nothing is lost, and any #ifdef can have its sense reversed at any time.
...

Concerning the style files it allows something like this: perl ppp.pl  polygons-master  polygons  -DGPSR
...
#include "indexsearch"
...
#ifndef GPSR
  building = * [0x13 resolution 20]
#endif
...

Klaus