Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/romanqed/jsm
A lightweight library that allows you to create fast finite state machine according to a given scheme.
https://github.com/romanqed/jsm
bytecode bytecode-generation fast finite finite-state-machine fsm java java-11 java-17 java11 java17 machine state
Last synced: 21 days ago
JSON representation
A lightweight library that allows you to create fast finite state machine according to a given scheme.
- Host: GitHub
- URL: https://github.com/romanqed/jsm
- Owner: RomanQed
- License: apache-2.0
- Created: 2023-09-30T11:02:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-09T11:37:16.000Z (4 months ago)
- Last Synced: 2024-11-22T09:05:30.649Z (3 months ago)
- Topics: bytecode, bytecode-generation, fast, finite, finite-state-machine, fsm, java, java-11, java-17, java11, java17, machine, state
- Language: Java
- Homepage:
- Size: 85 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsm [![maven-central](https://img.shields.io/maven-central/v/com.github.romanqed/jsm?color=blue)](https://repo1.maven.org/maven2/com/github/romanqed/jsm/)
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
```Groovy
dependencies {
implementation group: 'com.github.romanqed', name: 'jsm', version: 'LATEST'
}
```### Maven dependency
```
com.github.romanqed
jsm
LATEST```
## Example
```Java
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](https://gradle.org) - Dependency management
* [ASM](https://asm.ow2.io) - Generation of transition function
* [jeflect](https://github.com/RomanQed/jeflect) - Class definers and various bytecode tricks## Authors
* **[RomanQed](https://github.com/RomanQed)** - *Main work*
See also the list of [contributors](https://github.com/RomanQed/jsm/contributors)
who participated in this project.## License
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details