Skip to content

io7m-com/jlexing

Repository files navigation

jlexing

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.jlexing

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

jlexing

A package containing various types commonly used in lexical analyzers and parsers.

Features

  • Common immutable lexical position types.
  • High coverage test suite.
  • OSGi-ready
  • JPMS-ready
  • ISC license.

Motivation

Many io7m projects contain hand-written parsers and lexers. The jlexing package exists to declare common lexer types so that nearly-identical versions of those types don't have to be repeatedly written for every project.

Usage

The LexicalPositionType represents a span in a region of text. It includes a mutable builder for constructing immutable LexicalPosition values:

final LexicalPosition.Builder<Path> b0 =
  LexicalPosition.builder();

b0.setLine(23);
b0.setColumn(24);
b0.setColumnEnd(30);
b0.setFile(Optional.of(path0));
b0.setFile(path1);

final LexicalPosition<Path> p =
  b0.build();