WIP
This commit is contained in:
@@ -15,6 +15,7 @@ extern {
|
||||
|
||||
mod faenc;
|
||||
mod op_defs;
|
||||
mod tokenize;
|
||||
|
||||
use faenc::fe_enc64_1;
|
||||
use faenc::FeReg;
|
||||
|
||||
52
src/tokenize.rs
Normal file
52
src/tokenize.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
pub enum Token<'a> {
|
||||
String(&'a str),
|
||||
|
||||
Mnem(),
|
||||
Register(),
|
||||
Number(i64),
|
||||
|
||||
// Keywords
|
||||
Byte,
|
||||
Word,
|
||||
Dword,
|
||||
Qword,
|
||||
Ptr,
|
||||
Lock,
|
||||
Rep,
|
||||
|
||||
|
||||
// Punctuation
|
||||
DoubleColon,
|
||||
Comma,
|
||||
}
|
||||
|
||||
pub struct CodePos {
|
||||
line: u32,
|
||||
col: u32
|
||||
}
|
||||
|
||||
pub fn parse_stry<'a>(asm: &'a str) -> Vec<(CodePos, Token<'a>)> {
|
||||
let mut out = Vec::new();
|
||||
|
||||
for line in asm.lines() {
|
||||
let line = line.trim();
|
||||
// Remove comments
|
||||
let line = match line.find(|c: char| c == '#' || c == ';') {
|
||||
None => line,
|
||||
Some(idx) => &line[..idx]
|
||||
};
|
||||
let line = match line.find("//") {
|
||||
None => line,
|
||||
Some(idx) => &line[..idx]
|
||||
};
|
||||
if line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let line = line.trim();
|
||||
|
||||
}
|
||||
|
||||
out
|
||||
}
|
||||
Reference in New Issue
Block a user