Skip to content

Instantly share code, notes, and snippets.

View Bravotic's full-sized avatar
💻
Reinventing the wheel

Collin McKinley Bravotic

💻
Reinventing the wheel
View GitHub Profile
// The following is public domain, go wild.
// If you could however, please at least keep the blog URL in it if you use it verbaitum
// https://bravotic.com/dev/stdscr/index.php/2022/11/13/making-a-parser-generator-doesnt-have-to-be-hard/
// Step 1: Lets get a list of tokens
// Our list of tokens
var tokens = ["Hello", "Hi", "Goodbye", "Good", "World", "Wordlist"];
// Step 2: Create the trees
// We need to create a 'state' which holds the possible next letters, and a state for those as well