@@ -38,21 +38,28 @@ namespace microcode {
3838 if ( tokens . length == 0 || ! tokens [ 0 ] ) continue
3939 console . log ( `tok1 = ${ tokens [ 0 ] } ` )
4040 if ( tokens [ 0 ] == "Page" ) {
41+ if ( currPage ) {
42+ if ( currRule ) currPage . rules . push ( currRule )
43+ prog . pages . push ( currPage )
44+ currRule = undefined
45+ }
4146 currPage = new PageDefn ( )
42- } else if ( tokens [ 0 ] == "EOP" ) {
43- prog . pages . push ( currPage )
44- currPage = undefined
47+ continue
4548 } else if ( tokens [ 0 ] == "When" ) {
49+ control . assert ( currPage != undefined )
4650 if ( currRule ) currPage . rules . push ( currRule )
47- currRule = new RuleDefn ( )
48- } else {
51+ currRule = undefined
52+ tokens . shift ( )
53+ }
54+ let tok = tokens . shift ( )
55+ while ( tok ) {
4956 if ( ! currRule ) {
57+ currRule = new RuleDefn ( )
5058 currRule . sensors . push ( token2tile ( tokens [ 0 ] ) as number )
5159 tokens . shift ( )
5260 }
53- let tok = tokens . shift ( )
54- while ( tok ) {
55- console . log ( `tok2 = ${ tok } ` )
61+ console . log ( `tok2 = ${ tok } ` )
62+ if ( tok !== "Do" ) {
5663 currTile = token2tile ( tok )
5764 addTile ( currTile , currRule )
5865 if ( currTile instanceof IconEditor ) {
@@ -68,10 +75,12 @@ namespace microcode {
6875 currTile = undefined
6976 break
7077 }
71- tok = tokens . shift ( )
7278 }
79+ tok = tokens . shift ( )
7380 }
7481 }
82+ if ( currRule ) currPage . rules . push ( currRule )
83+ prog . pages . push ( currPage )
7584 return prog
7685 }
7786}
0 commit comments