Targets
Ruby Target
puts, begin/rescue/ensure, and Ruby-flavored output.
Implemented
gset run foo.rb defaults to the Ruby target; --target ruby forces it. Generated files are Ruby scripts executed with ruby.
Mapping table
| GSET | Ruby output |
|---|---|
print(...), say, echo, puts | puts(...) |
true/false | true/false |
null | nil |
| arrays / maps | [...] / {...} |
if/elif/else | if/elsif/else + end |
while | while … end |
for…in | for … in … end |
| functions | def name(...) … end |
try/catch/finally | begin / rescue / ensure / end |
throw | raise |
** | ** |
Verified example
$ gset run hello.rb --target rubyname = "World"
count = 3
puts("Hello, " + name)
while count > 0
puts(count)
count = count - 1
endOutput:
Hello, World
3
2
1Watch out
thenanddo: the emitter usesend-terminated blocks (nodo/thenrequired thanks to newline parsing).- Class flow: Ruby forces class definitions at the top level; today's class-shell support works for declarations but method bodies aren't emitted yet.
- Blocks vs lambdas: GSET lambdas become
defwrappers rather than Ruby->() {}; behavior matches for direct calls. - Runtime not present on all dev boxes: this repo's dev machine has no
rubybinary, so Ruby output is verified by transpile. Install Ruby torunit.
Runtime
Requires ruby on PATH. Override with compiler.ruby.command in gset.conf.