goruby/goruby
GoRuby, an implementation of Ruby written in Go
{ "createdAt": "2014-08-19T15:51:28Z", "defaultBranch": "master", "description": "GoRuby, an implementation of Ruby written in Go", "fullName": "goruby/goruby", "homepage": null, "language": "Go", "name": "goruby", "pushedAt": "2024-07-14T23:26:00Z", "stargazersCount": 609, "topics": [ "go", "golang", "interpreter", "language", "programming-language", "ruby" ], "updatedAt": "2025-10-16T01:25:09Z", "url": "https://github.com/goruby/goruby"}goruby
Section titled “goruby”GoRuby, an implementation of Ruby written in Go
Contribution
Section titled “Contribution”If anyone wants to help to get the project to the real implementation please ping me or fork it and send a pull request.
Community
Section titled “Community”- #goruby Channel on Gophers Slack (invites to Gophers Slack are available here)
License
Section titled “License”This project is released under the terms of the MIT License, as found in the LICENSE file.
There is a basic REPL within cmd/girb. It supports multiline expressions and all syntax elements the language supports yet.
To run it ad hoc run go run cmd/girb/main.go and exit the REPL with CTRL-D.
Command
Section titled “Command”To run the command as one off run go run main.go.
Supported features
Section titled “Supported features”goruby Command
Section titled “goruby Command”- parse program files
- program file arguments
- Flags
-
-0[octal]specify record separator (\0, if no argument) -
-aautosplit mode with -n or -p (splits $_ into $F) -
-ccheck syntax only -
-Cdirectorycd to directory before executing your script -
-dset debugging flags (set $DEBUG to true) -
-e 'command'one line of script. Several -e’s allowed. Omit [programfile] -
-Eex[:in]specify the default external and internal character encodings -
-Fpatternsplit() pattern for autosplit (-a) -
-i[extension]edit ARGV files in place (make backup if extension supplied) -
-Idirectoryspecify $LOAD_PATH directory (may be used more than once) -
-lenable line ending processing -
-nassume ‘while gets(); … end’ loop around your script -
-passume loop like -n but print line also like sed -
-rlibraryrequire the library before executing your script -
-senable some switch parsing for switches after script name -
-Slook for the script using PATH environment variable -
-T[level=1]turn on tainting checks -
-vprint version number, then turn on verbose mode -
-wturn warnings on for your script -
-W[level=2]set warning level; 0=silence, 1=medium, 2=verbose -
-x[directory]strip off text before #!ruby line and perhaps cd to directory -
-hshow this message, —help for more info
-
girb Command
Section titled “girb Command”- parse program files
- program file arguments
- Flags
-
-fSuppress read of ~/.irbrc -
-mBc mode (load mathn, fraction or matrix are available) -
-dSet $DEBUG to true (same as `ruby -d’) -
-r load-moduleSame as `ruby -r’ -
-I pathSpecify $LOAD_PATH directory -
-USame asruby -U -
-E encSame asruby -E -
-wSame asruby -w -
-W[level=2]Same asruby -W -
--context-mode nSet n[0-3] to method to create Binding Object, when new workspace was created -
--echoShow result(default) -
--noechoDon’t show result -
--inspectUse `inspect’ for output (default except for bc mode) -
--noinspectDon’t use inspect for output -
--readlineUse Readline extension module -
--noreadlineDon’t use Readline extension module -
--prompt prompt-mode/--prompt-mode prompt-modeSwitch prompt mode. Pre-defined prompt modes aredefault',simple’,xmp' andinf-ruby’ -
--inf-ruby-modeUse prompt appropriate for inf-ruby-mode on emacs. Suppresses —readline. -
--sample-book-mode/--simple-promptSimple prompt mode -
--nopromptNo prompt mode -
--single-irbShare self with sub-irb. -
--tracerDisplay trace for each execution of commands. -
--back-trace-limit nDisplay backtrace top n and tail n. The default value is 16. -
--irb_debug nSet internal debug level to n (not for popular use) -
--verboseShow details -
--noverboseDon’t show details -
-v,--versionPrint the version of irb -
-h,--helpPrint help -
--Separate options of irb from the list of command-line args
-
Supported language feature
Section titled “Supported language feature”- everything is an object
- allow method calls on everything
- operators are method calls
- full UTF8 support
- Unicode identifier
- Unicode symbols
- functions
- with parens
- without parens
- return keyword
- default values for parameters
- keyword arguments
- block arguments
- hash as last argument without braces
- function calls
- with parens
- without parens
- with block arguments
- conditionals
- if
- if/else
- if/elif/else
- tenary
? : - unless
- unless/else
- case
-
|| -
&&
- control flow
- for loop
- while loop
- until loop
- break
- next
- redo
- flip flop
- numbers
- integers
- integer arithmetics
- integers
1234 - integers with underscores
1_234 - decimal numbers
0d170,0D170 - octal numbers
0252,0o252,0O252 - hexadecimal numbers
0xaa,0xAa,0xAA,0Xaa,0XAa,0XaA - binary numbers
0b10101010,0B10101010
- floats
- float arithmetics
-
12.34 -
1234e-2 -
1.234E1 - floats with underscores
2.2_22
- integers
- booleans
- strings
- double quoted
- single quoted
- character literals (
?\n,?a,…) -
%q{} -
%Q{} - heredoc
- without indentation (
<<EOF) - indented (
<<-EOF) - “squiggly” heredoc
<<~ - quoted heredoc
- single quotes
<<-'HEREDOC' - double quotes
<<-"HEREDOC" - backticks <<-`HEREDOC`”
- single quotes
- without indentation (
- escaped characters
-
\abell, ASCII 07h (BEL) -
\bbackspace, ASCII 08h (BS) -
\thorizontal tab, ASCII 09h (TAB) -
\nnewline (line feed), ASCII 0Ah (LF) -
\vvertical tab, ASCII 0Bh (VT) -
\fform feed, ASCII 0Ch (FF) -
\rcarriage return, ASCII 0Dh (CR) -
\eescape, ASCII 1Bh (ESC) -
\sspace, ASCII 20h (SPC) -
\\backslash, \ -
\nnnoctal bit pattern, where nnn is 1-3 octal digits ([0-7]) -
\xnnhexadecimal bit pattern, where nn is 1-2 hexadecimal digits ([0-9a-fA-F]) -
\unnnnUnicode character, where nnnn is exactly 4 hexadecimal digits ([0-9a-fA-F]) -
\u{nnnn ...}Unicode character(s), where each nnnn is 1-6 hexadecimal digits ([0-9a-fA-F]) -
\cxor\C-xcontrol character, where x is an ASCII printable character -
\M-xmeta character, where x is an ASCII printable character -
\M-\C-xmeta control character, where x is an ASCII printable character -
\M-\cxsame as above -
\c\M-xsame as above -
\c?or\C-?delete, ASCII 7Fh (DEL)
-
- interpolation
#{} - automatic concatenation
- arrays
- array literal
[1,2] - array indexing
arr[2] - splat
- array decomposition
- implicit array assignment
- array of strings
%w{} - array of symbols
%i{}
- array literal
- nil
- hashes
- literal with
=>notation - literal with
key:notation - indexing
hash[:foo] - every Ruby Object can be a hash key
- literal with
- symbols
-
:symbol -
:"symbol" -
:"symbol"with interpolation -
:'symbol' -
%s{symbol} - singleton symbols
-
- regexp
-
/regex/ -
%r{regex}
-
- ranges
-
..inclusive -
...exclusive
-
- procs
-> - variables
- variable assignments
- globals
- operators
-
+ -
- -
/ -
* -
! -
< -
> -
**(pow) -
%(modulus) -
&(AND) -
^(XOR) -
>>(right shift) -
<<(left shift, append) -
==(equal) -
!=(not equal) -
===(case equality) -
=~(pattern match) -
!~(does not match) -
<=>(comparison or spaceship operator) -
<=(less or equal) -
>=(greater or equal) - assignment operators
-
+= -
-= -
/= -
*= -
%= -
**= -
&= -
|= -
^= -
<<= -
>>= -
||= -
&&=
-
-
- function blocks (procs)
- error handling
- begin/rescue
- ensure
- retry
- constants
- scope operator
:: - classes
- class objects
- class Class
- instance variables
- class variables
- class methods
- instance methods
- method overrides
- private
- protected
- public
- inheritance
- constructors
- new
-
self - singleton classes (also known as the metaclass or eigenclass)
class << self - assigment methods
- self defined classes
- self defined classes with inheritance
- modules
- object main
- comments ’#’