[#16113] Strange idea... exporting from a scope — "Hal E. Fulton" <hal9000@...>
Hello...
Hi,
matz@zetabits.com (Yukihiro Matsumoto) writes:
Hi,
matz@zetabits.com (Yukihiro Matsumoto) writes:
On Thu, 7 Jun 2001, Dave Thomas wrote:
[#16140] (?i:) in regexp — ts <decoux@...>
>>>>> "Y" == Yukihiro Matsumoto <matz@zetabits.com> writes:
[#16144] Re: Strange idea... exporting from a scope — hfulton@...
> |> I'm too lazy to type in "exprt" and variable name. so I'm
Hi,
[#16155] Re: Block arguments vs method arguments — hfulton@...
> | { | local, :up | }
[#16172] The Block Problem -A suggestion — Chris Moline <ugly-daemon@...>
Hi, I was thinking about our discussion and came up with an idea that might
[#16229] Re: String#scan strange behavior — ts <decoux@...>
>>>>> "W" == Wayne Blair <wayne.blair@relian.com> writes:
[#16245] line numbers in multiline regular expressions. — jonas <jonas.bulow@...>
Hi,
[#16259] Timezone in Time::{local,gm} — Stoned Elipot <Stoned.Elipot@...>
Hello,
[#16271] Re: odd obj.send behaviour — ts <decoux@...>
>>>>> "P" == Patrik Sundberg <ps@radiac.mine.nu> writes:
[#16283] ruby and fox — Albert Wagner <alwagner@...>
Just curious if anyone else in ruby-talk is attempting to use the fox GUI. I
[#16317] Re: ruby regex — ts <decoux@...>
>>>>> "D" == David Thiel <dthiel@nexprise.com> writes:
[#16325] Tcl string map lookalike — Wilbert Berendsen <wbsoft@...4all.nl>
Hi,
[#16364] Re: Garbage Collection? — Michael Davis <mdavis@...>
Windows 2000 and linux (RedHat 6.2). I have run these tests on both OSs.
[#16380] Method objects fail equivalence — mirian@... (Mirian Crzig Lennox)
I was surprised to observe the following:
Hi,
[#16400] Symbolic Computation III — Mathieu Bouchard <matju@...>
> ----- Original Message -----
>----- Original Message -----
On Tue, 12 Jun 2001, Wayne Blair wrote:
[#16415] Ruby - Objective C - GNUstep — Laurent Julliard <Laurent.Julliard@...>
So here is my story:
[#16433] Re: Inital Q's on Ruby grammar — ts <decoux@...>
>>>>> "R" == Robert Feldt <feldt@ce.chalmers.se> writes:
[#16462] Opinion sought: parsing non-regular languages — Robert Feldt <feldt@...>
(This is a bit long...)
Robert Feldt <feldt@ce.chalmers.se> writes:
On Thu, 14 Jun 2001, Dave Thomas wrote:
[#16489] Verify correct lexing of delimited strings — Robert Feldt <feldt@...>
Hi all,
[#16502] Playing with Ruby Syntax (was: Initial thoughts about Ruby From a Smalltalk Programmer) — jweirich@...
Michael> Hi Everyone, I have to say I'm utterly fascinated by Ruby
jweirich@one.net writes:
[#16503] walking the ruby_frame list — victor <victor@...>
Hi,
Hi,
On Sat, Jun 16, 2001 at 10:56:30PM +0900, Yukihiro Matsumoto wrote:
[#16505] Smalltalk vs. Ruby — Steve Tuckner <SAT@...>
I have never used Smalltalk so I have no knowledge of its use on a day by
[#16528] why only nil and false are regarded as false? — Steven Haryanto <steven@...>
I would appreciate some explanation on why Ruby behaves like
[#16540] Trapping method defs — Robert Feldt <feldt@...>
Hi all,
[#16556] Method overloading - How? — Uwe Lammers <Uwe.Lammers@...>
Hi,
[#16565] Configuration file parsing — "Anders Johannsen" <anders@...>
I'm currently writing an application in Ruby, which needs a
[#16567] [TOY] reversed regexp — ts <decoux@...>
[#16583] Two (or more) dimensional arrays? — "Kirk Lowery" <klowery@...>
After reading my way through various documentation, I didn't find any
[#16591] RCR: Enumerable: every() and none() — Hugh Sasse Staff Elec Eng <hgs@...>
I've been off the list for a while but I'm dipping back in to suggest:
[#16599] RE: RCR: Enumerable: every() and none() — "Benjamin J. Tilly" <ben_tilly@...>
>===== Original Message From Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> =====
[#16604] Creating arrays — Chris Moline <ugly-daemon@...>
Hi, I was wondering why do we have to do this
[#16634] mascot — redwolf <arm3@...>
The Ruby Crowned Kinglet is perfect!!!
[#16640] Re: Commenting code — Alvaro Segura <asegura@...>
James Kanze wrote:
[#16646] Serial Communications — Wai-Sun Chia <waisun.chia@...>
Hello Rubyists,
[#16657] bag difference — Hugh Sasse Staff Elec Eng <hgs@...>
Is there an elegant way to do a bag diffeence between 2 arrays, rather
[#16661] Problem running irb with Ruby 1.6.4 under FreeBSD 4.0 — Bob Alexander <balexander@...>
I've installed Ruby 1.6.4 on a FreeBSD 4.0 machine, and get the
Yukihiro Matsumoto wrote:
Hi,
In article <993579597.067351.15583.nullmailer@ev.netlab.zetabits.com>,
[#16662] installation option — Hung-Hsien Chang <hubert@...>
Hi!
[#16669] how to call super from singleton method? — viisi@... (Andi Riedl)
hi!
[#16681] RE: embedding C++ — Wyss Clemens <WYS@...>
Have you tried using SWIG?
[#16686] opening db files made by apache dbmmanage — Fritz Heinrichmeyer <fritz.heinrichmeyer@...>
[#16714] DBI 0.0.5 problem — "Krzysztof P. Jasiutowicz" <kpj@...>
Krzysztof P. Jasiutowicz wrote:
[#16715] File.flock blocks forever — Michael Witrant <mike@...>
Hello,
[#16723] setsockopt options — Joseph McDonald <joe@...>
Hi,
Hi,
[#16726] Simulating call-by-reference in Ruby — senderista@... (Tobin Baker)
I'm currently working on Ruby bindings for ORBit and thought that it
[#16737] socket bug — Joseph McDonald <joe@...>
Joseph McDonald <joe@vpop.net> writes:
[#16763] uniq and "equivalence" — Hugh Sasse Staff Elec Eng <hgs@...>
Array.uniq seems to rely on deleting multiple references to the same object.
>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
On Fri, 22 Jun 2001, ts wrote:
>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
[#16788] pretty printing with enscript? — Albert Wagner <alwagner@...>
By chance, has anyone done a pretty printing file for ruby in enscript?
[#16792] wrapping structures — Martin Chase <stillflame@...>
hey ruby hackers,
[#16799] Problems compiling FOX for Ruby (FXRuby) on NetBSD — Michael Neumann <neumann@...>
Hi,
[#16801] rb_define_class() vs Class.new() — Kero van Gelder <kero@...4050.upc-d.chello.nl>
Hi,
>>>>> "K" == Kero van Gelder <kero@d4050.upc-d.chello.nl> writes:
> K> From C, rb_define_class() defines a named class, however, on the Ruby
>>>>> "K" == Kero van Gelder <kero@d4050.upc-d.chello.nl> writes:
> >>>>> "K" == Kero van Gelder <kero@d4050.upc-d.chello.nl> writes:
>>>>> "K" == Kero van Gelder <kero@d4050.upc-d.chello.nl> writes:
> irb> B = a
>>>>> "K" == Kero van Gelder <kero@d4050.upc-d.chello.nl> writes:
[#16810] [BUG?] Kernel::load wrap parameter — Patrik Sundberg <ps@...>
(CC any replies to me please - not subscribed and have crappy newsserver)
[#16841] RE: national characters is strings — "Aleksei Guzev" <aleksei.guzev@...>
Next week I'll try to rebuild Ruby with Unicode strings. But it would be
Hi,
That's good enough. But I'm afraid this could ( not would ) cause string
Hi,
I'll help as soon as You call. I like C++ much more than Assembler :)))
Hi,
I've taken a look at m17n.
[#16861] Re: Problems compiling FOX for Ruby (FXRuby) on NetBSD — "Lyle Johnson" <ljohnson@...>
> I didn't get FXRuby (Ruby interface for FOX GUI Toolkit) available from
[#16868] Something strange with Ruby's inheritance mechanism — Eric Jacoboni <jaco@...>
As Ruby beginner, i try some "canonical" OO scripts. Doing so, I've
On Tue, 26 Jun 2001, Aleksei Guzev wrote:
[#16869] Something strange with Ruby's inheritance mechanism — Eric Jacoboni <jaco@...>
As Ruby beginner, i try some "canonical" OO scripts. Doing so, I've
[#16881] — "Aleksei Guzev" <aleksei.guzev@...>
Hi,
On Wed, 27 Jun 2001, Yukihiro Matsumoto wrote:
Hi,
On Thu, 28 Jun 2001, Yukihiro Matsumoto wrote:
Hi,
ts <decoux@moulon.inra.fr> writes:
Hi,
[#16885] Re: Something strange with Ruby's inheritance mechanism — Eric Jacoboni <jaco@...>
>>>>> "Mathieu" == Mathieu Bouchard <matju@sympatico.ca> writes:
[#16888] finalizers, destructors and whatnot — "David Leal" <david@...>
Hi all,
[#16973] Extension building — Tony Smith <tony@...>
I'm just getting started with Ruby and my first comment is "at last!". I've
[#16976] Introspection and 'where's the source'? — Johann Hibschman <johann@...>
Hi,
[#16982] RCR for the String class — Joseph McDonald <joe@...>
[#16991] eruby (or equiv) for windows? — "Derek Hamilton" <derek@...>
I am new to ruby so forgive me if this question has already been =
[#17002] FOX subclassing FXTextField and messages — Ralf Canis <rc@...>
Hello,
[#17004] the evolution of Ruby itself — Tobias Reif <tobiasreif@...>
Hi all;
Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
[#17008] Re: Poll results — Srecko.Howard@... (Srecko Howard)
Hi all
[#17020] Re: RCR for the String class — Steve Tuckner <SAT@...>
> While I'm complaining, I prefer Java's IO class hierarchy to Ruby's, too.
[#17027] sigprocmask — Joseph McDonald <joe@...>
[#17037] keeping an Exception object alive — David Alan Black <dblack@...>
Hello --
Hi,
Hello --
Hi,
Hello --
Hi,
Hello --
>>>>> "D" == David Alan Black <dblack@candle.superlink.net> writes:
Hello --
>>>>> "D" == David Alan Black <dblack@candle.superlink.net> writes:
On Mon, 2 Jul 2001, ts wrote:
[#17059] "cvs commit" from within ruby — Clemens Wyss <wys@...>
I am trying to commit a file from within a ruby script (automation
[#17069] Is the ruby GC compacting ? — Lothar Scholz <llothar@...>
Or can i safely assume that a reference to a Ruby object is always the
[#17080] (cvs?) configure / make problems — Kero van Gelder <kero@...4050.upc-d.chello.nl>
Hi!
> > fails
[#17091] ensure block not being executed — Joseph McDonald <joe@...>
I'm afraid You stop not the script but You stop the interpreter with ^C.
"Aleksei Guzev" <aleksei.guzev@bigfoot.com> writes:
Then what is MessageQueue? (I haven't foud it at my Ruby sources )
[#17102] Ruby on a PDA — Tobias Reif <tobiasreif@...>
Hi all;
[#17110] Re: Ruby on a PDA — Kent Dahl <kentda@...>
Tobias Reif wrote:
[ruby-talk:16413] Anniversary thanks and rockit
Hi all,
Last week was my Ruby one.year anniversary; I've now been a happy Ruby
user for a year. I just want to take the opportunity to thank matz and all
of you in the community for making Ruby such a wonderful
experience. The language itself is great and fills most of my programming
needs, and the prompt and to-the-point replies, ideas and code from the
community is invaluable.
To "celebrate" I decided its time I make a public release of rockit. Its
my largest pure-Ruby project so far and you can find the README
below. If you want to try it out download at
www.ce.chalmers.se/~feldt/ruby/rockit-0-3-5.tgz.
Note that its still alpha and there are lots of things todo. There is a
RubyInRuby parser in there but its very rudimentary and basically only
parses the literals and one-liners. I've simply translated parse.y to the
rockit grammar format. Need to go through and manually tune things so that
its a valid rockit grammar with proper priorities etc.
Anyway I hope someone finds this useful.
I intend to bug matz and the list heavily with questions on the Ruby
grammar to get a working RubyInRuby parser. Be glad if someone wants to
help out.
Regards,
Robert
Sorry for the length; I have to break it into pieces:
*****************************************************
* rockit - Ruby O-o Compiler construction toolKIT *
*****************************************************
Version: 0.3.5
Release date: 2001-06-11
Available from: https://sourceforge.net/projects/rockit/
but temporarily download from
www.ce.chalmers.se/~feldt/ruby/rockit-0-3-5.tgz (since I didn't have the
time to understand SourceForge's release process; I guess its
simple... ;))
Author: Robert Feldt, feldt@ce.chalmers.se
README version: $Id: README,v 1.6 2001/06/11 15:42:51 feldt Exp $
What is it?
-----------
An easy-to-use, object-oriented compiler construction toolkit written in
and generating code for Ruby. Currently focusing on the "front-end"
phases of compiler construction.
Main features of rockit:
* Grammars written in Extended Backus-Naur Form. (=> use *, ? and + ops).
* Generates both lexer and parser.
* Parsers will return abstract syntax trees (AST).
* Generated AST's support simple tree-walking using iterators.
* "Ruby-friendly" with for example Array's for repetition, Regexp's
for tokens etc.
* More advanced parser than yacc's LaLr(1) (If you're curious its called
"Generalized LR parsing with scanner forking"!)
* AST's can be dumped to postscript (if you have graphviz/dot)
* Reports when the grammar is ambigous and shows the alternative ways
to parse the sentence. Helps you resolve ambiguities.
* Associativity and precedence can be specified based on
productions/rules
in the grammar (NOT on operators which is less "portable").
Installation?
-------------
1. unpack tarball (if you haven't already)
2. install: ruby install.rb
3. If you've got RubyUnit you can also run tests: ruby tests/runtests.rb
Why is it needed?
-----------------
* No need to write a lexer/scanner; rockit gives you both a lexer and a
parser from the same grammar.
* No need to write standard code for building an abstract syntax tree;
rockit automatically generates it and you can specify how the tree
should
look.
* rockit-generated parsers builds the AST; *NO* need to write "action
code"
in the grammar. "Action code" separated from grammar.
* More powerful operators.
* You can write grammars directly in Ruby code.
* Rockit will show you why your grammar is ambigous (if it is!) by showing
you the two ways the sentence can be parsed. This helps you resolve
the ambiguity be introducing priorities.
But we already have two excellent compiler compilers in/for Ruby!
-----------------------------------------------------------------
Yes, but they (racc and rbison) both use the bison/yacc format which,
IMHO,
is not optimal for an OO language like Ruby. You also have
to write the "action code" (the one to be executed for each production)
by hand. This is sometimes a good thing if you simply want to extract some
info; but for general use you probably want to make several passes over
the
result from the parse (which will likely be an AST). Instead of writing
the
code for building the AST rockit does it for you.
In the longer term rockit will include components that are typically not
part
of compiler compilers like yacc and bison such as for example
syntax-directed
translation, pretty-printer generation etc.
Example of using the rockit command-line program?
-------------------------------------------------
$ rockit my_grammar.grammar myparser.rb MyModule my_parser
Generated parser for my_grammar.grammar and saved it in myparser.rb. Use
it by
doing:
require 'myparser'
ast = MyModule.my_parser.parse "..."
Example of using the rockit lib in Ruby code?
---------------------------------------------
require 'rockit/rockit'
parser = Parse.generate_parser <<-'END_OF_GRAMMAR'
Grammar ExampleGrammar
Tokens
Blank = /\s+/ [:Skip]
Number = /\d+/
Productions
Expr -> Number [^]
| Expr '+' Expr [Plus: left,_,right]
| Expr '-' Expr [Minus: left,_,right]
| Expr '*' Expr [Mul: left,_,right]
| Expr '/' Expr [Div: left,_,right]
| '(' Expr ')' [^: _,expr,_]
Priorities
left(Plus), left(Minus), left(Mul), left(Div)
Div = Mul > Plus = Minus
END_OF_GRAMMAR
def calc_eval(ast)
case ast.name
when "Plus"
calc_eval(ast.left) + calc_eval(ast.right)
when "Minus"
calc_eval(ast.left) - calc_eval(ast.right)
when "Mul"
calc_eval(ast.left) * calc_eval(ast.right)
when "Div"
calc_eval(ast.left) / calc_eval(ast.right)
when "Constant"
ast.lexeme.to_i
end
end
calc_eval(parser.parse '(4*((2+6)-3))/2') # => 10
Requirements?
-------------
Memoize from RAA (or my Ruby page) is needed for a slight performance
increase.
But things should work without it. Please mail me if it don't!
Otherwise it should work with any Ruby >= 1.6. If you've got strscan by
Minero
Aoki installed it will be used and give a slight performance increase.
But things work even if you haven't.
I've successfully used rockit with Ruby 1.7.0 (2001-04-02) and
cygwin 1.1.8 (gcc version 2.95.2-6) on Windows 2000 Professional.
NOTE THAT THIS IS AN ALPHA RELEASE SO THERE WILL LIKELY BE BUGS AND
THE API WILL LIKELY CHANGE.
RubyUnit is needed to run unit tests.
Documentation?
--------------
Not much yet. Check out the examples in the examples dir.
You can get a good intro to writing grammars by looking at the grammar
for rockit grammars. Its in lib and called 'rockit-grammar-files.grammar'.
You can also compare it to the grammar in bootstrap.rb which is (almost)
the same grammar but written directly in Ruby code.
Also check out the tests. Lots of good info and examples in there.
More examples of use?
---------------------
There are some stuff in the examples dir:
* calculator - simple read-eval calculator
* minibasic - interpreter for subset of basic in 46 LOC!
* polynomials - examples on evaluating and differentiating polynomials
from the ANTLR tutorial.
* ruby - rudimentary parser for Ruby. Translates parse.y to rockit
grammar.
But more work is needed for it to be useful. Note that I've
only
tried with parse.y from Ruby 1.6.3 and there is reported to be
a problem with later ones. I'll check it out soon...
License and legal issues?
-------------------------
rockit is copyright (c) 2001 Robert Feldt, feldt@ce.chalmers.se.
All rights reserved.
rockit is distributed under LGPL. See LICENSE and COPYING-LESSER.
Parsers you generate are LGPL so should not restrict you. If it does
please
mail me.
Special things to note?
-----------------------
Rockit is currently:
* SLOW! Especially when generating the parser but also when parsing.
I haven't given performance much thought yet and haven't profiled
so expect significant performance gains when we get to this issue
on
the TODO.
* BAD AT HANDLING AND REPORTING ERRORS! Will be fixed when someone shows
me
"the/a right way" to do it.
Plans for the future?
---------------------
Lots of stuff, see TODO.
Do you have comments or questions?
----------------------------------
I'd appreciate if you drop me a note if you're successfully using
rockit. If there are some known users I'll be more motivated to packing
up additions / new versions and post them to RAA.
Please give feedback!
What is Generalized LR parsing?
-------------------------------
(You don't need to understand this to use rockit but if you're interested
you might learn something about parsing...)
It is a pseudo-parallel parsing algorithm wihch runs a dynamically varying
number of LR parsers in parallel. LR parsing algorithms, such as for
example yacc and bison, generate a table with parsing actions. If there is
an ambiguity in the language or the generation technique used introduces
ambiguities because its "imperfect" there are multiple actions in some
position(s) in the table. In ordinary (yacc-style) LALR(1) parsing these
are called conflicts and must be resolved by rewriting the grammar or
introducing associativity and precedence rules since the parser must take
one and only one action. In generalized LR parsing all actions are taken
by spawning of parsers for each one of them. So if the ambiguity arose not
because of the grammar but because of the limitations of the parser
generator all but the parser taking the correct action will fail. And if
there are multiple ways to parse the sequence they will all be found! This
procedure incurs a performance penalty at compile-time, but it can be
overcome by clever encodings of the different parsers and their data.
Happy coding!
Robert Feldt, feldt@ce.chalmers.se