parrotcode: Tcl Parser | |
Contents | Language Implementations | TCL |
Tcl Parser
This is the parser that makes up the heart of Partcl. It follows the 11 rules that are found in the Tcl manpage, available online at <http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm>.
pmc commands = parse(string tcl_code)
int pos = skip_comment(string tcl_code, int pos)
Incoming: # comment\n
^
Outgoing: # comment\n
^
(pmc command, int pos) = get_command(string tcl_code, pmc chars, int pos)
Incoming: puts [lindex "a b c" 1]
^
Outgoing: puts [lindex "a b c" 1]
^
(pmc word, int pos) = get_word(string tcl_code, pmc chars, int pos)
Incoming: puts foo\n
^
Outgoing: puts foo\n
^^
(pmc word, int pos) = get_quote(string tcl_code, int pos, pmc chars)
Incoming; puts [lindex "a b c" 1]
^
Outgoing: puts [lindex "a b c" 1]
^
(pmc const, int pos) = get_brace(string tcl_code, int pos, pmc chars)
Incoming: puts {foo}
^
Outgoing: puts {foo}
^
(pmc command, int pos) = get_subcommand(string tcl_code, int pos)
Incoming: puts [lindex "a b c" 1]
^
Outgoing: puts [lindex "a b c" 1]
^
(pmc var, int pos) = get_variable(string tcl_code, int pos)
Incoming: puts $foo\n
^
Outgoing: puts $foo\n
^^
|