mirror of
				https://forge.katzen.cafe/katzen-cafe/iowo.git
				synced 2025-10-29 08:37:57 +01:00 
			
		
		
		
	implement raw token/typed repr debug printing
This commit is contained in:
		
					parent
					
						
							
								0a6d9a27c5
							
						
					
				
			
			
				commit
				
					
						3b0e7f3edd
					
				
			
		
					 4 changed files with 33 additions and 4 deletions
				
			
		|  | @ -19,21 +19,36 @@ use crate::{ | |||
|     typed::into_typed_repr, | ||||
| }; | ||||
| 
 | ||||
| pub struct EvalConfig { | ||||
|     debug_raw_toks: bool, | ||||
|     debug_print_typed_repr: bool, | ||||
| } | ||||
| 
 | ||||
| impl EvalConfig { | ||||
|     pub fn new(debug_raw_toks: bool, debug_print_typed_repr: bool) -> Self { | ||||
|         Self { | ||||
|             debug_raw_toks, | ||||
|             debug_print_typed_repr, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| // this is also bad
 | ||||
| // need a better architecture for this
 | ||||
| 
 | ||||
| pub struct Evaluator<'a> { | ||||
|     curr_phase: EvalPhase, | ||||
|     files: SimpleFiles<&'a str, String>, | ||||
|     errors: HashMap<usize, Vec<Errors>>, | ||||
|     cfg: EvalConfig, | ||||
| } | ||||
| 
 | ||||
| impl<'a> Evaluator<'a> { | ||||
|     pub fn init() -> Self { | ||||
|     pub fn init(cfg: EvalConfig) -> Self { | ||||
|         Self { | ||||
|             curr_phase: EvalPhase::Lex, | ||||
|             files: SimpleFiles::new(), | ||||
|             errors: HashMap::new(), | ||||
|             cfg, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -41,6 +56,9 @@ impl<'a> Evaluator<'a> { | |||
|         let fid = self.files.add(name.unwrap_or("input"), input.clone()); | ||||
| 
 | ||||
|         let syntax = parse_syntax(&input); | ||||
|         if self.cfg.debug_raw_toks { | ||||
|             println!("Raw tokens: {syntax:#?}"); | ||||
|         } | ||||
| 
 | ||||
|         match syntax { | ||||
|             Ok(syntax) => self.curr_phase = EvalPhase::Check(fid, syntax), | ||||
|  | @ -80,6 +98,11 @@ impl<'a> Evaluator<'a> { | |||
|                     self.errors.insert(file_id, vec![errs]); | ||||
|                     self.curr_phase = EvalPhase::Failed; | ||||
|                 } else { | ||||
|                     if self.cfg.debug_print_typed_repr { | ||||
|                         let typed = r.unwrap(); | ||||
|                         println!("Typed repr: {typed:#?}"); | ||||
|                     } | ||||
| 
 | ||||
|                     todo!() | ||||
|                 } | ||||
|             } | ||||
|  | @ -93,6 +116,7 @@ impl<'a> Evaluator<'a> { | |||
|             curr_phase, | ||||
|             files, | ||||
|             errors, | ||||
|             cfg, | ||||
|         } = self; | ||||
| 
 | ||||
|         let writer = StandardStream::stderr(ColorChoice::Always); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Schrottkatze
				Schrottkatze