Some various work
This commit is contained in:
parent
a829fb6cd8
commit
938c0401d1
@ -21,7 +21,7 @@ use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use itertools::Itertools;
|
||||
use schala_repl::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, LangMetaRequest, LangMetaResponse, GlobalOutputStats};
|
||||
use schala_repl::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, LangMetaRequest, LangMetaResponse, GlobalOutputStats, DebugRequest, DebugResponse};
|
||||
|
||||
macro_rules! bx {
|
||||
($e:expr) => { Box::new($e) }
|
||||
@ -82,6 +82,18 @@ impl Schala {
|
||||
s.run_computation(request);
|
||||
s
|
||||
}
|
||||
|
||||
fn handle_debug_immediate(&self, request: DebugRequest) -> DebugResponse {
|
||||
if request.kind == "symbol-table" {
|
||||
let debug = self.symbol_table.borrow().debug_symbol_table();
|
||||
return DebugResponse { kind: format!("symbol-table"), value: debug };
|
||||
}
|
||||
|
||||
DebugResponse {
|
||||
kind: format!("unknown"),
|
||||
value: format!(""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn tokenizing(input: &str, _handle: &mut Schala, comp: Option<&mut PassDebugArtifact>) -> Result<Vec<tokenizing::Token>, String> {
|
||||
@ -251,6 +263,8 @@ impl ProgrammingLanguageInterface for Schala {
|
||||
"ast reduction".into(), "ast-walking-evaluation".into()]
|
||||
),
|
||||
LangMetaRequest::Docs { source } => self.handle_docs(source),
|
||||
LangMetaRequest::ImmediateDebug(debug_request) =>
|
||||
LangMetaResponse::ImmediateDebug(self.handle_debug_immediate(debug_request)),
|
||||
LangMetaRequest::Custom { .. } => LangMetaResponse::Custom { kind: format!("not-implemented"), value: format!("") }
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ pub struct ComputationResponse {
|
||||
}
|
||||
|
||||
pub struct DebugRequest {
|
||||
kind: String,
|
||||
value: String
|
||||
pub kind: String,
|
||||
pub value: String
|
||||
}
|
||||
|
||||
pub struct DebugResponse {
|
||||
kind: String,
|
||||
value: String
|
||||
pub kind: String,
|
||||
pub value: String
|
||||
}
|
||||
|
||||
pub enum LangMetaRequest {
|
||||
@ -46,7 +46,8 @@ pub enum LangMetaRequest {
|
||||
Custom {
|
||||
kind: String,
|
||||
value: String
|
||||
}
|
||||
},
|
||||
ImmediateDebug(DebugRequest),
|
||||
}
|
||||
|
||||
pub enum LangMetaResponse {
|
||||
@ -57,7 +58,8 @@ pub enum LangMetaResponse {
|
||||
Custom {
|
||||
kind: String,
|
||||
value: String
|
||||
}
|
||||
},
|
||||
ImmediateDebug(DebugResponse),
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
|
@ -24,7 +24,7 @@ mod repl;
|
||||
mod language;
|
||||
mod webapp;
|
||||
|
||||
pub use language::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, LangMetaRequest, LangMetaResponse, GlobalOutputStats};
|
||||
pub use language::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, LangMetaRequest, LangMetaResponse, DebugRequest, DebugResponse, GlobalOutputStats};
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/static.rs"));
|
||||
const VERSION_STRING: &'static str = "0.1.0";
|
||||
|
@ -61,10 +61,11 @@ impl CommandTree {
|
||||
}
|
||||
}
|
||||
pub fn get_children(&self) -> Vec<&str> {
|
||||
use CommandTree::*;
|
||||
match self {
|
||||
CommandTree::Terminal { .. } => vec![],
|
||||
CommandTree::NonTerminal { children, .. } => children.iter().map(|x| x.get_cmd()).collect(),
|
||||
CommandTree::Top(children) => children.iter().map(|x| x.get_cmd()).collect(),
|
||||
Terminal { children, .. } |
|
||||
NonTerminal { children, .. } |
|
||||
Top(children) => children.iter().map(|x| x.get_cmd()).collect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||
|
||||
use colored::*;
|
||||
use itertools::Itertools;
|
||||
use crate::language::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, LangMetaRequest, LangMetaResponse};
|
||||
use crate::language::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, LangMetaRequest, LangMetaResponse, DebugRequest, DebugResponse};
|
||||
mod command_tree;
|
||||
use self::command_tree::{CommandTree, BoxedCommandFunction};
|
||||
|
||||
@ -16,6 +16,7 @@ pub struct Repl {
|
||||
interpreter_directive_sigil: char,
|
||||
line_reader: ::linefeed::interface::Interface<::linefeed::terminal::DefaultTerminal>,
|
||||
language_states: Vec<Box<ProgrammingLanguageInterface>>,
|
||||
debug_asks: Vec<String>,
|
||||
}
|
||||
|
||||
impl Repl {
|
||||
@ -23,9 +24,10 @@ impl Repl {
|
||||
use linefeed::Interface;
|
||||
let line_reader = Interface::new("schala-repl").unwrap();
|
||||
let interpreter_directive_sigil = ':';
|
||||
let debug_asks = vec![];
|
||||
|
||||
Repl {
|
||||
interpreter_directive_sigil, line_reader, language_states: initial_states,
|
||||
interpreter_directive_sigil, line_reader, language_states: initial_states, debug_asks
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,6 +233,7 @@ impl Repl {
|
||||
}
|
||||
Some(buf)
|
||||
})),
|
||||
CommandTree::nonterm("show-immediate", None, passes_directives.clone()),
|
||||
CommandTree::nonterm("show", None, passes_directives.clone()),
|
||||
CommandTree::nonterm("hide", None, passes_directives.clone()),
|
||||
CommandTree::nonterm("timing", None, vec![
|
||||
@ -239,7 +242,25 @@ impl Repl {
|
||||
])
|
||||
],
|
||||
Box::new(|repl: &mut Repl, cmds: &[&str]| {
|
||||
Some(format!("Commands: {:?}", cmds))
|
||||
let mut cur_state = repl.get_cur_language_state();
|
||||
match cmds.get(0) {
|
||||
Some(&"show-immediate") => {
|
||||
let debug_stage = match cmds.get(1) {
|
||||
Some(s) => s.to_string(),
|
||||
None => return Some(format!("Must specify a thing to debug")),
|
||||
};
|
||||
let meta = LangMetaRequest::ImmediateDebug(DebugRequest {
|
||||
kind: debug_stage,
|
||||
value: format!(""),
|
||||
});
|
||||
let response = cur_state.request_meta(meta);
|
||||
None
|
||||
},
|
||||
Some(&"show") => panic!(),
|
||||
Some(&"hide") => panic!(),
|
||||
Some(&"timing") => panic!(),
|
||||
e => Some(format!("Unsupported command: {:?}", e)),
|
||||
}
|
||||
})
|
||||
),
|
||||
CommandTree::nonterm("lang",
|
||||
|
Loading…
Reference in New Issue
Block a user