Re: Tcl/Tk grammar for lex/yacc/bison ?

Tom Lane <>
27 Aug 1999 01:50:13 -0400

          From comp.compilers

Related articles
Tcl/Tk grammar for lex/yacc/bison ? (Elmar Gerwalin) (1999-08-24)
Re: Tcl/Tk grammar for lex/yacc/bison ? (Tom Lane) (1999-08-27)
Re: Tcl/Tk grammar for lex/yacc/bison ? (Paul Evans) (1999-09-05)
| List of all articles for this month |

From: Tom Lane <>
Newsgroups: comp.compilers
Date: 27 Aug 1999 01:50:13 -0400
Organization: Netcom Online Communications Services
References: 99-08-096
Keywords: parse, analysis

Elmar Gerwalin <> writes:
> I'm looking for the Tcl/Tk grammar to use it with lex/yacc/ bison.

Our esteemed moderator responds:
> [TCL is so simple that it seems like overkill to parse with yacc. -John]

More to the point, Tcl has no grammar, by definition. What it's got
is some simple lexical rules for identifying words and grouping words
into commands, plus lexical rules for substituting variable values and
command results into words of commands. Everything beyond that is a
matter of how a particular command execution routine chooses to
interpret its argument words. (Tcl 8 bastardizes this simple design
in the name of speed, a choice I think Ousterhout will eventually
regret if he doesn't already...)

The Tcl lexical rules are probably too complicated for lex, since the
fact that command substitutions can be nested means a finite- state
automaton can't do the job. But yacc/bison don't seem like
appropriate tools either. I'd suggest borrowing the lexing code that
already exists in the Tcl distribution ;-)

regards, tom lane

Post a followup to this message

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