Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split (//, $s) is not handled well - results in a JS with a comment #22

Closed
shlomif opened this issue Oct 18, 2014 · 2 comments
Closed

Comments

@shlomif
Copy link
Collaborator

shlomif commented Oct 18, 2014

The code is taken from this branch:

https://github.com/shlomif/fc-solve/tree/Games-Solitaire-Verify--for-Perlito--Get-Rid-of-Getopt-Long

shlomif@telaviv1:~/Download/unpack/perl/Perlito/Perlito$ perl perlito5.pl -Cjs -I src5/lib/ -I/home/shlomif/progs/freecell/git/fc-solve/cpan/Games-Solitaire-Verify/Games-Solitaire-Verify/lib /home/shlomif/progs/freecell/git/fc-solve/cpan/Games-Solitaire-Verify/Games-Solitaire-Verify/script/expand-solitaire-multi-card-moves > ~/e.js
shlomif@telaviv1:~/Download/unpack/perl/Perlito/Perlito$ node ~/e.js 

/home/shlomif/e.js:5144
                                                var tmp276 = tmp275.slice(0);
                                                ^^^
SyntaxError: Unexpected token var
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3
shlomif@telaviv1:~/Download/unpack/perl/Perlito/Perlito$ perl -lane 'print if 5140..5150' ~/e.js 
                                        var v_rank;
                                        var v_suit;
                                        (function () {
                                                var tmp275 = p5list_to_a(p5pkg["Games::Solitaire::Verify::Card"].split(p5list_to_a((p5str(p5pkg["Games::Solitaire::Verify::Card"]["v__"]).match(//) ? 1 : 0), v_str), 1));
                                                var tmp276 = tmp275.slice(0);
                                                v_rank = tmp275.shift();
                                                v_suit = tmp275.shift();
                                                return tmp276
                                        })();
                                        if ( !( (p5call(v_self, "rank", p5list_to_a(p5call(v_self, "calc_rank", [v_rank], 1)), 0) != null)) ) {
                                                p5call(p5pkg["Games::Solitaire::Verify::Exception::Parse::Card::UnknownRank"], "throw", ['error', 'unknown rank'], null);
shlomif@telaviv1:~/Download/unpack/perl/Perlito/Perlito$ 
@fglock
Copy link
Owner

fglock commented Oct 19, 2014

The problem is that the js regex emitter doesn't know about list context.

I've committed a4f5c34 which propagates "wantarray" context into the regex emitter. But the regex emitter doesn't do anything with it just yet.

@fglock
Copy link
Owner

fglock commented Oct 20, 2014

this should be fixed with:

commit 997461e
Perlito5 - js - implement special syntax "PATTERN" for split()
commit 491ce2e
Perlito5 - js - split() runtime accepts regex as first argument

@fglock fglock closed this as completed Oct 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants