Skip to content

Commit

Permalink
Refactor parser (#181)
Browse files Browse the repository at this point in the history
* Refactor parser and bump lalrpop to 0.20

* Split cst into cst::exp and cst::decls

* Factor out the constituents of cst::Exp

All the constituent parts of cst::Exp are now
individual structs.

* Split lowering of cst::Exp into multiple impls

* Remove ParamInst and Telescope from CST

* Apply suggestions from code review

Co-authored-by: Tim Süberkrüb <[email protected]>

---------

Co-authored-by: Tim Süberkrüb <[email protected]>
  • Loading branch information
BinderDavid and timsueberkrueb authored Apr 17, 2024
1 parent b6ebd47 commit f3d9b77
Show file tree
Hide file tree
Showing 13 changed files with 653 additions and 331 deletions.
112 changes: 102 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions lang/lowering/src/ctx.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use codespan::Span;
use miette_util::ToMiette;
use parser::cst;
use parser::cst::{BindingSite, Ident};
use parser::cst::exp::{BindingSite, Ident};
use syntax::common::*;
use syntax::ctx::{Context, ContextElem};
use syntax::generic::lookup_table::DeclMeta;
Expand Down Expand Up @@ -171,20 +171,20 @@ impl ContextElem<Ctx> for Ident {
}
}

impl ContextElem<Ctx> for &cst::Param {
impl ContextElem<Ctx> for &cst::decls::Param {
fn as_element(&self) -> <Ctx as Context>::ElemIn {
match &self.name {
BindingSite::Var { name } => name.to_owned(),
BindingSite::Wildcard => "_".to_owned(),
BindingSite::Var { name, .. } => name.to_owned(),
BindingSite::Wildcard { .. } => "_".to_owned(),
}
}
}

impl ContextElem<Ctx> for &cst::ParamInst {
impl ContextElem<Ctx> for &cst::exp::BindingSite {
fn as_element(&self) -> <Ctx as Context>::ElemIn {
match &self.name {
BindingSite::Var { name } => name.to_owned(),
BindingSite::Wildcard => "_".to_owned(),
match self {
BindingSite::Var { name, .. } => name.to_owned(),
BindingSite::Wildcard { .. } => "_".to_owned(),
}
}
}
Expand Down
Loading

0 comments on commit f3d9b77

Please sign in to comment.