Skip to content

Commit

Permalink
Lint rule 2 (#21)
Browse files Browse the repository at this point in the history
* Failed to finish feature

multiple supporting peices are in place now. I will need to refactor
certain things with the ast/exprs, try to specify the exact type and
provide alternate Enums for if only two possible like function args self
vs symbol.

This will also help with the difference between when symbols are being
initalized, referenced in an Info, or accessed/assigned
  • Loading branch information
coffeebe4code authored Jun 20, 2024
1 parent 756a5e5 commit f576e7a
Show file tree
Hide file tree
Showing 6 changed files with 476 additions and 78 deletions.
36 changes: 27 additions & 9 deletions ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ impl Match {
#[derive(Debug, Clone, PartialEq)]
pub struct Declarator {
pub ident: Box<Expr>,
pub typ: Option<Box<Expr>>,
pub typ: Box<Expr>,
}

impl Declarator {
pub fn new(ident: Box<Expr>, typ: Option<Box<Expr>>) -> Self {
pub fn new(ident: Box<Expr>, typ: Box<Expr>) -> Self {
Declarator { ident, typ }
}
}
Expand Down Expand Up @@ -120,10 +120,10 @@ impl PropAccess {
#[derive(Debug, Clone, PartialEq)]
pub struct ArgDef {
pub ident: Box<Expr>,
pub typ: Option<Box<Expr>>,
pub typ: Box<Expr>,
}
impl ArgDef {
pub fn new(ident: Box<Expr>, typ: Option<Box<Expr>>) -> Self {
pub fn new(ident: Box<Expr>, typ: Box<Expr>) -> Self {
ArgDef { ident, typ }
}
}
Expand Down Expand Up @@ -551,10 +551,10 @@ impl ValueType {
#[derive(Debug, Clone, PartialEq)]
pub struct Sig {
// look at parser to see how this is implemented
pub left_most_ident: Option<Box<Expr>>,
pub left_most_type: Option<Box<Expr>>,
pub err: Option<Lexeme>,
pub undef: Option<Lexeme>,
pub right_most_ident: Option<Box<Expr>>,
pub right_most_type: Option<Box<Expr>>,
}

impl Sig {
Expand All @@ -565,10 +565,10 @@ impl Sig {
right_most_ident: Option<Box<Expr>>,
) -> Self {
Sig {
left_most_ident,
left_most_type: left_most_ident,
err,
undef,
right_most_ident,
right_most_type: right_most_ident,
}
}
}
Expand Down Expand Up @@ -659,10 +659,28 @@ impl Expr {
_ => panic!("issue no symbol found"),
}
}
pub fn into_self_val(&self) -> SelfValue {
match self {
Expr::SelfValue(x) => x.to_owned(),
_ => panic!("issue no self keyword found"),
}
}
pub fn is_self_val(&self) -> bool {
match self {
Expr::SelfValue(_) => true,
_ => false,
}
}
pub fn into_symbol(&self) -> Symbol {
match self {
Expr::Symbol(x) => x.to_owned(),
_ => panic!("issue no symbol found"),
_ => panic!("issue no symbol found {:?}", self),
}
}
pub fn into_arg_def(&self) -> ArgDef {
match self {
Expr::ArgDef(x) => x.to_owned(),
_ => panic!("issue no argument definition found"),
}
}
pub fn into_chars_value(&self) -> CharsValue {
Expand Down
5 changes: 1 addition & 4 deletions e2e/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ fn main() {
let result = linter.lint_check(&mut borrow.to_owned());

if linter.issues.len() > 0 {
println!(
" [fail]\n issues: {:?}\n completed: {:?}\n",
linter.issues, result
);
println!(" [fail]\n issues: {:?}\n", linter.issues);
std::process::exit(1);
}
}
Loading

0 comments on commit f576e7a

Please sign in to comment.