On Mon, 11 Jun 2001, Mathieu Bouchard wrote: > There needs to be a interface between a parser and an interpreter. Often > it's an AST system or a bytecode system. Matz has chosen the AST way with > his Ruby interpreter. Now our job is to make something similar to Matz' > AST system. But I want it like this: > > 1. It has to be expressed in Ruby, not in C. > > 2. *All* parser details go in the parser. > > 3. *All* interp details go in the interp. > > 4. The AST system must be a common middleground that allows for writing > parsers, unparsers, interpreters, compilers, decompilers, optimizers, > analyzers, refactorers, classbrowsers, obfuscators, deobfuscators, > highlighters, lintcheckers, indenters, whatevers. > > 5. It Must Make It Simple. I mean Simple. That's Simple to read, > understand, recite, encode in, decode out, process, transform, use in a > contorted fashion, use in an unintended fashion, extend, modify, rewrite, > extend, hack, butcher. Now to satisfy all of that at once it should do its > job, it should not do others' job, it should allow others to do their job, > there should be nothing to add, and nothing to remove. This is my kind of > Simple. > > 6. Therefore: > > 6.1. It shall be to Ruby source what DOM is to XML. > > 6.2. Structure of valid Ruby trees shall be expressed as a schema: > basically, a few dozen classes. > > 6.3. That schema should contain less rules than Matz' AST system. > > 6.4. Meta-types (Struct/Tuple, Choice, Array/List, Union) shall > describe how the schema is built (naming and typing), what it means, and > provide means to verify validity (as structures are created/modified, or > in a single pass when request, at choice). > > 6.5. Parsers will build such trees; interpreters, compilers, will read > them; optimisers will modify them; indenters will traverse them and follow > the annotations. > I heartily agree with all of this. In Rockit:examples/ruby there is a start at a grammar+ast spec that will fulfill these needs. I'll look into your RubyAST (which seems to be more complete) and try to add to /comply with that. I'll be back... /Robert