aifargonos2 / elk-reasoner

Automatically exported from code.google.com/p/elk-reasoner
Apache License 2.0
0 stars 0 forks source link

Grammar incorrectly defined for non-negative integers #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The grammar for non-negative integers is incorrectly defined. Line 265 of 
Owl2FunctionalStyleParser.jj reads:

< NON_NEGATIVE_INTEGER: ["1"-"9"] (<DIGIT>)* >

when (I believe) it should read:

< NON_NEGATIVE_INTEGER: ["0"-"9"] (<DIGIT>)* >

The effect of this is that a line such as:

ObjectExactCardinality(0 
<http://lsdis.cs.uga.edu/projects/glycomics/propreo#has_units>)

throws a org.semanticweb.elk.owl.parsing.javacc.ParseException when in-fact 
this is valid.

Hence ProPreo.owl, which contains the above example, fails with the following 
stack trace:

Exception in thread "main" 
org.semanticweb.elk.owl.parsing.javacc.ParseException: Encountered " <PN_LOCAL> 
"0 "" at line 313, column 528.
Was expecting:
    <NON_NEGATIVE_INTEGER> ...

        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.generateParseException(Owl2FunctionalStyleParser.java:2408)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.jj_consume_token(Owl2FunctionalStyleParser.java:2348)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.objectExactCardinality(Owl2FunctionalStyleParser.java:1145)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.classExpression(Owl2FunctionalStyleParser.java:911)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.classExpressionList(Owl2FunctionalStyleParser.java:1472)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.objectIntersectionOf(Owl2FunctionalStyleParser.java:947)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.classExpression(Owl2FunctionalStyleParser.java:881)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.subClassOf(Owl2FunctionalStyleParser.java:1420)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.classAxiom(Owl2FunctionalStyleParser.java:1393)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.axiom(Owl2FunctionalStyleParser.java:1318)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.axioms(Owl2FunctionalStyleParser.java:418)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.ontology(Owl2FunctionalStyleParser.java:334)
        at org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParser.ontologyDocument(Owl2FunctionalStyleParser.java:293)
        at org.semanticweb.elk.reasoner.Reasoner.loadOntologyFromStream(Reasoner.java:82)
        at org.semanticweb.elk.reasoner.Reasoner.loadOntologyFromFile(Reasoner.java:99)
        at org.semanticweb.elk.reasoner.Reasoner.loadOntologyFromFile(Reasoner.java:110)
        at org.semanticweb.elk.cli.Main.main(Main.java:90)

If that part of the file is changed to:

ObjectExactCardinality(1 
<http://lsdis.cs.uga.edu/projects/glycomics/propreo#has_units>)

then the file is successfully parsed.

Original issue reported on code.google.com by andy...@hotmail.co.uk on 10 Oct 2011 at 7:16

GoogleCodeExporter commented 8 years ago
The definition

< NON_NEGATIVE_INTEGER: ["0"-"9"] (<DIGIT>)* >

or, equivalently,

< NON_NEGATIVE_INTEGER: (<DIGIT>)+ >

would also capture strings like

00123

I am not sure it is intended, but it seems to agree with the OWL 2 specs, which 
define here:
http://www.w3.org/TR/owl2-syntax/#General_Definitions

nonNegativeInteger := a nonempty finite sequence of digits between 0 and 9

Alternatively, one can use

< NON_NEGATIVE_INTEGER: "0" | ["1"-"9"] (<DIGIT>)* >

to exclude numbers like 0XXX

Original comment by ykazako...@gmail.com on 10 Oct 2011 at 7:54

GoogleCodeExporter commented 8 years ago
This has been fixed in r367. The grammar for NON_NEGATIVE_INTEGERS is now 
according to OWL 2 specs.

Original comment by frantise...@gmail.com on 12 Oct 2011 at 8:29

GoogleCodeExporter commented 8 years ago

Original comment by frantise...@gmail.com on 12 Oct 2011 at 8:41