head	1.5;
access;
symbols
	Jan97:1.5;
locks; strict;
comment	@# @;


1.5
date	97.01.30.17.12.40;	author keller;	state Exp;
branches;
next	1.4;

1.4
date	97.01.30.15.21.08;	author keller;	state Exp;
branches;
next	1.3;

1.3
date	96.05.03.14.35.32;	author keller;	state Exp;
branches;
next	1.2;

1.2
date	96.02.10.21.17.26;	author schwencf;	state Exp;
branches;
next	1.1;

1.1
date	96.01.17.17.40.48;	author schwencf;	state Exp;
branches;
next	;


desc
@@


1.5
log
@tree now passes more than 2 parameters to browsetool.tk
@
text
@#!/bin/sh

# How to install tree and browsetool.tk:

# Move references of tree and browsetool.tk to the standard search
# path. E.g. when $HOME/cmd is included in $PATH, you can simply say
#  ln -s parallaxis/tree ~/cmd
#  ln -s parallaxis/browsetool.tk ~/cmd
#  rehash

b=`which browsetool.tk`
expectk $b $* >/dev/null
@


1.4
log
@Newer version of the browsetool, now without global paths.
@
text
@d12 1
a12 1
expectk $b $1 $2 >/dev/null
@


1.3
log
@*** empty log message ***
@
text
@d2 11
a12 1
expectk /home/schwencf/da/parallaxis/fehler/browsetool.tk $1 $2 >/dev/null @


1.2
log
@Former tree is now tree.tk; tree is a shell script.
The Text is now automatically scrolled if the curser reaches
the text-window
@
text
@d2 1
a2 1
expectk tree.tk $1 >/dev/null @


1.1
log
@A browser for examining the abstract syntax tree
@
text
@d2 1
a2 178
# the next line restarts using expectk \
exec expectk "$0" "$@@"
source static.tk
proc dpos w {
   wm geometry $w
}
set filename $argv
################################################################################
#The variable labnum garantuees that every constructed label
#get an unique name
set labnum 0
set depth 0
#set entrywidth [expr [string length $filename] + [string length " at Position 9999 99 "]]
set entrywidth 17
set labelwidth 20
set columns 2
###############################################################################
#This Procedure constructs an entry consisting if a label and an
#according value
#If the length of inhalt is greater than entrywidth a button will be construxted
#and inhalt can examined by clicking on this button
proc makeentry { pfad winnum marke inhalt  } {
   global  labnum entrywidth labelwidth 
   if [expr [string length $inhalt] <= $entrywidth ] {
      set labnum [expr $labnum +1]
	frame $pfad.frame$labnum
	label $pfad.frame$labnum.kind -text $marke -anchor w  -width $labelwidth
	label $pfad.frame$labnum.value -relief sunken -text $inhalt  -width $entrywidth
	pack $pfad.frame$labnum.kind -side left
	pack $pfad.frame$labnum.value -side right
	pack $pfad.frame$labnum -side top -fill x
   } else { 
      makebutton $pfad "" $marke "\
      toplevel .node$marke$winnum$labnum
      dpos .node$marke$winnum$labnum
      message .node$marke$winnum$labnum.msg -text \"$inhalt\"
      button .node$marke$winnum$labnum.back \
      -text READY -command \" destroy .node$marke$winnum$labnum \"
      pack .node$marke$winnum$labnum.back .node$marke$winnum$labnum.msg -side top "
  }
}
###############################################################################
proc makebutton { pfad marke inhalt kommando } {
   global labnum entrywidth labelwidth 
     set labnum [expr $labnum +1]
     frame $pfad.frame$labnum
     label $pfad.frame$labnum.kind -text $marke -anchor w -width $labelwidth
     button $pfad.frame$labnum.value  -text $inhalt -width [expr $entrywidth -3 ]\
     -pady 0 -borderwidth 0  -command $kommando -bg red -activebackground blue
     pack $pfad.frame$labnum.kind -side left
     pack $pfad.frame$labnum.value -side right
     pack $pfad.frame$labnum -side top -fill x
}
###############################################################################
source procs.tk
source symbols.tk
######################################################################
#Die Prozedur makenode_prolegomena legt die logische Struktur
#des fuer einen Knoten zu erzeugenden Fensters fest
proc makenode_prolegomena { name winnum  } {
     global depth columns entrywidth labelwidth
     toplevel .node$name$winnum
     dpos .node$name$winnum
     #       Der Name des zu erzeugenden Fensters richtet sich nach dem
     #       von Treenode, da dieser oft gleich sein kann, wird er durch
     #       Anhaengen von winnum einduetig gemacht
     #       
     label  .node$name$winnum.nodetype -text  $name 
     #       Mit dem Button "UP" steigt man in der Hierarchie eine Stufe
     #       aufwaerts der GMD-Browser erhaelt dabei das Kommando "parent",
     #       und das Fenster wird zerstoert
     #       
     pack .node$name$winnum.nodetype
     if $depth {
       button .node$name$winnum.up -text "UP" \
       -command "destroy .node$name$winnum; exp_send \"parent\n\"; set depth \[expr $depth - 1\]; startnode " \
       -width [expr $columns*($entrywidth+$labelwidth)]
       pack .node$name$winnum.up
     }
     #Die Entries werden in zwei Spalten dargestellt
     frame .node$name$winnum.entries
     frame .node$name$winnum.entries.left
     frame .node$name$winnum.entries.right
     set depth [expr $depth + 1]
}

