Drracket compat
parent
c1eb1ed61e
commit
46b96f3e82
|
@ -1 +1,2 @@
|
|||
/target
|
||||
*.scm~
|
|
@ -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",
|
||||
}
|
3708
src/grammar.rs
3708
src/grammar.rs
File diff suppressed because it is too large
Load Diff
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
(define (displayln x) (display x) (newline))
|
||||
(define (displayln x)
|
||||
(display x)
|
||||
(newline))
|
||||
|
||||
(displayln (+))
|
||||
(displayln (+ 1))
|
||||
|
|
Loading…
Reference in New Issue