Skip to content

Commit

Permalink
begin implementing composable parser
Browse files Browse the repository at this point in the history
  • Loading branch information
andogq committed Aug 29, 2024
1 parent 225db61 commit dfb3309
Show file tree
Hide file tree
Showing 4 changed files with 538 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/repr/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::Display;

use logos::{Lexer, Logos};

#[derive(Clone, Debug, Logos, PartialEq, Eq)]
#[derive(Clone, Debug, Logos, PartialEq, Eq, Hash)]
#[logos(skip r"[ \t\r\n\f]+")]
pub enum Token {
/*
Expand Down
6 changes: 6 additions & 0 deletions src/stage/parse/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ impl Precedence {
}
}

impl From<Token> for Precedence {
fn from(token: Token) -> Self {
Self::of(&token)
}
}

fn parse_prefix(compiler: &mut Compiler, lexer: &mut Lexer<'_>) -> Result<Expression, ParseError> {
match lexer.peek_token().unwrap().clone() {
Token::Integer(_) => Ok(Expression::Integer(parse_integer(compiler, lexer)?)),
Expand Down
1 change: 1 addition & 0 deletions src/stage/parse/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod block;
mod expression;
mod function;
mod parser;
mod statement;
mod ty;

Expand Down
Loading

0 comments on commit dfb3309

Please sign in to comment.