Stuff
This commit is contained in:
parent
f15427e5d9
commit
7e505dd88e
@ -56,7 +56,6 @@ pub fn tokenize(input: &str) -> Result<Vec<Token>, TokenError> {
|
|||||||
|
|
||||||
while let Some((idx, c)) = input.next() {
|
while let Some((idx, c)) = input.next() {
|
||||||
let cur_tok_type = match c {
|
let cur_tok_type = match c {
|
||||||
c if char::is_whitespace(c) && c != '\n' => continue,
|
|
||||||
'#' => {
|
'#' => {
|
||||||
if let Some(&(_, '{')) = input.peek() {
|
if let Some(&(_, '{')) = input.peek() {
|
||||||
} else {
|
} else {
|
||||||
@ -68,14 +67,17 @@ pub fn tokenize(input: &str) -> Result<Vec<Token>, TokenError> {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
|
c if char::is_whitespace(c) && c != '\n' => continue,
|
||||||
'\n' => Newline, ';' => Semicolon,
|
'\n' => Newline, ';' => Semicolon,
|
||||||
':' => Colon, ',' => Comma, '_' => Underscore, '.' => Period,
|
':' => Colon, ',' => Comma, '.' => Period,
|
||||||
'(' => LParen, ')' => RParen,
|
'(' => LParen, ')' => RParen,
|
||||||
'{' => LCurlyBrace, '}' => RCurlyBrace,
|
'{' => LCurlyBrace, '}' => RCurlyBrace,
|
||||||
'<' => LAngleBracket, '>' => RAngleBracket,
|
'<' => LAngleBracket, '>' => RAngleBracket,
|
||||||
'[' => LSquareBracket, ']' => RSquareBracket,
|
'[' => LSquareBracket, ']' => RSquareBracket,
|
||||||
|
'"' => handle_quote(&mut input),
|
||||||
c if is_digit(&c) => handle_digit(c, &mut input),
|
c if is_digit(&c) => handle_digit(c, &mut input),
|
||||||
_ => RSquareBracket,
|
c @ '_' | c if c.is_alphabetic() => handle_alphabetic(c, &mut input),
|
||||||
|
c => handle_operator(c, &mut input),
|
||||||
};
|
};
|
||||||
|
|
||||||
tokens.push(Token { token_type: cur_tok_type, offset: idx });
|
tokens.push(Token { token_type: cur_tok_type, offset: idx });
|
||||||
@ -100,6 +102,19 @@ fn handle_digit(c: char, input: &mut CharIter) -> TokenType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_quote(input: &mut CharIter) -> TokenType {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_alphabetic(c: char, input: &mut CharIter) -> TokenType {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_operator(c: char, input: &mut CharIter) -> TokenType {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Schala EBNF grammar
|
Schala EBNF grammar
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user