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>.
(int register_num, string pir_code) = compile(int register_num, string tcl_code)
(pmc invokable) = pir_compiler(int register_num, string PIR)
=item (string code) = pir_compiler(int register_num, string PIR, 1)
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, pmc chars, int pos)
Incoming; puts [lindex "a b c" 1]
^
Outgoing: puts [lindex "a b c" 1]
^
(pmc const, int pos) = get_brace(string tcl_code, pmc chars, int pos)
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
^^
(int register_num, str code) = compile_dispatch(pmc thing, int register_num)
Hey! The above document had some coding errors, which are explained below:
|