switched to lrpar parser generator
This commit is contained in:
		
							
								
								
									
										35
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -1,10 +1,37 @@ | ||||
| use lalrpop_util::lalrpop_mod; | ||||
| 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; | ||||
|  | ||||
| mod ast; | ||||
| mod errors; | ||||
| mod optimising; | ||||
| mod tests; | ||||
|  | ||||
| lalrpop_mod!(pub expressions); | ||||
| lrlex_mod!("grammar.l"); | ||||
| lrpar_mod!("grammar.y"); | ||||
|  | ||||
| fn main() { | ||||
|     println!("Hello, world!"); | ||||
| 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)?; | ||||
|  | ||||
|     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(()) | ||||
| } | ||||
|  | ||||
| // fn main() { | ||||
| //     if let Err(ref e) = main_() { | ||||
| //         return e.fmt() | ||||
| //     } | ||||
| // } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user