Skip to content

Commit

Permalink
Remove type and name resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
Amejonah1200 committed Oct 6, 2024
1 parent 67d3c10 commit 30c8ec7
Show file tree
Hide file tree
Showing 17 changed files with 8 additions and 3,832 deletions.
378 changes: 1 addition & 377 deletions src/main.rs

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions src/parsing/ast/declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ pub struct Parameter {
pub ty: Spanned<ParsedType>,
}

#[derive(Debug)]
pub struct Struct {
pub name: Spanned<Spur>,
pub fields: Box<[Field]>,
}

#[derive(Debug)]
pub struct Function {
pub name: Spanned<Spur>,
Expand All @@ -110,5 +104,4 @@ pub struct Variable {
pub enum Declaration {
Variable(Variable),
Function(Function),
Struct(Struct),
}
15 changes: 0 additions & 15 deletions src/parsing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use chumsky::span::SimpleSpan;

use crate::{source::DeclarationPath, typing::TypeId};

pub mod ast;
pub mod parsers;
pub mod tokenizer;
Expand Down Expand Up @@ -60,19 +58,6 @@ pub trait Infoable {
type Info;
}

#[derive(Debug, PartialEq)]
pub enum DeclarationRef {
LocalVariable(usize),
GlobalVariable(DeclarationPath),
Function(DeclarationPath),
}

#[derive(Debug, PartialEq)]
pub enum Info {
Type(Option<TypeId>),
DeclarationRef(Option<DeclarationRef>),
}

#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub struct Spanned<T>(pub T, pub SimpleSpan);

Expand Down
30 changes: 1 addition & 29 deletions src/parsing/parsers/declarations.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::parsing::{
ast::{
declarations::{Field, Function, Parameter, Struct, Variable},
declarations::{Field, Function, Parameter, Variable},
ParsedType,
},
parsers::{expressions::expression_parser, TokenInput, TokenParser},
Expand Down Expand Up @@ -38,34 +38,6 @@ fn field_parser<'a, I: TokenInput<'a>>() -> impl TokenParser<'a, I, Field> {
.boxed()
}

pub fn struct_parser<'a, I: TokenInput<'a>>() -> impl TokenParser<'a, I, Struct> {
keyword(Identifier::Struct)
.ignore_then(
ident()
.spur()
.spanned()
.paddedln()
.labelled("data-identifier")
.boxed(),
)
.then(
field_parser()
.paddedln()
.separated_by(just(Token::Comma))
.allow_trailing()
.collect_boxed_slice()
.boxed()
.delimited_by(just(Token::BraceOpen), just(Token::BraceClosed))
.labelled("data-fields")
.or_not()
.map(|f| f.unwrap_or_else(|| Box::new([])))
.boxed(),
)
.map(|(name, fields)| Struct { name, fields })
.labelled("data")
.boxed()
}

pub fn type_parser<'a, I: TokenInput<'a>>() -> impl TokenParser<'a, I, ParsedType> {
recursive(|p| {
choice((
Expand Down
3 changes: 1 addition & 2 deletions src/parsing/parsers/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use itertools::Itertools;
use crate::parsing::{
ast::declarations::{Declaration, UseDeclaration, UsePath, UsePathEnd},
parsers::{
declarations::{function_parser, struct_parser, variable_parser},
declarations::{function_parser, variable_parser},
CollectBoxedSliceExt, TokenInput, TokenParser, TokenParserExt,
},
tokenizer::{ident, keyword, newline, Identifier, Token},
Expand All @@ -22,7 +22,6 @@ pub type File = (Box<[UseDeclaration]>, Box<[Declaration]>);

pub fn file_parser<'a, I: TokenInput<'a>>() -> impl TokenParser<'a, I, File> {
choice((
struct_parser().map(Declaration::Struct).map(Either::Right),
variable_parser()
.map(Declaration::Variable)
.map(Either::Right),
Expand Down
11 changes: 0 additions & 11 deletions src/project/files.rs

This file was deleted.

Loading

0 comments on commit 30c8ec7

Please sign in to comment.