-
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
1 parent
ba0ac9e
commit 5258a8f
Showing
4 changed files
with
76 additions
and
2 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,3 +1,45 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
#![warn(clippy::pedantic)] | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
|
||
#[derive(Debug)] | ||
enum Statement { | ||
Declare, | ||
Define, | ||
Print, | ||
For, | ||
Function, | ||
If, | ||
Return, | ||
Math, | ||
Assign, | ||
Import, | ||
Object, | ||
Reference, | ||
Array, | ||
Flush, | ||
Break, | ||
Comment, | ||
} | ||
|
||
fn compile(input: &str) -> Vec<Statement> { | ||
let mut ans = vec![]; | ||
|
||
ans | ||
} | ||
|
||
fn main() -> std::io::Result<()> { | ||
let mut file = File::open("test001.wy")?; | ||
let mut contents = String::new(); | ||
file.read_to_string(&mut contents)?; | ||
println!("src: \n----------------------"); | ||
println!("{}", contents); | ||
println!("----------------------"); | ||
println!("\noutput: \n----------------------"); | ||
for st in compile(&contents) { | ||
println!("{:?}", st); | ||
} | ||
println!("----------------------"); | ||
|
||
Ok(()) | ||
} |
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,23 @@ | ||
fn num_to_hanzi(a: i32) -> String { | ||
match a { | ||
3 => "三".to_string(), | ||
0 => "零".to_string(), | ||
_ => unimplemented!() | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ans1 = "問天地好在。"; | ||
let _ans2 = ""; | ||
println!("{} {}", _ans1, _ans2); | ||
let _ans3 = "天地"; | ||
println!("{}", _ans3); | ||
let _ans4 = "宇宙"; | ||
let _ans5 = "洪荒"; | ||
let _ans6 = ""; | ||
let _ans7 = ""; | ||
println!("{} {} {} {}", _ans4, _ans5, _ans6, _ans7); | ||
let _ans8 = 3; | ||
let _ans9 = 0; | ||
println!("{} {}", num_to_hanzi(_ans8), num_to_hanzi(_ans9)); | ||
} |
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,4 @@ | ||
吾有二言。曰「「問天地好在。」」。書之。 | ||
吾有一言。曰「「天地」」。曰「「玄黄」」。書之。 | ||
吾有四言。曰「「宇宙」」。曰「「洪荒」」。書之。 | ||
吾有二數。曰三。書之。 |