Q: how to read language input from a Tcl interpreter?

olav@borneo.gmd.de (Olav Schettler)
Thu, 3 Feb 1994 18:08:51 GMT

          From comp.compilers

Related articles
Q: how to read language input from a Tcl interpreter? olav@borneo.gmd.de (1994-02-03)
| List of all articles for this month |

Newsgroups: comp.compilers,comp.lang.tcl
From: olav@borneo.gmd.de (Olav Schettler)
Summary: call for technology: compiler generator for Tcl
Keywords: parse, interpreter, question
Organization: GMD
Date: Thu, 3 Feb 1994 18:08:51 GMT

Dear comp.compilers and comp.lang.tcl wizzards:

I am looking for the best approach on
+---------------------------------------------------------------------+ |
how to incorporate language parsing capabilities into a Tcl program |
(Tool Command Language, the interpreted shell-like language created by J.
Ousterhout at UCB). I frequently have the problem of building parsers that
read a file in a specific language, creating objects and assign attributes
depending on the file's contents. I then want to traverse the resulting
object graph in Tcl.

My current approach
is to hand-craft a parser with flex/bison and build a C++ object graph
using semantic actions in bison. I then interface to the C++ objects by
creating new Tcl-commands for attribute manipulation. Although I can
automatically generate the Tcl/C++ binding, the whole process of creating
and debugging flex/bison specifications, defining the C++ classes and then
writing the semantic actions to create and fill the appropriate objects is
quite tedious, especially when the language being parsed is small or there
is more than one language to be parsed.

What I rather would like to see
(and program, if necessary) is a parser/scanner generator accepting a
syntax specification decorated with semantic actions in Tcl. This
generator will create tables to be fed into a generic driver that realises
the stack machine to parse the input language, invoking Tcl procedures on
the way. Combining this with [incr Tcl], an object oriented extension to
Tcl would result in a single executable containg a generic parser driver
and all the data structure support I need.

My questions
- Does such a parser/scanner generator for Tcl already exist?
- Are there universal parser/scanner generators for other interpreted
    languages (scheme, icon) that I can start with?
- What would be the best starting point? I know of at least the tool LALRGen
    described in the book by Fisher/LeBlanc that has a generic parser driver.
    I could however not find this tool in the compilers list on comp.compilers.

I am grateful for any ideas or pointers as this seems to be a major project!
I would therefore like to be sure not to duplicate existing efforts.

                    Olav Schettler

                    P.O. Box 1316 phone: +49 (2241) 14-2291
            Schloss Birlinghoven fax: +49 (2241) 14-2242
D-53757 Sankt Augustin 1, Germany email: Olav@GMD.de

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.