#Die Prozedur winpath_toggle wechsel bei jedem Aufruf
#den Rahmen, in dem ein Entry liegen soll, ob links oder rechts
#Entsprechend wechselt die Variable winpath ihren Wert
#Die Variablen place_left und place_position sind lokal 
#in den Prozeduren makenode und makesymbols definiert
proc winpath_toggle { name winnum } {
  uplevel 1 {  set place_left [expr 1-$place_left] 
    set winpath .node$name$winnum.entries.$place_position($place_left)
  }
}
   

######################################################################
#Die Prozedur makenode stellt mit Hilfe von expect die Attribute des momentan
#besuchten Knoten des abstrakten Syntaxbaumes dar.
#Hat dieser weitere Soehne, so werden diese durch Anlicken des
#entsprechenden Buttons besucht werden.
#Die Prozedur kommuniziert mittels expect mit dem Compiler, der
#seinerseits tcl-Kommandos schickt
staticproc makenode {name} { { winnum 0 } } {
   global entrywidth labelwidth columns depth
#Diese Variablen werden benoetigt, um festzulegen, ob ein Entry oder Button
#auf der linken oder der rechten Seite im Fensters liegen
     set place_left 1
     set place_position(0) left
     set place_position(1) right
     set winpath ""
###############################################################################
     set winnum [expr $winnum +1]
     makenode_prolegomena $name $winnum
     # A frame for the selectors
     frame .node$name$winnum.selector
     # A frame for the cp values
     frame .node$name$winnum.value
     exp_send "\n"
            # Wird ein Selector angezeigt, der seinerseits ein Baum ist,
	    # so wird ein Button erzeugt, der ein weiteres hinabsteigen 
	    # erlaubt. Dieser Kmmentar gehoert egentlich zwei Zeilen tiefer
	    # expect missinterprtetiert diesen jedoch
     expect  {
     -indices -re {:SELECTOR:(.*):BUTTON} {
           set buttonname $expect_out(1,string)
	   button .node$name$winnum.selector.selector$buttonname\
           -text $buttonname -command " destroy .node$name$winnum; \
           exp_send \"$buttonname\n\"; startnode "
	   pack .node$name$winnum.selector.selector$buttonname   -side left -fill y
	   exp_send "\n"
	   exp_continue }
     -indices -re {:SELECTOR:(.*):(.*)} {
           winpath_toggle $name $winnum 
	   set nodename $expect_out(1,string)
           eval $expect_out(2,string)
	   exp_send "\n"
	   exp_continue }
     -indices -re {:SELECTOR:(.*)\^([0-9]+)} {
           winpath_toggle $name $winnum 
	   set nodename $expect_out(1,string)
	   makeentry $winpath  $winnum $nodename "\^$expect_out(2,string)"
	   exp_send "\n"
	   exp_continue }
     -indices -re {:ENDTREENODE:} {
	pack .node$name$winnum.entries.left\
             .node$name$winnum.entries.right -side left -fill y
	pack .node$name$winnum.entries\
             .node$name$winnum.selector\
             -side top -fill x
	exp_send "\n"}
     }
}
#regexp {([0-9]+(|\.([0-9]+)(|e[\+\+][0-9]+)))$} 
#toplevel .listing
#dpos .listing
text .listing
pack .listing
#       Mit dem Button "QUIT" verlaesst man den Browser
button .quit -text "QUIT" -command "exp_send \"quit\n\n\" ; destroy . ; interact " -width 80 -bg red
pack .quit -side top

spawn ./p3c -Zq  -Zs  $filename

proc startnode {} {
   exp_send "\n"
   expect -indices -re {:BEGINTREENODE:([a-zA-Z]*)} {
      makenode $expect_out(1,string) 
   }
}
#     exp_send "quit\n"           
startnode




@
