| 
									
										
										
										
											2025-10-23 16:15:25 +02:00
										 |  |  | use crate::errors::CLIArgumentError;
 | 
					
						
							|  |  |  | use lrlex::lrlex_mod;
 | 
					
						
							|  |  |  | use lrpar::lrpar_mod;
 | 
					
						
							|  |  |  | use std::error::Error;
 | 
					
						
							|  |  |  | use std::fmt::{Display, format};
 | 
					
						
							|  |  |  | 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-23 16:15:25 +02:00
										 |  |  | lrlex_mod!("grammar.l");
 | 
					
						
							|  |  |  | lrpar_mod!("grammar.y");
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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-23 16:15:25 +02:00
										 |  |  |     let lexerdef = grammar_l::lexerdef();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let lexer = lexerdef.lexer((src_string.as_str()));
 | 
					
						
							|  |  |  |     let (res, errs) = grammar_y::parse(&lexer);
 | 
					
						
							|  |  |  |     if let Some(Ok(res)) = res {
 | 
					
						
							|  |  |  |         println!("{:#?}", res);
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  |     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()
 | 
					
						
							|  |  |  | //     }
 | 
					
						
							|  |  |  | // }
 |