@@ -109,7 +109,7 @@ var lex = (code) => {
109
109
tokens . push ( new Token ( "error" , "invalid move" , move , `${ move } is not a valid move on a 3x3 rubiks cube` ) ) ;
110
110
}
111
111
112
- for ( var move of ( code ?? "" ) . replace ( / \n / g, " " ) . replace ( / \s \s / g, " " ) . split ( " " ) ) {
112
+ for ( var move of ( code ?? "" ) . replace ( / \n / g, " " ) . replace ( / \s \s / g, " " ) . split ( " " ) . filter ( move => ! ! move ) ) {
113
113
if ( state == "string" ) {
114
114
if ( base36map . includes ( move ) ) {
115
115
token . push ( move ) ;
@@ -348,16 +348,17 @@ var compile = (tokens, input = "", options = {}) => {
348
348
compiled . push ( `}` ) ;
349
349
}
350
350
} else if ( token . type == "error" ) {
351
+ globalThis . errored = true ;
351
352
if ( options . platform == "node" ) {
352
- compiled . push ( `process.stdout.write("error:\\n ${ token . name } \\n ${ token . value } ");` ) ;
353
+ compiled . push ( `process.stdout.write("error:\\n ${ token . name } \\n ${ token . value } \\n ");` ) ;
353
354
} else if ( options . platform == "web" ) {
354
- compiled . push ( `$("#output").innerText += "error:\\n ${ token . name } \\n ${ token . value } ";` ) ;
355
+ compiled . push ( `$("#output").innerText += "error:\\n ${ token . name } \\n ${ token . value } \\n ";` ) ;
355
356
}
356
357
break ;
357
358
}
358
359
}
359
360
360
- if ( ! printed && options . setup ) {
361
+ if ( ! printed && options . setup && ! globalThis . errored ) {
361
362
compiled . push (
362
363
`var toPrint = ${ options . stackName } .pop() ?? "";` ,
363
364
`if (typeof toPrint != "string") toPrint = JSON.stringify(toPrint, null, 2);` ,
0 commit comments