Author: coke
Date: Sun Sep 25 08:47:49 2005
New Revision: 9245

Modified:
   branches/leo-ctx5/languages/tcl/README
   branches/leo-ctx5/languages/tcl/TODO
   branches/leo-ctx5/languages/tcl/tcl.pir
Log:
Add support for multi-line interactive tclsh...

set a {
  b
}

Now works.



Modified: branches/leo-ctx5/languages/tcl/README
==============================================================================
--- branches/leo-ctx5/languages/tcl/README      (original)
+++ branches/leo-ctx5/languages/tcl/README      Sun Sep 25 08:47:49 2005
@@ -31,12 +31,11 @@ cd'ing to the proper directory to run.
 To run the test suite, type C<make test>. Note - if I<any> tests fail, try
 setting the environment variable C<TEST_PROG_ARGS> to C<-G> and retry.
 
-If the tests now pass, there's a GC bug that needs to be reported to
-the perl6-internals list.
+If any tests fail (with C<-G> or not), please email the perl6-internals list.
 
 =head2 Documentation
 
-Various documentation (in various states of decay at the moment):
+See:
 
  docs/*
  TODO

Modified: branches/leo-ctx5/languages/tcl/TODO
==============================================================================
--- branches/leo-ctx5/languages/tcl/TODO        (original)
+++ branches/leo-ctx5/languages/tcl/TODO        Sun Sep 25 08:47:49 2005
@@ -37,10 +37,7 @@ at least for language interoperability.
 
 =item interactive tclsh
 
- o catch any real_exceptions thrown.
  o respect tcl_prompt1, tcl_prompt2
- o deal with incomplete input (needs better error handling)
- o add back in support for dispatch to shell.
 
 =item implement default globals, etc.
 
@@ -66,7 +63,7 @@ Perhaps via [namespace import]? Can fake
 
 =over 4
 
-=item [expr] mdiep is currently working on this.
+=item [expr]
 
 the expr AST could use a rework. Be nice if it just passed around something
 invokable.

Modified: branches/leo-ctx5/languages/tcl/tcl.pir
==============================================================================
--- branches/leo-ctx5/languages/tcl/tcl.pir     (original)
+++ branches/leo-ctx5/languages/tcl/tcl.pir     Sun Sep 25 08:47:49 2005
@@ -40,27 +40,42 @@
 
   .local pmc parse
   parse = find_global "_Tcl", "parse"
+  input_line = ""
 
-input_loop:
   print "% " # XXX Doesn't respect a set tcl_prompt1
   STDOUT."flush"()
-  input_line = readline STDIN
+input_loop:
+  $S0 = readline STDIN
+  input_line .= $S0
   unless STDIN goto done
-  $P1 = parse(input_line)
   push_eh loop_error
+    $P1 = parse(input_line)
     retval = $P1."interpret"()
   clear_eh
   # print out the result of the evaluation.
-  if_null retval, input_loop
-  if retval == "" goto input_loop
+  if_null retval, input_loop_continue
+  if retval == "" goto input_loop_continue
   print retval
   print "\n"
-  goto input_loop
+  goto input_loop_continue
 
 loop_error:
+  # Are we just missing a close-foo? XXX probably not the best way to check.
+  $P0 = P5[0] # message
+  $S0 = $P0
+  if $S0 == "missing close-brace" goto input_loop
+  if $S0 == "missing quote"       goto input_loop
+  
+loop_error_real:
   .get_stacktrace(P5,$S0)
   print $S0
   print "\n"
+  goto input_loop_continue
+
+input_loop_continue:
+  print "% " # XXX Doesn't respect a set tcl_prompt1
+  STDOUT."flush"()
+  input_line = ""
   goto input_loop
 
 open_file: 

Reply via email to