GitHunt

jsx

Maven Central
Maven Central (snapshot)
Codecov
Java Version

com.io7m.jsx

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)

jsx

A general-purpose, configurable S-expression parser.

Features

  • Hand-coded lexer and parser with full support for tokens using characters outside of the Unicode BMP.
  • Optional square brackets [f (g [x y])].
  • Optional multi-line strings.
  • Configurable comment characters (#, %, or ;).
  • Configurable pretty printing of expressions.
  • High coverage test suite.
  • OSGi-ready
  • JPMS-ready
  • ISC license.

User Manual

See the user manual.

Usage

Parsing

Give the configuration for the lexer:

var squareBrackets = true;
var newlinesInQuotedStrings = true;
var startAtLine = 1;

final var lexConfiguration =
  new JSXLexerConfiguration(
    squareBrackets,
    newlinesInQuotedStrings,
    Optional.of(URI.create("file.txt")),
    EnumSet.noneOf(JSXLexerComment.class),
    startAtLine
  );

Instantiate a parser using a parser and lexer configuration:

var preserveLexicalInfo = true;

final var parserConfig =
  new JSXParserConfiguration(preserveLexicalInfo);

final JSXParserSupplierType parsers =
  new JSXParserSupplier();

final var parser =
  parsers.createFromStreamUTF8(
    parserConfig,
    lexConfiguration,
    lexers,
    System.in
  );

Parse expressions:

final var exprOpt = parser.parseExpressionOrEOF();
if (exprOpt.isPresent()) {
  final var e = exprOpt.get();
  System.out.println(e);
}

Languages

Java98.7%Assembly1.3%CSS0.0%

Contributors

ISC License
Created August 23, 2015
Updated March 2, 2026
io7m-com/jsx | GitHunt