S-expression parsing
  • Java 98.7%
  • Assembly 1.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-07-31 18:42:57 +01:00
.forgejo Update workflows. 2026-07-31 18:42:57 +01:00
com.io7m.jsx.cmdline Reformat sources. 2026-07-14 09:44:08 +01:00
com.io7m.jsx.core Reformat sources. 2026-07-14 09:44:08 +01:00
com.io7m.jsx.documentation Reformat sources. 2026-07-14 09:44:08 +01:00
com.io7m.jsx.parser Reformat sources. 2026-07-14 09:44:08 +01:00
com.io7m.jsx.parser.api Reformat sources. 2026-07-14 09:44:08 +01:00
com.io7m.jsx.prettyprint Reformat sources. 2026-07-14 09:44:08 +01:00
com.io7m.jsx.tests Reformat sources. 2026-07-14 09:44:08 +01:00
src/site/resources Update site metadata. 2025-08-09 15:07:05 +00:00
.gitignore Update .gitignore. 2024-05-07 16:01:45 +00:00
doc7m-books.json Fix documentation generation, attach EPUB, update workflows. 2026-07-14 09:43:10 +01:00
pom.xml Upgrade junit 5.14.4 -> 6.1.2. 2026-07-14 19:33:55 +01:00
README-CHANGES.xml Mark release 4.0.0 2024-05-10 17:04:45 +00:00
README-LICENSE.txt Update LICENSE 2023-08-13 21:07:25 +00:00
README.in Migrate project. 2026-06-27 09:48:20 +01:00
README.md Migrate project. 2026-06-27 09:48:20 +01:00

jsx

Maven Central Maven Central (snapshot) Java Version

com.io7m.jsx

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);
}