Mercurial > hg > forks > multipaint-js
changeset 74:60892c9b4933
Add a JS post-processing script written in Perl.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Jul 2018 13:28:58 +0300 |
parents | d2a89e88f958 |
children | 3d68411c320c |
files | postprocess.pl |
diffstat | 1 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/postprocess.pl Thu Jul 05 13:28:58 2018 +0300 @@ -0,0 +1,23 @@ +#!/usr/bin/perl -w +# +# Perl script for filtering/post-processing the transpiled +# ProcessingJS code of Multipaint.JS to remove various uselessly +# complicated abstractions/transformations. +# +# Usage: +# 1) use "docompile.html" to transpile Multipaint, save to multipaint.js.orig +# 2) run the result through this script: +# perl postprocess.pl < multipaint.js.orig > multipaint.js +# +use strict; +use warnings; + + +while (defined(my $line = <STDIN>)) +{ + $line =~ s@.p\.parseByte\(@(@g; + $line =~ s@.p\.parseInt\(\(new\s+.p\.Character\('(.)'\)\)\)@sprintf('%d',ord($1))@eg; + $line =~ s@\(new\s+.p\.Character\('(.)'\)\)@sprintf('%d',ord($1))@eg; + $line =~ s@.p\.parseInt\(@Math.floor(@g; + print $line; +}