| 
									
										
										
										
											2025-10-23 16:15:25 +02:00
										 |  |  | use crate::errors::CLIArgumentError;
 | 
					
						
							|  |  |  | use lrlex::lrlex_mod;
 | 
					
						
							|  |  |  | use lrpar::lrpar_mod;
 | 
					
						
							|  |  |  | use std::error::Error;
 | 
					
						
							| 
									
										
										
										
											2025-10-25 11:39:07 +02:00
										 |  |  | use std::fmt::Display;
 | 
					
						
							| 
									
										
										
										
											2025-10-23 16:15:25 +02:00
										 |  |  | use std::io;
 | 
					
						
							|  |  |  | use std::io::ErrorKind::InvalidInput;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-10-20 19:29:49 +02:00
										 |  |  | mod ast;
 | 
					
						
							| 
									
										
										
										
											2025-10-23 16:15:25 +02:00
										 |  |  | mod errors;
 | 
					
						
							| 
									
										
										
										
											2025-10-20 19:29:49 +02:00
										 |  |  | mod optimising;
 | 
					
						
							| 
									
										
										
										
											2025-10-20 20:22:01 +02:00
										 |  |  | mod tests;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-10-25 11:39:07 +02:00
										 |  |  | lrlex_mod!("lexers/fudge.l");
 | 
					
						
							|  |  |  | lrpar_mod!("parsers/fudge.y");
 | 
					
						
							| 
									
										
										
										
											2025-10-23 16:15:25 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | fn main() -> Result<(), Box<dyn Error>> {
 | 
					
						
							|  |  |  |     let src_path = std::env::args()
 | 
					
						
							|  |  |  |         .nth(1)
 | 
					
						
							|  |  |  |         .ok_or(Box::new(CLIArgumentError("Source File Not Provided")))?;
 | 
					
						
							|  |  |  |     let src_string = std::fs::read_to_string(&src_path)?;
 | 
					
						
							| 
									
										
										
										
											2025-10-20 19:29:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-10-25 11:39:07 +02:00
										 |  |  |     let lexer_def = fudge_l::lexerdef();
 | 
					
						
							| 
									
										
										
										
											2025-10-23 16:15:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-10-25 11:39:07 +02:00
										 |  |  |     let lexer = lexer_def.lexer(src_string.as_str());
 | 
					
						
							|  |  |  |     let (res, errs) = fudge_y::parse(&lexer);
 | 
					
						
							|  |  |  |     match (res, errs) {
 | 
					
						
							|  |  |  |         (Some(Ok(res)), _) => {
 | 
					
						
							|  |  |  |             println!("Parsed succesfully:");
 | 
					
						
							|  |  |  |             println!("{:#?}", res);
 | 
					
						
							|  |  |  |         },
 | 
					
						
							|  |  |  |         (Some(Err(e)), _) => {
 | 
					
						
							|  |  |  |             println!("Parsing failed:");
 | 
					
						
							|  |  |  |             println!("{:#?}", e);
 | 
					
						
							|  |  |  |         }
 | 
					
						
							|  |  |  |         (_, vec) => {
 | 
					
						
							|  |  |  |             println!("LexParseErrors encountered:");
 | 
					
						
							|  |  |  |             println!("{:#?}", vec);
 | 
					
						
							|  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2025-10-23 16:15:25 +02:00
										 |  |  |     }
 | 
					
						
							| 
									
										
										
										
											2025-10-25 11:39:07 +02:00
										 |  |  |     
 | 
					
						
							| 
									
										
										
										
											2025-10-23 16:15:25 +02:00
										 |  |  |     Ok(())
 | 
					
						
							| 
									
										
										
										
											2025-10-20 19:29:49 +02:00
										 |  |  | }
 | 
					
						
							| 
									
										
										
										
											2025-10-23 16:15:25 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | // fn main() {
 | 
					
						
							|  |  |  | //     if let Err(ref e) = main_() {
 | 
					
						
							|  |  |  | //         return e.fmt()
 | 
					
						
							|  |  |  | //     }
 | 
					
						
							|  |  |  | // }
 |