Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

nbrugger-tgm/JainParse

Repository files navigation

JainParse

Archived

This project is no longer maintained. It was mostly a experiment to begin with. While it is in a useable state the performance of generic recursive decent parsers is already bad, that ontop of java not being c doen't make this project viable (which it wasn't intended to be)

Documentation

Jain parse is a lib to create your own parsers (and writers).
Its main features are

  • Custom functional parser building
  • Defining parsers as files
  • Stream/OnDemand Parsing (Sockets/InputStreams)
  • Tokenization using REGEX
  • Model Autogeneration

Installation

Use Maven (or Gradle) and add this as dependency

<dependency>
    <groupId>com.niton</groupId>
    <artifactId>jainparse</artifactId>
    <version>1.0.4</version>
</dependency>

Terminology

  • Token: a single character or multiple characters of the same type (Letters/Numbers)
  • Grammar: The "rule/s" how a string should be parsed -> The structural description

Example

These steps are in the order you are most likely to do when you create a parser

  1. Building a Grammar

    With code

    GrammarReference ref = new GrammarReferenceMap()
        .map(
            Grammar.build("Number")
                .token(DefaultToken.NUMBER).add("value")
        )
        .map(
            Grammar.build("calc_expression")
                .token(DefaultToken.BRACKET_OPEN).add()
                .grammar("expression").add("firstExpression")
                .tokens(DefaultToken.STAR, DefaultToken.PLUS, DefaultToken.MINUS, DefaultToken.SLASH).matchAny().add("calculationType")
                .grammar("expression").add("secondExpression")
                .token(DefaultToken.BRACKET_CLOSED).add()
        )
        .map(
            Grammar.build("expression")
                .grammars(new String[]{"Number", "calc_expression"}).matchAny().add("content")
        );

    As Grammar File

File Generator Grammar Files

Todo

  • Changing onGet - Generation of the autogen classes to - build on constructor

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages