Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
svelterust committed Jan 28, 2024
1 parent 5ce0d7b commit 3e2af53
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ because the operating system itself is the runtime.
git clone https://github.com/knarkzel/knarkos
cd knarkos
nix develop # or nix-shell
cd os/
cargo run
just build
```

## Goals
Expand Down
25 changes: 25 additions & 0 deletions lisp/Cargo.lock

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

3 changes: 1 addition & 2 deletions lisp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ name = "lisp"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
nom = "7.1.3"
34 changes: 33 additions & 1 deletion lisp/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
use nom::{
branch::alt,
bytes::complete::{tag, take_while_m_n},
combinator::{map, map_res},
sequence::tuple,
IResult,
};

enum Operator {
Plus,
Minus,
Times,
Divide,
}

// Atoms
enum Atom {
Number(i32),
Operator(Operator),
}

fn parse_atom(input: &str) -> IResult<&str, Atom> {
map(
alt((
map(tag("+"), |_| Operator::Plus),
map(tag("-"), |_| Operator::Minus),
map(tag("*"), |_| Operator::Times),
map(tag("/"), |_| Operator::Divide),
)),
|operator| Atom::Operator(operator),
)(input)
}

fn main() {
println!("Hello, world!");
}

0 comments on commit 3e2af53

Please sign in to comment.