mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
refactor: change register format
This commit is contained in:
parent
8230151489
commit
4831b1265f
|
@ -28,6 +28,7 @@ DONE:
|
|||
- Math:
|
||||
|
||||
TODO:
|
||||
- Prove turing complete
|
||||
- Do the intrinsic left
|
||||
- Quote, Quasiquote, etc.
|
||||
- Optimizing
|
||||
|
|
|
@ -52,7 +52,6 @@ impl Compiler {
|
|||
_ => {
|
||||
result.append(&mut self.compile_intrinsic(call, &cdr)?);
|
||||
}
|
||||
_ => { dbg!(call); unimplemented!() },
|
||||
} // End `match call`
|
||||
}, // End `Symbol(call)`
|
||||
_ => { dbg!(car); unimplemented!() },
|
||||
|
|
|
@ -161,15 +161,17 @@ impl Register {
|
|||
|
||||
impl Display for Register {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "r{}", self.value)
|
||||
write!(f, "%{}", self.value)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Register {
|
||||
type Err = ();
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let value = s[1..].parse::<usize>().map_err(|_| ())?;
|
||||
if !s.starts_with("%") { return Err(format!("Invalid register: {}", s)); }
|
||||
|
||||
let value = s[1..].parse::<usize>().map_err(|_| (format!("Invalid register: {}", s)))?;
|
||||
Ok(Register { value })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
(fun cool_number (/ (+ 345 345) 10))
|
||||
(fun main
|
||||
(print (/ (+ 345 345) 10)))
|
||||
(print cool_number))
|
27
test.sh
27
test.sh
|
@ -2,12 +2,21 @@ in=$1 # Get first's file name
|
|||
noext=${in%.*} # Remove extension
|
||||
name=${noext##*/} # Remove path
|
||||
|
||||
make debug
|
||||
blspc compile $noext.blsp
|
||||
echo -e "------------------------------------------- SOURCE"
|
||||
cat $noext.blsp
|
||||
echo -e "\n----------------------------------------- COMPILED"
|
||||
cat $name.bsm
|
||||
echo -e "------------------------------------------- OUTPUT"
|
||||
blspc run $name.bsm
|
||||
echo -e "--------------------------------------------------"
|
||||
echo $2
|
||||
# if $2 equal to "noecho"
|
||||
if [ $2 = "noecho" ];
|
||||
then
|
||||
make debug; echo ""; blspc compile $noext.blsp; echo ""
|
||||
cat $noext.blsp; echo -e "\n"; cat $name.bsm; echo ""
|
||||
blspc run $name.bsm
|
||||
else
|
||||
make debug
|
||||
blspc compile $noext.blsp
|
||||
echo -e "------------------------------------------- SOURCE"
|
||||
cat $noext.blsp
|
||||
echo -e "\n----------------------------------------- COMPILED"
|
||||
cat $name.bsm
|
||||
echo -e "------------------------------------------- OUTPUT"
|
||||
blspc run $name.bsm
|
||||
echo -e "--------------------------------------------------"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue