Version 3 of Tcl_ParseCommand

Updated 2003-02-10 16:48:47

Tcl_ParseCommand - function in Tcl's public C API for parsing a Tcl command from a string.


Official docs

http://www.purl.org/tcl/home/man/tcl8.4/TclLib/ParseCmd.htm


  int
  Tcl_ParseCommand(
      Tcl_Interp *interp,
      const char *string,
      int         numBytes,
      int         nested,
      Tcl_Parse  *parsePtr)

There have been several bugs deep in the Tcl core dealing with the parsing of commands that suggest the existing docs for Tcl_ParseCommand don't point out a tricky case well enough. See Tcl Bug 681641.

The end of a Tcl command is determined by the presence of a command terminator character. This might be a newline ("\n") or a semi-colon (";"). When Tcl_ParseCommand is asked to parse a command in a command substitution context (by setting the nested value to true), then the close-bracket character ("]") is also a command terminator.

Tcl_ParseCommand returns its parsing results in a Tcl_Parse structure pointed to by parsePtr.