diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index 0086496..32f4f5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -129,11 +129,13 @@ fn write_bytes_and_exit<P: AsRef<Path>>(bytes: &[u8], path: Option<&P>) -> ! { } -fn report_syntactic_errors(syntactic_tokens: &[SyntacticToken], source_code: &str) { +fn report_syntactic_errors(syntactic_tokens: &[syntactic::Token], source_code: &str) { + use syntactic::*; + for token in syntactic_tokens { let context = Context { source_code: &source_code, source: &token.source }; match &token.variant { - SyntacticTokenVariant::ConstantExpression(expr) => for t in &expr.tokens { + TokenVariant::ConstantExpression(expr) => for t in &expr.tokens { let context = Context { source_code: &source_code, source: &t.source }; if let ConstantExpressionTokenVariant::Error(err) = &t.variant { let ConstantExpressionParseError::InvalidHexadecimalLiteral(hex) = err; @@ -141,7 +143,7 @@ fn report_syntactic_errors(syntactic_tokens: &[SyntacticToken], source_code: &st report_source_issue(LogLevel::Error, &context, &message); } } - SyntacticTokenVariant::PackedBinaryLiteral(pbl) => for e in &pbl.errors { + TokenVariant::PackedBinaryLiteral(pbl) => for e in &pbl.errors { let context = Context { source_code: &source_code, source: &e.source }; match e.variant { PackedBinaryLiteralParseErrorVariant::DuplicateFieldName(name) => { @@ -154,20 +156,20 @@ fn report_syntactic_errors(syntactic_tokens: &[SyntacticToken], source_code: &st } } } - SyntacticTokenVariant::Error(err) => match err { - SyntacticParseError::InvalidHexadecimalLiteral(hex) => { + TokenVariant::Error(err) => match err { + ParseError::InvalidHexadecimalLiteral(hex) => { let message = format!("Invalid hexadecimal literal {hex:?}"); report_source_issue(LogLevel::Error, &context, &message); } - SyntacticParseError::InvalidSymbolIdentifier(name) => { + ParseError::InvalidSymbolIdentifier(name) => { let message = format!("Invalid identifier {name:?}"); report_source_issue(LogLevel::Error, &context, &message); } - SyntacticParseError::UnterminatedComment => { + ParseError::UnterminatedComment => { let message = format!("Unterminated comment"); report_source_issue(LogLevel::Error, &context, &message); } - SyntacticParseError::UnterminatedConstantExpression => { + ParseError::UnterminatedConstantExpression => { let message = format!("Unterminated constant expression"); report_source_issue(LogLevel::Error, &context, &message); } |