Created
April 24, 2023 00:41
-
-
Save thomasjslone/9fd67b3c4757b1c2b413d3d1cc35f867 to your computer and use it in GitHub Desktop.
for lruby parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shell.lrb ## LinearRuby version of the shell class from definitions. | |
@main = self | |
@context = @main | |
@cid = 0 | |
@input = nil | |
@res = nil | |
@excep = [] | |
@running = nil | |
def start | |
if @running == true; return false; end | |
@cid = 0; @excep = []; @running = true | |
while @running do | |
print @context.class.to_s+":"[email protected]_s+"<<" | |
@input = gets.chomp | |
if @input.to_s.downcase == "exit"; @running = false; @res = "Stopping shell." | |
else | |
begin; @res = @context.instance_eval(@input) | |
rescue => e; @res = "Exception: "+e.to_s+"\n"+e.backtrace.join("\n") | |
end | |
end | |
print @context.class.to_s+":"[email protected]_s+">> "[email protected]_s+"\n" | |
@cid += 1 | |
end | |
end | |
def stop | |
if @running == false; return false; end | |
@running = false | |
end | |
start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment