A lightweight library that allows you to create fast finite state machine according to a given scheme.
To install it, you will need:
- Java 11+
- Maven/Gradle
- Convenient and universal creation of a finite state machine model
- JIT compilation of the transition function according to the scheme of a finite automaton
dependencies {
implementation group: 'com.github.romanqed', name: 'jsm', version: 'LATEST'
}
<dependency>
<groupId>com.github.romanqed</groupId>
<artifactId>jsm</artifactId>
<version>LATEST</version>
</dependency>
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));
}
}
- Gradle - Dependency management
- ASM - Generation of transition function
- jeflect - Class definers and various bytecode tricks
- RomanQed - Main work
See also the list of contributors who participated in this project.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details