RBParser minimal example - parsing Smalltalk and generating code
Last updated at 10:23 am UTC on 5 January 2019
Example which gives an idea how simple JavaScript may be generated by parsing Smalltalk code with the RBParser.
| exp sel |
Transcript open;clear.
exp := (RBParser parseExpression: 'c:= Sketch minimal').
"exp inspect."
exp class == RBAssignmentNode ifTrue: [
Transcript show: exp variable token value, ':= '.
classname := exp value receiver name asString.
sel := exp value selector asString.
Transcript show: classname ; show:'.' ; show:sel,'()'.
Transcript show: ';';cr].
Output:
c:= Sketch.minimal();
See also
RBParseTreeRewriter