Added full log and replay functionality in the SCRIPT version (removed from binary).
[sgc2.git] / praat_module / praatscript2cprogram.pl
blobaf0821d456ff54cd2edb49fa1c8d60694ab6fd8a
1 #!/usr/bin/perl
3 # Convert an expanded praat script into a single string
4 # Output a stand alone Praat main program
6 # Use:
7 # perl praatscript2cprogram.pl script.praat > demoapplication.h
8 #
9 print <<'ENDOFHEADER';
10 /* C const char string with Praat script
11 * Generated automatically
12 * For license, see Praat script text
16 static char32_t myDemoScript [] = U""
17 ENDOFHEADER
18 while(<>){
19 # Remove comments
20 next if /^\s*#/;
21 # Remove logging/replay functionality (debugging code)
22 next if /^\s*\'(sgc2.logging\$|replaySGC2Log\$)\'/;
23 next if /index_regex\(replaySGC2Log\$/;
25 # Protect special characters
26 s/\\/\\\\/g;
27 s/[\n\r\l]/\\n/g;
28 s/\"/\\"/g;
29 print "\"$_\"\n";
31 print <<'ENDOFFOOTER';
34 ENDOFFOOTER