Add lexer dump to main and fix a couple of bugs

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-01-27 19:07:57 -05:00
parent a5388c8b86
commit c4c196a136
3 changed files with 35 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
use crate::vm::{inst::Inst, reg::Reg};
use crate::vm::inst::Inst;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Line {
@@ -10,6 +10,7 @@ pub enum Line {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Directive {
Section(String),
Org(Value),
}
#[derive(Debug, Clone, PartialEq, Eq)]

View File

@@ -17,7 +17,7 @@ Value: Value = {
}
Label: String = {
"[a-zA-Z]+" => String::from(<>),
r"[a-zA-Z]+" => String::from(<>),
}
Number: u64 = {
@@ -69,11 +69,16 @@ Inst: Inst = {
}
Directive: Directive = {
".section" <s:Label> => Directive::Section(s.to_string()),
r"\.section" <s:Label> => Directive::Section(s.to_string()),
r"\.org" <v:Value> => Directive::Org(v),
}
pub Line: Line = {
Line: Line = {
<Directive> => Line::Directive(<>),
<Inst> => Line::Inst(<>),
<LabelDef> => Line::LabelDef(<>),
}
pub Program: Vec<Line> = {
<Line*> => <>,
}