Bangla Script BNF Grammar
Back
<program>
::= { <statement> }
<statement>
::= <varDecl> ";"
| <assignment> ";"
| <ifStmt>
| <loopStmt>
| <ioStmt> ";"
<varDecl>
::= "box" <ident> "=" <expr>
<assignment>
::= <ident> "=" <expr>
<ifStmt>
::= "if" "(" <expr> ")" "{" { <statement> } "}"
[ "else" "{" { <statement> } "}" ]
<loopStmt>
::= "loop" "(" <condList> ")" "{" { <statement> } "}"
<condList>
::= <expr> { "," <expr> }
<ioStmt>
::= "output" "(" <expr> ")"
| "input" "(" <ident> ")"
<expr>
::= <orExpr>
<orExpr>
::= <andExpr> { ( "||" | "or" ) <andExpr> }
<andExpr>
::= <compExpr> { ( "&&" | "and" ) <compExpr> }
<compExpr>
::= <addExpr> [ ( "==" | "!=" | "<>" | "<" | ">" | "<=" | ">=" | "!<" | "!>" ) <addExpr> ]
<addExpr>
::= <mulExpr> { ( "+" | "-" ) <mulExpr> }
<mulExpr>
::= <unaryExpr> { ( "*" | "/" | "%" ) <unaryExpr> }
<unaryExpr>
::= ( "!" | "-" ) <unaryExpr> | <factor>
<factor>
::= <number>
| <string>
| <ident>
| "(" <expr> ")"
<number>
::= <digits> [ "." <digits> ]
<string>
::= "\"" { <char> } "\"" | "'" { <char> } "'"
<ident>
::= <letter> { <letter> | <digit> | "_" }
<letter>
::= "A"–"Z" | "a"–"z"
<digit>
::= "0"–"9"
- Basic Tutorial Guide
• Getting Started
– Open the runner page. Two boxes appear: the Code editor and the Scan Input field.
– The editor is preloaded with a sample program that shows variables, arithmetic, comparisons, loops, logic, and I/O.
• Variables & Expressions
– Declare with box name = expr; (numbers, strings, or expressions).
– Reassign with name = expr;.
– Arithmetic: +, -, *, /, %. Strings concatenate with +.
• Comparisons & Logic
– Comparisons: ==, !=, <>, <, >, <=, >=, plus !< (>=) and !> (<=).
– Logic: ! for NOT, &&/and for AND, ||/or for OR.
• Control Flow
– Conditional:
if (condition) { … } else { … }
– Loop:
- Fixed count: loop(5) { … } runs 5 times.
- While-style or combined conditions: loop(x < 5) or loop(x<3, y>0) repeats as long as all conditions are true.
• Input & Output
– input(var); reads the next token from the Scan Input buffer (space-separated).
– output(expr); appends the value to the result area.
• Running Your Code
- Edit or replace the code in the editor.
- Provide any needed input tokens in Scan Input.
- Click Run. The interpreter will parse, evaluate, and display each output(...) result line by line.