Convert WGSL reader to utils::StringStream.
This CL updates the WGSL reader to use utils::StringStream internally. Bug: tint:1686 Change-Id: I203c764bbb86e99da323fde2be2af555f158b7bf Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122001 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
0c184c2856
commit
0723a3c7f8
|
@ -214,7 +214,7 @@ ParserImpl::~ParserImpl() = default;
|
||||||
ParserImpl::Failure::Errored ParserImpl::add_error(const Source& source,
|
ParserImpl::Failure::Errored ParserImpl::add_error(const Source& source,
|
||||||
std::string_view err,
|
std::string_view err,
|
||||||
std::string_view use) {
|
std::string_view use) {
|
||||||
std::stringstream msg;
|
utils::StringStream msg;
|
||||||
msg << err;
|
msg << err;
|
||||||
if (!use.empty()) {
|
if (!use.empty()) {
|
||||||
msg << " for " << use;
|
msg << " for " << use;
|
||||||
|
@ -3165,7 +3165,7 @@ bool ParserImpl::expect(std::string_view use, Token::Type tok) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream err;
|
utils::StringStream err;
|
||||||
if (tok == Token::Type::kTemplateArgsLeft && t.type() == Token::Type::kLessThan) {
|
if (tok == Token::Type::kTemplateArgsLeft && t.type() == Token::Type::kLessThan) {
|
||||||
err << "missing closing '>'";
|
err << "missing closing '>'";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
|
||||||
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
namespace tint::reader::wgsl {
|
namespace tint::reader::wgsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -513,8 +515,8 @@ const i : vec2<i32> = vec2<i32>(!);
|
||||||
TEST_F(ParserImplErrorTest, GlobalDeclConstExprMaxDepth) {
|
TEST_F(ParserImplErrorTest, GlobalDeclConstExprMaxDepth) {
|
||||||
uint32_t kMaxDepth = 128;
|
uint32_t kMaxDepth = 128;
|
||||||
|
|
||||||
std::stringstream src;
|
utils::StringStream src;
|
||||||
std::stringstream mkr;
|
utils::StringStream mkr;
|
||||||
src << "const i : i32 = ";
|
src << "const i : i32 = ";
|
||||||
mkr << " ";
|
mkr << " ";
|
||||||
for (size_t i = 0; i < kMaxDepth + 8; i++) {
|
for (size_t i = 0; i < kMaxDepth + 8; i++) {
|
||||||
|
@ -530,7 +532,7 @@ TEST_F(ParserImplErrorTest, GlobalDeclConstExprMaxDepth) {
|
||||||
src << ")";
|
src << ")";
|
||||||
}
|
}
|
||||||
src << ";";
|
src << ";";
|
||||||
std::stringstream err;
|
utils::StringStream err;
|
||||||
err << "test.wgsl:1:529 error: maximum parser recursive depth reached\n"
|
err << "test.wgsl:1:529 error: maximum parser recursive depth reached\n"
|
||||||
<< src.str() << "\n"
|
<< src.str() << "\n"
|
||||||
<< mkr.str() << "\n";
|
<< mkr.str() << "\n";
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
|
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
|
||||||
|
|
||||||
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
namespace tint::reader::wgsl {
|
namespace tint::reader::wgsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -486,7 +488,7 @@ static std::vector<Case> Cases() {
|
||||||
using ParserImplMixedBinaryOpTest = ParserImplTestWithParam<Case>;
|
using ParserImplMixedBinaryOpTest = ParserImplTestWithParam<Case>;
|
||||||
|
|
||||||
TEST_P(ParserImplMixedBinaryOpTest, Test) {
|
TEST_P(ParserImplMixedBinaryOpTest, Test) {
|
||||||
std::stringstream wgsl;
|
utils::StringStream wgsl;
|
||||||
wgsl << GetParam();
|
wgsl << GetParam();
|
||||||
auto p = parser(wgsl.str());
|
auto p = parser(wgsl.str());
|
||||||
auto e = p->expression();
|
auto e = p->expression();
|
||||||
|
@ -498,7 +500,7 @@ TEST_P(ParserImplMixedBinaryOpTest, Test) {
|
||||||
EXPECT_TRUE(e.errored);
|
EXPECT_TRUE(e.errored);
|
||||||
EXPECT_EQ(e.value, nullptr);
|
EXPECT_EQ(e.value, nullptr);
|
||||||
EXPECT_TRUE(p->has_error());
|
EXPECT_TRUE(p->has_error());
|
||||||
std::stringstream expected;
|
utils::StringStream expected;
|
||||||
expected << "1:3: mixing '" << GetParam().lhs_op.symbol << "' and '"
|
expected << "1:3: mixing '" << GetParam().lhs_op.symbol << "' and '"
|
||||||
<< GetParam().rhs_op.symbol << "' requires parenthesis";
|
<< GetParam().rhs_op.symbol << "' requires parenthesis";
|
||||||
EXPECT_EQ(p->error(), expected.str());
|
EXPECT_EQ(p->error(), expected.str());
|
||||||
|
|
Loading…
Reference in New Issue