<< Previous

Early demo

After a lot of work, I have finally reached something that is catually usable to some extent. Therefore, I decided to publish a binary of the compiler at http://storm.fprg.se, alongside with more detailed documentation. I want to point out here as well that the compiler and language are nowhere near finished, but it is still stable enough and has enough features implemented that it can demonstrate the core ideas of Storm. When you launch the compiler, you will get to the top loop for the language Basic Storm, that I have talked about earlier. From there, you can poke around in the compiler, and see what it can do.

I want to show one example that shows the power of syntax extensions here:

Filip@FILIP-PC ~/Projects/storm (master)
$ StormMain.exe
Welcome to the Storm compiler!
Root directory: c:\Users\Filip\Projects\storm\root
Compiler boot in 74 ms

bs> (bf("hello", 1) { ,[.,] }) # " world!"
./(16): Syntax error: Unexpected {
Expected types: Operator, PrePost
Expected tokens: "!=", "#", "%", "&", ")", "-", "--", "/", ...
Rules in progress: Atom, BSDelimiter, Expr, Operator, PrePost, Whitespace

bs> use lang:bf
Using lang.bf.

bs> (bf("hello", 1) { ,[.,] }) # " world!"
=> hello world!

bs> dump{"A" # "B" # "C"}
"A" # "B" # "C" <=> {
  core.StrBuf b(core.StrBuf());
  {
    core.StrBuf.add(b, "A");
    core.StrBuf.add(b, "B");
    core.StrBuf.add(b, "C");
  };
  core.StrBuf.toS(b);
}
=> ABC

bs> exit
=> <void>

Filip@FILIP-PC ~/Projects/storm (master)
$

First, I try to evaluate an expression with embedded Brainfuck code, which fails with a syntax error. The problem was that I forgot to include the lang.bf syntax, which contains the Brainfuck syntax. When I do this, the same statements compiles and executes without problems!

After that, I want to inspect what the syntax "A" # "B" # "C" actually does, so I use the dump{} syntax, which outputs the expanded syntax tree at compile-time so that I can easily see what it does.

The cool part about this is that much of this is implemented in Basic Storm itself, so you can see the code used to implement these constructs, as well as create your own. Basic Storm is in lang.bs. There, you can find the syntax along with the implementation for string concatenation as shown above as well as array syntax, the top-loop itself and much more. The implementation of Brainfuck is implemented in lang.bf. The Brainfuck code is compiled, like everything else, into machine code before it is executed. You can also find some simple threading and parsing examples in the demo package.

See the documentation and download it at http://storm.fprg.se!

Have fun!

Comments

Johan

2015-12-10 12:12 (UTC)

Very nice, but i think you need to use a std::stringstream.

Alex Telon

2016-10-19 21:41 (UTC)

Snälla snälla filip, lägg gärna datum på när du laddade upp binären brevid länken på storm.fprg.se. Även om du inte har versionsnummer på den ännu så skulle det vara najs att se när du la upp något senast. :)

New comment

You can use GitHub flavored markdown here. Parsed by Parsedown, which does not support all of GitHub's features. For example, specifying the language of code listings is not supported.

Name: