hawkins / druid

🧙 A systems-level programming language with a focus on integrated build systems and deploying to native and web assembly at once
https://twitch.tv/druidlang
2 stars 0 forks source link

Language grammar #6

Open hawkins opened 5 years ago

hawkins commented 5 years ago

For the next step in the pipeline, the parser, we'll need a proper grammar. I think these are typically done in EBNF (or see these lecture notes).

hawkins commented 5 years ago

I wish I had more time lately to just sit down and churn out work on druid, but time's been an expensive commodity the last few days, so I'm going to edit this comment on occasion to at least get something on paper for a druid grammar...

Assumptions

Syntax

Assuming this example syntax (hello.druid w/o comments):

status entry_point()
{
    if(g:count)
    {
    }

    stdout("Hello world!\n");
    stdout("Fibb of %d: %d\n", 9, math:fib(9));

    data_cube = conjure(DataCube);
    data_cube:print_data();
    banish(data_cube);

    return(status:success);
}

Grammar:

P -> SS | λ S -> ...;