Skip to content

Commit

Permalink
Merge pull request #36 from FrankBro/website
Browse files Browse the repository at this point in the history
Website
  • Loading branch information
FrankBro authored Jan 22, 2024
2 parents 01de4ac + 8868aa9 commit 1661192
Show file tree
Hide file tree
Showing 30 changed files with 2,671 additions and 132 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target
web/dist
web/target
23 changes: 15 additions & 8 deletions Cargo.lock

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

15 changes: 3 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
[package]
name = "ordo"
version = "0.1.0"
edition = "2021"

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

[dependencies]
itertools = "0.12.0"
logos = "0.13.0"
wasmi = "0.31.1"
wat = "1.0.83"
[workspace]
members = ["cli", "ordo"]
exclude = ["web"]
9 changes: 9 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "cli"
version = "0.1.0"
edition = "2021"

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

[dependencies]
ordo = { path = "../ordo" }
112 changes: 3 additions & 109 deletions src/main.rs → cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,84 +1,6 @@
use core::make_env;
use std::{
fmt,
io::{self, stdout, BufRead, Write},
};
use std::io::{self, stdout, BufRead, Write};

use parser::Parser;

pub mod core;
pub mod emit;
pub mod eval;
pub mod expr;
pub mod infer;
pub mod lexer;
pub mod parser;

#[derive(Debug)]
enum Error {
Parser(parser::Error),
Infer(infer::Error),
Eval(eval::Error),
}

impl From<parser::Error> for Error {
fn from(value: parser::Error) -> Self {
Self::Parser(value)
}
}

impl From<infer::Error> for Error {
fn from(value: infer::Error) -> Self {
Self::Infer(value)
}
}

impl From<eval::Error> for Error {
fn from(value: eval::Error) -> Self {
Self::Eval(value)
}
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Parser(p) => write!(f, "parser: {}", p),
Error::Infer(i) => write!(f, "infer: {}", i),
Error::Eval(e) => write!(f, "eval: {}", e),
}
}
}

type Result<T, E = Error> = std::result::Result<T, E>;

struct Output {
ty: String,
val: String,
}

struct Env {
infer: infer::Env,
eval: eval::Env,
}

impl Default for Env {
fn default() -> Self {
let infer = make_env();
let eval = Default::default();
Self { infer, eval }
}
}

impl Env {
fn process(&mut self, source: &str) -> Result<Output> {
let expr = Parser::repl(source)?;
let typed_expr = self.infer.infer(expr.clone())?;
let value = self.eval.eval(&expr)?;
let ty = self.infer.ty_to_string(typed_expr.ty()).unwrap();
let val = value.to_string();
Ok(Output { ty, val })
}
}
use ordo::env::Env;

const ORDO: &str = "ordo>>> ";
const ERROR: &str = "error: ";
Expand Down Expand Up @@ -110,7 +32,7 @@ fn main() {

#[test]
fn readme_test() {
let file = std::fs::read_to_string("README.md").unwrap();
let file = std::fs::read_to_string("../README.md").unwrap();
let lines: Vec<&str> = file.lines().collect();
let mut i = 0;

Expand Down Expand Up @@ -155,31 +77,3 @@ fn readme_test() {
}
}
}

#[cfg(test)]
#[path = "tests/ifs.rs"]
mod ifs;

#[cfg(test)]
#[path = "tests/unwraps.rs"]
mod unwraps;

#[cfg(test)]
#[path = "tests/parse_only.rs"]
mod parse_only;

#[cfg(test)]
#[path = "tests/parse_at.rs"]
mod parse_at;

#[cfg(test)]
#[path = "tests/infer_tests.rs"]
mod infer_tests;

#[cfg(test)]
#[path = "tests/typed_exprs.rs"]
mod typed_exprs;

#[cfg(test)]
#[path = "tests/emit_tests.rs"]
mod emit_tests;
15 changes: 15 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html><head>
<meta charset="utf-8">
<link href="https://fonts.cdnfonts.com/css/source-code-pro" rel="stylesheet">
<title>ordo</title>
<style>
body {
font-family: "Source Code Pro", sans-serif;
}
</style>

<link rel="preload" href="/web-78a67224672b0005_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/web-78a67224672b0005.js"></head>
<body>

<script type="module">import init from '/web-78a67224672b0005.js';init('/web-78a67224672b0005_bg.wasm');</script></body></html>
Loading

0 comments on commit 1661192

Please sign in to comment.