mrt-lang 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 MRT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE.txt
3
+ recursive-include docs *
4
+ recursive-include examples *.mrt
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.1
2
+ Name: mrt-lang
3
+ Version: 0.1.4
4
+ Summary: MRT Programming Language - A modern, expressive programming language
5
+ Home-page: https://github.com/rithymeth/MRT
6
+ Author: MRT Team
7
+ Author-email: rithy1337@gmail.com
8
+ Keywords: programming language interpreter compiler
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Topic :: Software Development :: Interpreters
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE.txt
18
+
19
+ # MRT Programming Language
20
+
21
+ MRT is a modern, expressive programming language designed for simplicity and readability. It combines intuitive syntax with powerful features for both beginners and experienced programmers.
22
+
23
+ ## Features
24
+
25
+ - Simple and expressive syntax
26
+ - Dynamic typing with type inference
27
+ - First-class functions
28
+ - Rich built-in functions
29
+ - Comprehensive array operations
30
+ - Powerful string manipulation
31
+ - Modern module system
32
+
33
+ ## Installation
34
+
35
+ You can install MRT using pip:
36
+
37
+ ```bash
38
+ pip install mrt-lang
39
+ ```
40
+
41
+ After installation, you can run MRT programs using the `mrt` command:
42
+ ```bash
43
+ mrt your_program.mrt
44
+ ```
45
+
46
+ ## Quick Start
47
+
48
+ 1. Create a file `hello.mrt`:
49
+ ```mrt
50
+ func main() {
51
+ print("Hello, World!")
52
+ }
53
+ ```
54
+
55
+ 2. Run the program:
56
+ ```bash
57
+ mrt hello.mrt
58
+ ```
59
+
60
+ ## Language Examples
61
+
62
+ ### Variables and Basic Types
63
+ ```mrt
64
+ func variables_demo() {
65
+ var name = "Alice"
66
+ var age = 25
67
+ var height = 1.75
68
+ var isStudent = true
69
+
70
+ print("Name: " + name)
71
+ }
72
+ ```
73
+
74
+ ### Arrays
75
+ ```mrt
76
+ func array_demo() {
77
+ var numbers = [1, 2, 3, 4, 5]
78
+ push(numbers, 6)
79
+ print("Length:", len(numbers))
80
+ print("First element:", numbers[0])
81
+ }
82
+ ```
83
+
84
+ ### String Operations
85
+ ```mrt
86
+ func string_demo() {
87
+ var text = " Hello, World! "
88
+ print("Trimmed:", trim(text))
89
+ print("Uppercase:", toUpper(text))
90
+ print("Contains 'World':", contains(text, "World"))
91
+ }
92
+ ```
93
+
94
+ ## Built-in Functions
95
+
96
+ ### Array Operations
97
+ - `len(array)`: Returns array length
98
+ - `push(array, element)`: Adds element to end
99
+ - `pop(array)`: Removes and returns last element
100
+ - `slice(array, start, end)`: Returns array subset
101
+ - `join(array, separator)`: Joins elements into string
102
+ - `indexOf(array, element)`: Finds element index
103
+
104
+ ### String Operations
105
+ - `split(str, separator)`: Splits string into array
106
+ - `substring(str, start, end)`: Extracts string portion
107
+ - `toUpper(str)`: Converts to uppercase
108
+ - `toLower(str)`: Converts to lowercase
109
+ - `trim(str)`: Removes whitespace
110
+ - `replace(str, old, new)`: Replaces text
111
+ - `startsWith(str, prefix)`: Checks string start
112
+ - `endsWith(str, suffix)`: Checks string end
113
+ - `contains(str, substr)`: Checks for substring
114
+
115
+ ## Project Structure
116
+
117
+ - `src/`: Source code for the MRT interpreter
118
+ - `lexer.py`: Tokenizes source code
119
+ - `parser.py`: Parses tokens into AST
120
+ - `interpreter.py`: Executes MRT programs
121
+ - `ast.py`: Abstract Syntax Tree definitions
122
+ - `docs/`: Comprehensive documentation
123
+ - `language_guide.md`: Complete language reference
124
+ - `examples.md`: Example programs and tutorials
125
+ - `getting_started.md`: Installation and quick start
126
+ - `examples/`: Example MRT programs
127
+ - `tests/`: Test suite
128
+
129
+ ## Documentation
130
+
131
+ For more detailed information, check out:
132
+ - [Language Guide](docs/language_guide.md): Complete language reference
133
+ - [Examples](docs/examples.md): Example programs and tutorials
134
+ - [Getting Started](docs/getting_started.md): Installation and quick start
135
+
136
+ ## Development
137
+
138
+ To set up the development environment:
139
+
140
+ 1. Clone the repository:
141
+ ```bash
142
+ git clone <repository-url>
143
+ cd mrt
144
+ ```
145
+
146
+ 2. Install in development mode:
147
+ ```bash
148
+ pip install -e .
149
+ ```
150
+
151
+ 3. Install development dependencies:
152
+ ```bash
153
+ pip install -r requirements-dev.txt
154
+ ```
155
+
156
+ ## Contributing
157
+
158
+ We welcome contributions! Whether it's:
159
+ - Bug reports
160
+ - Feature requests
161
+ - Documentation improvements
162
+ - Code contributions
163
+
164
+ Please feel free to open issues and pull requests.
165
+
166
+ ## License
167
+
168
+ MIT License - see [LICENSE.txt](LICENSE.txt) for details.
@@ -0,0 +1,150 @@
1
+ # MRT Programming Language
2
+
3
+ MRT is a modern, expressive programming language designed for simplicity and readability. It combines intuitive syntax with powerful features for both beginners and experienced programmers.
4
+
5
+ ## Features
6
+
7
+ - Simple and expressive syntax
8
+ - Dynamic typing with type inference
9
+ - First-class functions
10
+ - Rich built-in functions
11
+ - Comprehensive array operations
12
+ - Powerful string manipulation
13
+ - Modern module system
14
+
15
+ ## Installation
16
+
17
+ You can install MRT using pip:
18
+
19
+ ```bash
20
+ pip install mrt-lang
21
+ ```
22
+
23
+ After installation, you can run MRT programs using the `mrt` command:
24
+ ```bash
25
+ mrt your_program.mrt
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ 1. Create a file `hello.mrt`:
31
+ ```mrt
32
+ func main() {
33
+ print("Hello, World!")
34
+ }
35
+ ```
36
+
37
+ 2. Run the program:
38
+ ```bash
39
+ mrt hello.mrt
40
+ ```
41
+
42
+ ## Language Examples
43
+
44
+ ### Variables and Basic Types
45
+ ```mrt
46
+ func variables_demo() {
47
+ var name = "Alice"
48
+ var age = 25
49
+ var height = 1.75
50
+ var isStudent = true
51
+
52
+ print("Name: " + name)
53
+ }
54
+ ```
55
+
56
+ ### Arrays
57
+ ```mrt
58
+ func array_demo() {
59
+ var numbers = [1, 2, 3, 4, 5]
60
+ push(numbers, 6)
61
+ print("Length:", len(numbers))
62
+ print("First element:", numbers[0])
63
+ }
64
+ ```
65
+
66
+ ### String Operations
67
+ ```mrt
68
+ func string_demo() {
69
+ var text = " Hello, World! "
70
+ print("Trimmed:", trim(text))
71
+ print("Uppercase:", toUpper(text))
72
+ print("Contains 'World':", contains(text, "World"))
73
+ }
74
+ ```
75
+
76
+ ## Built-in Functions
77
+
78
+ ### Array Operations
79
+ - `len(array)`: Returns array length
80
+ - `push(array, element)`: Adds element to end
81
+ - `pop(array)`: Removes and returns last element
82
+ - `slice(array, start, end)`: Returns array subset
83
+ - `join(array, separator)`: Joins elements into string
84
+ - `indexOf(array, element)`: Finds element index
85
+
86
+ ### String Operations
87
+ - `split(str, separator)`: Splits string into array
88
+ - `substring(str, start, end)`: Extracts string portion
89
+ - `toUpper(str)`: Converts to uppercase
90
+ - `toLower(str)`: Converts to lowercase
91
+ - `trim(str)`: Removes whitespace
92
+ - `replace(str, old, new)`: Replaces text
93
+ - `startsWith(str, prefix)`: Checks string start
94
+ - `endsWith(str, suffix)`: Checks string end
95
+ - `contains(str, substr)`: Checks for substring
96
+
97
+ ## Project Structure
98
+
99
+ - `src/`: Source code for the MRT interpreter
100
+ - `lexer.py`: Tokenizes source code
101
+ - `parser.py`: Parses tokens into AST
102
+ - `interpreter.py`: Executes MRT programs
103
+ - `ast.py`: Abstract Syntax Tree definitions
104
+ - `docs/`: Comprehensive documentation
105
+ - `language_guide.md`: Complete language reference
106
+ - `examples.md`: Example programs and tutorials
107
+ - `getting_started.md`: Installation and quick start
108
+ - `examples/`: Example MRT programs
109
+ - `tests/`: Test suite
110
+
111
+ ## Documentation
112
+
113
+ For more detailed information, check out:
114
+ - [Language Guide](docs/language_guide.md): Complete language reference
115
+ - [Examples](docs/examples.md): Example programs and tutorials
116
+ - [Getting Started](docs/getting_started.md): Installation and quick start
117
+
118
+ ## Development
119
+
120
+ To set up the development environment:
121
+
122
+ 1. Clone the repository:
123
+ ```bash
124
+ git clone <repository-url>
125
+ cd mrt
126
+ ```
127
+
128
+ 2. Install in development mode:
129
+ ```bash
130
+ pip install -e .
131
+ ```
132
+
133
+ 3. Install development dependencies:
134
+ ```bash
135
+ pip install -r requirements-dev.txt
136
+ ```
137
+
138
+ ## Contributing
139
+
140
+ We welcome contributions! Whether it's:
141
+ - Bug reports
142
+ - Feature requests
143
+ - Documentation improvements
144
+ - Code contributions
145
+
146
+ Please feel free to open issues and pull requests.
147
+
148
+ ## License
149
+
150
+ MIT License - see [LICENSE.txt](LICENSE.txt) for details.
@@ -0,0 +1,159 @@
1
+ # MRT Examples
2
+
3
+ This document provides practical examples of MRT programming language features.
4
+
5
+ ## Basic Examples
6
+
7
+ ### Hello World
8
+ ```mrt
9
+ func main() {
10
+ print("Hello, World!")
11
+ }
12
+ ```
13
+
14
+ ### Variable Usage
15
+ ```mrt
16
+ func variables_demo() {
17
+ var name = "Alice"
18
+ var age = 25
19
+ var height = 1.75
20
+ var isStudent = true
21
+
22
+ print("Name: " + name)
23
+ print("Age: " + age)
24
+ print("Height: " + height)
25
+ print("Is Student: " + isStudent)
26
+ }
27
+ ```
28
+
29
+ ### Control Flow
30
+ ```mrt
31
+ func check_number(n) {
32
+ if (n > 0) {
33
+ print("Positive")
34
+ } else if (n < 0) {
35
+ print("Negative")
36
+ } else {
37
+ print("Zero")
38
+ }
39
+ }
40
+
41
+ func count_to_ten() {
42
+ for (var i = 1; i <= 10; i = i + 1) {
43
+ print(i)
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## Array Operations
49
+
50
+ ### Array Manipulation
51
+ ```mrt
52
+ func array_demo() {
53
+ var numbers = [1, 2, 3, 4, 5]
54
+
55
+ // Add elements
56
+ push(numbers, 6)
57
+ print("After push:", numbers)
58
+
59
+ // Remove last element
60
+ var last = pop(numbers)
61
+ print("Popped value:", last)
62
+ print("After pop:", numbers)
63
+
64
+ // Get array slice
65
+ var subset = slice(numbers, 1, 4)
66
+ print("Slice [1:4]:", subset)
67
+
68
+ // Join array elements
69
+ var joined = join(numbers, ", ")
70
+ print("Joined string:", joined)
71
+
72
+ // Find element index
73
+ var index = indexOf(numbers, 3)
74
+ print("Index of 3:", index)
75
+ }
76
+ ```
77
+
78
+ ## String Operations
79
+
80
+ ### String Manipulation
81
+ ```mrt
82
+ func string_demo() {
83
+ var text = " Hello, World! "
84
+
85
+ // Basic operations
86
+ print("Original:", text)
87
+ print("Trimmed:", trim(text))
88
+ print("Uppercase:", toUpper(text))
89
+ print("Lowercase:", toLower(text))
90
+
91
+ // Substring
92
+ var hello = substring(trim(text), 0, 5)
93
+ print("First word:", hello)
94
+
95
+ // Split and join
96
+ var words = split(trim(text), ", ")
97
+ print("Split words:", words)
98
+ print("Rejoined:", join(words, "-"))
99
+
100
+ // Search operations
101
+ print("Starts with 'Hello':", startsWith(trim(text), "Hello"))
102
+ print("Contains 'World':", contains(text, "World"))
103
+ print("Ends with '!':", endsWith(trim(text), "!"))
104
+
105
+ // Replace
106
+ var new_text = replace(text, "World", "MRT")
107
+ print("After replace:", new_text)
108
+ }
109
+ ```
110
+
111
+ ## Advanced Examples
112
+
113
+ ### Calculator
114
+ ```mrt
115
+ func calculator(a, b, operation) {
116
+ if (operation == "+") {
117
+ return a + b
118
+ } else if (operation == "-") {
119
+ return a - b
120
+ } else if (operation == "*") {
121
+ return a * b
122
+ } else if (operation == "/") {
123
+ if (b == 0) {
124
+ print("Error: Division by zero")
125
+ return 0
126
+ }
127
+ return a / b
128
+ } else {
129
+ print("Error: Invalid operation")
130
+ return 0
131
+ }
132
+ }
133
+
134
+ func calc_demo() {
135
+ print("5 + 3 =", calculator(5, 3, "+"))
136
+ print("10 - 4 =", calculator(10, 4, "-"))
137
+ print("6 * 2 =", calculator(6, 2, "*"))
138
+ print("15 / 3 =", calculator(15, 3, "/"))
139
+ }
140
+ ```
141
+
142
+ ### Word Counter
143
+ ```mrt
144
+ func count_words(text) {
145
+ var words = split(trim(text), " ")
146
+ return len(words)
147
+ }
148
+
149
+ func word_counter_demo() {
150
+ var text = "The quick brown fox jumps over the lazy dog"
151
+ var count = count_words(text)
152
+ print("Word count:", count)
153
+
154
+ var words = split(text, " ")
155
+ print("Words:", words)
156
+ print("First word:", words[0])
157
+ print("Last word:", words[len(words) - 1])
158
+ }
159
+ ```
@@ -0,0 +1,134 @@
1
+ # Getting Started with MRT
2
+
3
+ ## Installation
4
+
5
+ There are two ways to install MRT:
6
+
7
+ ### 1. Install from PyPI (Recommended)
8
+
9
+ ```bash
10
+ pip install mrt-lang
11
+ ```
12
+
13
+ After installation, you can run MRT programs using the `mrt` command:
14
+ ```bash
15
+ mrt your_program.mrt
16
+ ```
17
+
18
+ ### 2. Install from Source
19
+
20
+ 1. Clone the repository:
21
+ ```bash
22
+ git clone <repository-url>
23
+ cd mrt
24
+ ```
25
+
26
+ 2. Install in development mode:
27
+ ```bash
28
+ pip install -e .
29
+ ```
30
+
31
+ 3. Install development dependencies (optional):
32
+ ```bash
33
+ pip install -r requirements-dev.txt
34
+ ```
35
+
36
+ ## Running MRT Programs
37
+
38
+ After installation, you can run MRT programs in two ways:
39
+
40
+ 1. Using the `mrt` command (if installed via pip):
41
+ ```bash
42
+ mrt your_program.mrt
43
+ ```
44
+
45
+ 2. Using Python directly:
46
+ ```bash
47
+ python -m src your_program.mrt
48
+ ```
49
+
50
+ ## Creating Your First Program
51
+
52
+ 1. Create a new file `hello.mrt`:
53
+ ```mrt
54
+ func main() {
55
+ print("Hello, World!")
56
+ }
57
+ ```
58
+
59
+ 2. Run the program:
60
+ ```bash
61
+ mrt hello.mrt
62
+ ```
63
+
64
+ ## Development Environment
65
+
66
+ MRT files use the `.mrt` extension. Any text editor can be used for MRT development, but we recommend using an editor with syntax highlighting support for better readability.
67
+
68
+ ## Project Structure
69
+
70
+ - `src/`: Source code for the MRT interpreter
71
+ - `lexer.py`: Tokenizes source code
72
+ - `parser.py`: Parses tokens into AST
73
+ - `interpreter.py`: Executes MRT programs
74
+ - `ast.py`: Abstract Syntax Tree definitions
75
+ - `examples/`: Example MRT programs
76
+ - `docs/`: Documentation
77
+ - `tests/`: Test suite
78
+
79
+ ## Basic Concepts
80
+
81
+ ### Program Structure
82
+ Every MRT program consists of functions and statements. The `main()` function is the entry point of the program.
83
+
84
+ ### Variables
85
+ Variables are declared using the `var` keyword:
86
+ ```mrt
87
+ var name = "John"
88
+ var age = 25
89
+ ```
90
+
91
+ ### Functions
92
+ Functions are declared using the `func` keyword:
93
+ ```mrt
94
+ func greet(name) {
95
+ print("Hello, " + name + "!")
96
+ }
97
+ ```
98
+
99
+ ### Data Types
100
+ MRT supports these basic data types:
101
+ - Numbers (integers and floats)
102
+ - Strings
103
+ - Booleans
104
+ - Arrays
105
+
106
+ ## Next Steps
107
+
108
+ 1. Review the [Language Guide](language_guide.md) for detailed documentation
109
+ 2. Check out the [Examples](examples.md) for practical code samples
110
+ 3. Try writing your own MRT programs
111
+ 4. Join the community (coming soon)
112
+
113
+ ## Common Issues and Solutions
114
+
115
+ ### Program Not Running
116
+ - Ensure Python 3.6+ is installed
117
+ - Check that all files are in the correct directory
118
+ - Verify syntax in your MRT file
119
+
120
+ ### Syntax Errors
121
+ - Check for missing parentheses or braces
122
+ - Verify all variables are properly declared
123
+ - Ensure strings are properly quoted
124
+
125
+ ## Getting Help
126
+
127
+ If you encounter any issues:
128
+ 1. Check the documentation
129
+ 2. Look at similar examples
130
+ 3. Report issues on the repository (coming soon)
131
+
132
+ ## Contributing
133
+
134
+ We welcome contributions! Please see our contributing guidelines (coming soon) for details on how to help improve MRT.