| name | banglacode-development |
| description | Development rules for BanglaCode programming language interpreter |
| version | 1.0.0 |
| tags | ["golang","interpreter","bengali","language-design","education"] |
| author | BanglaCode Team |
BanglaCode Development Skill
Project Identity
BanglaCode - Educational Programming Language in Bengali
- Go ≥1.20
- Tree-walking interpreter
- 29 Bengali keywords (Banglish)
- 135+ built-in functions
- Target: 300+ million Bengali speakers
Mandatory Workflows
After EVERY Code Change
go build -o banglacode main.go
go test ./...
go fmt ./...
go vet ./...
For ANY Language Feature
- Update lexer if new keyword
- Update parser if new syntax
- Update evaluator for execution
- Add tests in
test/
- Update SYNTAX.md
- Update Documentation/
Definition of "Done"
- ✅
go build passes
- ✅
go test ./... passes
- ✅ Existing programs work
- ✅ SYNTAX.md updated
- ✅ Documentation updated
- ✅ Error messages in Bengali
- ✅ Examples work
- ✅ Cross-platform tested
Architecture
Interpreter Pipeline
Source Code (.bang)
↓
Lexer (Tokenization)
↓
Parser (AST Building)
↓
Evaluator (Execution)
↓
Result
Components
src/
├── lexer/
│ ├── lexer.go # Tokenizer
│ └── token.go # 29 Bengali keywords
├── parser/
│ ├── parser.go # Pratt parsing
│ └── precedence.go # Operator precedence
├── ast/
│ └── ast.go # AST node types
├── object/
│ ├── object.go # Runtime types
│ └── environment.go # Variable scopes
├── evaluator/
│ ├── evaluator.go # Main Eval()
│ ├── builtins.go # 135+ functions
│ ├── async.go # Promises
│ ├── classes.go # OOP
│ ├── modules.go # Import/export
│ └── errors.go # Try/catch/finally
└── repl/
└── repl.go # Interactive shell
Go Standards (STRICT)
Error Handling - Bengali Messages
if err != nil {
return newError("ভুল: %s", err.Error())
}
return newError("%d লাইনে: অজানা ফাংশন '%s'", node.Line, fnName)
if err != nil {
return newError("Error: %s", err)
}
Type Assertions
intObj, ok := obj.(*object.Integer)
if !ok {
return newError("সংখ্যা প্রত্যাশিত, পেয়েছি: %s", obj.Type())
}
intObj := obj.(*object.Integer)
Object Types
type Integer struct {
Value int64
}
type String struct {
Value string
}
func (i *Integer) Type() ObjectType { return INTEGER_OBJ }
func (i *Integer) Inspect() string { return fmt.Sprintf("%d", i.Value) }
Key Patterns
Bengali Keywords
var keywords = map[string]TokenType{
"dhoro": LET,
"sthir": CONST,
"protiti": FOR,
"jodi": IF,
"nahole": ELSE,
"jokhon": WHILE,
"bhango": BREAK,
"kaj": FUNCTION,
"firao": RETURN,
"proyash": ASYNC,
"opekha": AWAIT,
"dol": CLASS,
"notun": NEW,
"ei": THIS,
"super": SUPER,
"ano": IMPORT,
"theke": FROM,
"pathao": EXPORT,
"hisabe": AS,
"chesta": TRY,
"dhoro_bhul": CATCH,
"shesh": FINALLY,
"chhar": THROW,
}
Built-in Functions
var builtins = map[string]*object.Builtin{
"dekho": &object.Builtin{Fn: dekhoPrint},
"input": &object.Builtin{Fn: inputRead},
"dorghyo": &object.Builtin{Fn: dorghyoLength},
"dhokao": &object.Builtin{Fn: dhokaoPush},
"chhino": &object.Builtin{Fn: chhinoPop},
"http_server": &object.Builtin{Fn: httpServer},
"http_get": &object.Builtin{Fn: httpGet},
"http_post": &object.Builtin{Fn: httpPost},
"postgres_connect":&object.Builtin{Fn: postgresConnect},
"mysql_connect": &object.Builtin{Fn: mysqlConnect},
"mongo_connect": &object.Builtin{Fn: mongoConnect},
"redis_connect": &object.Builtin{Fn: redisConnect},
"ghumaao": &object.Builtin{Fn: ghumaaoSleep},
"proyash_solve": &object.Builtin{Fn: proyashSolve},
}
AST Nodes
type LetStatement struct {
Token token.Token
Name *Identifier
Value Expression
}
type IfExpression struct {
Token token.Token
Condition Expression
Consequence *BlockStatement
Alternative *BlockStatement
}
type FunctionLiteral struct {
Token token.Token
Parameters []*Identifier
Body *BlockStatement
Async bool
}
Testing Requirements
Unit Tests
func TestLetStatement(t *testing.T) {
input := `dhoro x = 5;`
program := parseProgram(input)
if len(program.Statements) != 1 {
t.Fatalf("program.Statements বিবৃতি ১টি থাকা উচিত")
}
stmt := program.Statements[0].(*ast.LetStatement)
if stmt.Name.Value != "x" {
t.Errorf("নাম 'x' হওয়া উচিত, পেয়েছি %s", stmt.Name.Value)
}
}
Integration Tests
func TestHttpServer(t *testing.T) {
input := `
dhoro server = http_server(8080, kaj() {
dekho("সার্ভার চালু");
});
`
evaluated := testEval(input)
if !isNull(evaluated) {
t.Errorf("সার্ভার তৈরি ব্যর্থ")
}
}
Documentation Requirements
SYNTAX.md
Update when language features change:
- New keywords
- New operators
- New built-in functions
- Syntax changes
ARCHITECTURE.md
Update when internals change:
- New AST node types
- Parser modifications
- Evaluator changes
- Performance improvements
Documentation/ (Website)
Update for user-facing changes:
- Tutorials
- API reference
- Examples
- Best practices
Extension/ (VS Code)
Update when language features added:
- Syntax highlighting
- IntelliSense snippets
- Keyword completions
Security Standards
Input Validation
func validatePath(path string) error {
if strings.Contains(path, "..") {
return fmt.Errorf("পথে '..' অনুমোদিত নয়")
}
return nil
}
Safe Execution
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
Anti-Patterns (FORBIDDEN)
❌ English keywords (must be Bengali/Banglish)
❌ Breaking existing BanglaCode programs
❌ Non-Bengali error messages
❌ Missing tests for new features
❌ Undocumented syntax changes
❌ Unsafe type assertions (without ok check)
❌ Generic error messages
❌ Missing examples
Workflow Guidelines
When Adding New Keyword
- Add to
lexer/token.go keywords map
- Add token type constant
- Update parser to handle new syntax
- Update evaluator for execution
- Add tests
- Update SYNTAX.md
- Update VS Code extension syntax
When Adding Built-in Function
- Implement in
evaluator/builtins.go
- Add to
builtins map
- Follow naming: Bengali verb (e.g.,
dekho, dhokao)
- Add validation and error handling
- Add tests
- Document in SYNTAX.md
- Add VS Code snippet
When Fixing Bugs
- Write failing test
- Fix bug
- Verify test passes
- Check for similar issues
- Update CHANGELOG.md
Success Criteria
Every task must meet ALL:
- ✅
go build passes
- ✅
go test ./... passes
- ✅ Existing programs still work
- ✅ SYNTAX.md updated
- ✅ Documentation updated
- ✅ Error messages in Bengali
- ✅ Examples work
- ✅ Cross-platform tested (Linux, macOS, Windows)
- ✅ VS Code extension updated