Revision 29472

Date:
2010/01/06 05:10:11
Author:
diakopter
Revision Log:
[sprixel] an optimization for gplus. instead of behaving O(n**5), now it's O(n**2.5). :|
Files:

Legend:

 
Added
 
Removed
 
Modified
  • src/perl6/sprixel/jsemit.js

     
    759 759 var retry = new gtr(), check = new gtr(); // label for retry spot
    760 760 c.r.push(
    761 761 casel(this.init),d,
    762 val("t.z8=[],t.tr={}"), // create a container for the child objects
    762 val("t.z8=[];t.ret={}"), // create containers for the child objects
    763 763 casel(retry)
    764 764 );
    765 765 this.l.emit(c);
     
    769 769 // gotol(this.done)
    770 770 //]]),
    771 771 val("t.i.z8.push(t);t.nd=false;t=t.i"),
    772 cond(val("(t.ret[o])"),[[
    773 gotol(this.l.fail)
    774 ]]),
    775 val("t.ret[o]=true"),
    772 776 gotol(retry), // try another one
    773 777
    774 778 casel(this.l.notd), // left succeeded
    775 val("t.i.z8.push(t);t.nd=true;t=t.i"),
    779 val("t.i.z8.push(t);t.nd=true"),
    780 a,
    776 781 gotol(retry), // try another one
    777 782
    778 783 casel(this.l.fail), // left hit its base case
     
    784 789 cond(val("(t.z8.length==1&&t.z8[0].nd==false)"),[[
    785 790 gotol(this.done)
    786 791 ]]),
    792 val("t.ret[o]=true"),
    787 793 gotol(this.notd),
    788 794
    789 795 casel(this.bt),
     
    800 806 cond(val("(t.z8.length==1&&t.z8[0].nd==false)"),[[
    801 807 gotol(this.done)
    802 808 ]]),
    809 cond(val("(t.ret[o])"),[[
    810 gotol(this.bt)
    811 ]]),
    812 val("t.ret[o]=true"),
    803 813 gotol(this.notd)
    804 814 );
    805 815 };
     
    856 866 //grammar = either(either(lit("a"),either(lit("b"),lit("c"))),either(lit("f"),lit("haar")));
    857 867 //grammar = plus(lit("a"));
    858 868 //grammar = both(plus(lit("a")),lit("aa"));
    859 grammar = both(both(plus(either(lit("aa"),lit("a"))),lit('aaa')),end());
    869 //grammar = both(both(plus(either(lit("aa"),lit("a"))),lit('aaa')),end());
    870 grammar = both(both(plus(either(lit("aa"),lit("a"))),lit(Array(5000).join('a'))),end());
    860 871
    861 872 grammar.fail = {id:1};
    862 873 grammar.done = grammar.notd = {id:-1};
     
    882 893
    883 894 var parser = eval(parserf); // compile the javascript function to machine code
    884 895
    885 var input = utf32str('aaaa');
    896 var input = utf32str(Array(5001).join('a'));
    886 897
    887 898 parser(input);
    888 899