==================================================================== TYACC-0.9 README ==================================================================== Tyacc is a slightly modified and extended version of byacc that allows the parsers specified in .y files to also be generated in tcl (in addition to the already available C and perl options). INSTALLATION ------------ Same as for byacc - see other README files EXECUTION/DEMO ---------------- Use the byacc -T option to generate the parser in tcl of tcalc.y in ./test subdirectory, see README.tyacc in the ./test subdirectory. LEX --- The example, ./test/tcalc.y shows how to make a parser that uses a lex generated lexer. Since tcl has nice regexp stuff, writing your own lexer in tcl is sometimes less complicated than going through lex. BUGS, TO DO ----------- 1) The scanner (in reader.c) that copies the semantic actions out of the .y file and into the parser doesn't understand tcl very well. So immediately calling a tcl procedure and not putting any {, }, \, or " characters in the actions is the best guarantee not to confuse the scanner, i.e. write actions like THIS: ---------------------------------------- ... ... | iexpr TIMES iexpr { set $$ [evaluate $1 $2 $3] } ... .... %% proc evaluate {x op y} { puts stderr "hello, the expression is $x $op $y" expr "$x $op $y" } ---------------------------------------- AND NOT like THIS: ---------------------------------------- ... ... | iexpr TIMES iexpr { \ puts stderr "hello, the expression is $1 $2 $3" set $$ [expr "$1 * $3"] } ... .... %% ---------------------------------------- 2) Relationship to byacc: tyacc branches off from byacc at version 1.8. Do a 'grep TCL *' to see where changes were made. The executable is still called 'byacc'. Tyacc might better be released as new version of byacc. 3) Parser error handling stuff is not complete for tcl option. Use -vstates option to see where parser died. 4) Would be nice if this was an option of bison rather than byacc. 5) Tyacc parsers record, for pedagogical reasons, the syntax tree at each step of the parse in a global array yyParseTreeList. This is a bit of an abuse of space if you're not interested in seeing the syntax tree. Report bugs on tcl option to : Mike Kleyn kleyn@cs.utexas.edu MISC ----- The files ./lib/parsetree.tcl is a tcl script that takes the nested list representation of the syntax tree and displays it as a tree using Alan Brighton's very nice tree-3.6 Tk tree widget. Put it and ./lib/ptreedisp in the directory tree-3.6/demos and invoke ptreedisp with one argument: the file containing the nested list generated by the -vtree option DISCLAIMER ---------- The tcl version of Berkeley Yacc is distributed with no warranty whatever. The author and any other contributors take no responsibility for the consequences of its use. CREDITS ------- To the folks who made byacc in the first place: see ACKNOWLEDGEMENTS. - Mike Kleyn Wed Aug 24 13:22:03 1994