typeck: Add a query for all strings

This commit is contained in:
John 2024-07-29 15:55:53 -05:00
parent 5662bd8524
commit 1b217b2e75

View File

@ -1,3 +1,4 @@
use cl_structures::intern::string_interner::StringInterner;
use cl_typeck::{entry::Entry, stage::*, table::Table, type_expression::TypeExpression}; use cl_typeck::{entry::Entry, stage::*, table::Table, type_expression::TypeExpression};
use cl_ast::{ use cl_ast::{
@ -58,23 +59,25 @@ fn main_menu(prj: &mut Table) -> Result<(), RlError> {
match line.trim() { match line.trim() {
"c" | "code" => enter_code(prj)?, "c" | "code" => enter_code(prj)?,
"clear" => clear()?, "clear" => clear()?,
"d" | "desugar" => live_desugar()?,
"e" | "exit" => return Ok(Response::Break), "e" | "exit" => return Ok(Response::Break),
"f" | "file" => import_files(prj)?, "f" | "file" => import_files(prj)?,
"i" | "id" => get_by_id(prj)?,
"l" | "list" => list_types(prj), "l" | "list" => list_types(prj),
"q" | "query" => query_type_expression(prj)?, "q" | "query" => query_type_expression(prj)?,
"i" | "id" => get_by_id(prj)?,
"r" | "resolve" => resolve_all(prj)?, "r" | "resolve" => resolve_all(prj)?,
"d" | "desugar" => live_desugar()?, "s" | "strings" => print_strings(),
"h" | "help" => { "h" | "help" | "" => {
println!( println!(
"Valid commands are: "Valid commands are:
clear : Clear the screen
code (c): Enter code to type-check code (c): Enter code to type-check
desugar (d): WIP: Test the experimental desugaring passes
file (f): Load files from disk file (f): Load files from disk
id (i): Get a type by its type ID
list (l): List all known types list (l): List all known types
query (q): Query the type system query (q): Query the type system
id (i): Get a type by its type ID
resolve (r): Perform type resolution resolve (r): Perform type resolution
desugar (d): WIP: Test the experimental desugaring passes
help (h): Print this list help (h): Print this list
exit (e): Exit the program" exit (e): Exit the program"
); );
@ -118,6 +121,10 @@ fn live_desugar() -> Result<(), RlError> {
}) })
} }
fn print_strings() {
println!("{}", StringInterner::global());
}
fn query_type_expression(prj: &mut Table) -> Result<(), RlError> { fn query_type_expression(prj: &mut Table) -> Result<(), RlError> {
read_and(C_RESV, "ty>", "? >", |line| { read_and(C_RESV, "ty>", "? >", |line| {
if line.trim().is_empty() { if line.trim().is_empty() {