Skip to content

Commit

Permalink
Ignore `resetall (rather than erroring out)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcoram committed Jul 11, 2024
1 parent 04cb1fb commit 47df3de
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions openvaf/basedb/src/diagnostics/preprocessor_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ impl Diagnostic for PreprocessorDiagnostic {
}])
}
PreprocessorDiagnostic::MacroRecursion { .. } => todo!(),
PreprocessorDiagnostic::UnsupportedCompDir { span, .. } => {
let span = span.to_file_span(&sm);

Report::warning().with_labels(vec![Label {
style: LabelStyle::Primary,
file_id: span.file,
range: span.range.into(),
message: "directive ignored".to_owned(),
}])
}
PreprocessorDiagnostic::FileNotFound { span, .. } => {
let labels = if let Some(span) = span {
let span = span.to_file_span(&sm);
Expand Down
2 changes: 2 additions & 0 deletions openvaf/preprocessor/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub enum PreprocessorDiagnostic {
MacroNotFound { name: String, span: CtxSpan },
MacroNotDefined { name: String, span: CtxSpan },
MacroRecursion { name: String, span: CtxSpan },
UnsupportedCompDir { name: String, span: CtxSpan },
FileNotFound { file: String, error: io::ErrorKind, span: Option<CtxSpan> },
InvalidTextFormat { span: Option<CtxSpan>, file: VfsPath, err: InvalidTextFormatErr },
UnexpectedEof { expected: &'static str, span: CtxSpan },
Expand All @@ -26,6 +27,7 @@ impl_display! {
MacroNotFound{name,..} => "macro '`{}' has not been declared", name;
MacroNotDefined{name,..} => "cannot undefine macro '`{}'", name;
MacroRecursion { name,..} => "macro '`{}' was called recursively",name;
UnsupportedCompDir { name,.. } => "unsupported compiler directive {}",name;
FileNotFound { file, error, .. } => "failed to read '{}': {}", file, std::io::Error::from(*error);
InvalidTextFormat { file, ..} => "failed to read {}: file contents are not valid text", file;
UnexpectedEof { expected ,..} => "unexpected EOF, expected {}",expected;
Expand Down
2 changes: 2 additions & 0 deletions openvaf/preprocessor/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ impl<'a, 'd> Parser<'a, 'd> {
"`elsif" => CompilerDirective::ElseIf,
"`endif" => CompilerDirective::EndIf,
"`undef" => CompilerDirective::Undef,
"`resetall" => CompilerDirective::ResetAll,
_ => CompilerDirective::Macro,
}
}
Expand Down Expand Up @@ -332,5 +333,6 @@ pub enum CompilerDirective {
ElseIf,
EndIf,
Undef,
ResetAll,
Macro,
}
8 changes: 8 additions & 0 deletions openvaf/preprocessor/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ impl<'a> Processor<'a> {
}
p.bump();
}
CompilerDirective::ResetAll => {
let name = p.current_text();
err.push(PreprocessorDiagnostic::UnsupportedCompDir {
name: name.to_owned(),
span: p.current_span()
});
p.bump();
}
CompilerDirective::Macro => {
let (call, range) =
parse_macro_call(p, err, &[], &mut self.source_map, p.end());
Expand Down

0 comments on commit 47df3de

Please sign in to comment.