From 65ee41b9166635ea57f2ee22618bc5e86b6df003 Mon Sep 17 00:00:00 2001 From: William Joye Date: Wed, 21 Feb 2018 14:02:32 -0500 Subject: add namespace --- taccle/taccle.tcl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/taccle/taccle.tcl b/taccle/taccle.tcl index 368d8ea..9a325f4 100644 --- a/taccle/taccle.tcl +++ b/taccle/taccle.tcl @@ -2,7 +2,7 @@ # $Id: taccle.tcl,v 1.6 2005/03/17 20:42:21 tang Exp $ -set TACCLE_VERSION 1.1 +set TACCLE_VERSION 1.2 #//# # Taccle is another compiler compiler written in pure Tcl. reads a @@ -832,6 +832,9 @@ proc write_parser_utils {} { # author's license. See http://mini.net/tcl/taccle for other details. ###### +namespace eval ${::p} \{ +\} + proc ${::P}ABORT \{\} \{ return -code return 1 \} @@ -884,7 +887,7 @@ proc write_parser {} { set ${::p}state \[lindex \$${::p}state_stack end\] if {\$${::p}token == \"\"} { set ::${::p}lval \"\" - set ${::p}token \[${::p}lex\] + set ${::p}token \[${::p}::yylex\] set ${::p}buflval \$::${::p}lval } if {!\[info exists ::${::p}table(\$${::p}state:\$${::p}token)\]} { @@ -909,7 +912,7 @@ proc write_parser {} { return 1 } set ::${::p}lval {} - set ${::p}token \[${::p}lex\] + set ${::p}token \[${::p}::yylex\] set ${::p}buflval \$::${::p}lval } continue @@ -987,11 +990,13 @@ proc write_array {fd name values} { # Writes a header file that should be [source]d by the lexer. proc write_header_file {} { # scan through token_table and write out all non-implicit terminals + puts $::header "namespace eval ${::p} \{\}" + puts $::header "" foreach tok_id $::token_list { if {$::token_id_table($tok_id,t) == $::TERMINAL && \ [string is integer $tok_id] && $tok_id >= 256} { set token $::token_id_table($tok_id) - puts $::header "set ::${token} $tok_id" + puts $::header "set ${::p}::${token} $tok_id" } } puts $::header "set ::${::p}lval \{\}" -- cgit v0.12