diff --git a/src/diagnostic/diagnostic.h b/src/diagnostic/diagnostic.h index 843a00616e..98175fef06 100644 --- a/src/diagnostic/diagnostic.h +++ b/src/diagnostic/diagnostic.h @@ -37,20 +37,31 @@ inline bool operator>=(Severity a, Severity b) { /// message. class Diagnostic { public: + /// severity is the severity of the diagnostic message. Severity severity = Severity::Error; + /// source is the location of the diagnostic. Source source; + /// message is the text associated with the diagnostic. std::string message; }; /// List is a container of Diagnostic messages. class List { public: + /// iterator is the type used for range based iteration. using iterator = std::vector::const_iterator; + /// Constructs the list with no elements. List(); + + /// Constructs the list with a copy of the diagnostics in |list|. + /// @param list the list of diagnostics to copy into this list. List(std::initializer_list list); + ~List(); + /// adds a diagnostic to the end of this list. + /// @param diag the diagnostic to append to this list. void add(Diagnostic&& diag) { entries_.emplace_back(std::move(diag)); if (diag.severity >= Severity::Error) { diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h index 8ea3e6cdd3..9a902f4a1d 100644 --- a/src/reader/wgsl/parser_impl.h +++ b/src/reader/wgsl/parser_impl.h @@ -81,9 +81,12 @@ class ParserImpl { /// TypedIdentifier holds a parsed identifier and type. Returned by /// variable_ident_decl(). struct TypedIdentifier { - ast::type::Type* type = nullptr; /// Parsed type. - std::string name; /// Parsed identifier. - Source source; /// Source to the identifier. + /// Parsed type. + ast::type::Type* type = nullptr; + /// Parsed identifier. + std::string name; + /// Source to the identifier. + Source source; }; /// Creates a new parser using the given file diff --git a/src/source.h b/src/source.h index ffc873ba1b..e26c14a7f5 100644 --- a/src/source.h +++ b/src/source.h @@ -44,12 +44,11 @@ class Source { }; /// Location holds a 1-based line and column index. - /// 0's for |line| or |column| represent invalid values. class Location { public: - /// The line number, 1-based + /// the 1-based line number. 0 represents no line information. size_t line = 0; - /// The column number, 1-based + /// the 1-based column number. 0 represents no column information. size_t column = 0; }; @@ -60,12 +59,12 @@ class Source { inline Range() = default; /// Constructs a zero-length Range starting at |loc|. - /// @param loc the location to use to build the range + /// @param loc the start and end location for the range. inline explicit Range(const Location& loc) : begin(loc), end(loc) {} /// Constructs the Range beginning at |b| and ending at |e|. - /// @param b the beginning of the range - /// @param e the end of the range + /// @param b the range start location. + /// @param e the range end location. inline Range(const Location& b, const Location& e) : begin(b), end(e) {} /// The location of the first character in the range. @@ -78,21 +77,21 @@ class Source { inline Source() = default; /// Constructs the Source with the Range |rng| and a null File. - /// @param rng the range to assign to the source + /// @param rng the source range inline explicit Source(const Range& rng) : range(rng) {} /// Constructs the Source with the Range |loc| and a null File. - /// @param loc the location to assign to the source + /// @param loc the start and end location for the source range inline explicit Source(const Location& loc) : range(Range(loc)) {} /// Constructs the Source with the Range |rng| and File |f|. - /// @param rng the range for the source - /// @param f the file for the source + /// @param rng the source range + /// @param f the source file inline Source(const Range& rng, File const* f) : range(rng), file(f) {} - /// Line/column range for this source + /// range is the span of text this source refers to in |file| Range range; - /// Source file + /// file is the source file this source refers to File const* file = nullptr; };