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
*.scm~

View File

@ -9,7 +9,10 @@ match {
_
}
pub(crate) Trees = Tree+;
pub(crate) File = {Lang? <Trees> }
Trees = Tree+;
pub(crate) Tree: Tree = {
"(" <Tree+> ")" => Tree::Branch(<>),
@ -37,4 +40,11 @@ Num: f64 = { r"[0-9]+(\.[0-9]+)?" => <>.parse().unwrap() }
Bool: bool = {
"#t" => true,
"#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)]
mod tests;
// use debug2::dbg;
use rustyline::validate::{
MatchingBracketValidator, ValidationContext, ValidationResult, Validator,
@ -156,7 +155,7 @@ fn main() {
fn run_file(file: &str) -> io::Result<()> {
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();
for i in tree {
eval(&i, &mut env).unwrap();
@ -381,5 +380,3 @@ impl Validator for InputValidator {
self.brackets.validate(ctx)
}
}

View File

@ -1,3 +1,5 @@
#lang scheme
(define (displayln x) (display x) (newline))
(define (printbool x) (displayln (bool->int x)))
@ -9,8 +11,8 @@
(define (bool->int x)
(if
(equal? x true) 1
(if (equal? x false) 0 (- 1))))
(equal? x true) 1
(if (equal? x false) 0 (- 1))))
(printbool true)
(printbool false)

View File

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