Metadata-Version: 2.1
Name: jxlang
Version: 0.3.112
Summary: A custom programming language jxlang
Author-email: AndyKingXi <appleking0@icloud.com>
License: Apache 2.0
Project-URL: Homepage, https://gitee.com/JXX_CODE/jx-lang
Keywords: programming-language,repl,interpreter
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# JxLang 0.3.1

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:

```bash
pip install jxlang
```

## Update Content
<ul>
<li>Added function definition and calling capabilities</li>
<li>Implemented multi-line code input support</li>
<li>Enhanced Python library import with alias support</li>
<li>Optimized string definition and list operations</li>
<li>Improved underlying code logic and performance</li>
<li>Added support for '.jl' code file execution</li>
</ul>

## Features

- **Single-Line Comments**: `#` stands for single-line comments.
- **Variable Declaration**: Use `let` to declare variables.
- **Loops**: `for` loops with range-based iteration.
- **I/O Operations**: `enter()` for input, `say()` for output.
- **Library Imports**: Import Python libraries via `cite` with optional aliases.
- **List/Table Structures**: Create and manipulate lists (`table(...)`).
- **Function Support**: Define and call custom functions.
- **Multi-line Input**: Support for multi-line code input in REPL.
- **Exit Session**: `endend()` for exiting current session.
- **REPL Support**: Interactive shell for quick testing.

## Quick Examples

### 1. Variable Declaration and Printing
```python
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
```python
(i -> 1 && 5).for(
    say(i)
    )
# Output: 1 2 3 4 5
```

### 3. Function Definition and Calling
```python
func(x && y -> add):
    out x + y

say(add(5, 3))  # Output: 8

# Multi-line function definition
func(x && y -> calculate):
    let temp: x * 2
    out temp + y

say(calculate(3, 4))  # Output: 10
```

### 4. Input and Output
```python
let name: enter()  # User enters "Alice"
say("Hello, " + name)  # Output: Hello, Alice
```

### 5. Import Python Libraries with Aliases
```python
cite math as m
say(m.sqrt(25))  # Output: 5.0

cite numpy as np
let a: np.array([1,2,3])
say(a)          # Output: [1,2,3]

# Import specific module with alias
cite pandas as pd
let df: pd.DataFrame({'A': [1,2,3]})
say(df)         # Output: DataFrame with column A

# Data visualization with matplotlib
cite matplotlib.pyplot as plt
let x: np.linspace(0, 10, 100)
let y: np.sin(x)
plt.plot(x, y)
plt.title("Sine Wave")
plt.show()      # Displays the plot
```
<p>* JxLang can call Python Libraries only if they are installed in your Python environment.</p>

### 6. List and Table Operations
```python
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]]

# List manipulation
push 1 -> lst     # Add 1 to the end 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 first occurrence of 1 and store in outlist
say(lst)          # [2,3,[[1,2],[3,4]]]
say(lst.outlist)  # [1,1]

throw 2 -> lst    # Permanently remove 2 from the list
say(lst)          # [3,[[1,2],[3,4]]]

let lst[0]: 2     # Replace element at index 0 with 2
say(lst)          # [2,[[1,2],[3,4]]]
```
<p>* JxLang creates n+1 dimensional lists using n semicolons as separators.</p>

## Using the REPL

Start the interactive environment by running:
```bash
jxlang
```

Example REPL session with multi-line input:
```
jxlang> func(x && y -> add):
    ... out x + y
    ... 
jxlang> say(add(5, 3))
8
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! 🚀
