Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SrsParser

Hierarchy

Implements

Index

Constructors

constructor

  • new SrsParser(config?: Partial<IParserConfig>): SrsParser

Properties

BlankNode

BlankNode: function = this.RULE('BlankNode', () => {this.OR([{ ALT: () => this.CONSUME(turtleTokenMap.BLANK_NODE_LABEL) },{ ALT: () => this.CONSUME(turtleTokenMap.ANON) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

BooleanLiteral

BooleanLiteral: function = this.RULE('BooleanLiteral', () => {this.OR([{ ALT: () => this.CONSUME(turtleTokenMap.TRUE) },{ ALT: () => this.CONSUME(turtleTokenMap.FALSE) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

EmbeddedPredicateObjectList

EmbeddedPredicateObjectList: function = this.RULE('EmbeddedPredicateObjectList', () => {this.CONSUME(turtleTokenMap.LCurly);this.SUBRULE(this.predicateObjectList);this.CONSUME(turtleTokenMap.RCurly);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

EmbeddedTriplePattern

EmbeddedTriplePattern: function = this.RULE('EmbeddedTriplePattern', () => {this.CONSUME(turtleTokenMap.LEmbed);this.SUBRULE(this.triples);this.CONSUME(turtleTokenMap.REmbed);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

IfClause

IfClause: function = this.RULE('IfClause', () => {this.CONSUME(srsTokenMap.If);this.CONSUME(srsTokenMap.GroupGraphPattern);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

NumericLiteral

NumericLiteral: function = this.RULE('NumericLiteral', () => {this.OR([{ ALT: () => this.CONSUME(turtleTokenMap.INTEGER) },{ ALT: () => this.CONSUME(turtleTokenMap.DECIMAL) },{ ALT: () => this.CONSUME(turtleTokenMap.DOUBLE) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

PrefixedName

PrefixedName: function = this.RULE('PrefixedName', () => {const prefixedNameToken = this.OR([{ ALT: () => this.CONSUME(turtleTokenMap.PNAME_LN) },{ ALT: () => this.CONSUME(turtleTokenMap.PNAME_NS) },]);const pnameNsImage = prefixedNameToken.image.slice(0,prefixedNameToken.image.indexOf(':'));if (!(pnameNsImage in this.namespacesMap)) {this.semanticErrors.push({name: 'NoNamespacePrefixError',message: 'A prefix was used for which there was no namespace defined.',token: prefixedNameToken,context: {ruleStack: (<any>this).getHumanReadableRuleStack(),ruleOccurrenceStack: [...(<any>this).RULE_OCCURRENCE_STACK],},resyncedTokens: [], // these don't really make sense for semantic errors, since they don't cause the parser to resync});}})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

RDFLiteral

RDFLiteral: function = this.RULE('RDFLiteral', () => {this.SUBRULE(this.String);this.OPTION(() => {this.OR([{ ALT: () => this.CONSUME(turtleTokenMap.LANGTAG) },{ALT: () => {this.CONSUME(turtleTokenMap.DoubleCaret);this.SUBRULE(this.iri);},},]);});})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

RuleClause

RuleClause: function = this.RULE('RuleClause', () => {this.CONSUME(srsTokenMap.Rule);this.SUBRULE(this.iri);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

RuleDoc

RuleDoc: function = this.RULE('RuleDoc', () => {this.OPTION(() => this.SUBRULE(this.RuleClause));this.SUBRULE(this.IfClause);this.SUBRULE(this.ThenClause);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

SrsDoc

SrsDoc: function = this.RULE('SrsDoc', (mode: ModeString) => {const allowEdgeProperties = mode === 'stardog';this.SUBRULE(this.turtleDoc, { ARGS: [mode] });this.MANY(() => {this.SUBRULE(this.RuleDoc);this.MANY1(() => {this.SUBRULE(this.triples, { ARGS: [allowEdgeProperties] });this.CONSUME(sparqlTokenMap.Period);});});})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

String

String: function = this.RULE('String', () => {this.OR([{ ALT: () => this.CONSUME(turtleTokenMap.STRING_LITERAL_QUOTE) },{ ALT: () => this.CONSUME(turtleTokenMap.STRING_LITERAL_SINGLE_QUOTE) },{ALT: () =>this.CONSUME(turtleTokenMap.STRING_LITERAL_LONG_SINGLE_QUOTE),},{ ALT: () => this.CONSUME(turtleTokenMap.STRING_LITERAL_LONG_QUOTE) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

ThenClause

ThenClause: function = this.RULE('ThenClause', () => {this.CONSUME(srsTokenMap.Then);this.CONSUME(sparqlTokenMap.LCurly);this.CONSUME(srsTokenMap.TriplesBlock);this.CONSUME(srsTokenMap.EndThen);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

base

base: function = this.RULE('base', () => {this.CONSUME(turtleTokenMap.TTL_BASE);this.CONSUME(turtleTokenMap.IRIREF);this.CONSUME(turtleTokenMap.Period);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

Protected baseNamespacesMap

baseNamespacesMap: object = Object.freeze({...defaultNamespacesMap,})

Type declaration

blankNodePropertyList

blankNodePropertyList: function = this.RULE('blankNodePropertyList',(allowEdgeProperties: boolean) => {this.CONSUME(turtleTokenMap.LBracket);this.SUBRULE(this.predicateObjectList, { ARGS: [allowEdgeProperties] });this.CONSUME(turtleTokenMap.RBracket);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

collection

collection: function = this.RULE('collection', () => {this.CONSUME(turtleTokenMap.LParen);this.MANY(() => this.SUBRULE(this.object));this.CONSUME(turtleTokenMap.RParen);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

directive

directive: function = this.RULE('directive', () => {this.OR([{ ALT: () => this.SUBRULE(this.prefixID) },{ ALT: () => this.SUBRULE(this.base) },{ ALT: () => this.SUBRULE(this.sparqlPrefix) },{ ALT: () => this.SUBRULE(this.sparqlBase) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

errors

errors: IRecognitionException[]

input

input: IToken[]

iri

iri: function = this.RULE('iri', () => {this.OR([{ ALT: () => this.CONSUME(turtleTokenMap.IRIREF) },{ ALT: () => this.SUBRULE(this.PrefixedName) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

Protected lexer

lexer: Lexer

literal

literal: function = this.RULE('literal', () => {this.OR([{ ALT: () => this.SUBRULE(this.RDFLiteral) },{ ALT: () => this.SUBRULE(this.NumericLiteral) },{ ALT: () => this.SUBRULE(this.BooleanLiteral) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

Protected namespacesMap

namespacesMap: object

Type declaration

  • [key: string]: boolean

object

object: function = this.RULE('object', (allowEdgeProperties: boolean) => {this.OR([{ ALT: () => this.SUBRULE(this.iri) },{ ALT: () => this.SUBRULE(this.BlankNode) },{ ALT: () => this.SUBRULE(this.collection) },{ALT: () =>this.SUBRULE(this.blankNodePropertyList, {ARGS: [allowEdgeProperties],}),},{ ALT: () => this.SUBRULE(this.literal) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

objectList

objectList: function = this.RULE('objectList', (allowEdgeProperties: boolean) => {this.SUBRULE(this.object, { ARGS: [allowEdgeProperties] });this.MANY(() => {this.CONSUME(turtleTokenMap.Comma);this.SUBRULE1(this.object, { ARGS: [allowEdgeProperties] });});})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

predicate

predicate: function = this.RULE('predicate', () => {this.SUBRULE(this.iri);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

predicateObjectList

predicateObjectList: function = this.RULE('predicateObjectList',(allowEdgeProperties: boolean) => {this.SUBRULE(this.verb);this.OR([{ALT: () =>this.SUBRULE(this.objectList, { ARGS: [allowEdgeProperties] }),},{GATE: () => Boolean(allowEdgeProperties),ALT: () => {this.SUBRULE(this.EmbeddedPredicateObjectList);this.SUBRULE(this.object, { ARGS: [allowEdgeProperties] });},},]);this.MANY(() => {this.CONSUME(turtleTokenMap.Semicolon);this.OPTION(() => {this.SUBRULE1(this.verb);this.OR1([{ALT: () =>this.SUBRULE1(this.objectList, { ARGS: [allowEdgeProperties] }),},{GATE: () => Boolean(allowEdgeProperties),ALT: () => {this.SUBRULE1(this.EmbeddedPredicateObjectList);this.SUBRULE1(this.object, { ARGS: [allowEdgeProperties] });},},]);});});})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

prefixID

prefixID: function = this.RULE('prefixID', () => {this.CONSUME(turtleTokenMap.TTL_PREFIX);const pnameNsToken = this.CONSUME(turtleTokenMap.PNAME_NS);const iriToken = this.CONSUME(turtleTokenMap.IRIREF);const pnameImageWithoutColon = pnameNsToken.image.slice(0, -1);const iriImage = iriToken.image;this.namespacesMap[pnameImageWithoutColon] = iriImage;this.CONSUME(turtleTokenMap.Period);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

Protected semanticErrors

semanticErrors: IRecognitionException[] = []

sparqlBase

sparqlBase: function = this.RULE('sparqlBase', () => {this.CONSUME(turtleTokenMap.BASE);this.CONSUME(turtleTokenMap.IRIREF);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

sparqlPrefix

sparqlPrefix: function = this.RULE('sparqlPrefix', () => {this.CONSUME(turtleTokenMap.PREFIX);const pnameNsToken = this.CONSUME(turtleTokenMap.PNAME_NS);const iriToken = this.CONSUME(turtleTokenMap.IRIREF);const pnameImageWithoutColon = pnameNsToken.image.slice(0, -1);const iriImage = iriToken.image;this.namespacesMap[pnameImageWithoutColon] = iriImage;})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

Private sparqlSrsVisitor

sparqlSrsVisitor: ReturnType<getSparqlSrsVisitor>

statement

statement: function = this.RULE('statement', (allowEdgeProperties: boolean) => {this.OR([{ ALT: () => this.SUBRULE(this.directive) },{ALT: () => {this.SUBRULE(this.triples, { ARGS: [allowEdgeProperties] });this.CONSUME(turtleTokenMap.Period);},},]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

subject

subject: function = this.RULE('subject', () => {this.OR([{ ALT: () => this.SUBRULE(this.iri) },{ ALT: () => this.SUBRULE(this.BlankNode) },{ ALT: () => this.SUBRULE(this.collection) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

triples

triples: function = this.RULE('triples', (allowEdgeProperties: boolean) => {this.OR([{ALT: () => {this.SUBRULE(this.subject);this.SUBRULE1(this.predicateObjectList, {ARGS: [allowEdgeProperties],});},},{GATE: () => Boolean(allowEdgeProperties),ALT: () => {this.SUBRULE(this.EmbeddedTriplePattern);this.SUBRULE(this.predicateObjectList);},},{ALT: () => {this.SUBRULE(this.blankNodePropertyList, {ARGS: [allowEdgeProperties],});this.OPTION(() =>this.SUBRULE2(this.predicateObjectList, {ARGS: [allowEdgeProperties],}));},},]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

turtleDoc

turtleDoc: function = this.RULE('turtleDoc', (mode: ModeString) => {const allowEdgeProperties = mode === 'stardog';this.MANY(() =>this.SUBRULE(this.statement, { ARGS: [allowEdgeProperties] }));})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

verb

verb: function = this.RULE('verb', () => {this.OR([{ ALT: () => this.SUBRULE(this.predicate) },{ ALT: () => this.CONSUME(turtleTokenMap.A) },]);})

Type declaration

    • (idxInCallingRule?: number, ...args: any[]): T | any
    • Parameters

      • Optional idxInCallingRule: number
      • Rest ...args: any[]

      Returns T | any

Methods

Protected AT_LEAST_ONE

  • AT_LEAST_ONE(actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>): void
  • Convenience method, same as MANY but the repetition is of one or more. failing to match at least one repetition will result in a parsing error and cause a parsing error.

    see

    MANY

    Parameters

    • actionORMethodDef: GrammarAction<any> | DSLMethodOptsWithErr<any>

      The grammar action to optionally invoke multiple times or an "OPTIONS" object describing the grammar action and optional properties.

    Returns void

Protected AT_LEAST_ONE_SEP

  • AT_LEAST_ONE_SEP(options: AtLeastOneSepMethodOpts<any>): void
  • Convenience method, same as MANY_SEP but the repetition is of one or more. failing to match at least one repetition will result in a parsing error and cause the parser to attempt error recovery.

    Note that an additional optional property ERR_MSG can be used to provide custom error messages.

    see

    MANY_SEP

    Parameters

    • options: AtLeastOneSepMethodOpts<any>

      An object defining the grammar of each iteration and the separator between iterations

    Returns void

Protected BACKTRACK

  • BACKTRACK<T>(grammarRule: function, args?: any[]): function
  • Type parameters

    • T

    Parameters

    • grammarRule: function

      The rule to try and parse in backtracking mode.

        • (...args: any[]): T
        • Parameters

          • Rest ...args: any[]

          Returns T

    • Optional args: any[]

      argumens to be passed to the grammar rule execution

    Returns function

    a lookahead function that will try to parse the given grammarRule and will return true if succeed.

      • (): boolean
      • Returns boolean

Protected CONSUME

  • CONSUME(tokType: TokenType, options?: ConsumeMethodOpts): IToken
  • A Parsing DSL method use to consume a single Token. In EBNF terms this is equivalent to a Terminal.

    A Token will be consumed, IFF the next token in the token vector matches . otherwise the parser may attempt to perform error recovery (if enabled).

    The index in the method name indicates the unique occurrence of a terminal consumption inside a the top level rule. What this means is that if a terminal appears more than once in a single rule, each appearance must have a different index.

    For example:

      this.RULE("qualifiedName", () => {
      this.CONSUME1(Identifier);
        this.MANY(() => {
          this.CONSUME1(Dot);
          // here we use CONSUME2 because the terminal
          // 'Identifier' has already appeared previously in the
          // the rule 'parseQualifiedName'
          this.CONSUME2(Identifier);
        });
      })

    Parameters

    • tokType: TokenType

      The Type of the token to be consumed.

    • Optional options: ConsumeMethodOpts

      optional properties to modify the behavior of CONSUME.

    Returns IToken

Protected LA

  • LA(howMuch: number): IToken
  • Parameters

    • howMuch: number

    Returns IToken

Protected MANY

  • MANY(actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>): void
  • Parsing DSL method, that indicates a repetition of zero or more. This is equivalent to EBNF repetition {...}.

    Note that there are two syntax forms:

    • Passing the grammar action directly:

        this.MANY(() => {
          this.CONSUME(Comma)
          this.CONSUME(Digit)
         })
    • using an "options" object:

        this.MANY({
          GATE: predicateFunc,
          DEF: () => {
                 this.CONSUME(Comma)
                 this.CONSUME(Digit)
               }
        });

    The optional 'GATE' property in "options" object form can be used to add constraints to invoking the grammar action.

    As in CONSUME the index in the method name indicates the occurrence of the repetition production in it's top rule.

    Parameters

    • actionORMethodDef: GrammarAction<any> | DSLMethodOpts<any>

      The grammar action to optionally invoke multiple times or an "OPTIONS" object describing the grammar action and optional properties.

    Returns void

Protected MANY_SEP

  • MANY_SEP(options: ManySepMethodOpts<any>): void
  • Parsing DSL method, that indicates a repetition of zero or more with a separator Token between the repetitions.

    Example:

        this.MANY_SEP({
            SEP:Comma,
            DEF: () => {
                this.CONSUME(Number};
                // ...
            })

    Note that because this DSL method always requires more than one argument the options object is always required and it is not possible to use a shorter form like in the MANY DSL method.

    Note that for the purposes of deciding on whether or not another iteration exists Only a single Token is examined (The separator). Therefore if the grammar being implemented is so "crazy" to require multiple tokens to identify an item separator please use the more basic DSL methods to implement it.

    As in CONSUME the index in the method name indicates the occurrence of the repetition production in it's top rule.

    Note that due to current limitations in the implementation the "SEP" property must appear before the "DEF" property.

    Parameters

    • options: ManySepMethodOpts<any>

      An object defining the grammar of each iteration and the separator between iterations

    Returns void

Protected OPTION

  • OPTION<OUT>(actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>): OUT
  • Parsing DSL Method that Indicates an Optional production. in EBNF notation this is equivalent to: "[...]".

    Note that there are two syntax forms:

    • Passing the grammar action directly:

        this.OPTION(() => {
          this.CONSUME(Digit)}
        );
    • using an "options" object:

        this.OPTION({
          GATE:predicateFunc,
          DEF: () => {
            this.CONSUME(Digit)
        }});

    The optional 'GATE' property in "options" object form can be used to add constraints to invoking the grammar action.

    As in CONSUME the index in the method name indicates the occurrence of the optional production in it's top rule.

    Type parameters

    • OUT

    Parameters

    • actionORMethodDef: GrammarAction<OUT> | DSLMethodOpts<OUT>

      The grammar action to optionally invoke once or an "OPTIONS" object describing the grammar action and optional properties.

    Returns OUT

Protected OR

  • OR(altsOrOpts: IAnyOrAlt[] | OrMethodOpts): any
  • Parsing DSL method that indicates a choice between a set of alternatives must be made. This is equivalent to an EBNF alternation (A | B | C | D ...), except that the alternatives are ordered like in a PEG grammar. This means that the first matching alternative is always chosen.

    There are several forms for the inner alternatives array:

    • Passing alternatives array directly:

        this.OR([
          { ALT:() => { this.CONSUME(One) }},
          { ALT:() => { this.CONSUME(Two) }},
          { ALT:() => { this.CONSUME(Three) }}
        ])
    • Passing alternative array directly with predicates (GATE):

        this.OR([
          { GATE: predicateFunc1, ALT:() => { this.CONSUME(One) }},
          { GATE: predicateFuncX, ALT:() => { this.CONSUME(Two) }},
          { GATE: predicateFuncX, ALT:() => { this.CONSUME(Three) }}
        ])
    • These syntax forms can also be mixed:

        this.OR([
          {
            GATE: predicateFunc1,
            ALT:() => { this.CONSUME(One) }
          },
          { ALT:() => { this.CONSUME(Two) }},
          { ALT:() => { this.CONSUME(Three) }}
        ])
    • Additionally an "options" object may be used:

        this.OR({
          DEF:[
            { ALT:() => { this.CONSUME(One) }},
            { ALT:() => { this.CONSUME(Two) }},
            { ALT:() => { this.CONSUME(Three) }}
          ],
          // OPTIONAL property
          ERR_MSG: "A Number"
        })

    The 'predicateFuncX' in the long form can be used to add constraints to choosing the alternative.

    As in CONSUME the index in the method name indicates the occurrence of the alternation production in it's top rule.

    Parameters

    • altsOrOpts: IAnyOrAlt[] | OrMethodOpts

      A set of alternatives or an "OPTIONS" object describing the alternatives and optional properties.

    Returns any

    The result of invoking the chosen alternative.

Protected OVERRIDE_RULE

  • OVERRIDE_RULE<T>(name: string, impl: function, config?: IRuleConfig<T>): function
  • Same as {@link Parser.RULE}, but should only be used in "extending" grammars to override rules/productions from the super grammar. See Parser Inheritance Example.

    Type parameters

    • T

    Parameters

    • name: string
    • impl: function
        • (...implArgs: any[]): T
        • Parameters

          • Rest ...implArgs: any[]

          Returns T

    • Optional config: IRuleConfig<T>

    Returns function

      • (idxInCallingRule?: number, ...args: any[]): T | any
      • Parameters

        • Optional idxInCallingRule: number
        • Rest ...args: any[]

        Returns T | any

Protected RULE

  • RULE<T>(name: string, implementation: function, config?: IRuleConfig<T>): function
  • Type parameters

    • T

    Parameters

    • name: string

      The name of the rule.

    • implementation: function

      The implementation of the rule.

        • (...implArgs: any[]): T
        • Parameters

          • Rest ...implArgs: any[]

          Returns T

    • Optional config: IRuleConfig<T>

    Returns function

    • The parsing rule which is the production implementation wrapped with the parsing logic that handles
                    Parser state / error recovery&reporting/ ...
      • (idxInCallingRule?: number, ...args: any[]): T | any
      • Parameters

        • Optional idxInCallingRule: number
        • Rest ...args: any[]

        Returns T | any

Protected SKIP_TOKEN

  • SKIP_TOKEN(): IToken
  • Returns IToken

Protected SUBRULE

  • SUBRULE<T>(ruleToCall: function, options?: SubruleMethodOpts): T
  • The Parsing DSL Method is used by one rule to call another. It is equivalent to a non-Terminal in EBNF notation.

    This may seem redundant as it does not actually do much. However using it is mandatory for all sub rule invocations.

    Calling another rule without wrapping in SUBRULE(...) will cause errors/mistakes in the Parser's self analysis phase, which will lead to errors in error recovery/automatic lookahead calculation and any other functionality relying on the Parser's self analysis output.

    As in CONSUME the index in the method name indicates the occurrence of the sub rule invocation in its rule.

    Type parameters

    • T

    Parameters

    • ruleToCall: function

      The rule to invoke.

        • (idx: number): T
        • Parameters

          • idx: number

          Returns T

    • Optional options: SubruleMethodOpts

      optional properties to modify the behavior of SUBRULE.

    Returns T

    The result of invoking ruleToCall.

Protected canTokenTypeBeInsertedInRecovery

  • canTokenTypeBeInsertedInRecovery(tokType: TokenType): boolean
  • By default all tokens type may be inserted. This behavior may be overridden in inheriting Recognizers for example: One may decide that only punctuation tokens may be inserted automatically as they have no additional semantic value. (A mandatory semicolon has no additional semantic meaning, but an Integer may have additional meaning depending on its int value and context (Inserting an integer 0 in cardinality: "[1..]" will cause semantic issues as the max of the cardinality will be greater than the min value (and this is a false error!).

    Parameters

    • tokType: TokenType

    Returns boolean

computeContentAssist

  • computeContentAssist(startRuleName: string, precedingInput: IToken[]): ISyntacticContentAssistPath[]
  • Parameters

    • startRuleName: string
    • precedingInput: IToken[]

      The token vector up to (not including) the content assist point

    Returns ISyntacticContentAssistPath[]

getBaseCstVisitorConstructor

  • getBaseCstVisitorConstructor(): object
  • Returns object

    • constructor: function
      • new __type(...args: any[]): ICstVisitor<any, any>
      • Parameters

        • Rest ...args: any[]

        Returns ICstVisitor<any, any>

getBaseCstVisitorConstructorWithDefaults

  • getBaseCstVisitorConstructorWithDefaults(): object
  • Returns object

    • constructor: function
      • new __type(...args: any[]): ICstVisitor<any, any>
      • Parameters

        • Rest ...args: any[]

        Returns ICstVisitor<any, any>

getGAstProductions

  • getGAstProductions(): HashTable<Rule>
  • Returns HashTable<Rule>

Protected getNextPossibleTokenTypes

  • getNextPossibleTokenTypes(grammarPath: ITokenGrammarPath): TokenType[]
  • deprecated
    • will be removed in the future

    Parameters

    • grammarPath: ITokenGrammarPath

    Returns TokenType[]

getSerializedGastProductions

  • getSerializedGastProductions(): ISerializedGast[]
  • Returns ISerializedGast[]

Private getSparqlRulesFromVisitor

  • getSparqlRulesFromVisitor(cst: any): object

Protected getTokenToInsert

  • getTokenToInsert(tokType: TokenType): IToken
  • Returns an "imaginary" Token to insert when Single Token Insertion is done Override this if you require special behavior in your grammar. For example if an IntegerToken is required provide one with the image '0' so it would be valid syntactically.

    Parameters

    • tokType: TokenType

    Returns IToken

parse

Protected performSelfAnalysis

  • performSelfAnalysis(): void

reset

  • reset(): 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

Protected resetManagedState

  • resetManagedState(): void

setBaseNamespaces

  • setBaseNamespaces(newBaseNamespaces: object): void
  • Parameters

    • newBaseNamespaces: object
      • [key: string]: boolean

    Returns void

tokenize

  • tokenize(document: string): IToken[]

Private visitCst

  • visitCst(cst: any): void

Static Protected performSelfAnalysis

  • performSelfAnalysis(parserInstance: Parser): void
  • deprecated

    use {@link Parser.performSelfAnalysis} instance method instead.

    Parameters

    • parserInstance: Parser

    Returns void

Generated using TypeDoc