-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
219 additions
and
72 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
[package] | ||
name = "rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
[workspace] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
rand = "0.8.5" | ||
clap = { version = "4.4.11", features = ["derive"] } | ||
members = ["trc", "Chinese", "English"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "Chinese" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "English" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,58 @@ | ||
# The usage of Rust version Trc | ||
|
||
## Hello world | ||
|
||
Writing a hello world is the beginning of learning Trc. | ||
|
||
```rust | ||
println("Hello World!") | ||
``` | ||
|
||
Great!Now you are saying "Hello" to the programming world! | ||
|
||
## First written value for Trc | ||
|
||
you can write integer value in the following ways: | ||
you can write integer or float value in the following ways: | ||
|Way|Explain| | ||
|:---|:---| | ||
|12321312|commom value| | ||
|122_32432_4324324|use underline to split the number to read more easily| | ||
|0b32132|number in 2 radix| | ||
|0o324243|number in 8 radix| | ||
|0x324324|number in 16 radix| | ||
|1e9+7 or 2E9+7|Scientific notation| | ||
|
||
Tip:No matter how large is your number.Trc compiler will take it into enough type to store!Don't worry! | ||
Tip1:No matter how large is your number.Trc compiler will take it into enough type to store!Don't worry! | ||
|
||
Tip2:The form like 0x3.4 isn't supported | ||
|
||
Tip3:The form like 001 is supported | ||
|
||
The next is the string value. To make you to write strings more easily: | ||
|
||
|Way|Explain| | ||
|:---|:---| | ||
|"hello world"|commom value| | ||
|"hello_world"|use underline to split the number to read more easily| | ||
|'hello_world'|another method that equals to "hello world"| | ||
|"""hello world"""|this method is for code across multiple lines| | ||
|
||
If you add ```r``` or ```R``` in front of the string.Trc will treat it as a raw string. | ||
Yes.These rules are from Python.I love its grammar rules | ||
|
||
ok.now you know how to write value in Trc.Then let's go to the next part. | ||
|
||
## the control flow of Trc | ||
|
||
First,you can use ```if ... else if ... else``` statements | ||
|
||
An example: | ||
|
||
```python | ||
if 1 == 1 { | ||
|
||
} else if 2 != 1 { | ||
|
||
} else { | ||
|
||
} | ||
``` |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "trc" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "GPL3" | ||
authors = ["limuy"] | ||
description = "a easy-learn programming language" | ||
homepage = "https://github.com/limuy2022/trc" | ||
repository = "https://github.com/limuy2022/trc" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
rand = "0.8.5" | ||
clap = { version = "4.4.11", features = ["derive"] } | ||
English = { path = "../English" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
enum ErrorType { | ||
SyntaxError | ||
} | ||
|
||
pub struct ErrorInfo { | ||
pub message: String, | ||
errot_type: ErrorType | ||
} | ||
|
||
impl ErrorInfo { | ||
pub fn new(message: String) -> ErrorInfo { | ||
ErrorInfo { | ||
message, | ||
errot_type: ErrorType::SyntaxError | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.