@@ -377,6 +377,21 @@ function tokens2asc(
377377 }
378378 i ++ ;
379379 asc . push ( x ) ;
380+ } else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "iftrue" ) {
381+ asc . push ( { op : "if" , test : [ [ "ans" ] ] , pos } ) ;
382+ i ++ ;
383+ } else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "iffalse" ) {
384+ asc . push ( { op : "if" , test : [ [ "ans" ] ] , not : true , pos } ) ;
385+ i ++ ;
386+ } else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "elseif" ) {
387+ var x = { op : "if" , test : [ ] , elseif : true , pos } ;
388+ i ++ ;
389+ while ( ! ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "conj" ) ) {
390+ x . test . push ( tokens [ i ] ) ;
391+ i ++ ;
392+ }
393+ i ++ ;
394+ asc . push ( x ) ;
380395 } else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "end" ) {
381396 asc . push ( { op : "end" , pos } ) ;
382397 i ++ ;
@@ -392,6 +407,9 @@ function tokens2asc(
392407 } else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "break" ) {
393408 asc . push ( { op : "break" , pos } ) ;
394409 i += 1 ;
410+ } else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "continue" ) {
411+ asc . push ( { op : "continue" , pos } ) ;
412+ i += 1 ;
395413 } else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "else" ) {
396414 asc . push ( { op : "else" , pos } ) ;
397415 i += 1 ;
@@ -580,9 +598,13 @@ function tokens2asc(
580598 asc . push ( { op : "take" , count : cnt , pos } ) ;
581599 i += 2 ;
582600 } else if ( gettok ( i , 0 ) == "import" && gettok ( i , 1 ) == "file" ) {
583- typeassert ( i + 2 , [ "import" ] ) ;
584601 var x = { op : "import" , file : gettok ( i + 1 , 1 ) , iden : [ ] , pos } ;
585- i += 3 ;
602+ i += 2 ;
603+ while ( gettok ( i , 0 ) == "import" && gettok ( i , 1 ) == "in" ) {
604+ x . file += "/" + gettok ( i + 1 , 1 ) ;
605+ i += 2 ;
606+ }
607+ i += 1 ;
586608 if ( tokens [ i ] && gettok ( i , 0 ) == "import" && gettok ( i , 1 ) == "iden" ) {
587609 i ++ ;
588610 while ( ! ( gettok ( i , 0 ) == "import" && gettok ( i , 1 ) == "idenend" ) ) {
@@ -628,7 +650,9 @@ function tokens2asc(
628650}
629651
630652function jsWrapModule ( name , src ) {
631- return `/*___wenyan_module_${ name } _start___*/var ${ name } = new function(){ ${ src } };/*___wenyan_module_${ name } _end___*/` ;
653+ var splitted = name . split ( "/" ) ;
654+ var bname = splitted [ splitted . length - 1 ] ;
655+ return `/*___wenyan_module_${ name } _start___*/var ${ bname } = new function(){ ${ src } };/*___wenyan_module_${ name } _end___*/` ;
632656}
633657function pyWrapModule ( name , src ) {
634658 // return `#/*___wenyan_module_${name}_start___*/\nclass ${name}:\n${src.split("\n").map(x=>"\t"+x).join("\n")}\n#/*___wenyan_module_${name}_end___*/\n`;
0 commit comments