Move folders to add a new documentation generator binary
This commit is contained in:
parent
cc4f304d00
commit
a88729b395
0
.gitignore → compiler/.gitignore
vendored
0
.gitignore → compiler/.gitignore
vendored
0
Cargo.lock → compiler/Cargo.lock
generated
0
Cargo.lock → compiler/Cargo.lock
generated
@ -29,7 +29,6 @@ pub fn scan_impl(chars: &Vec<char>, start_pos: usize, current: String) -> LexRes
|
|||||||
// This should only detect an escaped `"`
|
// This should only detect an escaped `"`
|
||||||
scan_impl(chars, start_pos + 2, format!("{}{}", current, escape))
|
scan_impl(chars, start_pos + 2, format!("{}{}", current, escape))
|
||||||
} else {
|
} else {
|
||||||
// Ignore the backslash
|
|
||||||
scan_impl(chars, start_pos + 1, utils::str_append(current, *c))
|
scan_impl(chars, start_pos + 1, utils::str_append(current, *c))
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -51,8 +51,8 @@ pub fn try_parse<'a>(tokens: &'a Vec<Token>, pos: usize) -> Option<SyntaxResult>
|
|||||||
"There should be an identifier after a `{}` token",
|
"There should be an identifier after a `{}` token",
|
||||||
if is_val { "val" } else { "var" }
|
if is_val { "val" } else { "var" }
|
||||||
),
|
),
|
||||||
error_start: binding_token.position,
|
error_start: t.position,
|
||||||
error_end: binding_token.position + binding_token.value.len(),
|
error_end: t.position + t.value.len(),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
Result3::None => {
|
Result3::None => {
|
||||||
@ -119,6 +119,7 @@ pub fn try_parse<'a>(tokens: &'a Vec<Token>, pos: usize) -> Option<SyntaxResult>
|
|||||||
fn try_token_type(tokens: &Vec<Token>, pos: usize, token_type: TokenType) -> Result3<&Token> {
|
fn try_token_type(tokens: &Vec<Token>, pos: usize, token_type: TokenType) -> Result3<&Token> {
|
||||||
match tokens.get(pos) {
|
match tokens.get(pos) {
|
||||||
Some(t) if t.token_type == token_type => Result3::Ok(t),
|
Some(t) if t.token_type == token_type => Result3::Ok(t),
|
||||||
|
Some(t) if t.token_type == TokenType::Semicolon || t.token_type == TokenType::EOF => Result3::None,
|
||||||
Some(t) => Result3::Err(t),
|
Some(t) => Result3::Err(t),
|
||||||
None => Result3::None,
|
None => Result3::None,
|
||||||
}
|
}
|
||||||
@ -225,8 +226,21 @@ mod tests {
|
|||||||
|
|
||||||
match binding {
|
match binding {
|
||||||
SyntaxResult::Err(error) => {
|
SyntaxResult::Err(error) => {
|
||||||
// assert_eq!(4, error.error_start);
|
assert_eq!(4, error.error_start);
|
||||||
// assert_eq!(7, error.error_end);
|
assert_eq!(7, error.error_end);
|
||||||
|
}
|
||||||
|
_ => panic!("Error expected")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ERROR: when computing the length of the token "hello" the quotes are not considered
|
||||||
|
let tokens = get_tokens(&String::from("val \"hello\"")).unwrap();
|
||||||
|
let binding = try_parse(&tokens, 0).unwrap();
|
||||||
|
|
||||||
|
match binding {
|
||||||
|
SyntaxResult::Err(error) => {
|
||||||
|
assert_eq!(4, error.error_start);
|
||||||
|
assert_eq!(11, error.error_end);
|
||||||
}
|
}
|
||||||
_ => panic!("Error expected")
|
_ => panic!("Error expected")
|
||||||
}
|
}
|
8
doc-generator/Cargo.toml
Normal file
8
doc-generator/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "doc-generator"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
3
doc-generator/src/main.rs
Normal file
3
doc-generator/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user