Skip to content
/ jsm Public

A lightweight library that allows you to create fast finite state machine according to a given scheme.

License

Notifications You must be signed in to change notification settings

RomanQed/jsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsm maven-central

A lightweight library that allows you to create fast finite state machine according to a given scheme.

Getting Started

To install it, you will need:

  • Java 11+
  • Maven/Gradle

Features

  • Convenient and universal creation of a finite state machine model
  • JIT compilation of the transition function according to the scheme of a finite automaton

Installing

Gradle dependency

dependencies {
    implementation group: 'com.github.romanqed', name: 'jsm', version: 'LATEST'
}

Maven dependency

<dependency>
    <groupId>com.github.romanqed</groupId>
    <artifactId>jsm</artifactId>
    <version>LATEST</version>
</dependency>

Example

package com.github.romanqed.jsm;

import com.github.romanqed.jsm.bytecode.BytecodeMachineFactory;
import com.github.romanqed.jsm.model.MachineModelBuilder;

import java.util.List;

public class Main {
    public static void main(String[] args) {
        var builder = MachineModelBuilder.create(String.class, Character.class);
        var model = builder
                .setInitState("Init")
                .setExitState("Error")
                .addState("Hello")
                .addState("World")
                .addTransition("Init", "Hello", 'h')
                .addTransition("Hello", "World", 'w')
                .build();
        var factory = new BytecodeMachineFactory();
        var machine = factory.create(model);
        var tokens = List.of('h', 'w');
        System.out.println(machine.run(tokens));
    }
}

Built With

  • Gradle - Dependency management
  • ASM - Generation of transition function
  • jeflect - Class definers and various bytecode tricks

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

Releases

No releases published

Packages

No packages published

Languages