@faubulous/mentor-rdf-parsers
    Preparing search index...

    Class N3Parser

    A W3C compliant parser for the N3 (Notation3) syntax. Based on the N3 grammar: https://w3c.github.io/N3/spec/

    Hierarchy

    • CstParser
      • N3Parser

    Implements

    Index

    Constructors

    Properties

    anon: ParserMethod<[], CstNode> = ...
    base: ParserMethod<[], CstNode> = ...

    base ::= '@base' IRIREF '.' Note: The '.' is consumed by n3Doc.

    blankNode: ParserMethod<[], CstNode> = ...

    blankNode ::= BLANK_NODE_LABEL | anon

    blankNodePropertyList: ParserMethod<[], CstNode> = ...

    blankNodePropertyList ::= '[' predicateObjectList ']'

    booleanLiteral: ParserMethod<[], CstNode> = ...
    collection: ParserMethod<[], CstNode> = ...

    collection ::= '(' object* ')'

    datatype: ParserMethod<[], CstNode> = ...

    An array of recognition exceptions that occurred during parsing. This can be used to identify and handle any syntax errors in the input document.

    expression: ParserMethod<[], CstNode> = ...

    expression ::= path

    forAll: ParserMethod<[], CstNode> = ...

    :x, :y, :z.

    formula: ParserMethod<[], CstNode> = ...

    formula ::= '{' formulaContent? '}'

    formulaContent: ParserMethod<[], CstNode> = ...

    formulaContent ::= n3Statement ('.' formulaContent?)? | sparqlDirective formulaContent?

    forSome: ParserMethod<[], CstNode> = ...

    :a, :b, :c.

    iri: ParserMethod<[], CstNode> = ...

    iri ::= IRIREF | prefixedName

    literal: ParserMethod<[], CstNode> = ...

    literal ::= stringLiteral | numericLiteral | booleanLiteral

    n3Directive: ParserMethod<[], CstNode> = ...

    n3Directive ::= prefixID | base | forAll | forSome

    n3Doc: ParserMethod<[], CstNode> = ...

    n3Doc ::= (n3Statement '.' | sparqlDirective)* EOF

    n3Statement: ParserMethod<[], CstNode> = ...

    n3Statement ::= n3Directive | triples

    namespaces: Record<string, string> = {}

    A map of prefixes to their namespace IRI.

    numericLiteral: ParserMethod<[], CstNode> = ...
    object: ParserMethod<[], CstNode> = ...

    object ::= expression

    objectList: ParserMethod<[], CstNode> = ...

    objectList ::= object (',' object)*

    path: ParserMethod<[], CstNode> = ...

    path ::= pathItem ('!' path | '^' path)?

    pathItem: ParserMethod<[], CstNode> = ...

    pathItem ::= iri | blankNode | quickVar | collection | blankNodePropertyList | literal | formula

    predicate: ParserMethod<[], CstNode> = ...

    predicate ::= expression | '<-' expression

    predicateObjectList: ParserMethod<[], CstNode> = ...

    predicateObjectList ::= verb objectList (';' (verb objectList)?)*

    prefix: ParserMethod<[], CstNode> = ...

    prefixID ::= '@prefix' PNAME_NS IRIREF '.' Note: The '.' is consumed by n3Doc.

    prefixedName: ParserMethod<[], CstNode> = ...

    prefixedName ::= PNAME_LN | PNAME_NS

    N3 is more lenient than Turtle: it allows the empty prefix : to be used without explicit declaration, implicitly resolving to <#>.

    quickVar: ParserMethod<[], CstNode> = ...

    quickVar ::= '?' PN_CHARS_U PN_CHARS*

    RECORDING_PHASE: boolean

    Flag indicating the Parser is at the recording phase. Can be used to implement methods similar to BaseParser.ACTION Or any other logic to requires knowledge of the recording phase. See:

    semanticErrors: IRecognitionException[] = []

    Semantic errors collected during parsing (e.g., UndefinedNamespacePrefixError).

    sparqlBase: ParserMethod<[], CstNode> = ...

    sparqlBase ::= 'BASE' IRIREF

    sparqlDirective: ParserMethod<[], CstNode> = ...

    sparqlDirective ::= sparqlPrefix | sparqlBase

    sparqlPrefix: ParserMethod<[], CstNode> = ...

    sparqlPrefix ::= 'PREFIX' PNAME_NS IRIREF

    string: ParserMethod<[], CstNode> = ...
    stringLiteral: ParserMethod<[], CstNode> = ...
    subject: ParserMethod<[], CstNode> = ...

    subject ::= expression

    triples: ParserMethod<[], CstNode> = ...

    triples ::= subject predicateObjectList?

    In N3, subjects with zero predicates are valid (e.g., :a .).

    verb: ParserMethod<[], CstNode> = ...

    verb ::= predicate | 'a' | 'has' expression | 'is' expression 'of' | '=' | '<=' | '=>'

    Accessors

    • get input(): IToken[]

      An array of tokens that were created by the lexer and used as input for the parser. This can be used to inspect the tokens that were processed during parsing, and to identify any issues with the tokenization process.

      Returns IToken[]

    • set input(value: IToken[]): void

      An array of tokens that were created by the lexer and used as input for the parser. This can be used to inspect the tokens that were processed during parsing, and to identify any issues with the tokenization process.

      Parameters

      • value: IToken[]

      Returns void

    Methods

    • Type Parameters

      • IN = any
      • OUT = any

      Returns new (...args: any[]) => ICstVisitor<IN, OUT>

    • Type Parameters

      • IN = any
      • OUT = any

      Returns new (...args: any[]) => ICstVisitor<IN, OUT>

    • Returns Record<string, Rule>

    • Returns ISerializedGast[]

    • Parses a set of tokens created by the lexer into a concrete syntax tree (CST) representing the parsed document.

      Parameters

      • tokens: IToken[]

        A set of tokens created by the lexer.

      • throwOnErrors: boolean = true

        Whether to throw an error if any parsing errors are detected. Defaults to true.

      Returns CstNode

      A concrete syntax tree (CST) object.

    • Parameters

      • prefixToken: IToken
      • iriToken: IToken

      Returns void

    • Resets the parser state, should be overridden for custom parsers which "carry" additional state. When overriding, remember to also invoke the super implementation!

      Returns void