- HTML 56.4%
- Python 43.6%
| ide | ||
| Tests | ||
| website | ||
| debug_lexer.py | ||
| debug_parser.py | ||
| interpreter.py | ||
| lexer.py | ||
| main.py | ||
| parser.py | ||
| pynchi_ast.py | ||
| README.md | ||
Panchi Programming Language
A lightweight interpreted programming language with a simple syntax, dynamic typing, functions, control flow, object-oriented programming, modules, and built-in file operations.
Table of Contents
- 1. Overview
- 2. Language Philosophy
- 3. Installation and Execution
- 4. Hello World
- 5. Lexical Structure
- 6. Variables and Assignment
- 7. Data Types
- 8. Operators
- 9. Output
- 10. Input
- 11. Conditional Statements
- 12. Loops
- 13. Functions
- 14. Return Values
- 15. Lists
- 16. Modules
- 17. Object-Oriented Programming
- 18. Built-in Functions
- 19. File Operations
- 20. Truthiness
- 21. Errors and Exceptions
- 22. Execution Model
- 23. Panchi IDE
- 24. File Extensions
- 25. Complete Examples
- 26. Language Reference Summary
- 27. Current Implementation Notes
- 28. License
1. Overview
Panchi is a dynamically typed, interpreted programming language designed with a compact syntax and a straightforward execution model.
The language provides:
- Dynamic variables.
- Numbers and strings.
- Boolean values and
None. - Arithmetic and comparison operators.
- Logical operators.
- Conditional execution.
whileandforloops.breakandcontinue.- User-defined functions.
- Return values.
- Lists.
- Built-in functions.
- File input and output.
- Built-in modules.
- Classes and objects.
- Methods and constructors.
- Static class variables.
- Single inheritance.
- A graphical IDE implemented with Python and Tkinter.
A Panchi program is processed through the following pipeline:
Source Code
│
▼
Lexical Analysis
│
▼
Token Stream
│
▼
Parsing
│
▼
Abstract Syntax Tree (AST)
│
▼
Interpretation
│
▼
Program Output
The provided development tools demonstrate this pipeline by tokenizing source code, parsing it into an AST, and executing it through the interpreter.
2. Language Philosophy
Panchi is designed around the following principles:
- Simple syntax — programs should be easy to read and write.
- Dynamic typing — variables do not require explicit type declarations.
- Interpreted execution — source code is executed by the Panchi interpreter.
- Incremental language design — core procedural programming features are combined with object-oriented features.
- Practical built-ins — common operations such as input, conversion, collections, and file operations are available directly from the language runtime.
3. Installation and Execution
Panchi is implemented using Python.
The interpreter consists of the following major components:
lexer.py Lexical analysis
parser.py Syntax analysis and AST construction
pynchi_ast.py AST node definitions
interpreter.py Runtime execution
A typical execution pipeline is:
lexer = Lex(code)
tokens = lexer.tokenize()
parser = Parser(tokens)
ast = parser.parse()
interpreter = Interpreter()
interpreter.interpret(ast)
The interpreter evaluates the parsed AST statement by statement.
4. Hello World
The simplest Panchi program is:
PANCHI "Hello, World!"
Output:
Hello, World!
PANCHI is the language's output operator.
A standard function example is:
def greet(name):
PANCHI "Hello, " + name + "!"
greet("World")
The language tooling uses this form as a basic function example.
5. Lexical Structure
5.1 Identifiers
Identifiers are names used for variables, functions, classes, and other program entities.
Examples:
name := "Panchi"
age := 17
result := 42
Common identifier examples:
name
age
result
my_function
Person
5.2 String Literals
Strings are enclosed in double quotation marks:
message := "Hello"
String concatenation is performed with +:
name := "Alice"
PANCHI "Hello, " + name
Output:
Hello, Alice
When either operand of + is a string, the runtime converts the other operand to a string and performs concatenation.
5.3 Numeric Literals
Panchi supports numeric values, including integers and floating-point values:
integer_value := 42
decimal_value := 3.14
The interpreter preserves numeric values as runtime numbers and supports arithmetic operations on them.
5.4 Comments
Comments are supported by the development environment examples using the # prefix:
# This is a comment
PANCHI "Hello"
6. Variables and Assignment
Variables are created with the := assignment operator:
name := "Panchi"
age := 17
Variables do not require explicit type declarations.
A variable may contain different types of values during execution:
value := 10
value := "Now a string"
Assignment expressions evaluate the right-hand side and store the resulting value under the specified variable name.
7. Data Types
Panchi is dynamically typed.
7.1 Numbers
integer_value := 10
float_value := 3.14
Supported numeric operations include:
a := 10
b := 3
PANCHI a + b
PANCHI a - b
PANCHI a * b
PANCHI a / b
PANCHI a // b
PANCHI a % b
PANCHI a ** b
7.2 Strings
text := "Panchi"
Strings support concatenation:
greeting := "Hello, " + "World!"
PANCHI greeting
Strings can also be repeated using multiplication by an integer:
text := "Panchi" * 3
7.3 Booleans
Panchi provides the built-in boolean values:
True
False
Example:
is_ready := True
is_finished := False
7.4 None
None represents the absence of a value:
value := None
7.5 Lists
Lists are ordered collections of values:
numbers := [1, 2, 3, 4, 5]
Lists may contain expressions:
x := 10
values := [x, x + 1, x + 2]
List concatenation is supported:
a := [1, 2]
b := [3, 4]
combined := a + b
List repetition is supported:
values := [0] * 5
8. Operators
8.1 Arithmetic Operators
| Operator | Description |
|---|---|
+ |
Addition or string/list concatenation |
- |
Subtraction |
* |
Multiplication or repetition |
/ |
Division |
// |
Floor division |
% |
Modulo |
** |
Exponentiation |
Example:
x := 10
y := 3
PANCHI x + y
PANCHI x - y
PANCHI x * y
PANCHI x / y
PANCHI x // y
PANCHI x % y
PANCHI x ** y
Division by zero raises a runtime error.
8.2 Comparison Operators
| Operator | Description |
|---|---|
== |
Equal |
!= |
Not equal |
< |
Less than |
> |
Greater than |
<= |
Less than or equal |
>= |
Greater than or equal |
Example:
x := 10
y := 20
PANCHI x == y
PANCHI x != y
PANCHI x < y
PANCHI x > y
PANCHI x <= y
PANCHI x >= y
Comparison expressions return boolean values.
8.3 Logical Operators
Panchi supports:
and
or
not
Examples:
a := True
b := False
result1 := a and b
result2 := a or b
result3 := not a
and and or use short-circuit evaluation.
8.4 Unary Operators
The following unary operators are supported:
+
-
not
Examples:
x := -10
y := +10
result := not False
9. Output
The PANCHI operator prints a value:
PANCHI "Hello"
Expressions can be printed:
x := 10
PANCHI x + 5
Strings and other values may be combined:
name := "Panchi"
version := 1
PANCHI "Language: " + name
PANCHI "Version: " + version
The interpreter evaluates the expression and sends the resulting value to standard output.
The built-in print() function is also available:
print("Hello")
10. Input
User input is read with input():
name := input("Enter your name: ")
PANCHI name
The optional argument is displayed as a prompt.
The built-in input function prints the prompt and returns the value entered by the user.
11. Conditional Statements
Panchi supports conditional execution with if and else.
Example:
age := 20
if age >= 18:
PANCHI "Adult"
else:
PANCHI "Minor"
The condition is evaluated using Panchi truthiness rules.
The interpreter executes the then block when the condition is truthy and the else block otherwise.
12. Loops
12.1 while
A while loop repeatedly executes its body while its condition is truthy:
count := 0
while count < 5:
PANCHI count
count := count + 1
12.2 for
A for loop iterates over an iterable value:
for item in [1, 2, 3]:
PANCHI item
The built-in range() function can be used for numeric iteration:
for i in range(5):
PANCHI i
The interpreter evaluates the iterable and assigns each item to the loop variable.
12.3 break
break terminates the nearest active loop:
while True:
break
12.4 continue
continue skips the remaining statements in the current iteration:
for i in range(10):
continue
The runtime implements loop control using dedicated break and continue control-flow exceptions.
13. Functions
Functions are declared using def:
def greet(name):
PANCHI "Hello, " + name
greet("World")
Functions may accept multiple parameters:
def add(a, b):
return a + b
result := add(10, 20)
PANCHI result
Functions are dynamically represented at runtime and retain their definition environment as a closure.
13.1 Function Arguments
The number of arguments must match the number of declared parameters.
def greet(name):
PANCHI name
greet("Alice")
An incorrect number of arguments produces a runtime error.
13.2 Function Scope
Function calls create a local execution scope.
Example:
x := 10
def test():
x := 20
PANCHI x
test()
PANCHI x
The function executes using a local scope containing its captured environment and parameters.
14. Return Values
Functions return values using return:
def square(x):
return x * x
result := square(5)
PANCHI result
A function may return no explicit value:
def greet():
PANCHI "Hello"
In that case, the function result is None.
Using return outside a function results in a runtime error.
15. Lists
Lists are created with square brackets:
numbers := [1, 2, 3]
Lists can be iterated:
for number in [1, 2, 3]:
PANCHI number
Lists support:
a := [1, 2]
b := [3, 4]
combined := a + b
repeated := a * 3
The runtime evaluates every list element and constructs a native list value.
16. Modules
Panchi provides built-in modules through the import mechanism.
Currently supported built-in modules are:
math
os
json
16.1 Math Module
import math
Available members include:
math.pi
math.e
math.sqrt
math.sin
math.cos
math.tan
math.log
math.exp
math.pow
math.floor
math.ceil
math.abs
Example:
import math
result := math.sqrt(25)
PANCHI result
The module is backed by the Python math library.
16.2 OS Module
import os
Available operations include:
os.getcwd()
os.listdir()
os.mkdir()
os.remove()
os.rename()
os.path_exists()
os.path_isdir()
os.path_isfile()
Example:
import os
PANCHI os.getcwd()
16.3 JSON Module
import json
Available operations include:
json.dumps()
json.loads()
json.dump()
json.load()
Example:
import json
data := json.dumps([1, 2, 3])
PANCHI data
Only the built-in modules recognized by the interpreter can currently be imported. An unknown module raises a runtime error.
17. Object-Oriented Programming
Panchi supports classes, objects, methods, properties, constructors, static variables, and inheritance.
17.1 Class Definition
A class is declared with class:
class Person:
name := "Unknown"
The runtime represents a class as a PuchiClass containing methods, static variables, and an optional parent class.
17.2 Object Creation
Objects are created with new:
person := new Person()
The interpreter creates a runtime object associated with the class definition.
17.3 Methods
Methods are functions defined inside classes:
class Person:
def greet(self):
PANCHI "Hello"
person := new Person()
person.greet()
Methods receive an implicit self object context.
17.4 Constructors
A method named init is used as the object initialization method:
class Person:
def init(self, name):
self.name := name
person := new Person("Alice")
When an object is created, the interpreter looks for an init method and calls it when present.
17.5 Properties
Properties may be accessed with dot notation:
person.name
The runtime supports object fields and class-level static variables.
17.6 Static Variables
A class may contain static values:
class Config:
version := 1
Static variables are associated with the class definition rather than an individual object.
17.7 Inheritance
Classes may inherit from another class:
class Animal:
def speak(self):
PANCHI "Animal"
class Dog(Animal):
def bark(self):
PANCHI "Woof"
The runtime searches the parent class when a method is not found in the child class.
18. Built-in Functions
The interpreter provides the following built-in functions.
print
Prints one or more values:
print("Hello")
len
Returns the length of an object:
length := len([1, 2, 3])
range
Creates a numeric range:
numbers := range(5)
int
Converts a value to an integer:
value := int("42")
float
Converts a value to a floating-point number:
value := float("3.14")
str
Converts a value to a string:
text := str(42)
type
Returns a runtime type representation:
result := type(42)
abs
Returns the absolute value:
value := abs(-10)
min
Returns the minimum value:
value := min(3, 1, 2)
max
Returns the maximum value:
value := max(3, 1, 2)
sum
Returns the sum of an iterable:
total := sum([1, 2, 3])
list
Converts an iterable to a list:
values := list(range(5))
The built-in runtime initializes these functions when an Interpreter instance is created.
19. File Operations
Panchi provides built-in file functions.
read_file
Reads the contents of a file:
content := read_file("data.txt")
PANCHI content
write_file
Writes content to a file:
write_file("data.txt", "Hello, Panchi!")
Existing content is replaced.
append_file
Appends content to a file:
append_file("data.txt", "\nAdditional content")
file_exists
Checks whether a file exists:
exists := file_exists("data.txt")
delete_file
Deletes a file:
delete_file("data.txt")
File operation errors are converted into runtime errors with descriptive messages.
20. Truthiness
Panchi uses truthiness when evaluating conditions.
The following values are false:
None
False
0
""
[]
Other values are considered true.
Examples:
if 0:
PANCHI "Not executed"
if "Panchi":
PANCHI "Executed"
The interpreter implements these truthiness rules directly in the runtime.
21. Errors and Exceptions
Panchi distinguishes between syntax and runtime failures.
Syntax Errors
A syntax error occurs when source code cannot be parsed correctly.
Example IDE output:
Syntax Error: ...
Runtime Errors
A runtime error occurs during program execution.
Examples include:
Variable 'x' is not defined
Division by zero!
Function 'foo' expects 2 arguments, got 1
Module 'unknown' not found
Class 'Unknown' not found
The IDE displays syntax errors and runtime errors separately.
22. Execution Model
Panchi uses an interpreted execution model.
Step 1: Lexical Analysis
Source code is converted into tokens:
Source Code → Tokens
Step 2: Parsing
The token stream is converted into an Abstract Syntax Tree:
Tokens → AST
Step 3: Interpretation
The interpreter evaluates AST nodes:
AST → Runtime Values and Side Effects
Supported runtime AST categories include:
- Numbers.
- Strings.
- Variables.
- Unary expressions.
- Binary expressions.
- Assignments.
- Function definitions.
- Function calls.
- Return statements.
- Conditional statements.
whileloops.forloops.break.continue.- Lists.
- Imports.
- Class definitions.
- Object construction.
- Method calls.
- Property access.
The interpreter dispatches execution based on the AST node type.
23. Panchi IDE
Panchi includes a graphical IDE implemented with Python and Tkinter.
The IDE provides:
- Code editing.
- Syntax highlighting.
- File creation.
- File opening.
- File saving.
- Program execution.
- AST inspection.
- Token inspection.
- Output display.
- Variable inspection.
- Built-in examples.
- Built-in documentation.
- Keyboard shortcuts.
The IDE title identifies the application as Pynchi IDE and provides an editor, output view, variables view, and examples view.
23.1 Run Program
Press:
F5
or use:
Run → Run
The IDE executes the full pipeline:
Lexing
↓
Parsing
↓
AST Construction
↓
Interpretation
The program output is displayed in the Output tab.
23.2 Show AST
The IDE can display the generated Abstract Syntax Tree:
Run → Run and Show AST
The AST is generated after lexical analysis and parsing, before interpretation.
23.3 Show Tokens
The IDE can display the token stream:
Run → Run and Show Tokens
The tokens are produced by the lexer before parsing.
23.4 Variable Viewer
After successful execution, the IDE displays global runtime variables in the Variables tab.
The viewer displays:
Variable Name
Value
The interpreter exposes its global variable environment to the IDE.
23.5 Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+N |
New file |
Ctrl+O |
Open file |
Ctrl+S |
Save file |
F5 |
Run program |
24. File Extensions
Panchi source files use:
.panchi
.pynchi
The IDE uses .panchi as the default extension when saving a new file.
25. Complete Examples
25.1 Basic Program
name := "Panchi"
version := 1
PANCHI "Language: " + name
PANCHI "Version: " + version
25.2 Arithmetic
x := 10
y := 20
sum := x + y
difference := y - x
product := x * y
quotient := y / x
PANCHI sum
PANCHI difference
PANCHI product
PANCHI quotient
25.3 Conditions
age := 17
if age >= 18:
PANCHI "Adult"
else:
PANCHI "Minor"
25.4 Functions
def multiply(a, b):
return a * b
result := multiply(6, 7)
PANCHI result
25.5 Loops
for i in range(5):
PANCHI i
25.6 Lists
numbers := [1, 2, 3, 4, 5]
total := sum(numbers)
PANCHI total
25.7 Input
name := input("Name: ")
PANCHI "Hello, " + name
25.8 File Operations
write_file("example.txt", "Hello from Panchi!")
content := read_file("example.txt")
PANCHI content
25.9 Modules
import math
value := math.sqrt(144)
PANCHI value
25.10 Object-Oriented Example
class Person:
def init(self, name):
self.name := name
def greet(self):
PANCHI "Hello, " + self.name
person := new Person("Alice")
person.greet()
26. Language Reference Summary
Keywords and Special Constructs
| Construct | Purpose |
|---|---|
PANCHI |
Output |
def |
Function definition |
return |
Return a value |
if |
Conditional execution |
else |
Alternative branch |
while |
Conditional loop |
for |
Iterable loop |
break |
Exit a loop |
continue |
Skip the current iteration |
import |
Import a built-in module |
class |
Define a class |
new |
Create an object |
True |
Boolean true |
False |
Boolean false |
None |
Null-like value |
Assignment
name := value
Arithmetic
a + b
a - b
a * b
a / b
a // b
a % b
a ** b
Comparison
a == b
a != b
a < b
a > b
a <= b
a >= b
Logic
a and b
a or b
not a
27. Current Implementation Notes
This documentation describes the language capabilities represented by the supplied interpreter and IDE implementation.
The current runtime explicitly supports:
- Dynamic global and local scopes.
- Function closures.
- Built-in functions.
- File operations.
math,os, andjsonmodules.- Classes.
- Objects.
- Methods.
- Constructors through
init. - Static class variables.
- Single inheritance.
- Property access.
- Method calls.
- Runtime control flow.
The interpreter's runtime implementation is the authoritative source for these behaviors.
The IDE also contains a simplified embedded documentation and example section covering the core syntax, including assignment, arithmetic, comparisons, strings, and execution through F5.
Note: The uploaded project files included the lexer debug script, parser debug script, IDE, and interpreter implementation. The complete lexer and parser source files themselves were not included in the uploaded set. Therefore, syntax descriptions beyond the constructs directly demonstrated by the interpreter and IDE are documented according to the available AST/runtime implementation and examples.
UPD: IDE will be relised later
28. License
Add the project's license information here.
Example:
Copyright (c) 2026
Distributed under the terms of the project's selected open-source license.
Panchi
A small interpreted language for learning, experimentation, and practical programming.