#include "src/tint/lang/wgsl/reader/parser/parser.h"
#include <limits>
#include <utility>
#include "src/tint/lang/core/attribute.h"
#include "src/tint/lang/core/type/depth_texture.h"
#include "src/tint/lang/core/type/external_texture.h"
#include "src/tint/lang/core/type/multisampled_texture.h"
#include "src/tint/lang/core/type/sampled_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/wgsl/ast/assignment_statement.h"
#include "src/tint/lang/wgsl/ast/break_if_statement.h"
#include "src/tint/lang/wgsl/ast/break_statement.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/continue_statement.h"
#include "src/tint/lang/wgsl/ast/discard_statement.h"
#include "src/tint/lang/wgsl/ast/id_attribute.h"
#include "src/tint/lang/wgsl/ast/if_statement.h"
#include "src/tint/lang/wgsl/ast/increment_decrement_statement.h"
#include "src/tint/lang/wgsl/ast/input_attachment_index_attribute.h"
#include "src/tint/lang/wgsl/ast/invariant_attribute.h"
#include "src/tint/lang/wgsl/ast/loop_statement.h"
#include "src/tint/lang/wgsl/ast/return_statement.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/ast/switch_statement.h"
#include "src/tint/lang/wgsl/ast/unary_op_expression.h"
#include "src/tint/lang/wgsl/ast/var.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
#include "src/tint/lang/wgsl/ast/workgroup_attribute.h"
#include "src/tint/lang/wgsl/reader/parser/classify_template_args.h"
#include "src/tint/lang/wgsl/reader/parser/lexer.h"
#include "src/tint/utils/containers/reverse.h"
#include "src/tint/utils/macros/defer.h"
#include "src/tint/utils/text/string.h"
#include "src/tint/utils/text/string_stream.h"
namespace tint::wgsl::reader {
namespace {
Void;
static constexpr Void kSuccess;
Expect;
Maybe;
constexpr uint32_t kMaxParseDepth = …;
constexpr size_t const kMaxResynchronizeLookahead = …;
bool is_reserved(const Token& t) { … }
struct BlockCounters { … };
}
class Parser::MultiTokenSource { … };
Parser::TypedIdentifier::TypedIdentifier() = default;
Parser::TypedIdentifier::TypedIdentifier(const TypedIdentifier&) = default;
Parser::TypedIdentifier::TypedIdentifier(ast::Type type_in, const ast::Identifier* name_in)
: … { … }
Parser::TypedIdentifier::~TypedIdentifier() = default;
Parser::FunctionHeader::FunctionHeader() = default;
Parser::FunctionHeader::FunctionHeader(const FunctionHeader&) = default;
Parser::FunctionHeader::FunctionHeader(Source src,
const ast::Identifier* n,
VectorRef<const ast::Parameter*> p,
ast::Type ret_ty,
VectorRef<const ast::Attribute*> ret_attrs)
: … { … }
Parser::FunctionHeader::~FunctionHeader() = default;
Parser::FunctionHeader& Parser::FunctionHeader::operator=(const FunctionHeader& rhs) = default;
Parser::Parser(Source::File const* file) : … { … }
Parser::~Parser() = default;
Parser::Failure::Errored Parser::AddError(const Source& source,
std::string_view err,
std::string_view use) { … }
Parser::Failure::Errored Parser::AddError(const Token& t, std::string_view err) { … }
Parser::Failure::Errored Parser::AddError(const Source& source, std::string_view err) { … }
Parser::Failure::Errored Parser::AddError(const Source& source, StyledText&& err) { … }
void Parser::AddNote(const Source& source, std::string_view err) { … }
void Parser::deprecated(const Source& source, std::string_view msg) { … }
const Token& Parser::next() { … }
const Token& Parser::peek(size_t count) { … }
bool Parser::peek_is(Token::Type tok, size_t idx) { … }
void Parser::split_token(Token::Type lhs, Token::Type rhs) { … }
Source Parser::last_source() const { … }
void Parser::InitializeLex() { … }
bool Parser::Parse() { … }
void Parser::translation_unit() { … }
Maybe<Void> Parser::global_directive(bool have_parsed_decl) { … }
Maybe<Void> Parser::diagnostic_directive() { … }
Maybe<Void> Parser::enable_directive() { … }
Maybe<Void> Parser::requires_directive() { … }
Maybe<Void> Parser::global_decl() { … }
Maybe<const ast::Variable*> Parser::global_variable_decl(AttributeList& attrs) { … }
Maybe<const ast::Variable*> Parser::global_constant_decl(AttributeList& attrs) { … }
Maybe<Parser::VarDeclInfo> Parser::variable_decl() { … }
Expect<Parser::TypedIdentifier> Parser::expect_ident_with_optional_type_specifier(
std::string_view use,
bool allow_inferred) { … }
Expect<Parser::TypedIdentifier> Parser::expect_optionally_typed_ident(std::string_view use) { … }
Expect<Parser::TypedIdentifier> Parser::expect_ident_with_type_specifier(std::string_view use) { … }
Maybe<Parser::VariableQualifier> Parser::variable_qualifier() { … }
Maybe<const ast::Alias*> Parser::type_alias_decl() { … }
Maybe<ast::Type> Parser::type_specifier() { … }
template <typename ENUM>
Expect<ENUM> Parser::expect_enum(std::string_view name,
ENUM (*parse)(std::string_view str),
Slice<const std::string_view> strings,
std::string_view use) { … }
Expect<ast::Type> Parser::expect_type(std::string_view use) { … }
Maybe<const ast::Struct*> Parser::struct_decl() { … }
Expect<Parser::StructMemberList> Parser::expect_struct_body_decl() { … }
Expect<const ast::StructMember*> Parser::expect_struct_member() { … }
Maybe<const ast::ConstAssert*> Parser::const_assert_statement() { … }
Maybe<const ast::Function*> Parser::function_decl(AttributeList& attrs) { … }
Maybe<Parser::FunctionHeader> Parser::function_header() { … }
Expect<Parser::ParameterList> Parser::expect_param_list() { … }
Expect<const ast::Parameter*> Parser::expect_param() { … }
Expect<ast::BlockStatement*> Parser::expect_compound_statement(std::string_view use) { … }
Expect<ast::BlockStatement*> Parser::expect_compound_statement(AttributeList& attrs,
std::string_view use) { … }
Expect<const ast::Expression*> Parser::expect_paren_expression() { … }
Expect<Parser::StatementList> Parser::expect_statements() { … }
Maybe<const ast::Statement*> Parser::statement() { … }
Maybe<const ast::Statement*> Parser::non_block_statement() { … }
Maybe<const ast::ReturnStatement*> Parser::return_statement() { … }
Maybe<const ast::VariableDeclStatement*> Parser::variable_statement() { … }
Maybe<const ast::IfStatement*> Parser::if_statement(AttributeList& attrs) { … }
Maybe<const ast::SwitchStatement*> Parser::switch_statement(AttributeList& attrs) { … }
Maybe<const ast::CaseStatement*> Parser::switch_body() { … }
Expect<Parser::CaseSelectorList> Parser::expect_case_selectors() { … }
Maybe<const ast::CaseSelector*> Parser::case_selector() { … }
Maybe<const ast::LoopStatement*> Parser::loop_statement(AttributeList& attrs) { … }
ForHeader::ForHeader(const ast::Statement* init,
const ast::Expression* cond,
const ast::Statement* cont)
: … { … }
ForHeader::~ForHeader() = default;
Maybe<const ast::Statement*> Parser::for_header_initializer() { … }
Maybe<const ast::Statement*> Parser::for_header_continuing() { … }
Expect<std::unique_ptr<ForHeader>> Parser::expect_for_header() { … }
Maybe<const ast::ForLoopStatement*> Parser::for_statement(AttributeList& attrs) { … }
Maybe<const ast::WhileStatement*> Parser::while_statement(AttributeList& attrs) { … }
Maybe<const ast::CallStatement*> Parser::func_call_statement() { … }
Maybe<const ast::BreakStatement*> Parser::break_statement() { … }
Maybe<const ast::ContinueStatement*> Parser::continue_statement() { … }
Maybe<const ast::Statement*> Parser::break_if_statement() { … }
Maybe<const ast::BlockStatement*> Parser::continuing_compound_statement() { … }
Maybe<const ast::BlockStatement*> Parser::continuing_statement() { … }
Maybe<const ast::Expression*> Parser::primary_expression() { … }
Maybe<const ast::Expression*> Parser::component_or_swizzle_specifier(
const ast::Expression* prefix) { … }
Expect<Parser::ExpressionList> Parser::expect_argument_expression_list(std::string_view use) { … }
Maybe<const ast::Expression*> Parser::bitwise_expression_post_unary_expression(
const ast::Expression* lhs,
const Source& lhs_source) { … }
Maybe<core::BinaryOp> Parser::multiplicative_operator() { … }
Expect<const ast::Expression*> Parser::expect_multiplicative_expression_post_unary_expression(
const ast::Expression* lhs,
const Source& lhs_source) { … }
Maybe<core::BinaryOp> Parser::additive_operator() { … }
Expect<const ast::Expression*> Parser::expect_additive_expression_post_unary_expression(
const ast::Expression* lhs,
const Source& lhs_source) { … }
Expect<const ast::Expression*> Parser::expect_math_expression_post_unary_expression(
const ast::Expression* lhs,
const Source& lhs_source) { … }
Maybe<const ast::Expression*> Parser::shift_expression() { … }
Expect<const ast::Expression*> Parser::expect_shift_expression_post_unary_expression(
const ast::Expression* lhs,
const Source& lhs_source) { … }
Maybe<const ast::Expression*> Parser::relational_expression() { … }
Expect<const ast::Expression*> Parser::expect_relational_expression_post_unary_expression(
const ast::Expression* lhs,
const Source& lhs_source) { … }
Expect<const ast::Expression*> Parser::expect_expression(std::string_view use) { … }
Maybe<Parser::ExpressionList> Parser::expression_list(std::string_view use,
Token::Type terminator) { … }
Expect<Parser::ExpressionList> Parser::expect_expression_list(std::string_view use,
Token::Type terminator) { … }
Maybe<const ast::Expression*> Parser::expression() { … }
Maybe<const ast::Expression*> Parser::singular_expression() { … }
Maybe<const ast::Expression*> Parser::unary_expression() { … }
Maybe<core::BinaryOp> Parser::compound_assignment_operator() { … }
Maybe<const ast::Expression*> Parser::core_lhs_expression() { … }
Maybe<const ast::Expression*> Parser::lhs_expression() { … }
Maybe<const ast::Statement*> Parser::variable_updating_statement() { … }
Maybe<const ast::LiteralExpression*> Parser::const_literal() { … }
Maybe<Parser::AttributeList> Parser::attribute_list() { … }
Expect<const ast::Attribute*> Parser::expect_attribute() { … }
Maybe<const ast::Attribute*> Parser::attribute() { … }
Expect<Void> Parser::expect_attributes_consumed(VectorRef<const ast::Attribute*> in) { … }
Expect<Void> Parser::expect_next_not_template_list(const Source& lhs_source) { … }
Expect<Void> Parser::expect_not_templated_ident_expr(const ast::Expression* expr) { … }
Expect<wgsl::DiagnosticSeverity> Parser::expect_severity_control_name() { … }
Expect<ast::DiagnosticControl> Parser::expect_diagnostic_control() { … }
Expect<const ast::DiagnosticRuleName*> Parser::expect_diagnostic_rule_name() { … }
bool Parser::match(Token::Type tok, Source* source ) { … }
bool Parser::expect(std::string_view use, Token::Type tok) { … }
Expect<int32_t> Parser::expect_sint(std::string_view use, Source* source ) { … }
Expect<uint32_t> Parser::expect_positive_sint(std::string_view use) { … }
Expect<uint32_t> Parser::expect_nonzero_positive_sint(std::string_view use) { … }
Expect<const ast::Identifier*> Parser::expect_ident(std::string_view use,
std::string_view kind ) { … }
template <typename F, typename T>
T Parser::expect_block(Token::Type start, Token::Type end, std::string_view use, F&& body) { … }
template <typename F, typename T>
T Parser::expect_paren_block(std::string_view use, F&& body) { … }
template <typename F, typename T>
T Parser::expect_brace_block(std::string_view use, F&& body) { … }
template <typename F, typename T>
T Parser::expect_lt_gt_block(std::string_view use, F&& body) { … }
template <typename F, typename T>
T Parser::expect_template_arg_block(std::string_view use, F&& body) { … }
template <typename F, typename T>
T Parser::sync(Token::Type tok, F&& body) { … }
bool Parser::sync_to(Token::Type tok, bool consume) { … }
bool Parser::is_sync_token(const Token& t) const { … }
bool Parser::handle_error(const Token& t) { … }
template <typename F, typename T>
T Parser::without_diag(F&& body) { … }
}