Can't load CPP14 as lexer or parser - antlr4

I am trying to execute this
java -cp .\antlr-4.7.2-complete.jar org.antlr.v4.gui.TestRig CPP14 translationUnit -gui example.cc
command but it showing this error
Can't load CPP14 as lexer or parser

You should make sure that:
the classes CPP14Lexer.java and CPP14Parser.java are generated
the generated CPP14Lexer.java and CPP14Parser.java are compiled
the compiled CPP14Lexer and CPP14Parser classes are added to the classpath
So, assuming CPP14Lexer and CPP14Parser are in the default package (and reside in the same folder as the antlr-4.7.2-complete.jar file), then your command should look like this:
java -cp .\antlr-4.7.2-complete.jar;. org.antlr.v4.gui.TestRig CPP14 translationUnit -gui example.cc

Related

SOOT - CompilationDeathException (and a phantom army)

here is the command I use on WIndows 10 command shell :
java
-cp .\soot-2.5.0.jar soot.Main
-cp ".;R:\...\OCLRuler\lib;C:\...\jdk1.8.0_144\bin"
-pp -process-dir R:\...\OCLRuler\src\
-src-prec java
-d R:\...\test\soot
-allow-phantom-refs
-main-class OCLRuler
When I execute it, I get the following output:
Soot started on Tue Sep 26 13:28:32 EDT 2017
Warning: java.dyn.InvokeDynamic is a phantom class!
Warning: Main is a phantom class!
Warning: MainMulti is a phantom class!
Warning: oclruler.a_test.MainRawTesting is a phantom class!
... all of them (100+ lines)...
Warning: oclruler.utils.ToolBox is a phantom class!
OCLRuler.java: Class "oclruler.genetics.EvaluatorOCL" not found.
OCLRuler.java: Class "oclruler.genetics.EvaluatorOCL" not found.
Exception in thread "main" soot.CompilationDeathException: Could not compile
at soot.javaToJimple.JavaToJimple.compile(JavaToJimple.java:104)
at soot.javaToJimple.InitialResolver.formAst(InitialResolver.java:117)
at soot.JavaClassSource.resolve(JavaClassSource.java:54)
at soot.SootResolver.bringToHierarchy(SootResolver.java:215)
at soot.SootResolver.bringToSignatures(SootResolver.java:239)
at soot.SootResolver.processResolveWorklist(SootResolver.java:154)
at soot.SootResolver.resolveClass(SootResolver.java:124)
at soot.Scene.loadClass(Scene.java:448)
at soot.Scene.loadClassAndSupport(Scene.java:433)
at soot.Scene.loadNecessaryClasses(Scene.java:1076)
at soot.Main.run(Main.java:167)
at soot.Main.main(Main.java:141)
All libs used in the OCLRUler project are included in OCLRUler/lib and all sources in OCLRuler/src. The output directory is not included in the soot directory. Also, the project does compile (I'm working on and with it). The . directory contains all soot/jasmin/heros jars.
Still, all classes are considered phantoms, and Soot compilation abords because (I guess) it lacks bodies from these classes. I mean that "EvaluatorOCL" (i.e., still guessing, the source of the CompilationDeathException) is a "Phantom class".
What's wrong ?
SHould I add all and every packages in Soot's classpath ?
I've tried all sorts of command line expressions - until I got profundly lost. Anybody has a clue on the matter ?
Thanks a lot.
Edouard
Changed the -pp -process-dir R:\...\OCLRuler\src\ argument for -pp -process-dir R:\...\OCLRuler\
and it seems to work fine... The phantoms are still strolling around, but there are result files in the output folder!
[edit:]
Oups, this is gona become a new question... The ouput files are... EMPTY !!!
As I said, there are still warnings about phantoms and outputs are generated for all files (java and class alike)
Why are they empty ??
[/edit]
This might well be a problem with Soot's source-code frontend, which is heavily outdated by now. I would recommend compiling the .java files to .class and then giving those to Soot.

Stanford CoreNLP: nndep.DependencyParser in pipeline with geman model

i want to use the nndep in CoreNLP for dependency Parsing. So the Input is a simple german sentence and the output should be like this:
case(Schulen-3, An-1)
amod(Schulen-3, Stuttgarter-2)
nmod(gegrüßt-13, Schulen-3)
aux(gegrüßt-13, darf-4)
case(MitschülerInnen-7, wegen-5)
amod(MitschülerInnen-7, muslimischer-6)
nmod(gegrüßt-13, MitschülerInnen-7)
neg(gegrüßt-13, nicht-8)
advmod(nicht-8, mehr-9)
case(Gott-12, mit-10)
amod(Gott-12, Grüß-11)
nmod(gegrüßt-13, Gott-12)
root(ROOT-0, gegrüßt-13)
auxpass(gegrüßt-13, werden-14)
punct(gegrüßt-13, .-15)
and this command is working for a single file:
java -cp "*" -Xmx2g edu.stanford.nlp.parser.nndep.DependencyParser -model edu/stanford/nlp/models/parser/nndep/UD_German.gz -textFile /Users/.../input.txt
But I need to to this with 60.000 files. So i need the nlp.pipeline. If i execute the following command, the output is only the normal parse tree but not the parsed dependencies.
java -Xmx6g -cp "*:." -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP -filelist /Users/.../filelist.txt -props StanfordCoreNLP-german.properties -outputFormat text -parse.originalDependencies
Can someone help?
You need to add
-annotators tokenize,ssplit,pos,lemma,parse,depparse
and
-pos.model edu/stanford/nlp/models/pos-tagger/german/german-ud.tagger
The first addition is telling it to use the dependency parser, the second is telling it to use the UD POS tagger, which is necessary since the dependency parser expects UD POS tags.
Also make sure to use the latest Stanford CoreNLP from GitHub or the last released version (more stable) from here:
https://stanfordnlp.github.io/CoreNLP/download.html

How to run spock test from command line?

I have checked this link:
https://gist.github.com/ysb33r/5825457
It seems like that it can be run like this:
groovyc *.groovy
java -cp ~/.grapes/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar:$GROOVY_HOME/embeddable/groovy-all-2.1.4.jar:$GROOVY_HOME/lib/junit-4.11.jar:$GROOVY_HOME/lib/hamcrest-core-1.3.jar:.org.junit.runner.JUnitCore ExampleSpec
And I have added all third part jars to CLASSPATH,so all imports from these libs found.But all my own classes can't be found,and error message like this:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
LoginTest.groovy: 11: unable to resolve class com.vsi.icareos.client.home.HomePage
# line 11, column 1.
import com.vsi.icareos.client.home.HomePage
^
LoginTest.groovy: 22: unable to resolve class LoginByPwdPage
# line 22, column 2.
LoginByPwdPage loginPage
^
LoginTest.groovy: 35: unable to resolve class LoginByPwdPage
# line 35, column 13.
loginPage=new LoginByPwdPage(browser,Consts.PAGE_ID)
^
3 errors
I guess that the option like:--sourcepath is needed,but I found this command option deprecated,so How to slove this problem?
I was able to run the tests described in the gist, but with modification of the groovyc to add the -cp flag with spock jar to it, also if you have the sources in sub-directories you should use **/*.groovy instead of *.groovy
Looking at the way you run the java command, it seams to be missing a space between . and org.junit.runner.JUnitCore
So instead of
java -cp ~/.grapes/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar:$GROOVY_HOME/embeddable/groovy-all-2.1.4.jar:$GROOVY_HOME/lib/junit-4.11.jar:$GROOVY_HOME/lib/hamcrest-core-1.3.jar:.org.junit.runner.JUnitCore ExampleSpec
I should be
java -cp ~/.grapes/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar:$GROOVY_HOME/embeddable/groovy-all-2.1.4.jar:$GROOVY_HOME/lib/junit-4.11.jar:$GROOVY_HOME/lib/hamcrest-core-1.3.jar:. org.junit.runner.JUnitCore ExampleSpec
Please note the space in the second.
The . is the current directory added to the classpath
hope this helps

ANTLR4 Error "Problems calling org.antlr.v4.gui.TestRig.main"

Hello I get this error when I try the simple esample of the tutorial:
"grun Hello -r tree
Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically
Problems calling org.antlr.v4.gui.TestRig.main(args)
"
I cannot figure out what is going on.
Can you help me please.
It sounds like you have setup your 'grun' alias to use :
org.antlrv4.runtime.misc.TestRig
//and from antlr4 onwards they deprecated that and use this instead.
org.antlrv4.gui.TestRig
So you should try resetting your 'grun' alias either from terminal or batch file depending on how you set it up. If there are still errors comment here and i will try and help:
alias grun='java org.antlr.v4.gui.TestRig'
if you still have any errors after updating your setup alias then leave a comment and i will try to help further.
Setup TestRig - Added here so content is not lost after the documentation section is shut down.
ANTLR contains a testing tool in its runtime library, this tool can be used to display information detailing how the parsing is performed to match input against defined rules in your grammar file.
To use this tool contained within the ANTLR jar file you should setup your systems classpath to allow access to both the ANTLR tool and the runtime library :
export CLASSPATH=".:/usr/local/lib/antlr-4.5.3-complete.jar:$CLASSPATH"
Note: Ensure the Dot precedes any path to ensure the java virtual machine wont see classes in your current working directory.
Alises can be used on Linux/MAC/Unix to simplify commands used:
alias antlr4='java -jar /usr/local/lib/antlr-4.5.3-complete.jar'
//or any directory where your jar is located
Note setup on windows for aliases and classpath setup may be more complicated, see here for more comprehensive details.
Accessing TestRig
Once you have setup your alias you can setup TestRig in the following way, again using an alias is recommended as reduces the amount of time required to perform the action:
alias grun='java org.v4.runtime.misc.TestRig'
If you do not wish to setup an alias on windows you can access TestRig by running the following command in the same location as your ANTLR jar directory:
java -cp .;antlr.4.5.3-complete.jar org.antlrv4.runtime.misc.TestRig
//or
java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig
To run TestRig on your grammar you can pass the parameters in for your grammar like this :
grun yourGrammar yourRule -tree //using the setup alias java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig yourGrammar YourRule -tree //on windows with no alias java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig yourGrammar Hello r -tree //Windows with the grammar Hello.g4 starting from the rule 'r'.
grun yourGrammar yourRule -tree //using the setup alias
java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig yourGrammar YourRule -tree //on windows with no alias
java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig yourGrammar Hello r -tree
//Windows with the grammar Hello.g4 starting from the rule 'r'.

"Unrecognized option: --format=COBERTURAXML" in trying to convert JSCover report to cobertura xml

I'm trying to convert JSCover to cobertura xml.
Based on what i've read the command is as follows:
java -cp JSCover-all.jar jscover.report.Main --format=COBERTURAXML REPORT-DIR SRC-DIRECTORY
But I get an error
"Error: Could not find or load main class jscover.report.Main"
Even if I set the fully qualified path of there the JSCover-all.jar is located.
So I tried including the JSCover-al.jar into the classpath and run the following command instead:
java -cp jscover.report.Main --format=COBERTURAXML target/local-storage-proxy target/local-storage-proxy/original-src
I no longer get the first error but i'm now getting the following error:
Unrecognized option: --format=COBERTURAXML
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I hope someone could help me with it. Many thanks!
The first attempt is the correct approach. The error means that JSCover-all.jar is not in the same directory that you are executing the command from. An absolute path to is not needed - a relative one will do.
In the second approach, you have passed 'jscover.report.Main' as the class-path to the JVM and '--format=COBERTURAXML' as parameter to the 'java' command.

Resources