org.spoofax.interpreter.terms.BasicTermFactory can't parse negative integers
I was caching some trees as ATerms using the open-import strategy in lib/editor-common.generated.str, and encountered this exception when the cached ATerm contained a negative integer:
org.spoofax.interpreter.core.InterpreterException: org.strategoxt.lang.StrategoException: Exception in execution of primitive ‘SSL_read_term_from_stream’
at org.strategoxt.HybridInterpreter.invoke(HybridInterpreter.java:367)
at org.strategoxt.imp.runtime.Environment$1.invoke(Environment.java:196)
at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:565)
at org.strategoxt.imp.runtime.services.StrategoBuilder.invokeObserver(StrategoBuilder.java:305)
at org.strategoxt.imp.runtime.services.StrategoBuilder.execute(StrategoBuilder.java:178)
at org.strategoxt.imp.runtime.services.StrategoBuilder.access$1(StrategoBuilder.java:163)
at org.strategoxt.imp.runtime.services.StrategoBuilder$1.run(StrategoBuilder.java:150)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.strategoxt.lang.StrategoException: Exception in execution of primitive ‘SSL_read_term_from_stream’
at org.strategoxt.lang.Context.invokePrimitive(Context.java:234)
at org.strategoxt.lang.Context.invokePrimitive(Context.java:210)
at org.strategoxt.stratego_lib.$Read$From$File_0_0.invoke($Read$From$File_0_0.java:54)
at org.strategoxt.lang.compat.ReadFromFile_cached_0_0.invoke(ReadFromFile_cached_0_0.java:76)
at org.strategoxt.lang.Strategy.invokeDynamic(Strategy.java:30)
at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:194)
at org.strategoxt.lang.InteropSDefT.evaluate(InteropSDefT.java:185)
at org.strategoxt.lang.InteropSDefT$StrategyBody.evaluate(InteropSDefT.java:247)
at org.strategoxt.lang.InteropSDefT$StrategyBody.eval(InteropSDefT.java:240)
at org.spoofax.interpreter.stratego.Strategy.evaluate(Strategy.java:96)
at org.spoofax.interpreter.core.Interpreter.invoke(Interpreter.java:72)
at org.strategoxt.HybridInterpreter.invoke(HybridInterpreter.java:359)
… 7 more
Caused by: org.spoofax.interpreter.terms.ParseError: Invalid term: ‘-’
at org.spoofax.interpreter.terms.BasicTermFactory.parseFromStream(BasicTermFactory.java:92)
at org.spoofax.interpreter.terms.BasicTermFactory.parseTermSequence(BasicTermFactory.java:224)
at org.spoofax.interpreter.terms.BasicTermFactory.parseAppl(BasicTermFactory.java:191)
at org.spoofax.interpreter.terms.BasicTermFactory.parseFromStream(BasicTermFactory.java:87)
at org.spoofax.interpreter.terms.BasicTermFactory.parseTermSequence(BasicTermFactory.java:224)
at org.spoofax.interpreter.terms.BasicTermFactory.parseList(BasicTermFactory.java:243)
at org.spoofax.interpreter.terms.BasicTermFactory.parseFromStream(BasicTermFactory.java:80)
at org.spoofax.interpreter.terms.BasicTermFactory.parseTermSequence(BasicTermFactory.java:224)
at org.spoofax.interpreter.terms.BasicTermFactory.parseAppl(BasicTermFactory.java:191)
at org.spoofax.interpreter.terms.BasicTermFactory.parseFromStream(BasicTermFactory.java:87)
at org.spoofax.interpreter.terms.BasicTermFactory.parseFromStream(BasicTermFactory.java:73)
at org.strategoxt.lang.terms.TermFactory.parseFromStream(TermFactory.java:114)
at org.spoofax.interpreter.library.ssl.SSL_read_term_from_stream.call(SSL_read_term_from_stream.java:48)
at org.strategoxt.lang.Context.invokePrimitive(Context.java:221)
… 18 moreThe C tools accept negative integers. (Actually, the C tools also accept badly formed integers, e.g. “—–1” or simply “-”, which are both parsed as 0.)
As far as I can see it’s a missing case in BasicTermFactory.java,
IStrategoTerm parseFromStream(PushbackInputStream bis)
method and a few fixes toparseNumber
and/orparseDigitSequence
.If I remember I may look at it myself once my checkout of that dir finishes (takes a while as I’m using git-svn).
Submitted by Tobi Vollebregt on 9 December 2010 at 11:30
Issue Log
Checkout was faster than I thought. Fixed in r21478.
Log in to post comments