Skip to content

Accurately define the grammar #15

@bit-hack

Description

@bit-hack

This is a starting point but it would be nice to accurately define the grammar, and generate a railroad diagram for the manual.

Program ::= ( FunctionDecl | VarDecl )* 

Identifier ::= [a-fA-F_] [0-9a-fA-F_]*

Number ::= [0-9]+

Expression ::= Identifier
             | Number
             | FunctionCall

ExpressionList ::= Expression ( ',' Expression )*

VarDecl ::= 'var' Identifier ( '=' Number )?

ArgDeclList ::= Identifier ( ',' Identifier )+

FunctionCall ::= Identifier '(' ExpressionList? ')'

FunctionDecl ::= 'function' Identifier '(' ArgDeclList? ')' ( Statement )* 'end'

IfStatement ::= 'if' '(' Expression ')' ( Statement )* 'end'

WhileStatement ::= 'while' '(' Expression ')' ( Statement )* 'end'

Statement ::= ( 'return' Expression )
            | IfStatement
            | WhileStatement
            | VarDecl
            | FunctionCall

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions