GreyMatter is an experimental programming language developed in Python with the goal of helping students and developers understand how programming languages work internally. The language demonstrates fundamental concepts behind interpreters, lexical analysis, parsing, syntax evaluation, and runtime execution.
Unlike production programming languages that prioritize performance and large ecosystems, GreyMatter focuses on simplicity, experimentation, and educational exploration. The syntax is intentionally designed to be simple and expressive so that beginners can easily understand how a custom programming language behaves.
GreyMatter includes many core programming constructs such as variables, arithmetic operations, conditionals, loops, functions, and built-in utilities. The interpreter processes user code through several internal steps including tokenization, parsing, abstract syntax tree construction, and execution.
The project is implemented in Python and uses SLY for building the lexer and parser components of the interpreter.
GreyMatter is primarily intended for:
- Learning programming language design
- Understanding interpreter development
- Exploring syntax parsing techniques
- Experimenting with custom programming languages
- Educational demonstrations for computer science students
The concept and name of GreyMatter were inspired by the highly intelligent alien Grey Matter from the animated television series Ben 10.
In the Ben 10 universe, Grey Matter represents intelligence, analytical thinking, and problem solving. This programming language was created with a similar philosophy: encouraging logical thinking and experimentation through programming.
Many built-in functions in the GreyMatter language are named after alien characters and abilities from the Ben 10 universe. These names symbolize the different abilities and operations the language can perform.
The GreyMatter project was designed with the following goals:
• Demonstrate how programming languages are implemented • Provide an educational interpreter written in Python • Help students learn parsing and syntax evaluation • Encourage experimentation with programming language design • Combine creativity with programming concepts
GreyMatter is implemented using the following technologies:
| Technology | Purpose |
|---|---|
| Python | Core interpreter implementation |
| SLY | Lexer and parser construction |
| AST Model | Program execution structure |
| Python Standard Library | Utility functions |
GreyMatter includes the following features:
- Dynamic variables
- Arithmetic expressions
- Conditional logic
- Logical operators
- Loop structures
- User-defined functions
- Built-in utility functions
- String manipulation
- Time utilities
- Memory storage utilities
- Experimental web and AI query features
x = 10 y = 20 z = x + y PRINT(z)Output
30 Variables in GreyMatter are dynamically typed. They are automatically created when a value is assigned.
Example
name = "Abinesh" age = 21 score = 95Example program
name = INPUT("Enter your name: ") PRINT("Hello", name)GreyMatter supports basic mathematical operations.
| Operator | Description |
|---|---|
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| % | Modulus |
Example
x = 10 y = 3 PRINT(x + y) PRINT(x - y) PRINT(x * y) PRINT(x / y) PRINT(x % y)Output
13 7 30 3.33 1 GreyMatter allows increment and decrement operators.
Example
x = 5 x++ PRINT(x)Output
6 Example
x = 10 x-- PRINT(x)Output
9 Compound assignments simplify arithmetic updates.
Example
x = 10 x += 5 PRINT(x)Output
15 Other operators
x -= 3 x *= 2 x /= 4 x %= 3The PRINT function displays output to the console.
Example
PRINT("Welcome to GreyMatter")Example with variables
name = "Developer" PRINT("Hello", name)Output
Hello Developer INPUT reads text input from the user.
Example
name = INPUT("Enter your name: ") PRINT(name)Converts a value to an integer.
Example
age = INT(INPUT("Enter your age: ")) PRINT(age)Converts a value to a string.
Example
number = 100 text = STR(number) PRINT(text)GreyMatter supports conditional logic using IF and ELSE.
Example
age = INT(INPUT("Enter age: ")) IF(age >= 18){ PRINT("Eligible to vote") } ELSE{ PRINT("Not eligible") }| Operator | Description |
|---|---|
| == | Equal |
| != | Not Equal |
| > | Greater Than |
| < | Less Than |
| >= | Greater Than or Equal |
| <= | Less Than or Equal |
Example
x = 10 y = 5 IF(x > y){ PRINT("x is greater") }| Operator | Meaning |
|---|---|
| AND | Logical AND |
| OR | Logical OR |
Example
x = 10 y = 20 IF(x > 5 AND y < 30){ PRINT("Condition satisfied") }Example
x = 1 WHILE(x <= 5){ PRINT(x) x++ }Output
1 2 3 4 5 Example
FOR(i = 0 ; i <= 5 ; i++){ PRINT(i) }Short loop example
FOR(3){ PRINT("GreyMatter") }Output
GreyMatter GreyMatter GreyMatter Functions allow code reuse.
Example
FUNCTION add(x,y){ result = x + y FEEDBACK(result) }Calling function
sum = add(5,6) PRINT(sum)Output
11 FEEDBACK returns values from functions.
Example
FUNCTION square(x){ FEEDBACK(x*x) }Example call
PRINT(square(4))Output
16 Many functions in GreyMatter are named after alien abilities from the Ben 10 universe.
Prints a blank line.
Example
PRINT("Hello") ECHO PRINT("World")Prints multiple blank lines.
Example
PRINT("Start") ECHOECHO PRINT("End")Returns length of a string.
Example
text = "GreyMatter" PRINT(LEN(text))Output
10 Returns character at a given index.
Example
word = "hello" PRINT(word.FASTTRACK(1))Output
e Converts text to uppercase.
Example
text = "hello" PRINT(text.WAYBIG())Output
HELLO Converts text to lowercase.
Example
text = "HELLO" PRINT(text.NANOMECH())Output
hello Checks whether text is uppercase.
Example
text = "HELLO" PRINT(text.ISWAYBIG())Output
True Checks whether text is lowercase.
Example
text = "hello" PRINT(text.ISNANOMECH())Output
True Pauses program execution.
Example
PRINT("Start") PARADOX.SLEEP(3) PRINT("End")Returns system time.
Example
PRINT(PARADOX.UNITIME())Returns system date.
Example
PRINT(PARADOX.UNIDATE())BRAINSTORM is a simple data storage system inside GreyMatter.
Stores value in memory.
Example
BRAINSTORM.READ(10) BRAINSTORM.READ(20)Writes value to memory.
Example
BRAINSTORM.WRITE(x)Retrieves stored data.
Example
BRAINSTORM.GET()Executes fast interpreter commands.
Example
JETRAY("system_task")Example
PRINT(@WEB_SEARCH "Python programming language")Example
PRINT(@AI "Explain machine learning")Stops loop execution.
Example
WHILE(1){ PRINT("Running") BREAK }GreyMatter supports two comment formats.
Example
# this is a comment #Example
// this is another comment //| Function | Description | Example |
|---|---|---|
| PRINT() | Display output | PRINT("Hello") |
| INPUT() | Get user input | name = INPUT("Name") |
| INT() | Convert to integer | age = INT(INPUT()) |
| STR() | Convert to string | STR(100) |
| LEN() | Get string length | LEN("hello") |
| FASTTRACK() | Character index access | word.FASTTRACK(1) |
| WAYBIG() | Convert to uppercase | text.WAYBIG() |
| NANOMECH() | Convert to lowercase | text.NANOMECH() |
| ISWAYBIG() | Check uppercase | text.ISWAYBIG() |
| ISNANOMECH() | Check lowercase | text.ISNANOMECH() |
| ECHO | Blank line | ECHO |
| ECHOECHO | Multiple blank lines | ECHOECHO |
| PARADOX.SLEEP() | Pause program | PARADOX.SLEEP(5) |
| PARADOX.UNITIME() | Get system time | PARADOX.UNITIME() |
| PARADOX.UNIDATE() | Get system date | PARADOX.UNIDATE() |
| BRAINSTORM.READ() | Store value | BRAINSTORM.READ(x) |
| BRAINSTORM.WRITE() | Write memory value | BRAINSTORM.WRITE(x) |
| BRAINSTORM.GET() | Retrieve stored values | BRAINSTORM.GET() |
| JETRAY() | Execute fast operation | JETRAY(cmd) |
| @WEB_SEARCH | Web search query | @WEB_SEARCH "Python" |
| @AI | AI query system | @AI "Explain AI" |
| BREAK | Exit loop | BREAK |
| FUNCTION | Define function | FUNCTION add(x,y) |
| FEEDBACK | Return value | FEEDBACK(x+y) |
GreyMatter follows a traditional interpreter architecture:
- Lexical Analysis (Tokenization)
- Syntax Parsing
- Abstract Syntax Tree (AST) Generation
- Runtime Execution Engine
This architecture allows the interpreter to process and execute GreyMatter programs dynamically.
GreyMatter helps developers learn:
- Programming language design
- Interpreter construction
- Parsing techniques
- Runtime evaluation
- Custom language experimentation
Abinesh N
GitHub https://github.com/Abineshabee