You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.2 KiB
Rust
58 lines
1.2 KiB
Rust
// See the end of this file for copyright and license terms.
|
|
|
|
use std::str::Chars;
|
|
|
|
pub struct Lexer<'a> {
|
|
stream: Chars<'a>,
|
|
}
|
|
|
|
impl <'a> Lexer<'a> {
|
|
pub const fn new(stream: Chars<'a>) -> Lexer<'a> {
|
|
Lexer {
|
|
stream: stream,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct Token {
|
|
pub kind: TokenKind,
|
|
pub line: usize,
|
|
pub col: usize,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum TokenKind {
|
|
Semi,
|
|
Ident(String),
|
|
BoolLiteral(bool),
|
|
IntLiteral(i64),
|
|
StringLiteral(String),
|
|
}
|
|
|
|
impl <'a> Iterator for Lexer<'a> {
|
|
type Item = Result<Token, SyntaxError>;
|
|
|
|
fn next(&mut self) -> Option<Result<Token, SyntaxError>> {
|
|
// TODO
|
|
None
|
|
}
|
|
}
|
|
|
|
pub struct SyntaxError {
|
|
pub msg: String,
|
|
pub line: usize,
|
|
pub col: usize,
|
|
}
|
|
|
|
// Copyright (C) 2021 Fefie <owo@fef.moe>
|
|
// This file is part of gayconf.
|
|
//
|
|
// gayconf is ethical software: you can use, redistribute,
|
|
// and/or modify it under the terms of the CNPLv5+ as found
|
|
// in the LICENSE file in the source code root directory or
|
|
// at <https://git.pixie.town/thufie/CNPL>.
|
|
//
|
|
// gayconf comes with ABSOLUTELY NO WARRANTY, to the extent
|
|
// permitted by applicable law. See the CNPL for details.
|