The document discusses implementing a Brainfuck interpreter using GraalVM and distributing it as a language component that can be installed and run on GraalVM, providing examples of defining the language, evaluating code, debugging it, and integrating tools using the Truffle and Instrument APIs.
9. command meaning
+ increase value
- decrease value
. print value to std out
, read one byte from std in
[ if value eq 0, jump after matching ]
] if value neq 0, jump after matching [
< move pointer left
> move pointer right
17. A S TA S T
ROOT
INCR_VAL INCR_VAL INCR_VAL INCR_VAL INCR_VAL JUMP INCR_VAL INCR_VAL
DECR_PTR INCR_VAL INCR_PTR DECR_VAL
(part of the program that adds 5 and 2)
19. P EP E
Calculate for positive integers
If we know that , the program becomes simpler:
x
n
f (x, n) =
⎧
⎩
⎨
⎪
⎪
1
,(f (x, 0.5 ∗ n))
2
x ∗ f (x, n − 1),
if n = 0
if n is even
otherwise
n = 5
f (x) = x ∗ ( )x
2
2
25. W G VM JVMW G VM JVM
function abs (int i)
if ( we saw only positive integers in the input ) {
return i;
} else {
transferToInterpreterAndInvalidate;
return i < 0 ? i : i;
}
}