Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

fglock (5723)

fglock
  (email not shown publicly)

Journal of fglock (5723)

Saturday September 12, 2009
01:08 PM

Playing with V8 parser

[ #39617 ]

I've downloaded V8 (the javascript compiler). I was planning to try it out as a MiniPerl6 backend, but I started to play with the parser instead:

  --- src/scanner.cc (revision 2877)
  +++ src/scanner.cc (working copy)
  @@ -858,6 +858,12 @@
      bool has_escapes = false;

      StartLiteral();
  +
  + if (c0_ == '$') {
  + AddChar(c0_);
  + Advance();
  + }

Now I can use perl style var names:

  $ ./shell
  V8 version 1.3.10
  > $my_var = "hello, World!"; print($my_var);
  hello, World!

*update* - I've changed a few more things, and I've got some timings:

  $ time ./shell -e ' my $x = 0; for (my $i=1; $i < 10000000; $i++) { $x++ }; print($x);'
  9999999

  real 0m0.164s
  user 0m0.152s
  sys 0m0.008s

  $ time perl -e ' my $x = 0; for (my $i=1; $i < 10000000; $i++) { $x++ }; print($x);'
  9999999
  real 0m1.123s
  user 0m1.091s
  sys 0m0.008s

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.