Use colored in symbol table debug

This commit is contained in:
greg 2019-09-25 02:28:24 -07:00
parent 2e42313991
commit 58251d3f28
4 changed files with 8 additions and 4 deletions

1
Cargo.lock generated
View File

@ -728,6 +728,7 @@ dependencies = [
name = "schala-lang"
version = "0.1.0"
dependencies = [
"colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"derivative 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -13,6 +13,7 @@ failure = "0.1.5"
ena = "0.11.0"
stopwatch = "0.0.7"
derivative = "1.0.3"
colored = "1.8"
schala-lang-codegen = { path = "../codegen" }
schala-repl = { path = "../../schala-repl" }

View File

@ -17,6 +17,7 @@ extern crate schala_repl;
extern crate schala_lang_codegen;
extern crate ena;
extern crate derivative;
extern crate colored;
macro_rules! bx {

View File

@ -32,13 +32,14 @@ pub struct ScopeSegment {
impl fmt::Display for ScopeSegment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use colored::*;
use ScopeSegmentKind::*;
let kind = match self.kind {
Function => "fn",
Type => "ty",
Terminal => "tr",
Function => "[fn]".green(),
Type => "[ty]".red(),
Terminal => "[tr]".blue(),
};
write!(f, "{}({})", self.name, kind)
write!(f, "{}{}", self.name, kind)
}
}