Skip to content

Commit 898dab7

Browse files
committed
0.1.52
1 parent 9695394 commit 898dab7

File tree

4 files changed

+956
-487
lines changed

4 files changed

+956
-487
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambdascript"
3-
version = "0.1.51"
3+
version = "0.1.52"
44
authors = ["Chuck Liang"]
55
edition = "2021"
66
license = "MIT"
@@ -13,4 +13,5 @@ categories = ["command-line-utilities", "parsing", "mathematics"]
1313
[dependencies]
1414
rustlr = "0.4"
1515
fixedstr = "0.2.9"
16-
chrono = "0.4"
16+
#chrono = "0.4"
17+
curl = "0.4.44"

src/main.rs

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ extern crate fixedstr;
1010
use fixedstr::str16;
1111
//mod abstmachine;
1212
//use crate::abstmachine::*;
13-
use chrono;
14-
use chrono::{Datelike,Timelike};
15-
use std::io::Write;
13+
//use chrono;
14+
//use chrono::{Datelike, Timelike};
1615
use std::collections::HashMap;
16+
use std::io::Write;
1717

1818
mod untyped;
1919
use untyped::*;
@@ -23,56 +23,54 @@ use untypedparser::*;
2323
//mod exsubs;
2424
//mod lmb;
2525

26-
fn main()
27-
{
28-
println!("Beta-Reducer for Untyped Lambda Calculus, by Chuck Liang.");
29-
println!("For educational reasons this program may be temporarily disabled during certain time periods");
30-
let time = chrono::offset::Local::now();
26+
fn main() {
27+
println!("Beta-Reducer for Untyped Lambda Calculus, by Chuck Liang.");
28+
println!("For educational reasons this program may be temporarily disabled during certain time periods");
29+
if !lambda_formal() {return;}
30+
let mut parser = make_parser();
31+
let ref mut defs = HashMap::<str16, Term>::new();
32+
let args: Vec<String> = std::env::args().collect(); // command-line args
33+
if args.len() > 1 {
34+
let srcfile = &args[1];
35+
let source = LexSource::new(srcfile).unwrap();
36+
// let mut lexer = LamLexer::new(StrTokenizer::from_source(&source));
37+
let mut lexer = untypedlexer::from_source(&source);
38+
parser.parse(&mut lexer);
39+
//parser.parse_train(&mut lexer,"src/untypedparser.rs");
40+
eval_prog(&parser.exstate, defs);
41+
if parser.error_occurred() {
42+
println!("\nPARSER ERRORS OCCURRED, RESULTS NOT GUARANTEED");
43+
}
44+
//return;
45+
} // source file indicated
46+
println!("Entering interactive mode, enter 'exit' to quit...");
47+
loop
48+
// will break from within
49+
{
50+
print!("<<< ");
51+
let res = std::io::stdout().flush();
52+
let mut buf = String::new();
53+
let res2 = std::io::stdin().read_line(&mut buf);
54+
let bln = buf.len();
55+
let buftrim = buf.trim();
56+
if bln < 3 {
57+
continue;
58+
} else if buftrim == "exit" || buftrim == "quit" {
59+
break;
60+
}
3161

32-
/*
33-
if time.year()>2022 || time.month()>8 {
34-
println!("\nThe lifetime of this program has expired. A new version will be released at the appropriate time.");
35-
return;
36-
}
37-
*/
62+
if !buftrim.ends_with(';') {
63+
buf = format!("{};",buftrim);
64+
}
3865

39-
if time.year()==2023 && time.month()==2 && ((time.day()==14 && time.hour()>=4 && time.minute()>=20) || time.day()>14) && time.day()<=16 {
40-
println!("\nThis tool is temporarily disabled because of online exams in CSC252DL");
41-
return;
42-
}
4366

44-
let mut parser = make_parser();
45-
let ref mut defs = HashMap::<str16,Term>::new();
46-
let args:Vec<String> = std::env::args().collect(); // command-line args
47-
if args.len()>1 {
48-
let srcfile = &args[1];
49-
let source = LexSource::new(srcfile).unwrap();
50-
// let mut lexer = LamLexer::new(StrTokenizer::from_source(&source));
51-
let mut lexer = untypedlexer::from_source(&source);
52-
parser.parse(&mut lexer);
53-
//parser.parse_train(&mut lexer,"src/untypedparser.rs");
54-
eval_prog(&parser.exstate,defs);
55-
if parser.error_occurred() {
56-
println!("\nPARSER ERRORS OCCURRED, RESULTS NOT GUARANTEED");
57-
}
58-
//return;
59-
} // source file indicated
60-
println!("Entering interactive mode, enter 'exit' to quit...");
61-
loop // will break from within
62-
{
63-
print!("<<< "); let res =std::io::stdout().flush();
64-
let mut buf = String::new();
65-
let res2 = std::io::stdin().read_line(&mut buf);
66-
if buf.len()<3 {continue;}
67-
else if buf.trim()=="exit" || buf.trim()=="quit" {break;}
68-
//let mut lexer = LamLexer::new(StrTokenizer::from_str(buf.trim()));
69-
let mut lexer = untypedlexer::from_str(buf.trim());
70-
parser.exstate.clear();
71-
parser.parse(&mut lexer);
72-
//parser.parse_train(&mut lexer,"src/untypedparser.rs");
73-
//println!("exstate: {:?}",&parser.exstate);
67+
let mut lexer = untypedlexer::from_str(buf.trim());
68+
parser.exstate.clear();
69+
parser.parse(&mut lexer);
70+
//parser.parse_train(&mut lexer,"src/untypedparser.rs");
71+
//println!("exstate: {:?}",&parser.exstate);
7472

75-
eval_prog(&parser.exstate,defs);
76-
} // repl
77-
}//main
73+
eval_prog(&parser.exstate, defs);
74+
} // repl
75+
} //main
7876

0 commit comments

Comments
 (0)