fix comment syntax

replace/7746dba3cc6b3860afe1faf69e86ed84ee46988d
Natapat Samutpong 2022-03-12 07:35:16 +07:00
parent 9fb5a8e715
commit 1079d53f05
2 changed files with 11 additions and 9 deletions

View File

@ -111,9 +111,7 @@ pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, Error = Simple<char>> {
.or(keyword)
.recover_with(skip_then_retry_until([]));
let comment = just("--")
.ignore_then(filter(|c| *c != '\n').repeated())
.then_ignore(just('\n'));
let comment = just("--").then(take_until(just('\n'))).padded();
token
.padded_by(comment.repeated())

View File

@ -64,6 +64,7 @@ fn main() {
for err in lex_error { diagnostics.add_lex_error(err); }
for err in parse_error { diagnostics.add_parse_error(err); }
// Report syntax errors if any
if diagnostics.has_error() {
diagnostics.display(src);
logif!(0, "Epic parsing fail");
@ -77,6 +78,8 @@ fn main() {
// Convert the AST to HIR
let (ir, lowering_error) = ast_to_ir(ast);
for err in lowering_error { diagnostics.add_lowering_error(err); }
// Report lowering errors if any
if diagnostics.has_error() {
diagnostics.display(src);
logif!(0, "Epic Lowering(HIR) fail");
@ -98,17 +101,18 @@ fn main() {
let mut file = fs::File::create(&output_path).expect("Failed to create file");
file.write_all(codegen.emitted.as_bytes()).expect("Failed to write to file");
// End timer
let duration = start.elapsed().as_millis();
logif!(0, format!("Compilation took {}ms", duration));
logif!(0, format!("Wrote output to `{}`", output_path.display()));
// Compile the generate code
let compiler = &config.compiler.compiler;
Command::new(compiler)
.arg(&output_path)
.spawn()
.expect("Failed to run compiler");
// End timer
let duration = start.elapsed().as_millis();
logif!(0, format!("Compilation took {}ms", duration));
logif!(0, format!("Wrote output to `{}`", output_path.display()));
},
None => { unreachable!(); }
}