Name : perl-Preproc-Tiny
| |
Version : 0.02
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 1.65
| Date : 2024-08-05 19:57:37
|
Group : Development/Libraries/Perl
| Source RPM : perl-Preproc-Tiny-0.02-1.65.src.rpm
|
Size : 0.03 MB
| |
Packager : (none)
| |
Summary : Minimal stand-alone preprocessor for code generation using perl
|
Description :
This preprocessor originated from the need to generate C++ code in a flexible way and without having to adapt to limitations of the several mini-languages of other templating engines available in CPAN. The template language used is just perl.
Being a Tiny module, it has no external dependencies and can be used by just copying the pp.pl file to any executable directory.
The input file has to have a .pp extension. The .pp is removed to generate the output file, e.g.
$ pp.pl main.c.pp # parses main.c.pp and generates main.c
Inside the input file, the default action is to copy plain text to the output file, e.g.
// main.c.pp: int main() { return 0; }
// main.c: int main() { return 0; }
Any text after \'AATTAATT\' is interpreted as perl code and executed. The global variable $OUT contains the text to be dumped to the output file, e.g.
// main.c.pp: AATTAATT $ret = 0; int main() { return AATTAATT $OUT .= $ret.\";\"; }
// main.c: int main() { return 0; }
Perl code can also be interpolated inside the text and span multiple lines by enclosing it between \'[AATT\' and \'AATT]\', e.g.
// main.c.pp: [AATT use strict; use warnings; my $ret = 0; AATT] int main() { return [AATT $OUT .= $ret AATT]; }
// main.c:
int main() { return 0; }
The extra newline after the closing quote can be removed by using \'-AATT]\', e.g.
// main.c.pp: [AATT use strict; use warnings; my $ret = 0; -AATT] int main() { return [AATT $OUT .= $ret AATT]; }
// main.c: int main() { return 0; }
The common case of appending text in the perl section has the shortcut \'[AATT>\', e.g.
// main.c.pp: [AATT use strict; use warnings; my $ret = 0; -AATT] int main() { return [AATT> $ret AATT]; }
// main.c: int main() { return 0; }
Global actions can be executed by manipulating the $OUT variable, e.g.
// main.c.pp: int main() { return 0; // comment } AATTAATT $OUT =~ s!//.*!!g;
// main.c: int main() { return 0; }
Any perl control structure can be used in the code blocks, e.g.
// main.c.pp: AATTAATT $ok = 1; int main() { return [AATT if ($ok) { AATT] 0 [AATT } else { AATT] 1 [AATT } AATT]; }
// main.c: int main() { return 0 ; }
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-P/openSUSE_Tumbleweed/noarch |