@@ -5,32 +5,30 @@ const path = require("path");
55
66const template = fs . readFileSync ( path . join ( __dirname , "template.txt" ) , "utf8" ) ;
77
8- let mkwire , mktwins , getfv , subst ;
8+ let mkwire , mktwins , getfv ;
99
10- function box ( fv , list , lvl )
11- {
12- for ( const atom in fv ) {
13- const ref = fv [ atom ] . ref ;
14- const agent = `\\bra_{${ lvl } }(${ ref } )` ;
15-
16- list . push ( `${ atom } = ${ agent } ` ) ;
17- }
18- }
19-
20- function psi ( shared , list , lvl )
10+ function psi ( shared , list )
2111{
2212 for ( const atom in shared ) {
2313 const twins = shared [ atom ] ;
2414 const wleft = twins . left ;
2515 const wright = twins . right ;
26- const agent = `\\fan_{${ lvl } }` ;
16+ const agent = `\\fan_{0 }` ;
2717 const tree = `${ agent } (${ wright } , ${ wleft } )` ;
2818
2919 list . push ( `${ atom } = ${ tree } ` ) ;
3020 }
3121}
3222
33- function gamma ( obj , root , list , lvl )
23+ function mkscope ( n , s )
24+ {
25+ for ( let i = 0 ; i < n ; i ++ )
26+ s = `\\scope_{0}(${ s } )` ;
27+
28+ return s ;
29+ }
30+
31+ function gamma ( obj , root , list )
3432{
3533 const node = obj . node ;
3634
@@ -41,7 +39,7 @@ function gamma(obj, root, list, lvl)
4139
4240 list . push ( `${ root } = ${ agent } ` ) ;
4341 } else {
44- const agent = `\\cro_{ ${ lvl } }( ${ root } )` ;
42+ const agent = mkscope ( obj . index , root ) ;
4543
4644 list . push ( `${ obj . name } = ${ agent } ` ) ;
4745 }
@@ -51,38 +49,25 @@ function gamma(obj, root, list, lvl)
5149 const fv = getfv ( body ) ;
5250 const wire = mkwire ( ) ;
5351 const agent = ( id in fv ) ? id : "\\erase" ;
54- const tree = `\\lam_{ ${ lvl } } (${ agent } , ${ wire } )` ;
52+ const tree = `\\lambda (${ agent } , ${ wire } )` ;
5553
5654 list . push ( `${ root } = ${ tree } ` ) ;
5755
58- gamma ( body , wire , list , lvl ) ;
56+ gamma ( body , wire , list ) ;
5957 } else if ( "appl" == node ) {
6058 const wleft = mkwire ( ) ;
6159 const wright = mkwire ( ) ;
6260 const left = obj . left ;
6361 const right = obj . right ;
6462 const shared = mktwins ( left , right ) ;
65- const agent = `\\app_{${ lvl } }` ;
66- const tree = `${ agent } (${ wright } , ${ root } )` ;
67- const fv = getfv ( right ) ;
68-
69- for ( const atom in fv ) {
70- const wref = mkwire ( ) ;
71-
72- fv [ atom ] = {
73- ref : wref
74- } ;
75- }
76-
77- subst ( right , fv , "ref" ) ;
63+ const agent = `\\apply(${ wright } , ${ root } )` ;
7864
79- list . push ( `${ wleft } = ${ tree } ` ) ;
65+ list . push ( `${ wleft } = ${ agent } ` ) ;
8066
81- gamma ( left , wleft , list , lvl ) ;
82- gamma ( right , wright , list , lvl + 1 ) ;
67+ gamma ( left , wleft , list ) ;
68+ gamma ( right , wright , list ) ;
8369
84- box ( fv , list , lvl ) ;
85- psi ( shared , list , lvl ) ;
70+ psi ( shared , list ) ;
8671 }
8772}
8873
@@ -95,9 +80,8 @@ function encode(generic, term)
9580 mkwire = generic . mkwire ;
9681 mktwins = generic . mktwins ;
9782 getfv = generic . getfv ;
98- subst = generic . subst ;
9983
100- gamma ( term , "root" , inconfig , 0 ) ;
84+ gamma ( term , "root" , inconfig ) ;
10185
10286 inconfig . inet = template ;
10387 return inconfig ;
0 commit comments