Skip to content

JoeStrout/bantam-miniscript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

bantam-miniscript

MiniScript port of Bantam, a Pratt parser demo by Bob Nystrom

What's all this, then?

Bantam is a toy language created by Bob Nystrom to demonstrate Pratt parsing — an approach to parsing (computer) languages in which little mini-parsers (or "parselets" as he calls them) are each responsible for one type of statement or sub-expression.

Read more about it in my blog post, Pratt Parsing in MiniScript. And for more background and explanation, certainly read Bob's blog post.

Running the code

You can run the code in Mini Micro.

  1. Clone or download the code from this repo to your local hard drive.
  2. Download Mini Micro, if you don't have it already. Launch it.
  3. Click the top disk slot (bottom-left corner of the window), choose "Mount Folder", and mount the "src" folder from this repo.
  4. Type run "main" and press return/enter.

The code should show "Passed all 24 tests." That means it worked!

If you like, you can now type interact to enter a sort of interactive REPL mode. Type an expression at the $ prompt, and it will show you how it is parsed. For example, enter "a+b*c", and it will print (a + (b * c)).

You can also get it to run in command-line MiniScript, but it will take a bit more work: (1) add importUtil.ms to your lib folder, if you don't have it already; and (2) either ensure that . (the current directory) is in your MS_IMPORT_PATH, or move all the files except main.ms into a lib subfolder.

About

MiniScript port of Bantam, a Pratt parser demo by Bob Nystrom

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published