diff --git a/.agents/skills/banglacode-development/SKILL.md b/.agents/skills/banglacode-development/SKILL.md new file mode 100644 index 0000000..435ace1 --- /dev/null +++ b/.agents/skills/banglacode-development/SKILL.md @@ -0,0 +1,368 @@ +--- +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 +```bash +go build -o banglacode main.go +go test ./... +go fmt ./... +go vet ./... +``` + +### For ANY Language Feature +1. Update lexer if new keyword +2. Update parser if new syntax +3. Update evaluator for execution +4. Add tests in `test/` +5. Update SYNTAX.md +6. 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 +```go +// ✅ REQUIRED - Bengali-friendly +if err != nil { + return newError("ভুল: %s", err.Error()) +} + +// ✅ Context with line numbers +return newError("%d লাইনে: অজানা ফাংশন '%s'", node.Line, fnName) + +// ❌ FORBIDDEN - English only +if err != nil { + return newError("Error: %s", err) +} +``` + +### Type Assertions +```go +// ✅ GOOD - Safe type assertion +intObj, ok := obj.(*object.Integer) +if !ok { + return newError("সংখ্যা প্রত্যাশিত, পেয়েছি: %s", obj.Type()) +} + +// ❌ BAD - Unsafe +intObj := obj.(*object.Integer) // Can panic! +``` + +### Object Types +```go +// ✅ Define runtime types +type Integer struct { + Value int64 +} + +type String struct { + Value string +} + +// ✅ Implement Object interface +func (i *Integer) Type() ObjectType { return INTEGER_OBJ } +func (i *Integer) Inspect() string { return fmt.Sprintf("%d", i.Value) } +``` + +## Key Patterns + +### Bengali Keywords +```go +// lexer/token.go +var keywords = map[string]TokenType{ + // Variables + "dhoro": LET, // let/var + "sthir": CONST, // const + "protiti": FOR, // for + + // Control Flow + "jodi": IF, // if + "nahole": ELSE, // else + "jokhon": WHILE, // while + "bhango": BREAK, // break + + // Functions + "kaj": FUNCTION, // function + "firao": RETURN, // return + "proyash": ASYNC, // async + "opekha": AWAIT, // await + + // OOP + "dol": CLASS, // class + "notun": NEW, // new + "ei": THIS, // this + "super": SUPER, // super + + // Modules + "ano": IMPORT, // import + "theke": FROM, // from + "pathao": EXPORT, // export + "hisabe": AS, // as + + // Error Handling + "chesta": TRY, // try + "dhoro_bhul": CATCH, // catch + "shesh": FINALLY, // finally + "chhar": THROW, // throw +} +``` + +### Built-in Functions +```go +// evaluator/builtins.go +var builtins = map[string]*object.Builtin{ + // I/O + "dekho": &object.Builtin{Fn: dekhoPrint}, // print + "input": &object.Builtin{Fn: inputRead}, // input + + // String/Array + "dorghyo": &object.Builtin{Fn: dorghyoLength}, // length + "dhokao": &object.Builtin{Fn: dhokaoPush}, // push + "chhino": &object.Builtin{Fn: chhinoPop}, // pop + + // HTTP + "http_server": &object.Builtin{Fn: httpServer}, // HTTP server + "http_get": &object.Builtin{Fn: httpGet}, // GET request + "http_post": &object.Builtin{Fn: httpPost}, // POST request + + // Database + "postgres_connect":&object.Builtin{Fn: postgresConnect}, // PostgreSQL + "mysql_connect": &object.Builtin{Fn: mysqlConnect}, // MySQL + "mongo_connect": &object.Builtin{Fn: mongoConnect}, // MongoDB + "redis_connect": &object.Builtin{Fn: redisConnect}, // Redis + + // Async + "ghumaao": &object.Builtin{Fn: ghumaaoSleep}, // sleep + "proyash_solve": &object.Builtin{Fn: proyashSolve}, // Promise.resolve + + // ... 135+ total +} +``` + +### AST Nodes +```go +// ast/ast.go +type LetStatement struct { + Token token.Token // DHORO token + Name *Identifier + Value Expression +} + +type IfExpression struct { + Token token.Token // JODI token + Condition Expression + Consequence *BlockStatement + Alternative *BlockStatement +} + +type FunctionLiteral struct { + Token token.Token // KAJ token + Parameters []*Identifier + Body *BlockStatement + Async bool // proyash flag +} +``` + +## Testing Requirements + +### Unit Tests +```go +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 +```go +// test/integration_test.go +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 +```go +// ✅ Validate file paths +func validatePath(path string) error { + if strings.Contains(path, "..") { + return fmt.Errorf("পথে '..' অনুমোদিত নয়") + } + return nil +} +``` + +### Safe Execution +```go +// ✅ Timeout for async operations +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 +1. Add to `lexer/token.go` keywords map +2. Add token type constant +3. Update parser to handle new syntax +4. Update evaluator for execution +5. Add tests +6. Update SYNTAX.md +7. Update VS Code extension syntax + +### When Adding Built-in Function +1. Implement in `evaluator/builtins.go` +2. Add to `builtins` map +3. Follow naming: Bengali verb (e.g., `dekho`, `dhokao`) +4. Add validation and error handling +5. Add tests +6. Document in SYNTAX.md +7. Add VS Code snippet + +### When Fixing Bugs +1. Write failing test +2. Fix bug +3. Verify test passes +4. Check for similar issues +5. 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 diff --git a/.codex/config.toml b/.codex/config.toml new file mode 100644 index 0000000..3023915 --- /dev/null +++ b/.codex/config.toml @@ -0,0 +1,50 @@ +# OpenAI Codex CLI Configuration for BanglaCode + +[project] +name = "BanglaCode" +description = "Educational Programming Language in Bengali" +language = "Go" +runtime = "Go ≥1.20" + +[model] +default = "gpt-4-turbo" +temperature = 0.2 + +[build] +command = "go build -o banglacode main.go" +required = true + +[test] +command = "go test ./..." +required = true + +[rules] +bengali_keywords = true +bengali_errors = true +compatibility = true +educational_focus = true + +[rules.naming] +keywords = "Bengali/Banglish" +builtins = "Bengali verbs" +errors = "Bengali messages" + +[documentation] +update_syntax = true +update_architecture = true +update_website = true +update_vscode_extension = true + +[antipatterns] +no_english_keywords = true +no_english_errors = true +no_breaking_changes = true + +[completion] +required = [ + "go build passes", + "go test passes", + "Existing programs work", + "SYNTAX.md updated", + "Bengali error messages" +] diff --git a/.cursor/rules/banglacode-core.mdc b/.cursor/rules/banglacode-core.mdc new file mode 100644 index 0000000..832ce41 --- /dev/null +++ b/.cursor/rules/banglacode-core.mdc @@ -0,0 +1,85 @@ +# BanglaCode Core Rules for Cursor IDE + +## Project Context + +**BanglaCode** - Educational Programming Language in Bengali (Go interpreter) + +## Mandatory Workflows + +```bash +go build -o banglacode main.go +go test ./... +go fmt ./... +go vet ./... +``` + +## Definition of "Done" + +- ✅ `go build` passes +- ✅ Tests pass +- ✅ Existing programs work +- ✅ SYNTAX.md updated +- ✅ Bengali error messages +- ✅ Docs updated + +## Architecture + +``` +Source → Lexer → Parser → AST → Evaluator → Result +``` + +## Components + +``` +src/ (lexer, parser, ast, object, evaluator, repl) +examples/ (BanglaCode programs) +Extension/ (VS Code extension) +``` + +## Go Standards + +### Errors (Bengali) +```go +// ✅ Bengali messages +if err != nil { + return newError("ভুল: %s", err.Error()) +} +``` + +### Type Safety +```go +// ✅ Safe assertions +intObj, ok := obj.(*object.Integer) +if !ok { + return newError("সংখ্যা প্রত্যাশিত") +} +``` + +## Key Patterns + +### Bengali Keywords +29 keywords: `dhoro` (let), `jodi` (if), `kaj` (function), `proyash` (async), `dol` (class), `ano` (import), `chesta` (try) + +### Built-ins +135+ functions: `dekho` (print), `dorghyo` (length), `http_server`, `postgres_connect`, `ghumaao` (sleep) + +## Testing + +- Unit: Lexer, parser, evaluator +- Integration: Full programs +- Examples: `examples/` directory + +## Anti-Patterns + +❌ English keywords +❌ Breaking programs +❌ Non-Bengali errors +❌ Missing docs + +## Success + +- ✅ Builds +- ✅ Tests pass +- ✅ Programs work +- ✅ Docs updated +- ✅ Bengali-friendly diff --git a/.gemini/settings.json b/.gemini/settings.json new file mode 100644 index 0000000..9bd4773 --- /dev/null +++ b/.gemini/settings.json @@ -0,0 +1,16 @@ +{ + "version": "1.0", + "project": { + "name": "BanglaCode", + "type": "Programming Language Interpreter", + "language": "Go", + "runtime": "Go ≥1.20" + }, + "context": { + "fileName": ["GEMINI.md", "SYNTAX.md"], + "hierarchical": true + }, + "tools": { + "enabled": ["codeSearch", "fileOperations", "shellCommands"] + } +} diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 97cbaee..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,128 +0,0 @@ -name: Bug Report -description: Report a bug in BanglaCode -title: "[Bug]: " -labels: ["bug", "needs-triage"] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to report a bug! Please fill out the form below. - - Before submitting, please search existing issues to avoid duplicates. - - - type: input - id: version - attributes: - label: BanglaCode Version - description: What version of BanglaCode are you using? - placeholder: "3.3.0" - validations: - required: true - - - type: dropdown - id: os - attributes: - label: Operating System - description: What operating system are you using? - options: - - Linux (Ubuntu/Debian) - - Linux (Fedora/RHEL) - - Linux (Arch) - - Linux (Other) - - macOS - - Windows 10 - - Windows 11 - - Other - validations: - required: true - - - type: input - id: go-version - attributes: - label: Go Version - description: What version of Go do you have installed? - placeholder: "1.21.5" - validations: - required: false - - - type: textarea - id: description - attributes: - label: Bug Description - description: A clear and concise description of what the bug is. - placeholder: Describe the bug... - validations: - required: true - - - type: textarea - id: reproduction - attributes: - label: Steps to Reproduce - description: Steps to reproduce the behavior. - placeholder: | - 1. Create a file with the following code... - 2. Run `./banglacode file.bang` - 3. See error... - validations: - required: true - - - type: textarea - id: code - attributes: - label: Code Sample - description: Minimal code that reproduces the issue. - render: banglacode - placeholder: | - dhoro x = 5; - // ... minimal code example - validations: - required: true - - - type: textarea - id: expected - attributes: - label: Expected Behavior - description: What did you expect to happen? - placeholder: Describe expected behavior... - validations: - required: true - - - type: textarea - id: actual - attributes: - label: Actual Behavior - description: What actually happened? - placeholder: Describe actual behavior... - validations: - required: true - - - type: textarea - id: error - attributes: - label: Error Message - description: If there's an error message, please paste it here. - render: shell - placeholder: | - Error [line X, col Y]: ... - validations: - required: false - - - type: textarea - id: additional - attributes: - label: Additional Context - description: Add any other context about the problem here. - validations: - required: false - - - type: checkboxes - id: checklist - attributes: - label: Checklist - options: - - label: I have searched existing issues to ensure this is not a duplicate - required: true - - label: I am using the latest version of BanglaCode - required: false - - label: I have included a minimal code example that reproduces the issue - required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 3030856..0000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,11 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: GitHub Discussions - url: https://github.com/nexoral/BanglaCode/discussions - about: Ask questions, share ideas, and connect with the community - - name: Documentation - url: https://banglacode.dev - about: Check out the documentation for guides and references - - name: Security Issues - url: https://github.com/nexoral/BanglaCode/security/advisories/new - about: Report security vulnerabilities privately diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml deleted file mode 100644 index f1388cf..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,132 +0,0 @@ -name: Feature Request -description: Suggest a new feature for BanglaCode -title: "[Feature]: " -labels: ["enhancement", "needs-triage"] -body: - - type: markdown - attributes: - value: | - Thanks for suggesting a feature! We appreciate your input in making BanglaCode better. - - Please search existing issues first to avoid duplicates. - - - type: dropdown - id: category - attributes: - label: Feature Category - description: What category does this feature belong to? - options: - - Language Feature (new keyword, syntax) - - Built-in Function - - Standard Library - - Performance - - Error Messages - - REPL Enhancement - - VSCode Extension - - Documentation - - Tooling (formatter, linter) - - Other - validations: - required: true - - - type: textarea - id: problem - attributes: - label: Problem Statement - description: Is your feature request related to a problem? Please describe. - placeholder: | - I'm frustrated when... - It would be easier if... - Currently, I have to... - validations: - required: true - - - type: textarea - id: solution - attributes: - label: Proposed Solution - description: Describe the solution you'd like. - placeholder: | - I would like to have... - This could work by... - validations: - required: true - - - type: textarea - id: syntax - attributes: - label: Proposed Syntax (if applicable) - description: If this is a language feature, show how it would look. - render: banglacode - placeholder: | - // Example of how the new feature would be used - dhoro result = newFeature(arg); - validations: - required: false - - - type: textarea - id: alternatives - attributes: - label: Alternatives Considered - description: Describe any alternative solutions you've considered. - placeholder: | - Other ways this could be done... - Workarounds I currently use... - validations: - required: false - - - type: textarea - id: use-cases - attributes: - label: Use Cases - description: Describe specific use cases for this feature. - placeholder: | - 1. When building a web application... - 2. When working with data... - 3. For educational purposes... - validations: - required: true - - - type: dropdown - id: breaking - attributes: - label: Breaking Change - description: Would this feature require breaking existing code? - options: - - "No - fully backwards compatible" - - "Maybe - some edge cases might break" - - "Yes - requires migration" - - "Not sure" - validations: - required: true - - - type: dropdown - id: contribution - attributes: - label: Willingness to Contribute - description: Would you be willing to help implement this feature? - options: - - "Yes, I can implement this" - - "Yes, I can help with guidance" - - "No, but I can test it" - - "No" - validations: - required: true - - - type: textarea - id: additional - attributes: - label: Additional Context - description: Add any other context, screenshots, or references. - validations: - required: false - - - type: checkboxes - id: checklist - attributes: - label: Checklist - options: - - label: I have searched existing issues to ensure this is not a duplicate - required: true - - label: I have considered the impact on existing code - required: true diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml deleted file mode 100644 index 8a98e2f..0000000 --- a/.github/ISSUE_TEMPLATE/question.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: Question -description: Ask a question about BanglaCode -title: "[Question]: " -labels: ["question"] -body: - - type: markdown - attributes: - value: | - Have a question about BanglaCode? We're here to help! - - **Note**: For general questions and discussions, consider using [GitHub Discussions](https://github.com/nexoral/BanglaCode/discussions) instead. - - - type: dropdown - id: topic - attributes: - label: Question Topic - description: What is your question about? - options: - - Installation / Setup - - Language Syntax - - Built-in Functions - - Module System - - Error Handling - - HTTP / Web Features - - VSCode Extension - - Performance - - Best Practices - - Other - validations: - required: true - - - type: textarea - id: question - attributes: - label: Your Question - description: Please describe your question in detail. - placeholder: | - I'm trying to understand... - How do I... - What is the best way to... - validations: - required: true - - - type: textarea - id: context - attributes: - label: Context - description: What are you trying to achieve? What have you already tried? - placeholder: | - I'm building... - I tried... - I expected... - validations: - required: false - - - type: textarea - id: code - attributes: - label: Related Code (if applicable) - description: If your question involves code, please share it. - render: banglacode - placeholder: | - dhoro x = 5; - // Your code here - validations: - required: false - - - type: input - id: version - attributes: - label: BanglaCode Version - description: What version are you using? - placeholder: "3.3.0" - validations: - required: false - - - type: checkboxes - id: checklist - attributes: - label: Checklist - options: - - label: I have checked the documentation (README.md, SYNTAX.md) - required: true - - label: I have searched existing issues and discussions - required: true diff --git a/.github/copilot/instructions.md b/.github/copilot/instructions.md new file mode 100644 index 0000000..ecfeb63 --- /dev/null +++ b/.github/copilot/instructions.md @@ -0,0 +1,112 @@ +# GitHub Copilot Instructions for BanglaCode + +## Project Overview + +**BanglaCode** - Educational Programming Language in Bengali +- **Language**: Go ≥1.20 +- **Type**: Tree-walking interpreter +- **Keywords**: 29 Bengali keywords (Banglish) +- **Built-ins**: 135+ functions +- **Target**: Bengali-speaking students and developers + +## Core Rules + +### 1. Bengali-First +All keywords must be Bengali/Banglish: +- `dhoro` (let), `jodi` (if), `kaj` (function) +- `proyash` (async), `dol` (class), `ano` (import) + +### 2. Error Messages in Bengali +```go +// ✅ GOOD +return newError("ভুল: %s", err.Error()) +return newError("%d লাইনে: অজানা ফাংশন '%s'", line, name) + +// ❌ BAD +return newError("Error: %s", err) +``` + +### 3. Compatibility +Don't break existing BanglaCode programs + +## Commands + +```bash +go build -o banglacode main.go +./banglacode examples/hello.bang +./banglacode # REPL +go test ./... +``` + +## Architecture + +``` +Source → Lexer → Parser → AST → Evaluator → Result + +src/ +├── lexer/ # Tokenization +├── parser/ # AST building +├── ast/ # Node types +├── object/ # Runtime types +├── evaluator/ # Execution +│ ├── builtins.go # 135+ functions +│ ├── async.go # Promises +│ ├── classes.go # OOP +│ └── modules.go # Import/export +└── repl/ # Interactive shell +``` + +## Go Standards + +### Error Handling +```go +// ✅ GOOD - Bengali context +if err != nil { + return newError("ভুল: %s", err.Error()) +} +``` + +### Type Safety +```go +// ✅ Safe assertions +intObj, ok := obj.(*object.Integer) +if !ok { + return newError("সংখ্যা প্রত্যাশিত, পেয়েছি: %s", obj.Type()) +} +``` + +## Key Features + +### 29 Bengali Keywords +`dhoro`, `jodi`, `nahole`, `kaj`, `firao`, `proyash`, `opekha`, `dol`, `notun`, `ei`, `ano`, `pathao`, `chesta`, `dhoro_bhul`, `shesh` + +### 135+ Built-in Functions +- I/O: `dekho`, `input` +- String/Array: `dorghyo`, `dhokao`, `chhino` +- HTTP: `http_server`, `http_get`, `http_post` +- Database: `postgres_connect`, `mysql_connect`, `mongo_connect`, `redis_connect` +- Async: `ghumaao`, `proyash_solve` + +## Documentation + +Update when features change: +- SYNTAX.md - Language reference +- ARCHITECTURE.md - Design docs +- Documentation/ - Website +- Extension/ - VS Code extension + +## Testing + +- Unit tests: Lexer, parser, evaluator +- Integration: Full programs +- Examples: `examples/` directory +- Cross-platform: Linux, macOS, Windows + +## Success Criteria + +- ✅ `go build` passes +- ✅ `go test ./...` passes +- ✅ Existing programs work +- ✅ Docs updated +- ✅ Bengali-friendly errors +- ✅ Cross-platform tested diff --git a/.github/copilot/settings.json b/.github/copilot/settings.json new file mode 100644 index 0000000..65a64aa --- /dev/null +++ b/.github/copilot/settings.json @@ -0,0 +1,58 @@ +{ + "version": "1.0", + "project": { + "name": "BanglaCode", + "type": "Programming Language Interpreter", + "language": "Go", + "runtime": "Go ≥1.20" + }, + "build": { + "command": "go build -o banglacode main.go", + "required": true + }, + "test": { + "command": "go test ./...", + "required": true + }, + "instructions": [ + "CRITICAL: All keywords must be Bengali/Banglish", + "CRITICAL: Error messages must be in Bengali", + "CRITICAL: Don't break existing BanglaCode programs", + "Use Bengali-friendly variable names in error contexts", + "Update SYNTAX.md for language changes", + "Update Documentation/ for user-facing changes", + "Update Extension/ for VS Code features", + "Safe type assertions with ok check", + "Test on Linux, macOS, Windows" + ], + "patterns": { + "bengaliKeywords": { + "description": "29 keywords in Banglish", + "examples": ["dhoro", "jodi", "kaj", "proyash", "dol", "ano"] + }, + "builtinFunctions": { + "description": "135+ built-in functions", + "naming": "Bengali verbs (dekho, dhokao, ghumaao)" + }, + "errorMessages": { + "description": "Error messages in Bengali", + "required": true + } + }, + "antiPatterns": [ + "Never use English keywords", + "Never use English-only error messages", + "Never break existing programs", + "Never skip Bengali documentation" + ], + "completionCriteria": { + "required": [ + "go build passes", + "go test passes", + "Existing programs work", + "SYNTAX.md updated", + "Bengali error messages", + "Cross-platform tested" + ] + } +} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..4c304e8 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,141 @@ +# AGENTS.md + +OpenAI Codex CLI Instructions for BanglaCode + +## Project Overview + +**BanglaCode** - Educational Programming Language in Bengali + +- **Language**: Go ≥1.20 +- **Type**: Tree-walking interpreter +- **Keywords**: 29 Bengali keywords (Banglish) +- **Built-ins**: 135+ functions +- **Purpose**: Accessible programming for Bengali speakers + +## Build Commands + +```bash +# Development +go build -o banglacode main.go +./banglacode examples/hello.bang +./banglacode # REPL + +# Test +go test ./... +go fmt ./... +go vet ./... + +# Cross-compile +GOOS=windows GOARCH=amd64 go build -o banglacode.exe . +``` + +## Core Principles + +### 1. Bengali-First +- All keywords in Banglish (Bengali in English script) +- Error messages in Bengali +- Documentation bilingual (English + Bengali) + +### 2. Educational Focus +- Clear, learnable syntax +- Comprehensive built-in functions +- Real-world capabilities (HTTP, DB, async) + +### 3. Compatibility +- Don't break existing programs +- Maintain keyword consistency +- Preserve built-in function signatures + +## Architecture + +### Interpreter Pipeline +``` +Source → Lexer → Parser → AST → Evaluator → Result +``` + +### Components +``` +src/ +├── lexer/ # Tokenization +├── parser/ # AST building +├── ast/ # Node types +├── object/ # Runtime types +├── evaluator/ # Execution +│ ├── builtins.go # 135+ functions +│ ├── async.go # Promises +│ ├── classes.go # OOP +│ ├── modules.go # Import/export +│ └── errors.go # Try/catch +└── repl/ # Interactive shell +``` + +## Go Standards + +### Error Handling +```go +// ✅ GOOD - Bengali messages +if err != nil { + return newError("ভুল: %s", err.Error()) +} + +// ✅ Context +return newError("%d লাইনে: অজানা চিহ্ন '%s'", node.Line, token) +``` + +### Type Safety +```go +// ✅ Type assertions +intObj, ok := obj.(*object.Integer) +if !ok { + return newError("সংখ্যা প্রত্যাশিত, পেয়েছি: %s", obj.Type()) +} +``` + +## Key Features + +### Keywords (29) +- `dhoro` (let), `jodi` (if), `kaj` (function) +- `proyash` (async), `opekha` (await) +- `dol` (class), `notun` (new), `ei` (this) +- `ano` (import), `pathao` (export) +- `chesta` (try), `dhoro_bhul` (catch) + +### Built-ins (135+) +- I/O: `dekho`, `input`, file operations +- String/Array: `dorghyo`, `dhokao`, `chhino` +- HTTP: `http_server`, `http_get`, `http_post` +- Database: PostgreSQL, MySQL, MongoDB, Redis +- Async: `ghumaao`, promises + +## Documentation + +Update when features change: +- README.md - Overview +- SYNTAX.md - Language reference +- ARCHITECTURE.md - Design +- Documentation/ - Website +- Extension/ - VS Code extension + +## Testing + +- Unit tests: Lexer, parser, evaluator +- Integration: Full programs +- Examples: `examples/` directory +- Cross-platform: Linux, macOS, Windows + +## Anti-Patterns + +❌ English keywords +❌ Breaking existing programs +❌ Non-Bengali error messages +❌ Missing documentation +❌ Generic errors + +## Success Criteria + +- ✅ `go build` passes +- ✅ `go test ./...` passes +- ✅ Existing programs work +- ✅ Docs updated +- ✅ Bengali-friendly errors +- ✅ Cross-platform tested diff --git a/Documentation/package.json b/Documentation/package.json index 01497f4..e902078 100644 --- a/Documentation/package.json +++ b/Documentation/package.json @@ -1,6 +1,6 @@ { "name": "documentation", - "version": "9.1.0", + "version": "9.2.0", "private": true, "scripts": { "dev": "next dev --turbopack", diff --git a/Extension/package.json b/Extension/package.json index 21e7c11..77f9b60 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "banglacode", "displayName": "BanglaCode", "description": "Language support for BanglaCode (.bang, .bangla, .bong) - Bengali Programming Language created by Ankan from West Bengal, India", - "version": "9.1.0", + "version": "9.2.0", "publisher": "AnkanSaha", "author": { "name": "AnkanSaha" diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 0000000..e5a659e --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,178 @@ +# GEMINI.md + +This file provides guidance to Gemini Code Assist when working with code in this repository. + +## Project Overview + +**BanglaCode** - Educational Programming Language in Bengali + +- **Language**: Go ≥1.20 +- **Type**: Tree-walking interpreter for Bengali-syntax programming +- **Platform**: Cross-platform (Linux, macOS, Windows) +- **Purpose**: Make programming accessible to 300+ million Bengali speakers + +## Commands + +```bash +# Build & Run +go build -o banglacode main.go +./banglacode examples/hello.bang +./banglacode # REPL + +# Test +go test ./... +go fmt ./... +go vet ./... + +# Cross-compile +GOOS=windows GOARCH=amd64 go build -o banglacode.exe . +GOOS=darwin GOARCH=arm64 go build -o banglacode . +``` + +## Core Rules (NON-NEGOTIABLE) + +1. **Bengali keywords**: Use Banglish (Bengali in English script) +2. **ALWAYS test**: Run test files after changes +3. **ALWAYS build**: `go build` after code changes +4. **Maintain compatibility**: Don't break existing BanglaCode programs +5. **Clear errors**: Bengali-friendly error messages +6. **Update docs**: README, SYNTAX.md, Documentation/ + +## Architecture + +### Interpreter Pipeline +``` +Source Code → Lexer → Parser → AST → Evaluator → Result +``` + +### Structure +``` +src/ +├── lexer/ # Tokenization (29 Bengali keywords) +├── parser/ # Pratt parsing, AST building +├── ast/ # Node definitions +├── object/ # Runtime types, Environment +├── evaluator/ # Tree-walking interpreter +│ ├── evaluator.go # Main Eval() switch +│ ├── builtins.go # 135+ built-in functions +│ ├── async.go # Async/await, promises +│ ├── classes.go # OOP support +│ ├── modules.go # Import/export +│ └── errors.go # Try/catch/finally +└── repl/ # Interactive shell + +examples/ # BanglaCode example programs +test/ # Test files +Extension/ # VS Code extension +``` + +## Go Standards + +### Error Handling +```go +// ✅ GOOD +if err != nil { + return newError("ভুল: %s", err.Error()) +} + +// ❌ BAD +if err != nil { + return nil +} +``` + +### Type Safety +```go +// ✅ Use object types +type Integer struct { + Value int64 +} + +// ✅ Type assertions +intObj, ok := obj.(*object.Integer) +if !ok { + return newError("সংখ্যা প্রত্যাশিত") +} +``` + +## Key Patterns + +### Bengali Keywords +```go +// Token definitions in lexer/token.go +var keywords = map[string]TokenType{ + "dhoro": LET, // let/var + "jodi": IF, // if + "nahole": ELSE, // else + "kaj": FUNCTION, // function + "firao": RETURN, // return + "proyash": ASYNC, // async + "opekha": AWAIT, // await + // ... 29 keywords total +} +``` + +### Built-in Functions +```go +// evaluator/builtins.go +var builtins = map[string]*object.Builtin{ + "dekho": &object.Builtin{Fn: dekhoPrint}, // print + "dorghyo": &object.Builtin{Fn: dorghyoLength}, // length + "dhokao": &object.Builtin{Fn: dhokaoPush}, // push + // ... 135+ functions +} +``` + +### Error Messages +```go +// ✅ Bengali-friendly errors +return newError("'%s' চিহ্ন অপারেটর সমর্থন করে না: %s", operator, left.Type()) + +// ✅ Context in errors +return newError("%d লাইনে: অজানা ফাংশন '%s'", node.Line, fn.Name) +``` + +## Documentation + +Update when features change: +- README.md - Overview, installation, usage +- SYNTAX.md - Language syntax reference +- ARCHITECTURE.md - Interpreter design +- Documentation/ - Website docs +- Extension/ - VS Code extension features + +## Testing + +- Unit tests for lexer, parser, evaluator +- Integration tests for full programs +- Example programs in `examples/` +- REPL testing +- Cross-platform testing + +## Bengali Language Features + +### Keywords (29 total) +- Variables: `dhoro`, `sthir`, `protiti` +- Control: `jodi`, `nahole`, `jokhon`, `bhango` +- Functions: `kaj`, `firao`, `proyash`, `opekha` +- OOP: `dol`, `notun`, `ei`, `super` +- Modules: `ano`, `theke`, `pathao`, `hisabe` +- Error: `chesta`, `dhoro_bhul`, `shesh`, `chhar` + +### Built-in Functions (135+) +- I/O: `dekho`, `input`, `file_lekho`, `file_poro` +- String: `dorghyo`, `boro_hater`, `choto_hater` +- Array: `dhokao`, `chhino`, `jog_koro`, `filter_koro` +- Math: `gononaa`, `bolod`, `muladhon`, `ghuriye` +- HTTP: `http_server`, `http_get`, `http_post` +- Database: `postgres_connect`, `mysql_connect`, `mongo_connect` +- Async: `ghumaao`, `somoy_dekhao`, `proyash_solve` + +## Definition of "Done" + +- ✅ `go build` passes +- ✅ `go test ./...` passes +- ✅ Existing BanglaCode programs work +- ✅ Documentation updated +- ✅ Error messages in Bengali +- ✅ Cross-platform tested diff --git a/VERSION b/VERSION index 47da986..deeb3d6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -9.1.0 +9.2.0 diff --git a/main.go b/main.go index 4a0fcbc..51df087 100644 --- a/main.go +++ b/main.go @@ -82,10 +82,10 @@ func printHelp() { func printVersion() { fmt.Println("\033[1;36m╔════════════════════════════════════════════════════════╗") - fmt.Println("║ BanglaCode v9.1.0 ║") + fmt.Println("║ BanglaCode v9.2.0 ║") fmt.Println("║ A Programming Language in Bengali (Banglish) ║") fmt.Println("╠════════════════════════════════════════════════════════╣\033[0m") - fmt.Println("\033[1;36m║\033[0m 📦 \033[1mVersion:\033[0m \033[1;32m9.1.0\033[0m \033[1;36m║\033[0m") + fmt.Println("\033[1;36m║\033[0m 📦 \033[1mVersion:\033[0m \033[1;32m9.2.0\033[0m \033[1;36m║\033[0m") fmt.Println("\033[1;36m║\033[0m 👨‍💻 \033[1mAuthor:\033[0m \033[1;35mAnkan Saha\033[0m \033[1;36m║\033[0m") fmt.Println("\033[1;36m║\033[0m 🌍 \033[1mFrom:\033[0m \033[1;37mWest Bengal, India\033[0m \033[1;36m║\033[0m") fmt.Println("\033[1;36m║\033[0m 🔗 \033[1mGitHub:\033[0m \033[1;34mhttps://github.com/nexoral/BanglaCode\033[0m \033[1;36m║\033[0m") diff --git a/src/repl/repl.go b/src/repl/repl.go index 80ced73..e93b36d 100644 --- a/src/repl/repl.go +++ b/src/repl/repl.go @@ -12,7 +12,7 @@ import ( "strings" ) -const Version = "9.1.0" +const Version = "9.2.0" const PROMPT = "\033[1;33m>> \033[0m"