Skip to content

Commit

Permalink
Alphabetize a few enums in the compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
rdaum committed Jan 27, 2024
1 parent 3487fcc commit bbd4f58
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 82 deletions.
40 changes: 20 additions & 20 deletions crates/compiler/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,36 @@ pub struct ScatterItem {
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum BinaryOp {
Add,
Sub,
Mul,
Div,
Mod,
Eq,
NEq,
Exp,
Gt,
GtE,
In,
Lt,
LtE,
Exp,
In,
Mod,
Mul,
NEq,
Sub,
}

impl BinaryOp {
pub fn from_binary_opcode(opcode: Op) -> Self {
match opcode {
Op::Add => Self::Add,
Op::Sub => Self::Sub,
Op::Mul => Self::Mul,
Op::Div => Self::Div,
Op::Mod => Self::Mod,
Op::Eq => Self::Eq,
Op::Ne => Self::NEq,
Op::Gt => Self::Gt,
Op::Ge => Self::GtE,
Op::Lt => Self::Lt,
Op::Le => Self::LtE,
Op::Exp => Self::Exp,
Op::Ge => Self::GtE,
Op::Gt => Self::Gt,
Op::In => Self::In,
Op::Le => Self::LtE,
Op::Lt => Self::Lt,
Op::Mod => Self::Mod,
Op::Mul => Self::Mul,
Op::Ne => Self::NEq,
Op::Sub => Self::Sub,
_ => panic!("Invalid binary opcode: {:?}", opcode),
}
}
Expand All @@ -82,18 +82,18 @@ impl Display for BinaryOp {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Add => write!(f, "+"),
Self::Sub => write!(f, "-"),
Self::Mul => write!(f, "*"),
Self::Div => write!(f, "/"),
Self::Mod => write!(f, "%"),
Self::Eq => write!(f, "=="),
Self::NEq => write!(f, "!="),
Self::Exp => write!(f, "^"),
Self::Gt => write!(f, ">"),
Self::GtE => write!(f, ">="),
Self::In => write!(f, "in"),
Self::Lt => write!(f, "<"),
Self::LtE => write!(f, "<="),
Self::Exp => write!(f, "^"),
Self::In => write!(f, "in"),
Self::Mod => write!(f, "%"),
Self::Mul => write!(f, "*"),
Self::NEq => write!(f, "!="),
Self::Sub => write!(f, "-"),
}
}
}
Expand Down
102 changes: 51 additions & 51 deletions crates/compiler/src/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,83 +20,83 @@ use crate::labels::{Label, Name, Offset};

#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Encode, Decode)]
pub enum Op {
If(Label),
Add,
And(Label),
CallVerb,
Catch(Label),
CheckListForSplice,
Continue,
Div,
Done,
Eif(Label),
IfQues(Label),
While(Label),
Jump { label: Label },
EndCatch(Label),
EndExcept(Label),
EndFinally,
Eq,
Exit { stack: Offset, label: Label },
ExitId(Label),
Exp,
ForList { id: Name, end_label: Label },
ForRange { id: Name, end_label: Label },
Pop,
ImmNone,
Fork { fv_offset: Offset, id: Option<Name> },
FuncCall { id: Name },
GPush { id: Name },
GPut { id: Name },
Ge,
GetProp,
Gt,
IfQues(Label),
Imm(Label),
ImmBigInt(i64),
ImmInt(i32),
ImmEmptyList,
ImmErr(Error),
ImmInt(i32),
ImmNone,
ImmObjid(Objid),
ImmEmptyList,
Imm(Label),
In,
IndexSet,
Jump { label: Label },
Le,
Length(Offset),
ListAddTail,
ListAppend,
IndexSet,
MakeSingletonList,
CheckListForSplice,
PutTemp,
PushTemp,
Eq,
Ne,
Gt,
Lt,
Ge,
Le,
In,
Mul,
Sub,
Div,
MakeSingletonList,
Mod,
Add,
And(Label),
Or(Label),
Mul,
Ne,
Not,
UnaryMinus,
Ref,
Or(Label),
Pass,
Pop,
Push(Name),
PushGetProp,
PushLabel(Label),
PushRef,
PushTemp,
Put(Name),
RangeRef,
GPut { id: Name },
GPush { id: Name },
GetProp,
PushGetProp,
PutProp,
Fork { fv_offset: Offset, id: Option<Name> },
CallVerb,
PutTemp,
RangeRef,
RangeSet,
Ref,
Return,
Return0,
Done,
FuncCall { id: Name },
Pass,
RangeSet,
Length(Offset),
Exp,
Scatter(Box<ScatterArgs>),
PushLabel(Label),
TryFinally(Label),
Catch(Label),
Sub,
TryExcept { num_excepts: usize },
EndCatch(Label),
EndExcept(Label),
EndFinally,
TryFinally(Label),
UnaryMinus,
While(Label),
WhileId { id: Name, end_label: Label },
Continue,
ExitId(Label),
Exit { stack: Offset, label: Label },
If(Label),
}

#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Encode, Decode)]
pub enum ScatterLabel {
Optional(Name, Option<Label>),
Required(Name),
Rest(Name),
Optional(Name, Option<Label>),
}

#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Encode, Decode)]
Expand Down
22 changes: 11 additions & 11 deletions crates/compiler/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ fn parse_atom(
Rule::err => {
let e = pairs.as_str();
Ok(Expr::Value(match e.to_lowercase().as_str() {
"e_type" => v_err(E_TYPE),
"e_args" => v_err(E_ARGS),
"e_div" => v_err(E_DIV),
"e_perm" => v_err(E_PERM),
"e_propnf" => v_err(E_PROPNF),
"e_verbnf" => v_err(E_VERBNF),
"e_varnf" => v_err(E_VARNF),
"e_float" => v_err(E_FLOAT),
"e_invarg" => v_err(E_INVARG),
"e_invind" => v_err(E_INVIND),
"e_recmove" => v_err(E_RECMOVE),
"e_maxrec" => v_err(E_MAXREC),
"e_range" => v_err(E_RANGE),
"e_args" => v_err(E_ARGS),
"e_nacc" => v_err(E_NACC),
"e_invarg" => v_err(E_INVARG),
"e_quota" => v_err(E_QUOTA),
"e_float" => v_err(E_FLOAT),
"e_none" => v_err(E_NONE),
"e_perm" => v_err(E_PERM),
"e_propnf" => v_err(E_PROPNF),
"e_quota" => v_err(E_QUOTA),
"e_range" => v_err(E_RANGE),
"e_recmove" => v_err(E_RECMOVE),
"e_type" => v_err(E_TYPE),
"e_varnf" => v_err(E_VARNF),
"e_verbnf" => v_err(E_VERBNF),
&_ => {
panic!("unknown error")
}
Expand Down

0 comments on commit bbd4f58

Please sign in to comment.