Exception in thread "main" org.jawk.SemanticException: Inappropriate use. class
= org.jawk.Awk$AssociativeArray, this = pieces={6=pieces[6]=, 5=pieces[5]=, 4=p
ieces[4]=, 3=pieces[3]=, 2=pieces[2]=blablabla, 1=piec
es[1]=ab}
at org.jawk.Awk$ValueAdapter.clear(Awk.java:6328)
at org.jawk.Awk$DotSepAST.forceReferenceAsAssocArray(Awk.java:4967)
at org.jawk.Awk$ExpressionListAST.executeList(Awk.java:3917)
at org.jawk.Awk$ExpressionListAST.executeList(Awk.java:3935)
at org.jawk.Awk$ExpressionListAST.executeList(Awk.java:3909)
at org.jawk.Awk$SPLIT_InternalFunction.executeFunction(Awk.java:5506)
at org.jawk.Awk$DotSepAST.executeFunction(Awk.java:5380)
at org.jawk.Awk$DotSepAST.execute(Awk.java:4827)
at org.jawk.Awk$DotSepAST.execute(Awk.java:4815)
at org.jawk.Awk$ExpressionListAST.execute(Awk.java:3893)
at org.jawk.Awk$StatementListAST.execute(Awk.java:3576)
at org.jawk.Awk$InputBlockAST.executeBlock(Awk.java:3554)
at org.jawk.Awk.processInputRecords(Awk.java:871)
at org.jawk.Awk.consumeStdin(Awk.java:736)
at org.jawk.Awk.<init>(Awk.java:618)
at org.jawk.Awk.main(Awk.java:80)
It looks like a bug with the split() function within Jawk. It seems to require the 2nd arg to be a non-initialized variable of any kind. Therefore, a work around is to add the following code prior to the last closing brace:
for (p in pieces)
delete pieces[p];
About more docs, agreed. :) I will put some together. In the mean time, if you haven't checked the homepage, checkout http://www.jawk.org/. It has the overview which provides a brief description of the Java service extensions to the language.
Regards,
Dan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
that worked just fine. checked out the jawk.org homepage already, looks really interesting. however, for now i just wanted to be able to run some awk scripts on any system. and this works now, so thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i get this output/error:
VW=test
line:12
Exception in thread "main" org.jawk.SemanticException: Inappropriate use. class
= org.jawk.Awk$AssociativeArray, this = pieces={6=pieces[6]=, 5=pieces[5]=, 4=p
ieces[4]=, 3=pieces[3]=, 2=pieces[2]=blablabla, 1=piec
es[1]=ab}
at org.jawk.Awk$ValueAdapter.clear(Awk.java:6328)
at org.jawk.Awk$DotSepAST.forceReferenceAsAssocArray(Awk.java:4967)
at org.jawk.Awk$ExpressionListAST.executeList(Awk.java:3917)
at org.jawk.Awk$ExpressionListAST.executeList(Awk.java:3935)
at org.jawk.Awk$ExpressionListAST.executeList(Awk.java:3909)
at org.jawk.Awk$SPLIT_InternalFunction.executeFunction(Awk.java:5506)
at org.jawk.Awk$DotSepAST.executeFunction(Awk.java:5380)
at org.jawk.Awk$DotSepAST.execute(Awk.java:4827)
at org.jawk.Awk$DotSepAST.execute(Awk.java:4815)
at org.jawk.Awk$ExpressionListAST.execute(Awk.java:3893)
at org.jawk.Awk$StatementListAST.execute(Awk.java:3576)
at org.jawk.Awk$InputBlockAST.executeBlock(Awk.java:3554)
at org.jawk.Awk.processInputRecords(Awk.java:871)
at org.jawk.Awk.consumeStdin(Awk.java:736)
at org.jawk.Awk.<init>(Awk.java:618)
at org.jawk.Awk.main(Awk.java:80)
when i try to run this script:
BEGIN{
level = 0;
if(separator == "")
separator = "#";
}
/^VW.*/{
split($0, pieces, separator);
code = pieces[1];
if(length(code) == 2){
print code "=" pieces[2];
}
else if (length(code) == 3){
print substr(code,1,2) "." substr(code,3,1) "=" pieces[3];
}
else if (length(code) == 4){
print substr(code,1,2) "." substr(code,3,1) "." substr(code,4,1) "=" pieces[4];
}
else {
print substr(code,1,2) "." substr(code,3,1) "." substr(code,4,1) "." substr(code,5) "=" pieces[5];
}
}
on a file that looks a bit like this
VW#test###
VWA#test#subtest sentence##
VWAA#test#subtest sentence#subsubtestA#
VWB#test#bsubtest##
...
it somehow manages to get past the first line but then fails.
i have no idea what's wrong, works fine with awk on windows...
great idea to port it to java, but some more documentation would be nice :-)
It looks like a bug with the split() function within Jawk. It seems to require the 2nd arg to be a non-initialized variable of any kind. Therefore, a work around is to add the following code prior to the last closing brace:
for (p in pieces)
delete pieces[p];
About more docs, agreed. :) I will put some together. In the mean time, if you haven't checked the homepage, checkout http://www.jawk.org/. It has the overview which provides a brief description of the Java service extensions to the language.
Regards,
Dan
Hello Dan,
that worked just fine. checked out the jawk.org homepage already, looks really interesting. however, for now i just wanted to be able to run some awk scripts on any system. and this works now, so thank you!