Coder Social home page Coder Social logo

compile errors about perlito HOT 9 CLOSED

fglock avatar fglock commented on August 25, 2024
compile errors

from perlito.

Comments (9)

fglock avatar fglock commented on August 25, 2024
  • Fixed missing "1;" in Macro.pm.
  • Investigating "Text::CSV::Easy_PP": I've commented out "use Exporter" for
    now, as it is not yet implemented.
  • Fixed a compiler bug with too-strict Bareword checking on "ARGV" (ARGV is
    the default filehandle for "<>")
  • Fixed a bug in Java caller(), this fixes a "Can't call method
    Perlito5::Compiler::error on unblessed reference".
  • Nodejs now complains about:
    "Invalid flags supplied to RegExp constructor 'xsg'".
  • Testing in Java requires implementing "readline" function.

Current status / TODO:

  • Finish "Exporter" debugging.
  • Investigate why missing "1;" in module is not catched by the compiler.
  • Investigate how to implement the missing regex flags in JavaScript and
    Java.
  • Finish readline implementation in Java.

2016-05-03 21:57 GMT+02:00 H.Merijn Brand [email protected]:

  1. All invocations like ::error "foo"; need parens:

$ node perlito5.js -I src5/lib -I /pro/lib/perl5/site_perl/5.22.0 ../Text-CSV6/csv-test-pp.pl
Can't call method Perlito5::Compiler::error on unblessed reference at ../Text-CSV6/csv-test-pp.pl line 143

to start:

vi +18 Perlito5/Grammar/Attribute.pm
vi +273 Perlito5/Grammar/Sigil.pm
vi +123 Perlito5/Grammar/Scope.pm
vi +3205 Perlito5/Java/Emitter.pm

  1. All modules need a true value at the end

Perlito5/Macro.pm needs a 1; on line 407

The script I started to test with is

#!/usr/bin/perl

use strict;
use warnings;

use Text::CSV_PP;

my @rows;
my $csv = Text::CSV_PP->new ({ binary => 1, auto_diag => 1 } )
or die "Cannot use CSV: ", Text::CSV->error_diag ();

my $sum = 0;
while (my $row = $csv->getline (*ARGV)) {
$sum += scalar @$row;
}
print "$sum\n";

where the input is a valid CSV file

Alternatively this is smaller PP code:

#!/usr/bin/perl

use strict;
use warnings;

use Text::CSV::Easy_PP qw(csv_parse);

my $sum = 0;
while (my $line = <>) {
my @Row = csv_parse ($line);
$sum += @Row;
}
print "$sum\n";


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#43

from perlito.

fglock avatar fglock commented on August 25, 2024

I think there is something wrong with Text::CSV::Easy_PP, a zero at the end of line gives an error:

$ cat > csv2.pl
#!/usr/bin/perl

use strict;
use warnings;

use Text::CSV::Easy_PP qw(csv_parse);

my $sum = 0;
while (my $line = <>) {
    my @row = csv_parse ($line);
    $sum += @row;
    }
print "$sum\n";

Run:

$ perl csv2.pl
1,2,3
1,2,0
invalid line: 1,2,0
 at csv2.pl line 10.

from perlito.

Tux avatar Tux commented on August 25, 2024

Yes, that is plain wrong. That is not my module, so I filed a ticket

from perlito.

fglock avatar fglock commented on August 25, 2024

Regex and readline are working now; Exporter is not yet implemented.

Testing with a tweaked version to avoid Exporter: https://gist.github.com/fglock/0c91002af68a7ba074886edc196eea20

Performance needs to improve (tested with a 2MB csv file):

Perl-to-Java:

$ perl perlito5.pl -I src5/lib -Cjava mtest.pl > Main.java ; javac Main.java
$ time java Main csv.txt
508033

real    0m4.345s
user    0m8.917s
sys 0m0.604s

Perl:

$ time perl mtest.pl csv.txt
508033

real    0m2.344s
user    0m2.313s
sys 0m0.010s

from perlito.

fglock avatar fglock commented on August 25, 2024

This works now (at commit 9f0ed67):

file "csv1.pl":

#!/usr/bin/perl

use strict;
use warnings;

use Text::CSV::Easy_PP;

my $sum = 0;
while (my $line = <>) {
    my @row = Text::CSV::Easy_PP::csv_parse ($line);
    $sum += @row;
    }
print "$sum\n";

file "text.csv":

1,"a",123,"567"
"x",text,2,4

env:

$ echo $PERL5LIB
/usr/local/lib/perl5/site_perl/5.20.1
$ perldoc -l Text::CSV::Easy_PP
/usr/local/lib/perl5/site_perl/5.20.1/Text/CSV/Easy_PP.pm

compile:

perl perlito5.pl -I src5/lib -Cjava csv1.pl > Main.java
javac Main.java 

run:

$ java Main text.csv
8

from perlito.

Tux avatar Tux commented on August 25, 2024
Perlito-git 503 > perl perlito5.pl  -I src5/lib -Cjava ../Text-CSV6/csv-easy-pp.pl >Main.java
Perlito-git 504 > javac Main.java
Perlito-git 505 > java Main /tmp/hello.csv
Exception in thread "main" PlDieException: Can't use an undefined value as a subroutine reference
        at PlCORE.die(Main.java:554)
        at PlCORE.die(Main.java:565)
        at PlUndef.apply(Main.java:5211)
        at PlLvalue.apply(Main.java:3664)
        at Main.main(Main.java:6456)

which means that the

use Blah qw( foo );

syntax still is unsupported.

If I remove the import list and use the fully qualified name as your example does, the test passes. I'll include the results on my speed compare page.

from perlito.

Tux avatar Tux commented on August 25, 2024

And I am missing something else too :/

Perlito-git 527 > zip -9 csv-pi-easy-pp.jar Main.class
  adding: Main.class (deflated 51%)
Perlito-git 528 > time java -cp csv-pi-easy-pp.jar Main /tmp/hello.csv
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: PlReturnException
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: PlReturnException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
0.046u 0.009s 0:00.05 80.0%     0+0k 0+72io 0pf+0w

from perlito.

Tux avatar Tux commented on August 25, 2024
Perlito-git 529 > time java -cp csv-pi-easy-pp.jar:. Main /tmp/hello.csv
50000
1.345u 0.044s 0:00.41 336.5%    0+0k 0+72io 0pf+0w

from perlito.

Tux avatar Tux commented on August 25, 2024

http://tux.nl/Talks/CSV6/speed5.html - neat! 0.400

from perlito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.