Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alafty/fallbackdfa
Task 3 for the Compilers lab where the needed deliverable is a function that takes a DFA and should simulate a Fallback DFA with any given input
https://github.com/alafty/fallbackdfa
compilers compilers-design dfa fallback-dfa regex
Last synced: about 8 hours ago
JSON representation
Task 3 for the Compilers lab where the needed deliverable is a function that takes a DFA and should simulate a Fallback DFA with any given input
- Host: GitHub
- URL: https://github.com/alafty/fallbackdfa
- Owner: alafty
- Created: 2024-02-25T18:57:00.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-03-07T00:15:29.000Z (9 months ago)
- Last Synced: 2024-07-29T17:22:47.360Z (4 months ago)
- Topics: compilers, compilers-design, dfa, fallback-dfa, regex
- Language: Java
- Homepage:
- Size: 2.21 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FallbackDFA
## Description
The Fallback DFA is a modified version of a DFA that allows for lexing (tokenizing) input strings. It reads a formatted string representation of the DFA and simulates its behavior on input strings to tokenize them. The tokenization process involves recognizing patterns in the input string based on the DFA's states and transitions.
### Installation
Clone the repository to your local machine:
```bash
git clone https://github.com/username/FallbackDFA.git
```### Running the Code
To use the FallbackDFA class in your Java project, simply include the `FallbackDfa.java` file in your project directory. You can then create an instance of the `FallbackDfa` class and use its `run()` method to tokenize input strings.
Example usage:
```java
String fdfaRepresentation = "state1;state2;state3#symbol1;symbol2;symbol3#state1,symbol1,state2;state2,symbol2,state3#state1#state3";
FallbackDfa dfa = new FallbackDfa(fdfaRepresentation);
String input = "input_string_to_tokenize";
String tokens = dfa.run(input);
System.out.println("Tokens: " + tokens);
```### Input Format
The input to the FallbackDfa constructor and the `run()` method follows a specific format:
```
state1;state2;state3#symbol1;symbol2;symbol3#state1,symbol1,state2;state2,symbol2,state3#start_state#accept_states
```### Output Format
The `run()` method returns a formatted string representation of the list of tokens. The string representation follows the one described in the input format.
## Authors
- [Mohamed El-Alafty](https://github.com/alafty)