NAME
sqlpp - SQL preprocessor
DESCRIPTION
sqlpp
is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also #perldef for calling arbitrary perl code.
SYNOPSIS
sqlpp [options] filename
options:
-I path - include path
-D var[=value] - define variable
-o output - output to file ( default to stdout )
-h,--help - display this text
-hh - display man page
COPYRIGHT
Copyright (c) 2005 catpipe Systems ApS. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SYNTAX
- #define TAG
-
Identical to cpp
- #define TAG([PARAMETERS]) MACRO
-
Not fully identical to cpp, the behavior is slightly different. Concatenation ( a ## b ) and stringification ( # a ) behave similar to as in cpp.
The multiline macro can be declared either tranditionally via CPP backslash line continuation, or a perl's heredoc style. In the latter case, TAG must be prepended with
<<
. - #if EXPRESSION
-
Analogous to cpp.
Note: EXPRESSION is evaluated via perl runtime engine, and although can execute arbitrary perl code, it is recommended to use simple arithmetic operators. To operate with defines as strings, use double quotes.
The
defined()
function works like in cpp, not like in perl. - #ifdef, #ifndef, #else, #elif, #endif, #undef, #include, #error
-
Identical to cpp
- #pragma macro(simple|all|off)
-
Pragma
macro
defines how defines and macros should be tracked and substituted. The reason is that SQL code may contain non-SQL code that is so complicated that would confuse the macro parser. Such sections can be guarded with#pragma macro(simple)
/#pragma macro(all)
brackets, for example.There are three
macro
modes:- off
-
Neither defines nor macros are substituted.
- simple
-
Defines are substituted, macros are not substituted.
- all
-
Both defines are macros are substituted.
- #pragma comments(strip|leave)
-
Pragma
comments
tells what to do with#
and--
comments. The default isstrip
these from the output, however, the parts of input that are not SQL, can be guarded from incorrect parsing by#pragma comments(leave)
/#pragma comments(strip)
macros. Note that#
comments are ineffectual in macro definitions, because#
is a macro concatenation symbol. - #pragma lang(sql|perl)
-
A combination of existing pragmas.
- sql
-
Same as
#pragma macro(all)
and#pragma comments(strip)
. These are defaults settings. - perl
-
Same as
#pragma macro(simple)
and#pragma comments(leave)
. Useful if perl code is embedded.
- #perldef TAG [(PARAMETERS)] CODE
-
Creates a special define or a macro, where CODE is perl code. PARAMETERS is either a list of perl scalar names ( dollar sign included ), then the code may access the parameters directly. Or, PARAMETERS is the ellipsis (...) string, in which case the code must parse
@_
by itself.The multiline perl code can be declared either tranditionally via CPP backslash line continuation, or a perl's heredoc style. In the latter case, TAG must be prepended with
<<
.The perl code is executed in the anonymous subroutine context, and the return values are passed to further processing. Perl
print
andprintf
statements may be used to produce direct output into the program output, bypassign the preprocessing.For the shared storage the code can use
%global
; for accessing contents of defines and macros,%defines
and%macros
internal hashes may be used. - Predefined macros
AUTHOR
Dmitry Karasik <dk@catpipe.net>