Overview
This custom programming language is a small, interpreted language built from scratch using Python. (took me 50+ hours)
The language uses core compiler/interpreter concepts including lexical analysis, parsing, and interpretation.
Language Processing Pipeline
Language Syntax
Basic Syntax Rules
Element | Syntax | Description |
---|---|---|
Comments | # This is a comment |
Single line comments using the # symbol |
Integer Declaration | age = int(15) |
Declare and initialize an integer variable |
String Declaration | name = string("Jim") |
Declare and initialize a string variable |
Output Statement | say("Hello World") |
Print text or variable values to output |
Variable Output | say(variableName) |
Print the value of a variable |
Code Examples
Hello World Program
say("Hello, World!")
Variable Declaration and Usage
age = int(16)
name = string("Alice")
# Output variables
say(name)
say(age)
Technical Architecture
Lexer (Tokenizer)
Reads the code and splits it into pieces called tokens, like words and symbols.
Parser
Uses these tokens to build a tree that shows the program’s structure.
Interpreter
Walks through the tree and runs the program step-by-step.
Symbol Table
Keeps track of variables, their types, and current values while the program runs.
Token Types
The lexer recognizes the following token types:
- Keywords: int, string
- Identifiers: Variable names
- Literals: String literals, integer literals
- Operators: Assignment (=)
- Delimiters: Parentheses, quotes
- Functions: say
- Comments: Lines starting with #
Getting Started
Requirements
This project requires NO pip imports!
To run programs in this custom language, you need:
- Python 3.6 or higher installed on your system
- The github repository cloned
- A text editor to write your programs
Running Your First Program
Follow these steps to create and run your first program:
# 2. Write your program:
say("Hello from my custom language!")
# 3. Run using the python file:
# python run.py hello.txt
Debug Mode
Enable debug mode to see how your program is processed:
