Skip to content

Commit

Permalink
Layout parser
Browse files Browse the repository at this point in the history
  • Loading branch information
rozukke committed Aug 10, 2024
1 parent e110ecb commit 65cfb92
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::lexer::cursor::Cursor;
use crate::span::{Idx, Span};
use crate::symbol::Register;

mod cursor;
pub mod cursor;

#[derive(Debug)]
pub struct Token {
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use lexer::{tokenize, TokenKind};

mod lexer;
mod ops;
mod parser;
mod runtime;
mod span;
mod symbol;
Expand Down
37 changes: 37 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use crate::lexer::{cursor::Cursor, TokenKind};

/// Transforms token stream into 'AST'
pub struct Parser<'source> {
/// Reference to the source file
src: &'source str,
/// Used to parse tokens
cur: Cursor<'source>,
}

impl<'a> From<&'a str> for Parser<'a> {
fn from(value: &'a str) -> Self {
Parser {
src: value,
cur: Cursor::new(value),
}
}
}

impl<'source> Parser<'source> {
pub fn parse(&self) {
// First, check that there is an .orig directive with an appropriate value.
todo!()
}

pub fn expect(kind: TokenKind) {
todo!()
}

pub fn parse_direc(&self) {
todo!()
}

pub fn parse_op(&self) {
todo!()
}
}

0 comments on commit 65cfb92

Please sign in to comment.