User:Ben Russell/thue/hq9p.t

From Esolang
Jump to: navigation, search

Here's an HQ9+ interpreter, written in Thue. Note a few things:

  • Inputted program MUST ONLY consist of 'H', 'Q', '9', and '+', and they MUST be in capitals. If you look in the code, you'll see why.
  • 99 bottles of beer is not generated dynamically. It's just uncompressed from its packed state.

Have fun!

P.S. If you have the Thue interpreter from Cat's Eye Technologies, use the Python version instead of the C version. The C version has a tendency to cock up the strings. Only use the C version when the Python version cocks up.

This code is public domain, though if you could attribute my name to it, that'll be great.

[STDIN]::=:::
`A::=~ bottle
`E::=~s
`B::=~ of beer
`C::=~ on the wall
`F::=~No more
`,::=~,
`.::=~.
`D::=~Take one down, pass it around,
`\::=~
`0::=~0
`1::=~1
`2::=~2
`3::=~3
`4::=~4
`5::=~5
`6::=~6
`7::=~7
`8::=~8
`9::=~9
_$::=`
!0::=$0$
!1::=$1$
!2::=$2$
!3::=$3$
!4::=$4$
!5::=$5$
!6::=$6$
!7::=$7$
!8::=$8$
!9::=$9$
`H::=~Hello World!
`pH::=~H
`pQ::=~Q
`p9::=~9
`p+::=~+
[BOTTLES]::=!99$A$E$B$C$,$\!99$A$E$B$,$\$D$\!98$A$E$B$C$.$\$\!98$A$E$B$C$,$\!98$A$E$B$,$\$D$\!97$A$E$B$C$.$\$\!97$A$E$B$C$,$\!97$A$E$B$,$\$D$\!96$A$E$B$C$.$\$\!96$A$E$B$C$,$\!96$A$E$B$,$\$D$\!95$A$E$B$C$.$\$\!95$A$E$B$C$,$\!95$A$E$B$,$\$D$\!94$A$E$B$C$.$\$\!94$A$E$B$C$,$\!94$A$E$B$,$\$D$\!93$A$E$B$C$.$\$\!93$A$E$B$C$,$\!93$A$E$B$,$\$D$\!92$A$E$B$C$.$\$\!92$A$E$B$C$,$\!92$A$E$B$,$\$D$\!91$A$E$B$C$.$\$\!91$A$E$B$C$,$\!91$A$E$B$,$\$D$\!90$A$E$B$C$.$\$\!90$A$E$B$C$,$\!90$A$E$B$,$\$D$\!89$A$E$B$C$.$\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