mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-25 07:51:30 +02:00
implement basic namespacing for types, traits and commands
This commit is contained in:
parent
3cca2bc2cc
commit
b6b8c5085a
5 changed files with 287 additions and 6 deletions
18
src/main.rs
18
src/main.rs
|
@ -1,3 +1,4 @@
|
|||
use builtins::initialise_globals;
|
||||
use codespan_reporting::files::SimpleFiles;
|
||||
use codespan_reporting::term;
|
||||
use codespan_reporting::term::termcolor::ColorChoice;
|
||||
|
@ -6,6 +7,8 @@ use syntax::parse_syntax;
|
|||
|
||||
use crate::syntax::check::check;
|
||||
|
||||
mod builtins;
|
||||
mod hir;
|
||||
mod lexer;
|
||||
mod syntax;
|
||||
|
||||
|
@ -13,6 +16,11 @@ fn main() {
|
|||
let mut files = SimpleFiles::new();
|
||||
let mut out_errs = Vec::new();
|
||||
|
||||
let global_ns = initialise_globals();
|
||||
let int = global_ns.get_type_by_name("integer").unwrap();
|
||||
let numeric = global_ns.get_trait_by_name("Numeric").unwrap();
|
||||
assert!(int.has_trait(&numeric));
|
||||
|
||||
let invalid_toks = "meow | gay $ error!\\";
|
||||
let invalid_toks_id = files.add("invalid_toks", invalid_toks);
|
||||
if let Err(err) = parse_syntax(invalid_toks, invalid_toks_id) {
|
||||
|
@ -39,6 +47,16 @@ fn main() {
|
|||
out_errs.append(&mut errs)
|
||||
}
|
||||
|
||||
let invalid_no_sink = "meow | invert | ";
|
||||
let invalid_no_sink_id = files.add("invalid_no_sink", invalid_no_sink);
|
||||
if let Err(mut errs) = check(
|
||||
parse_syntax(invalid_no_sink, invalid_no_sink_id).unwrap(),
|
||||
invalid_no_sink,
|
||||
invalid_no_sink_id,
|
||||
) {
|
||||
out_errs.append(&mut errs)
|
||||
}
|
||||
|
||||
// invalid
|
||||
let writer = StandardStream::stderr(ColorChoice::Always);
|
||||
let config = term::Config::default();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue