Comments (9)
- 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]:
- 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 143to 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
- 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.
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.
Yes, that is plain wrong. That is not my module, so I filed a ticket
from perlito.
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.
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.
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.
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.
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.
http://tux.nl/Talks/CSV6/speed5.html - neat! 0.400
from perlito.
Related Issues (20)
- Error "Unexpected block after expression" HOT 1
- Could perlito compile exiftool to javascript? HOT 2
- "Too much recursion" for the JS backend HOT 3
- Tests fail on perl built with -Duselongdouble HOT 1
- Package org.perlito.Perlito5 does not exist with jrunscript HOT 5
- Lost Java types HOT 5
- successive runs of perl code giving different resulsts HOT 6
- Tests for perl 5.26 functionality, while package expects only Perl 5.14 HOT 1
- Getting started? Errors with perl5 HOT 2
- double fat-arrow error
- java "Named capturing group <name> is already defined"
- Java MIME::Base64 breaks in Java9 because missing javax.xml.bind.DatatypeConverter HOT 1
- Code examples on website don't compile HOT 1
- java -jar perlito5.jar -Isrc5/lib array.t failed to run with OpenJDK (not official Java)
- Some Perl6 programs won't compile
- make fails on Ubuntu WSL HOT 1
- can't "make" under Windows 10 w/Strawberry Perl 5.18 x64 HOT 2
- Bareword "Perlito5::Java::pkg" not allowed
- wasm backend ? HOT 4
- Modifying substr expressions evaluate incorrectly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from perlito.