Drracket compat

trunk
Alona EM 2021-12-27 15:07:07 +00:00
parent c1eb1ed61e
commit 46b96f3e82
6 changed files with 2135 additions and 1603 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target /target
*.scm~

View File

@ -9,7 +9,10 @@ match {
_ _
} }
pub(crate) Trees = Tree+;
pub(crate) File = {Lang? <Trees> }
Trees = Tree+;
pub(crate) Tree: Tree = { pub(crate) Tree: Tree = {
"(" <Tree+> ")" => Tree::Branch(<>), "(" <Tree+> ")" => Tree::Branch(<>),
@ -38,3 +41,10 @@ Bool: bool = {
"#t" => true, "#t" => true,
"#f" => false, "#f" => false,
} }
Lang: () = { "#lang" LangName }
LangName = {
// TODO: What should these be?
"scheme",
"r7rs",
}

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,6 @@ mod grammar;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
// use debug2::dbg; // use debug2::dbg;
use rustyline::validate::{ use rustyline::validate::{
MatchingBracketValidator, ValidationContext, ValidationResult, Validator, MatchingBracketValidator, ValidationContext, ValidationResult, Validator,
@ -156,7 +155,7 @@ fn main() {
fn run_file(file: &str) -> io::Result<()> { fn run_file(file: &str) -> io::Result<()> {
let src = std::fs::read_to_string(file)?; let src = std::fs::read_to_string(file)?;
let tree = grammar::TreesParser::new().parse(&src).unwrap(); let tree = grammar::FileParser::new().parse(&src).unwrap();
let mut env = default_env(); let mut env = default_env();
for i in tree { for i in tree {
eval(&i, &mut env).unwrap(); eval(&i, &mut env).unwrap();
@ -381,5 +380,3 @@ impl Validator for InputValidator {
self.brackets.validate(ctx) self.brackets.validate(ctx)
} }
} }

View File

@ -1,3 +1,5 @@
#lang scheme
(define (displayln x) (display x) (newline)) (define (displayln x) (display x) (newline))
(define (printbool x) (displayln (bool->int x))) (define (printbool x) (displayln (bool->int x)))

View File

@ -1,4 +1,6 @@
(define (displayln x) (display x) (newline)) (define (displayln x)
(display x)
(newline))
(displayln (+)) (displayln (+))
(displayln (+ 1)) (displayln (+ 1))