A custom programming language jxlang
Project description
JxLang 0.2.6 -> 0.2.9
A lightweight custom programming language designed for simplicity and interactive scripting. Built with Python, jxlang provides a REPL environment and supports basic programming constructs, including variables, loops, functions, and library imports.
Installation
Install jxlang via PyPI:
pip install jxlang
Update Content
- Optimized string definition.
- Support adding, deleting and modifying elements in the list.
- Solved some known underlying logic problems.
- Preparing for supporting '.jl' code documents, pre support one-time running of written code.
Features
- Single-Line Comments:
#stands for single-line comments. - Variable Declaration: Use
letto declare variables. - Loops:
forloops with range-based iteration. - I/O Operations:
enter()for input,say()for output. - Library Imports: Import Python libraries via
cite. - List/Table Structures: Create lists (
table(...)). - Exit Session:
endend()for exiting current session. - REPL Support: Interactive shell for quick testing.
Quick Examples
1. Variable Declaration and Printing
let x: 5
say(x + 3) # Output: 8
# You can use double quotation marks or single quotation marks when assigning strings to variable names
let a: "hello"
say(a) # hello
let a: 'hello'
say(a) # hello
2. Loop
(i -> 1 && 5).for(say(i))
# Output: 1 2 3 4 5
3. Function Definition (Not open for users now)
4. Input and Output
let name: enter() # User enters "Alice"
say("Hello, " + name) # Output: Hello, Alice
5. Import a Python Library
cite math
say(math.sqrt(25)) # Output: 5.0
cite numpy
let a: numpy.array([1,2,3])
say(a) # Output: [1,2,3]
* JxLang can calls Python Libraries only if you installed in your python environment.
6. List and Table
let lst: table(1, 2, 3)
say(lst[0]) # Output: 1
say(lst) # Output: [1,2,3]
let tbl = table(1, 2; 3, 4)
say(tbl) # Output: [[1, 2], [3, 4]]
push 1 -> lst # Add 1 to the bottom of the list
say(lst) # [1,2,3,1]
push tbl -> lst
say(lst) # [1,2,3,1,[[1,2],[3,4]]]
out 1 -> lst # Remove 1 from the list but leave it in memory
say(lst) # [2,3,[[1,2],[3,4]]]
# Outlist can display the deleted list elements
say(lst.outlist) # [1,1]
throw 2 -> lst # Deleting 2 from the list cannot be restored
say(lst) # [3,[[1,2],[3,4]]]
let lst[0]: 2 # Replace the element with index 0 in the list with 2
say(lst) # [2,[[1,2],[3,4]]]
* JxLang splits into n-plus-1-dimensional lists by n semicolons.
Using the REPL
Start the interactive environment by running:
jxlang
Example REPL session:
jxlang> say(42)
42
jxlang> endend(0) # you can use numbers from 0 to 9 for endend()
Exiting with code 0
Contributing
Contributions are welcome! Please fork the repository and submit a pull request.
For major changes, open an issue first to discuss your ideas.
License
This project is licensed under the Apache License.
Happy coding! 🚀
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jxlang-0.2.93.tar.gz.
File metadata
- Download URL: jxlang-0.2.93.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25a0dc9376873ef70a30caaa4422a0387e47ca0bc1b931db13f4dc0d9c7e753b
|
|
| MD5 |
91bc51b1267a399d2a4a3d025c62da88
|
|
| BLAKE2b-256 |
dea88fba77abc38d103469ac06b065671a1aa8ff2f763dc6f3d9a95f378a9c09
|
File details
Details for the file jxlang-0.2.93-py3-none-any.whl.
File metadata
- Download URL: jxlang-0.2.93-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
506b3198f290b24fdced8364d6740ba403aca70d000c4043152fb51972d81bbc
|
|
| MD5 |
b661f004a3164c4b1009d7dc388605d9
|
|
| BLAKE2b-256 |
d8a992a3526c7467fbc7686e143f52d8f6cfd0874fe5a67b7706c0882a5edb81
|