amr-lang
v1.0.8
Published
A simple programming language with bilingual support (English & Arabic)
Downloads
854
Maintainers
Readme
AMR Lang 🚀
A simple programming language with support for both English and Arabic keywords.
Installation
Install globally from npm
npm install -g amr-langOr install locally in your project
npm install amr-langUsage
Running AMR files
# Run a specific file
amr example.amr
amr test.amr
amr yourfile.amr
# Run the default file (example.amr)
amrAlternative methods
# Using npm scripts
npm start # Runs example.amr
amr myfile.amr # Runs any fileLanguage Syntax
Variables
let x : 10
let name : 5
خلي y : 20Print Output
show x
show x + 5
اطبع yArithmetic Operations
show 10 + 5 # Addition
show 10 - 5 # Subtraction
show 10 * 5 # Multiplication
show 10 / 5 # DivisionComparison Operations
show 10 > 5 # Greater than
show 5 < 10 # Less thanFunctions
make add(a, b) {
return a + b
}
show add(10, 20)
# Arabic version
اعمل multiply(x, y) {
رجع x * y
}Conditional Statements
let age : 18
when age > 17 {
show 1
}
when age > 21 {
show 100
} otherwise {
show 0
}
# Arabic version
لو age > 17 {
اطبع 1
} لولا {
اطبع 0
}While Loops
let counter : 5
loop counter > 0 {
show counter
let counter : counter - 1
}
# Arabic version
كرر counter > 0 {
اطبع counter
}Comments
# This is a comment
show 10 # Inline commentKeywords
English Keywords
let- Variable declarationshow- Print outputmake- Function declarationreturn- Return from functionwhen- If statementotherwise- Else statementloop- While loop
Arabic Keywords (عربي)
خلي- Variable declaration (let)اطبع- Print output (show)اعمل- Function declaration (make)رجع- Return from function (return)لو- If statement (when)لولا- Else statement (otherwise)كرر- While loop (loop)
Example Programs
Example 1: Basic Operations
let x : 10
let y : 5
show x + y
show x * yExample 2: Factorial Function
make factorial(n) {
when n < 2 {
return 1
}
return n * factorial(n - 1)
}
show factorial(5) # Output: 120Example 3: Mixed English & Arabic
خلي x : 10
let y : 5
اطبع x + y
show x * yProject Structure
My-Lang/
├── src/
│ ├── index.ts # Entry point
│ ├── lexer.ts # Tokenizer
│ ├── parser.ts # Parser
│ ├── interpreter.ts # Interpreter
│ ├── ast.ts # AST definitions
│ ├── environment.ts # Variable environment
│ └── run.ts # Runner
├── bin/
│ └── amr.js # CLI executable
├── example.amr # Example program
├── test.amr # Test program
└── package.jsonDevelopment
# Run in development mode
npm start
# Run a specific file
amr yourfile.amrFeatures
✅ Variable declarations
✅ Arithmetic operations (+, -, *, /)
✅ Comparison operations (>, <)
✅ Function declarations and calls
✅ Conditional statements (if/else)
✅ While loops
✅ Comments
✅ Bilingual support (English & Arabic)
✅ Recursive functions
✅ Proper operator precedence
License
MIT
Author
Amr Elsherbiny
