SPL Facade
TL;DR
We demonstrate the SPL
Facade class for the PetitParser SPL case study.
SPL Facade
SPL
is a simple Facade class for the SPL parser and interpreter, containing a few examples and convenience methods.
To parse and interpret a program, and print the final output, use SPL>>#run:
.
SPL run: 'print "Hello world!";'
To obtain an interpreter (context) for a program, use SPL>>#contextFor:
.
SPL contextFor: 'print "Hello world!";'
To obtain an interpreter for expressions rather than programs, use SPL>>#contextForExpression:
.
SPL contextForExpression: '6*(3+4)'
To reduce a program to its final state, use SPL>>#reduce:
.
SPL reduce: 'print "Hello world!";'
SPL demos
Here are a few simple demo programs you can try or modify. (You can edit the code before stepping or reducing.)
SPL empty. "The empty program"
SPL hello.
SPL factorial.
SPL fibonacci.
"The non-terminating program. Step, but don't reduce!" SPL omega.