more lowering

This commit is contained in:
nora 2023-05-22 22:14:53 +02:00
parent e68ec920f5
commit 8bf9849641
7 changed files with 295 additions and 17 deletions

View file

@ -3,7 +3,8 @@ use std::fmt::Debug;
use bitflags::bitflags;
use dbg_pls::DebugPls;
use crate::{sym::Symbol, Spanned};
use crate::sym::Symbol;
pub use crate::Spanned;
pub type Ident = Spanned<Symbol>;
@ -14,7 +15,7 @@ pub type Ident = Spanned<Symbol>;
#[derive(Debug, DebugPls)]
pub enum Atom {
Ident(Ident),
Int(i128),
Int(u128),
Float(f64),
String(String),
Char(u8),

View file

@ -512,7 +512,6 @@ where
// TODO: recover here
let stmt = self.statement()?;
stmts.push(stmt);
};
Ok((stmts, brace_span.extend(end_span)))

View file

@ -1,4 +1,8 @@
use std::{cell::RefCell, fmt::Debug, marker::PhantomData};
use std::{
cell::RefCell,
fmt::{Debug, Display},
marker::PhantomData,
};
use dbg_pls::DebugPls;
use lasso::Spur;
@ -37,3 +41,9 @@ impl DebugPls for Symbol {
self.as_str(|s| f.debug_ident(s))
}
}
impl Display for Symbol {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
INTERNER.with(|i| f.write_str(i.borrow_mut().resolve(&self.spur)))
}
}

View file

@ -71,7 +71,7 @@ pub enum Keyword {
#[derive(Debug, Clone, Copy)]
pub enum Constant {
Int(i128),
Int(u128),
Float(f64),
Char(u8),
// adding enumerations here makes no sense.