@@ -15,7 +15,7 @@ namespace microcode {
1515
1616 export function parse ( str : string ) {
1717 const token2tile = ( tok : string ) => {
18- const tid = tooltip2tid ( tok )
18+ const tid = tooltip2tid ( tok . replaceAll ( "_" , " " ) )
1919 // check to see if field editor needed
2020 const tile = getEditor ( tid )
2121 if ( tile instanceof ModifierEditor ) {
@@ -35,7 +35,16 @@ namespace microcode {
3535 const lines = str . split ( "\n" )
3636 let currPage : PageDefn = undefined
3737 let currRule : RuleDefn = undefined
38+ let currTile : Tile = undefined
3839 for ( let i = 0 ; i < lines . length ; i ++ ) {
40+ if ( currTile instanceof IconEditor ) {
41+ // grab the next 4 lines as well
42+ const all5 = lines . slice ( i , i + 4 ) . join ( "\n" )
43+ currTile . field = currTile . fieldEditor . fromString ( all5 )
44+ currTile = undefined
45+ i = i + 4
46+ continue
47+ }
3948 const line = lines [ 0 ] . split ( " " )
4049 if ( line [ 0 ] == "Page" ) {
4150 currPage = new PageDefn ( )
@@ -53,11 +62,23 @@ namespace microcode {
5362 }
5463 let tok = line . shift ( )
5564 while ( tok ) {
56- const tile = token2tile ( tok )
57- placeTile ( tile , currRule )
58- if ( tile instanceof ModifierEditor ) {
59- // TODO: process the field, based on context
60- } else tok = line . shift ( )
65+ if ( ! currTile ) {
66+ currTile = token2tile ( tok )
67+ placeTile ( currTile , currRule )
68+ tok = line . shift ( )
69+ } else if ( currTile instanceof IconEditor ) {
70+ break
71+ } else if ( currTile instanceof DigitEditor ) {
72+ currTile . field = currTile . fieldEditor . fromString ( tok )
73+ currTile = undefined
74+ tok = line . shift ( )
75+ } else if ( currTile instanceof MelodyEditor ) {
76+ currTile . field = currTile . fieldEditor . fromString (
77+ tok + line . join ( " " )
78+ )
79+ currTile = undefined
80+ break
81+ }
6182 }
6283 }
6384 }
0 commit comments