Skip to content

[SLI-0088] The a keyword is not recognized by the grammar #88

@thewillyhuman

Description

@thewillyhuman

Introduction

In turtle the keyword a was included as alias of rdf: type. The language of shapes expressions adopted it and therefore shex-lite should support it too.

Current Behavior

Currently for the scheme (input_correct_java_schema_user_car_1.shexl),

prefix : <example.org>
prefix xsd: <schema.org>
prefix foaf: <foaf.org>

:User {
    a		foaf:person ;
    :name       xsd:string  ;
    :surname    xsd:string  ;
    :age        xsd:integer ;
    :knows      @:User *
}

: Car {
    :plateNumber    xsd:string  ;
    :owner          @:User
}

If we execute java -jar shexlc-2.0-beta.jar input_correct_java_schema_user_car_1.shexl the compiler produces the following output:

Output:

line 6:7 extraneous input 'foaf' expecting ':'
line 6:19 extraneous input ';' expecting {':', 'iri', '.', 'nonliteral', '[', 'bnode', 'literal', '@', LABEL, IRI_LITERAL, REAL_LITERAL, STRING_LITERAL}
line 7:28 extraneous input ';' expecting {':', 'iri', '.', 'nonliteral', '[', 'bnode', 'literal', '@', LABEL, IRI_LITERAL, REAL_LITERAL, STRING_LITERAL}
line 8:28 extraneous input ';' expecting {':', 'iri', '.', 'nonliteral', '[', 'bnode', 'literal', '@', LABEL, IRI_LITERAL, REAL_LITERAL, STRING_LITERAL}
line 9:28 extraneous input ';' expecting {':', 'iri', '.', 'nonliteral', '[', 'bnode', 'literal', '@', LABEL, IRI_LITERAL, REAL_LITERAL, STRING_LITERAL}
line 10:16 extraneous input '@' expecting {':', '}', ';', LABEL, IRI_LITERAL}
line 10:23 mismatched input '*' expecting {':', 'iri', '.', 'nonliteral', '[', 'bnode', 'literal', '@', LABEL, IRI_LITERAL, REAL_LITERAL, STRING_LITERAL}
Exception in thread "main" java.lang.NullPointerException
        at es.weso.shexlc.syntactic.parser.ConstraintTripleExprPsr.getParseResult(ConstraintTripleExprPsr.scala:45)
        at es.weso.shexlc.syntactic.Syn01ASTBuilderVisitor.visitConstraint_triple_expr(Syn01ASTBuilderVisitor.scala:78)
        at es.weso.shexlc.syntactic.Syn01ASTBuilderVisitor.visitConstraint_triple_expr(Syn01ASTBuilderVisitor.scala:30)
        at es.weso.shexlc.syntactic.generated.Shexl2Parser$Constraint_triple_exprContext.accept(Shexl2Parser.java:1250)
        at es.weso.shexlc.syntactic.parser.ConstraintBlockTripleExprPsr.$anonfun$getParseResult$1(ConstraintBlockTripleExprPsr.scala:50)
        at scala.collection.Iterator$$anon$9.next(Iterator.scala:573)
        at scala.collection.mutable.Growable.addAll(Growable.scala:62)
        at scala.collection.mutable.Growable.addAll$(Growable.scala:59)
        at scala.collection.mutable.ArrayBuffer.addAll(ArrayBuffer.scala:147)
        at scala.collection.mutable.ArrayBuffer.addAll(ArrayBuffer.scala:40)
        at scala.collection.mutable.ArrayBuffer$.from(ArrayBuffer.scala:265)
        at scala.collection.mutable.ArrayBuffer$.from(ArrayBuffer.scala:253)
        at scala.collection.IterableOps.map(Iterable.scala:672)
        at scala.collection.IterableOps.map$(Iterable.scala:672)
        at scala.collection.AbstractIterable.map(Iterable.scala:921)
        at es.weso.shexlc.syntactic.parser.ConstraintBlockTripleExprPsr.getParseResult(ConstraintBlockTripleExprPsr.scala:50)
        at es.weso.shexlc.syntactic.Syn01ASTBuilderVisitor.visitConstraint_block_triple_expr(Syn01ASTBuilderVisitor.scala:74)
        at es.weso.shexlc.syntactic.Syn01ASTBuilderVisitor.visitConstraint_block_triple_expr(Syn01ASTBuilderVisitor.scala:30)
        at es.weso.shexlc.syntactic.generated.Shexl2Parser$Constraint_block_triple_exprContext.accept(Shexl2Parser.java:1170)
        at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
        at es.weso.shexlc.syntactic.generated.Shexl2BaseVisitor.visitConstraint_expr(Shexl2BaseVisitor.java:118)
        at es.weso.shexlc.syntactic.generated.Shexl2Parser$Constraint_exprContext.accept(Shexl2Parser.java:983)
        at es.weso.shexlc.syntactic.parser.ShapeDefStmtPsr.getParseResult(ShapeDefStmtPsr.scala:47)
        at es.weso.shexlc.syntactic.Syn01ASTBuilderVisitor.visitShape_def_stmt(Syn01ASTBuilderVisitor.scala:53)
        at es.weso.shexlc.syntactic.Syn01ASTBuilderVisitor.visitShape_def_stmt(Syn01ASTBuilderVisitor.scala:30)
        at es.weso.shexlc.syntactic.generated.Shexl2Parser$Shape_def_stmtContext.accept(Shexl2Parser.java:557)
        at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
        at es.weso.shexlc.syntactic.generated.Shexl2BaseVisitor.visitDefinition_stmt(Shexl2BaseVisitor.java:41)
        at es.weso.shexlc.syntactic.generated.Shexl2Parser$Definition_stmtContext.accept(Shexl2Parser.java:320)
        at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
        at es.weso.shexlc.syntactic.generated.Shexl2BaseVisitor.visitStatement(Shexl2BaseVisitor.java:27)
        at es.weso.shexlc.syntactic.generated.Shexl2Parser$StatementContext.accept(Shexl2Parser.java:200)
        at es.weso.shexlc.syntactic.parser.SchemaPsr.$anonfun$getParseResult$1(SchemaPsr.scala:44)
        at scala.collection.Iterator$$anon$9.next(Iterator.scala:573)
        at scala.collection.mutable.Growable.addAll(Growable.scala:62)
        at scala.collection.mutable.Growable.addAll$(Growable.scala:59)
        at scala.collection.mutable.ArrayBuffer.addAll(ArrayBuffer.scala:147)
        at scala.collection.mutable.ArrayBuffer.addAll(ArrayBuffer.scala:40)
        at scala.collection.mutable.ArrayBuffer$.from(ArrayBuffer.scala:265)
        at scala.collection.mutable.ArrayBuffer$.from(ArrayBuffer.scala:253)
        at scala.collection.IterableOps.map(Iterable.scala:672)
        at scala.collection.IterableOps.map$(Iterable.scala:672)
        at scala.collection.AbstractIterable.map(Iterable.scala:921)
        at es.weso.shexlc.syntactic.parser.SchemaPsr.getParseResult(SchemaPsr.scala:44)
        at es.weso.shexlc.syntactic.Syn01ASTBuilderVisitor.visitSchema(Syn01ASTBuilderVisitor.scala:33)
        at es.weso.shexl.DefaultShExLCompiler.buildAST(DefaultShExLCompiler.scala:105)
        at es.weso.shexl.DefaultShExLCompiler.$anonfun$compile$1(DefaultShExLCompiler.scala:82)
        at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:553)
        at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:551)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:921)
        at es.weso.shexl.DefaultShExLCompiler.compile(DefaultShExLCompiler.scala:75)
        at es.weso.shexl.cli.ShExLiteCLI$.run(ShExLiteCLI.scala:51)
        at es.weso.shexl.cli.ShExLiteCLI$.run(ShExLiteCLI.scala:29)
        at org.backuity.clist.CliMain.$anonfun$runWith$1(CliMain.scala:14)
        at org.backuity.clist.Parser.$anonfun$withCommand$1(Parser.scala:156)
        at org.backuity.clist.Parser.withParsingException(Parser.scala:199)
        at org.backuity.clist.Parser.withCommand(Parser.scala:154)
        at org.backuity.clist.CliMain.runWith(CliMain.scala:14)
        at org.backuity.clist.CliMain.main(CliMain.scala:6)
        at es.weso.shexl.cli.ShExLiteCLI.main(ShExLiteCLI.scala)

Expected Behavior

Typically, the grammar would accept this keyword and then be automatically replaced by the compiler with rdf: type.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions