Execute HQ9+/E: Difference between revisions

m
Fixed syntax highlighting.
(Created page with '{{implementation|HQ9+}}{{collection|RCHQ9+}}Category:E The original author of this example would like to note the following deficiencies in [http://www.cl…')
 
m (Fixed syntax highlighting.)
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{implementation|HQ9+}}{{collection|RCHQ9+}}[[Category:E]]
[[User:Kevin Reid|The original author of this example]] (written in [[E]]) would like to note the following deficiencies in [http://www.cliff.biffle.org/esoterica/hq9plus.html the HQ9+ specification]:
 
* The treatment of unrecognized characters other than whitespace is unspecified. However, the only implementation provided, in Ocaml[[OCaml]], rejects them, so this implementation also does. Additionally, rejecting unknown characters ensures that the compiler will not incorrectly compile [[HQ9+]] programs using future extensions.
* While the given "qqqq" example implies that whitespace (specifically, trailing newlines) is permissible and that operation codes are case-insensitive, neither of these are explicitly stated.
* The initial value of the accumulator is unspecified. This implementation has chosen 11472, which is of course the value such that executing the HQ9+ program "HQ9+" will result in the accumulator having a value equal to the length of the program's output.
 
<br clear=all><langsyntaxhighlight lang="e">def makeSeqExpr := <elang:evm.makeSeqExpr>
def makeLiteralExpr := <elang:evm.makeLiteralExpr>
def eParser := <elang:syntax.makeEParser>
 
# the extra $ protects this as an RC example by breaking up the close tag
def `@_<langsyntaxhighlight lang="e">@beerSource</la${""}ng>@_` :=
<http://rosettacode.org/mw/index.php?title=99_Bottles_of_Beer&action=raw>.getText()
def beerProgram := eParser(beerSource)
Line 46:
# the consequences as the beerProgram is incorporated from a wiki source
# over unsecured HTTP.
}</langsyntaxhighlight>
9,482

edits