[#6954] Why isn't Perl highly orthogonal? — Terrence Brannon <brannon@...>

27 messages 2000/12/09

[#7022] Re: Ruby in the US — Kevin Smith <kevinbsmith@...>

> Is it possible for the US to develop corporate

36 messages 2000/12/11
[#7633] Re: Ruby in the US — Dave Thomas <Dave@...> 2000/12/19

tonys@myspleenklug.on.ca (tony summerfelt) writes:

[#7636] Re: Ruby in the US — "Joseph McDonald" <joe@...> 2000/12/19

[#7704] Re: Ruby in the US — Jilani Khaldi <jilanik@...> 2000/12/19

> > first candidates would be mysql and postgressql because source is

[#7705] Code sample for improvement — Stephen White <steve@...> 2000/12/19

During an idle chat with someone on IRC, they presented some fairly

[#7750] Re: Code sample for improvement — "Guy N. Hurst" <gnhurst@...> 2000/12/20

Stephen White wrote:

[#7751] Re: Code sample for improvement — David Alan Black <dblack@...> 2000/12/20

Hello --

[#7755] Re: Code sample for improvement — "Guy N. Hurst" <gnhurst@...> 2000/12/20

David Alan Black wrote:

[#7758] Re: Code sample for improvement — Stephen White <steve@...> 2000/12/20

On Wed, 20 Dec 2000, Guy N. Hurst wrote:

[#7759] Next amusing problem: talking integers (was Re: Code sample for improvement) — David Alan Black <dblack@...> 2000/12/20

On Wed, 20 Dec 2000, Stephen White wrote:

[#7212] New User Survey: we need your opinions — Dave Thomas <Dave@...>

16 messages 2000/12/14

[#7330] A Java Developer's Wish List for Ruby — "Richard A.Schulman" <RichardASchulman@...>

I see Ruby as having a very bright future as a language to

22 messages 2000/12/15

[#7354] Ruby performance question — Eric Crampton <EricCrampton@...>

I'm parsing simple text lines which look like this:

21 messages 2000/12/15
[#7361] Re: Ruby performance question — Dave Thomas <Dave@...> 2000/12/15

Eric Crampton <EricCrampton@worldnet.att.net> writes:

[#7367] Re: Ruby performance question — David Alan Black <dblack@...> 2000/12/16

On Sat, 16 Dec 2000, Dave Thomas wrote:

[#7371] Re: Ruby performance question — "Joseph McDonald" <joe@...> 2000/12/16

[#7366] GUIs for Rubies — "Conrad Schneiker" <schneik@...>

Thought I'd switch the subject line to the subject at hand.

22 messages 2000/12/16

[#7416] Re: Ruby IDE (again) — Kevin Smith <kevins14@...>

>> >> I would contribute to this project, if it

17 messages 2000/12/16
[#7422] Re: Ruby IDE (again) — Holden Glova <dsafari@...> 2000/12/16

-----BEGIN PGP SIGNED MESSAGE-----

[#7582] New to Ruby — takaoueda@...

I have just started learning Ruby with the book of Thomas and Hunt. The

24 messages 2000/12/18

[#7604] Any corrections for Programming Ruby — Dave Thomas <Dave@...>

12 messages 2000/12/18

[#7737] strange border-case Numeric errors — "Brian F. Feldman" <green@...>

I haven't had a good enough chance to familiarize myself with the code in

19 messages 2000/12/20

[#7801] Is Ruby part of any standard GNU Linux distributions? — "Pete McBreen, McBreen.Consulting" <mcbreenp@...>

Anybody know what it would take to get Ruby into the standard GNU Linux

15 messages 2000/12/20

[#7938] Re: defined? problem? — Kevin Smith <sent@...>

matz@zetabits.com (Yukihiro Matsumoto) wrote:

26 messages 2000/12/22
[#7943] Re: defined? problem? — Dave Thomas <Dave@...> 2000/12/22

Kevin Smith <sent@qualitycode.com> writes:

[#7950] Re: defined? problem? — Stephen White <steve@...> 2000/12/22

On Fri, 22 Dec 2000, Dave Thomas wrote:

[#7951] Re: defined? problem? — David Alan Black <dblack@...> 2000/12/22

On Fri, 22 Dec 2000, Stephen White wrote:

[#7954] Re: defined? problem? — Dave Thomas <Dave@...> 2000/12/22

David Alan Black <dblack@candle.superlink.net> writes:

[#7975] Re: defined? problem? — David Alan Black <dblack@...> 2000/12/22

Hello --

[#7971] Hash access method — Ted Meng <ted_meng@...>

Hi,

20 messages 2000/12/22

[#8030] Re: Basic hash question — ts <decoux@...>

>>>>> "B" == Ben Tilly <ben_tilly@hotmail.com> writes:

15 messages 2000/12/24
[#8033] Re: Basic hash question — "David A. Black" <dblack@...> 2000/12/24

On Sun, 24 Dec 2000, ts wrote:

[#8178] Inexplicable core dump — "Nathaniel Talbott" <ntalbott@...>

I have some code that looks like this:

12 messages 2000/12/28

[#8196] My first impression of Ruby. Lack of overloading? (long) — jmichel@... (Jean Michel)

Hello,

23 messages 2000/12/28

[#8198] Re: Ruby cron scheduler for NT available — "Conrad Schneiker" <schneik@...>

John Small wrote:

14 messages 2000/12/28

[#8287] Re: speedup of anagram finder — "SHULTZ,BARRY (HP-Israel,ex1)" <barry_shultz@...>

> -----Original Message-----

12 messages 2000/12/29

[ruby-talk:7831] Help a Ruby newbie?

From: Nolan Darilek <nolan_d@...>
Date: 2000-12-21 02:40:01 UTC
List: ruby-talk #7831
Hello. Please CC me any replies to this message; I was using
comp.lang.ruby, but I don't appear to have news access at my current
account.

I've recently begun learning Ruby. I'd really like to use it to code a
few console apps which I'm planning on developing. I'm a Python coder,
and one class which I missed tremendously during the Ruby migration
was cmd, which quickly constructs command line interpreters.

So, in order to better learn Ruby, I decided to port the cmd
class. Yes I know about the Ruby python interpreter, but I'd rather
avoid that if I can. So, several hours and a few pots of coffee later,
I've got most of the cmd class ported. I still have to add the help
facilities, and I may get brave and try to support readline, but first
things first. :)

Anyhow, I've poured over this code for a few hours. There's an error
in the onecmd method, but I can't find it. It's probably something
rediculously silly, but after coding for hours I'm just not seeing
it. I'll attach the code and blatantly-ripped-off spec which it was
ported from; would someone be able to help me track down what's going
on? I'll include a transcript of 'ruby cmd.rb' below as well.

--------------------------------------------------------------------------------
# A generic class to build line-oriented command interpreters
#
# Interpreters constructed with this class obey the following conventions:
#
# 1. End of file on input is processed as the command 'EOF'.
# 2. A command is parsed out of each line by collecting the prefix composed
#    of characters in the identchars member.
# 3. A command `foo' is dispatched to a method 'do_foo()'; the do_ method
#    is passed a single argument consisting of the remainder of the line.
# 4. Typing an empty line repeats the last command.  (Actually, it calls the
#    method `emptyline', which may be overridden in a subclass.)
# 5. There is a predefined `help' method.  Given an argument `topic', it
#    calls the command `help_topic'.  With no arguments, it lists all topics
#    with defined help_ functions, broken into up to three topics; documented
#    commands, miscellaneous help topics, and undocumented commands.
# 6. The command '?' is a synonym for `help'.  The command '!' is a synonym
#    for `shell', if a do_shell method exists.
#
# The `default' method may be overridden to intercept commands for which there
# is no do_ method.
#
# The data member `self.ruler' sets the character used to draw separator lines
# in the help messages.  If empty, no ruler line is drawn.  It defaults to "=".
#
# If the value of `self.intro' is nonempty when the cmdloop method is called,
# it is printed out on interpreter startup.  This value may be overridden
# via an optional argument to the cmdloop() method.
#
# The data members `@doc_header', `@misc_header', and
# `@undoc_header' set the headers used for the help function's
# listings of documented functions, miscellaneous topics, and undocumented
# functions respectively.
#

class Cmd
  @prompt = ">"
  @identchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ123456789_"
  @ruler = "="
  @lastcmd = ""
  @cmdqueue = []
  @intro = nil
  @doc_leader = ""
  @doc_header = "Documented commands (type help <topic>):"
  @misc_header = "Miscellaneous help topics:"
  @undoc_header = "Undocumented commands:"
  @nohelp = "*** No help on %s"
  
  def preloop
  end # preloop

  def postloop
  end # postloop

  def precmd line
    line
  end # precmd

  def postcmd line
    line
  end # postcmd

  def emptyline
    return self.onecmd @lastcmd if @lastcmd
  end # emptyline

  def default line
    print "*** Unknown syntax:"+line+"\n"
  end # default

  def onecmd line
    line = line.strip
    line = "help" if line == "?"
    line = "shell" if line == "!" and self.method_defined?("do_shell")
    return self.emptyline if line == ""
    @lastcmd = line
    i, n = 0, line.length
    while i < n
	break if not (line[i] === @identchars)
	i++
	end # while i < n
    cmd = line[0,i]
    arg = line[i, line.length].strip
    return self.default line if cmd == ""
    return self.module_eval("self.do_"+cmd+"("+arg+")") if self.method_defined?("do_"+cmd)
    self.default(line)
  end # onecmd
  
  def cmdloop(intro=nil)
    self.preloop
@intro = intro if intro
    print @intro+"\n\n" if @intro
    stop = nil
    while not stop
      if @cmdqueue.length > 0
	line = @cmdqueue[0]
	@cmdqueue.delete_at 0
      else
	print @prompt
	line = gets
      end # if @cmdqueue.length > 0
      line = self.precmd line
      stop = self.onecmd line
      stop = self.postcmd stop line
    end # while not stop
    self.postloop
  end # cmdloop
end # class Cmd
--------------------------------------------------------------------------------

cmd.rb:80: parse error
	end # while i < n
	   ^
cmd.rb:88: nested method definition
  def cmdloop(intro=nil)
              ^
cmd.rb:107: parse error
Exit 3


Thanks in advance for any assistance!

In This Thread

Prev Next