Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Provide transcoding logic to HLL::Compiler, so that it can
transcode variable-width encodings to fixed-width encodings
for faster parsing, when possible.
  • Loading branch information
pmichaud committed Nov 8, 2009
1 parent e8e145d commit 95cd73d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/cheats/hll-compiler.pir
Expand Up @@ -15,6 +15,36 @@
.param pmc source
.param pmc options :slurpy :named
.local string tcode
tcode = options['transcode']
unless tcode goto transcode_done
.local pmc tcode_it
$P0 = split ' ', tcode
tcode_it = iter $P0
tcode_loop:
unless tcode_it goto transcode_done
tcode = shift tcode_it
push_eh tcode_enc
$I0 = find_charset tcode
$S0 = source
$S0 = trans_charset $S0, $I0
assign source, $S0
pop_eh
goto transcode_done
tcode_enc:
pop_eh
push_eh tcode_fail
$I0 = find_encoding tcode
$S0 = source
$S0 = trans_encoding $S0, $I0
assign source, $S0
pop_eh
goto transcode_done
tcode_fail:
pop_eh
goto tcode_loop
transcode_done:
.local pmc parsegrammar, parseactions, match
parsegrammar = self.'parsegrammar'()
Expand All @@ -34,3 +64,14 @@
self.'panic'('Unable to parse source')
.return (match)
.end
.sub 'pir' :method
.param pmc source
.param pmc adverbs :slurpy :named
$P0 = compreg 'POST'
$S0 = $P0.'to_pir'(source, adverbs :flat :named)
.return ($S0)
.end

0 comments on commit 95cd73d

Please sign in to comment.