@@ -56,7 +56,7 @@ namespace microcode {
5656 }
5757 }
5858 const addTile = ( tile : Tile , rule : RuleDefn ) => {
59- control . assert ( rule != undefined )
59+ control . assert ( rule != undefined , `No Rule definition` )
6060 const tid = getTid ( tile )
6161 if ( isSensor ( tid ) ) rule . push ( tile , "sensors" , false )
6262 if ( isFilter ( tid ) ) rule . push ( tile , "filters" , false )
@@ -76,6 +76,10 @@ namespace microcode {
7676 cursor ++
7777 prev = cursor
7878 } else {
79+ if ( str [ cursor ] == "`" ) {
80+ cursor ++
81+ return "`"
82+ }
7983 gotToken = true
8084 cursor ++
8185 }
@@ -91,23 +95,30 @@ namespace microcode {
9195 let currTile : Tile = undefined
9296 let tok : string = undefined
9397 while ( ( tok = getToken ( ) ) ) {
94- console . log ( `tok1 = ${ tok } ` )
98+ // console.log(`tok1 = ${tok}`)
9599 if ( currTile ) {
96100 if (
97101 currTile instanceof IconEditor ||
98102 currTile instanceof MelodyEditor
99103 ) {
100104 const thisTile = currTile as ModifierEditor
101- control . assert ( tok == "`" )
105+ control . assert ( tok == "`" , `expected \`, got ${ tok } ` )
102106 let tokens = [ ]
103- while ( ( tok = getToken ( ) ) != "`" ) tokens . push ( tok )
104- control . assert ( tok == "`" )
107+ while ( ( tok = getToken ( ) ) == "." || tok == "1" ) {
108+ tokens . push ( tok )
109+ }
110+ control . assert (
111+ tok == "`" ,
112+ `expected {0, 1, \`}, got ${ tok } `
113+ )
105114 currTile . field = thisTile . fieldEditor . fromTokens ( tokens )
106115 } else if ( currTile instanceof DigitEditor ) {
107116 currTile . field = currTile . fieldEditor . fromTokens ( [ tok ] )
108117 }
109- currTile = undefined
110- } else if ( tok == "Page" ) {
118+ continue
119+ }
120+ currTile = undefined
121+ if ( tok == "Page" ) {
111122 if ( currPage ) {
112123 if ( currRule ) currPage . rules . push ( currRule )
113124 prog . pages . push ( currPage )
@@ -117,11 +128,11 @@ namespace microcode {
117128 getToken ( ) // consume page #
118129 continue
119130 } else if ( tok == "When" ) {
120- control . assert ( currPage != undefined )
131+ control . assert ( currPage != undefined , `No Page defined` )
121132 if ( currRule ) currPage . rules . push ( currRule )
122133 currRule = new RuleDefn ( )
123134 } else if ( tok == "Do" ) {
124- control . assert ( currRule != undefined )
135+ control . assert ( currRule != undefined , `No When defined` )
125136 } else {
126137 currTile = token2tile ( tok )
127138 addTile ( currTile , currRule )
0 commit comments