Definitive Antlr Reference - Chapter 3 and AntlrWorks - antlr3

I am new to Antlr and my setup is as follows: Windows 7, Java JDK 1.7.0_17, AntlrWorks 1.5, Antlr 3.5.
The AntlrWorks Help-About shows the following information:
ANTLRWorks 1.5
ANTLR 3.5
StringTemplate v3 3.2.1
StringTemplate v4 4.0.7-SNAPSHOT
Java 1.7.0_17 (Oracle Corporation)
Chapter 3 of the Definitive Antlr Reference book introduces a sample grammar for expression evaluation (Expr.g), which I downloaded from the hyperlink in the PDF version of the book.
The book recomends using AntlrWorks and I am, however when I Generate Code (Ctrl+Shift+G) in AntlrWorks it produces code without the "throws" clause.
For example, the following is generated in AntlrWorks:
// $ANTLR start "prog"
// C:\\Users\\Mark\\Documents\\output\\Expr.g:12:1: prog : ( stat )+ ;
public final void prog() throws {
try {
Note the missing code after the throws keyword...
If I generate from the command prompt using this command line:
java -cp antlr-3.5-complete.jar org.antlr.Tool Expr.g
I get this output:
// $ANTLR start "prog"
// Expr.g:12:1: prog : ( stat )+ ;
public final void prog() throws RecognitionException {
try {
My question is this - how do I get AntlrWorks to generate the same code?

This is a known issue in ANTLRWorks 1.5 which has been resolved for the next release.
#5: ANTLRworks fails to generate proper Java Code

Related

NullPointerException with Stanford NLP Spanish POS tagging

All -
Running Stanford CoreNLP 3.4.1, plus the Spanish models. I have a directory of approximately 100 Spanish raw text documents, UTF-8 encoded. For each one, I execute the following commandline:
java -cp stanford-corenlp-3.4.1.jar:stanford-spanish-corenlp-2014-08-26-models.jar:xom.jar:joda-time.jar:jollyday.jar:ejml-0.23.jar -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP -props <propsfile> -file <txtfile>
The props file looks like this:
annotators = tokenize, ssplit, pos
tokenize.language = es
pos.model = edu/stanford/nlp/models/pos-tagger/spanish/spanish-distsim.tagger
For almost every file, I get the following error:
Exception in thread "main" java.lang.RuntimeException: Error annotating :
at edu.stanford.nlp.pipeline.StanfordCoreNLP$15.run(StanfordCoreNLP.java:1287)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:1347)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.run(StanfordCoreNLP.java:1389)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.main(StanfordCoreNLP.java:1459)
Caused by: java.lang.NullPointerException
at edu.stanford.nlp.tagger.maxent.ExtractorSpanishStrippedVerb.extract(ExtractorFramesRare.java:1626)
at edu.stanford.nlp.tagger.maxent.Extractor.extract(Extractor.java:153)
at edu.stanford.nlp.tagger.maxent.TestSentence.getExactHistories(TestSentence.java:465)
at edu.stanford.nlp.tagger.maxent.TestSentence.getHistories(TestSentence.java:440)
at edu.stanford.nlp.tagger.maxent.TestSentence.getHistories(TestSentence.java:428)
at edu.stanford.nlp.tagger.maxent.TestSentence.getExactScores(TestSentence.java:377)
at edu.stanford.nlp.tagger.maxent.TestSentence.getScores(TestSentence.java:372)
at edu.stanford.nlp.tagger.maxent.TestSentence.scoresOf(TestSentence.java:713)
at edu.stanford.nlp.sequences.ExactBestSequenceFinder.bestSequence(ExactBestSequenceFinder.java:91)
at edu.stanford.nlp.sequences.ExactBestSequenceFinder.bestSequence(ExactBestSequenceFinder.java:31)
at edu.stanford.nlp.tagger.maxent.TestSentence.runTagInference(TestSentence.java:322)
at edu.stanford.nlp.tagger.maxent.TestSentence.testTagInference(TestSentence.java:312)
at edu.stanford.nlp.tagger.maxent.TestSentence.tagSentence(TestSentence.java:135)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.tagSentence(MaxentTagger.java:998)
at edu.stanford.nlp.pipeline.POSTaggerAnnotator.doOneSentence(POSTaggerAnnotator.java:147)
at edu.stanford.nlp.pipeline.POSTaggerAnnotator.annotate(POSTaggerAnnotator.java:110)
at edu.stanford.nlp.pipeline.AnnotationPipeline.annotate(AnnotationPipeline.java:67)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:847)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$15.run(StanfordCoreNLP.java:1275)
Any ideas? I haven't even begun to track this down. I'm certain the problem is in POS; tokenize and ssplit run just fine.
P.S. Please don't say "Upgrade to 3.5.0"; I don't currently have Java 8 installed and don't want to install it yet.
Thanks in advance.
Yes, it seems like there's a bug in the 3.4.1 Spanish models.
The Spanish 3.5.0 models actually seem to be compatible with Java 7. You can download the models used in 3.5 (stanford-spanish-corenlp-2014-10-23-models.jar) and put that on your classpath instead. This fixed the problem for me running Java 7 locally.

Unable to Build Boost.python in Visual Studio 2008. Compilation gives error

I am in a HUGE depression now! I spend 2 days trying to use boost.python . PLEASE guide me! I will explain what I did.
I have Winows 7 64 bit.
The Python is 64 bit 2.7.3 installed at C:\Python27_amd64.
Now, I take boost_1_54_0.zip and unzip in F: directory.
The I use cmd.
bootstrap
this creates project-config.jam. I edit it and insert
using msvc : 9.0 ;
using python : 2.7 : C:\Python27_amd64\python : C:\Python27_amd64\include : C:\Python27_amd64\libs ;
Now i do
.\b2
This process runs for 20 something minutes and I am told that boost has successfully been build.
After that I install boost binaries from http://sourceforge.net/projects/boost/files/boost-binaries/
The binaries get installed in C:\local\boost_1_54_0.
Now I want to create a General project.
Now, I use the code given for embedding python in C++ here
#include <boost/python.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
namespace py = boost::python;
using namespace std;
int main()
{
// Initialize the interpreter
Py_Initialize();
py::object main_module = py::import("__main__");
py::object main_namespace = main_module.attr("__dict__");
py::exec("print 'Hello, world'", main_namespace);
py::exec("print 'Hello, world'[3:5]", main_namespace);
py::exec("print '.'.join(['1','2','3'])", main_namespace);
}
I setup the header files and library in VC++ directories to F:\boost_1_54_0\boost_1_54_0 and F:\boost_1_54_0\boost_1_54_0\stage\lib respectively.
I also setup project-->properties-->configuration properties-->C/C++-->General-->Additional Include directories to C:\Python27_amd64\include
Likewise, I also setup project-->properties-->configuration properties--> Linker--> General to C:\Python27_amd64\libs;"C:\local\boost_1_54_0\lib64-msvc-9.0" .
Now when I compile using x64 debugger. It gives me an error
Unhandled exception at 0x00000000 in test8.exe: 0xC0000005: Access violation at location 0x0000000000000000.
I am struck since last 2 days...but thats the closest I have been since then. please help me!
So you mean a runtime error, right?
I think you should first ensure, that there is no exception thrown by boost::python itself.
First try to set the try block around you python calls with a catch(...)
If exception is caught it is most probably the boost::python::error_already_set exception.
So, you then should decode it like here

jdk 1.7.25 CORBA idl build warning: Anonymous sequences and array are deprecated

My java project updated to jdk 1.7.25, over Solaris 10 environment, this is the first time seen that there is a new warning message in build log: Anonymous sequences and array are deprecated (build IDL)
problem: The main GUI(build by jdk 1.7.25) cannot been brought up
We think this maybe a problem(but not sure). The idl file is very simple:
$ cat UnsubscribeAttb.idl
//../../../proj/request/requestIfc/UnsubscribeAttb.idl
include ../../../proj/request/requestIfc/subscribeKey.idl
module requestIfc {
struct requestIfc {
bool subscribeKeys;
sequence<subscribeKey> UnsubscribeAttbList;
}
}
I put in "typedef" at the front of the last line, but build immediately gives an error complained this line, but didnot give me a specific reason. Looking for your help.
Thanks,
Curtis

how to solve the java error for File: (no associated file) [line: (no source location)]

I'm learning java as you can probably see. I'm stuck on the first lesson I can't compile it for this error.
1./*
2.Java Hello World example.
3.*/
4.
5.public class HelloWorldExample{
6.
7. public static void main(String args[]){
8.
9. /*
10. Use System.out.println() to print on console.
11. */
12. System.out.println("Hello World !");
13.
14. }
15.
16.}
17.
18./*
19.
20.OUTPUT of the above given Java Hello World Example would be :
21.
22.Hello World !
23.
24.*/
1 error found:
File: (no associated file) [line: (no source location)]
Error: Compile exception: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/impl/IrritantSet
please help this blind fool find the associated file, Thanks
You have misconfigured your JRE in Eclipse. It'll work if you run it outside eclipse or fix your Eclipse JRE settings.

Gallio error "An exception was thrown while exploring tests."

Hi I have a test project with Gallio 3.2 b.435 within VisualStudio 2010. Every time I launch any test the output windows pops out.
this is the error message
[error] An exception was thrown while exploring tests.
Location: C:\xxxxxxx(73)
Details: System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
this is the code at the line specified
71: [Test, ExpectedException(typeof(RulesException<Story>))]
72: public void CanNotSaveItemIfInvalid()
73: {
74: var story= new Story{ Id = 100, Tilte= "test" };
75: repository.Save(story, new MembershipUser());
76: }
This error isthrown no metter what test is under testing (the project contains 700 test)
Of course ;) the test compiles and passes and I cannot understand the error.
bye Stefano
This error is a known issue. It's due to a bug in the early version of Mono.Cecil (v0.6) that was used by the Gallio core engine. It has been fixed recently: Gallio is now using Mono.Cecil v0.9.
Please try out the latest version of Gallio (v3.2.2)

Resources