npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@traqula/parser-sparql-1-1

v1.0.0

Published

SPARQL 1.1 parser

Readme

Traqula parser engine for SPARQL 1.1

npm version

Traqula Sparql 1.1 is a SPARQL 1.1 query parser for TypeScript.

Installation

npm install @traqula/parser-sparql-1-1

or

yarn add @traqula/parser-sparql-1-1

Import

Either through ESM import:

import {Parser} from 'engines/parser-sparql-1-1';

or CJS require:

const Parser = require('engines/parser-sparql-1-1').Parser;

Usage

This package contains a Parser that is able to parse SPARQL 1.1 queries:

const parser = new Parser();
const abstractSyntaxTree = parser.parse('SELECT * { ?s ?p ?o }');

Note that a single parser cannot parse multiple queries in parallel.

The package also contains multiple parserBuilders. These builders can be used either to consume to a parser, or to usage as a starting point for your own grammar.

Consuming parserBuilder to parser

At the core of Traqula, parser are constructed of multiple parser rules that have been consumed by the builder. This consumption returns a parser that can parse strings starting from any grammar rule.

The sparql11ParserBuilder for example contains both the rules queryOrUpdate and path (among many others). The consumption of sparql11ParserBuilder will thus return an object that has function queryOrUpdate and path. Calling those function with a string will cause that string to be parsed using the appropriate rule as a starting rule.

const parser: {
  queryOrUpdate: (input: string) => SparqlQuery;
  path: (input: string) => PropertyPath | IriTerm;
} = sparql11ParserBuilder.consumeToParser({
  tokenVocabulary: l.sparql11Tokens.build(),
}, {
  parseMode: new Set([ gram.canParseVars, gram.canCreateBlankNodes ]),
  dataFactory: new DataFactory(),
});

Constructing a new grammar from an existing one

The builders can also be used to construct new parsers. As an example the triplesBlockParserBuilder is created by merging the objectListBuilder with some new rules.

Configuration

Optionally, the following parameters can be set in the Parser constructor:

  • dataFactory: A custom RDFJS DataFactory to construct terms and triples. (Default: require('@rdfjs/data-model'))
  • baseIRI: An initial default base IRI. (Default: none)
  • prefixes: An initial map of prefixes
  • skipValidation: Can be used to disable the validation that used variables in a select clause are in scope.