Skip to content
xoxynPublic

About

A programming language created with go

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

Repository files navigation

Bat 🦇

A Simple programming Language written in Go

Features

  • Arithmetic operations (+, -, *, /)
  • Variables and assignments
  • If statements
  • Functions and return values
  • REPL (Read-Eval-Print Loop) for interactive coding

Running the REPL

go run main.go

You should see the REPL prompt:

>>

Type Bat code directly, for example:

>> let a = 5;
>> let b = 10;
>> a + b;
15

Grammar

Bat follows a simple, C-like syntax. Here's the core grammar:

<program>        ::= <statement>*

<statement>      ::= "let" <identifier> "=" <expression> ";"
                   | "return" <expression> ";"
                   | <expression> ";"

<expression>     ::= <integer>
                   | <boolean>
                   | <identifier>
                   | <expression> <operator> <expression>
                   | "(" <expression> ")"
                   | "if" "(" <expression> ")" "{" <program> "}" ("else" "{" <program> "}")?
                   | "fn" "(" <parameters> ")" "{" <program> "}"
                   | <expression> "(" <arguments> ")"

<parameters>     ::= <identifier> ("," <identifier>)*
                   | ε

<arguments>      ::= <expression> ("," <expression>)*
                   | ε

<operator>       ::= "+" | "-" | "*" | "/" | "==" | "!=" | "<" | ">" 

<identifier>     ::= [a-zA-Z_][a-zA-Z0-9_]*
<integer>        ::= [0-9]+
<boolean>        ::= "true" | "false"
                      _..-'(                       )'-.._
                   ./'. '||\\.       (\_/)       .//|' .'\.
                ./'.|'.'||||\\|..    )O O(    ..|//|||'.'|.'\.
             ./'..|'.|| |||||\'''''' '"'" ''''''/||||| ||'|..'\.
           ./'.||'.|||| ||||||||||||.     .|||||||||||| |||||'||.'\.
          /'|||'.|||||| ||||||||||||{     }|||||||||||| ||||||'|||'\
         '.|||'.||||||| ||||||||||||{     }|||||||||||| |||||||'|||.'
        '.||| ||||||||| |/'   ''\||''     ''||/''   '\| ||||||||| |||.'
        |/' \./'     '\./         \!|\   /|!/         \./'     '\./ '\|
        V    V         V          }' '\ /' '{          V         V    V
        '    '         '               V               '         '    '

Ty Thorsten Ball

About

A programming language created with go

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages