mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-14 17:35:03 +01:00
test program
This commit is contained in:
parent
1ed076a5d3
commit
bea961bbbd
4 changed files with 28 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ impl Span {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct Token<'code> {
|
||||
span: Span,
|
||||
kind: TokenType<'code>,
|
||||
pub(crate) kind: TokenType<'code>,
|
||||
}
|
||||
|
||||
impl<'code> Token<'code> {
|
||||
|
|
|
|||
|
|
@ -5,5 +5,11 @@ mod parse;
|
|||
pub fn run_program(program: &str) {
|
||||
let lexer = lex::Lexer::lex(program);
|
||||
let tokens: Result<Vec<_>, _> = lexer.collect();
|
||||
println!("{:#?}", tokens);
|
||||
println!(
|
||||
"{:#?}",
|
||||
tokens.map(|tokens| tokens
|
||||
.into_iter()
|
||||
.map(|token| token.kind)
|
||||
.collect::<Vec<_>>())
|
||||
);
|
||||
}
|
||||
|
|
|
|||
14
src/main.rs
14
src/main.rs
|
|
@ -1,3 +1,15 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
if let Some(filename) = std::env::args().skip(1).next() {
|
||||
println!("'{}'", filename);
|
||||
match std::fs::read_to_string(filename) {
|
||||
Ok(contents) => {
|
||||
script_lang::run_program(&contents);
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("{}", err);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eprintln!("Usage: <filename>")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
7
test.sl
Normal file
7
test.sl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fn main() {
|
||||
let number = 5
|
||||
let number2 = 5325
|
||||
let is_equal = number == number2
|
||||
|
||||
print("Is Equal: " + is_equal)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue