@@ -377,6 +377,21 @@ function tokens2asc(
377
377
}
378
378
i ++ ;
379
379
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 ) ;
380
395
} else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "end" ) {
381
396
asc . push ( { op : "end" , pos } ) ;
382
397
i ++ ;
@@ -392,6 +407,9 @@ function tokens2asc(
392
407
} else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "break" ) {
393
408
asc . push ( { op : "break" , pos } ) ;
394
409
i += 1 ;
410
+ } else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "continue" ) {
411
+ asc . push ( { op : "continue" , pos } ) ;
412
+ i += 1 ;
395
413
} else if ( gettok ( i , 0 ) == "ctrl" && gettok ( i , 1 ) == "else" ) {
396
414
asc . push ( { op : "else" , pos } ) ;
397
415
i += 1 ;
@@ -580,9 +598,13 @@ function tokens2asc(
580
598
asc . push ( { op : "take" , count : cnt , pos } ) ;
581
599
i += 2 ;
582
600
} else if ( gettok ( i , 0 ) == "import" && gettok ( i , 1 ) == "file" ) {
583
- typeassert ( i + 2 , [ "import" ] ) ;
584
601
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 ;
586
608
if ( tokens [ i ] && gettok ( i , 0 ) == "import" && gettok ( i , 1 ) == "iden" ) {
587
609
i ++ ;
588
610
while ( ! ( gettok ( i , 0 ) == "import" && gettok ( i , 1 ) == "idenend" ) ) {
@@ -628,7 +650,9 @@ function tokens2asc(
628
650
}
629
651
630
652
function 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___*/` ;
632
656
}
633
657
function pyWrapModule ( name , src ) {
634
658
// 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