Home

Awesome

Broccoli

Broccoli is a stack-based, semi-concatenative programming language.

You can try the JS interpreter at this address.

Overview

Control flow

Broccoli does not have keywords, but has predefined variables that can be used for codeflow instead.

Predefined variables

Broccoli features the following predefined variables:

Nearly grammar for broccoli

braced[X] -> "{" $X "}"
parenthesized[X] -> "(" $X ")"

main -> _ program _

program -> (expression (__ expression):*):?

expression -> identifier | string | number | operation | assignment | functionassignment | codeblock | group

identifier -> [A-Za-z_] [0-9A-Za-z_]:*

access -> "." identifier

string -> "\"" string_content:* "\""

string_content -> [^"\n\\] | "\\" .

number -> [1-9] [0-9]:*

operation -> operator __ expression

operator -> "==" | "!=" | "<=" | ">=" | "<<" | ">>" | [-+*/%<>&^|]

assignment -> "=" _ identifier

functionassignment -> ":" _ identifier

codeblock -> braced[_ program _]

group -> parenthesized[_ program _]

_  -> [ \t\n]:* (comment [ \t\n]:*):?
__ -> [ \t\n]:+ (comment [ \t\n]:*):* | (comment [ \t\n]:*):+

comment -> "#" .:* "\n"

Also see grammar.ne

Develop

git clone https://github.com/mathieucaroff/broccoli
# or git clone https://github.com/mathieucaroff/broccoli.git

cd broccoli

yarn install
# or npm install

yarn serve
# or npm run serve

Run the test

To test the parser, run yarn parcel test/parser/test.html and open the given given link.

To test the code samples, run yarn parcel test/runner/test.html and open the given link.