Rename brace and bracket to match spec

The names for brace and bracket got flipped in the spec, update Tint to
match.

Change-Id: Ifbad5f239834b77b9aa27ef21b9d704cab742f4f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21260
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
dan sinclair 2020-05-07 19:47:39 +00:00 committed by David Neto
parent 1f1f08f94a
commit 4dfda012b2
5 changed files with 46 additions and 46 deletions

View File

@ -351,21 +351,21 @@ Token Lexer::try_punctuation() {
pos_ += 1; pos_ += 1;
column_ += 1; column_ += 1;
} else if (matches(pos_, "[")) { } else if (matches(pos_, "[")) {
type = Token::Type::kBraceLeft;
pos_ += 1;
column_ += 1;
} else if (matches(pos_, "]")) {
type = Token::Type::kBraceRight;
pos_ += 1;
column_ += 1;
} else if (matches(pos_, "{")) {
type = Token::Type::kBracketLeft; type = Token::Type::kBracketLeft;
pos_ += 1; pos_ += 1;
column_ += 1; column_ += 1;
} else if (matches(pos_, "}")) { } else if (matches(pos_, "]")) {
type = Token::Type::kBracketRight; type = Token::Type::kBracketRight;
pos_ += 1; pos_ += 1;
column_ += 1; column_ += 1;
} else if (matches(pos_, "{")) {
type = Token::Type::kBraceLeft;
pos_ += 1;
column_ += 1;
} else if (matches(pos_, "}")) {
type = Token::Type::kBraceRight;
pos_ += 1;
column_ += 1;
} else if (matches(pos_, "&&")) { } else if (matches(pos_, "&&")) {
type = Token::Type::kAndAnd; type = Token::Type::kAndAnd;
pos_ += 2; pos_ += 2;

View File

@ -366,10 +366,10 @@ INSTANTIATE_TEST_SUITE_P(
TokenData{"]]", Token::Type::kAttrRight}, TokenData{"]]", Token::Type::kAttrRight},
TokenData{"/", Token::Type::kForwardSlash}, TokenData{"/", Token::Type::kForwardSlash},
TokenData{"!", Token::Type::kBang}, TokenData{"!", Token::Type::kBang},
TokenData{"[", Token::Type::kBraceLeft}, TokenData{"[", Token::Type::kBracketLeft},
TokenData{"]", Token::Type::kBraceRight}, TokenData{"]", Token::Type::kBracketRight},
TokenData{"{", Token::Type::kBracketLeft}, TokenData{"{", Token::Type::kBraceLeft},
TokenData{"}", Token::Type::kBracketRight}, TokenData{"}", Token::Type::kBraceRight},
TokenData{":", Token::Type::kColon}, TokenData{":", Token::Type::kColon},
TokenData{",", Token::Type::kComma}, TokenData{",", Token::Type::kComma},
TokenData{"=", Token::Type::kEqual}, TokenData{"=", Token::Type::kEqual},

View File

@ -987,7 +987,7 @@ std::unique_ptr<ast::type::StructType> ParserImpl::struct_decl() {
} }
t = peek(); t = peek();
if (!t.IsBracketLeft()) { if (!t.IsBraceLeft()) {
set_error(t, "missing { for struct declaration"); set_error(t, "missing { for struct declaration");
return nullptr; return nullptr;
} }
@ -1042,13 +1042,13 @@ ast::StructDecoration ParserImpl::struct_decoration() {
// : BRACKET_LEFT struct_member* BRACKET_RIGHT // : BRACKET_LEFT struct_member* BRACKET_RIGHT
ast::StructMemberList ParserImpl::struct_body_decl() { ast::StructMemberList ParserImpl::struct_body_decl() {
auto t = peek(); auto t = peek();
if (!t.IsBracketLeft()) if (!t.IsBraceLeft())
return {}; return {};
next(); // Consume the peek next(); // Consume the peek
t = peek(); t = peek();
if (t.IsBracketRight()) if (t.IsBraceRight())
return {}; return {};
ast::StructMemberList members; ast::StructMemberList members;
@ -1064,12 +1064,12 @@ ast::StructMemberList ParserImpl::struct_body_decl() {
members.push_back(std::move(mem)); members.push_back(std::move(mem));
t = peek(); t = peek();
if (t.IsBracketRight() || t.IsEof()) if (t.IsBraceRight() || t.IsEof())
break; break;
} }
t = next(); t = next();
if (!t.IsBracketRight()) { if (!t.IsBraceRight()) {
set_error(t, "missing } for struct declaration"); set_error(t, "missing } for struct declaration");
return {}; return {};
} }
@ -1376,7 +1376,7 @@ ast::PipelineStage ParserImpl::pipeline_stage() {
// : BRACKET_LEFT statements BRACKET_RIGHT // : BRACKET_LEFT statements BRACKET_RIGHT
ast::StatementList ParserImpl::body_stmt() { ast::StatementList ParserImpl::body_stmt() {
auto t = peek(); auto t = peek();
if (!t.IsBracketLeft()) if (!t.IsBraceLeft())
return {}; return {};
next(); // Consume the peek next(); // Consume the peek
@ -1386,7 +1386,7 @@ ast::StatementList ParserImpl::body_stmt() {
return {}; return {};
t = next(); t = next();
if (!t.IsBracketRight()) { if (!t.IsBraceRight()) {
set_error(t, "missing }"); set_error(t, "missing }");
return {}; return {};
} }
@ -1733,7 +1733,7 @@ std::unique_ptr<ast::IfStatement> ParserImpl::if_stmt() {
} }
t = peek(); t = peek();
if (!t.IsBracketLeft()) { if (!t.IsBraceLeft()) {
set_error(t, "missing {"); set_error(t, "missing {");
return nullptr; return nullptr;
} }
@ -1781,7 +1781,7 @@ ast::ElseStatementList ParserImpl::elseif_stmt() {
} }
t = peek(); t = peek();
if (!t.IsBracketLeft()) { if (!t.IsBraceLeft()) {
set_error(t, "missing {"); set_error(t, "missing {");
return {}; return {};
} }
@ -1812,7 +1812,7 @@ std::unique_ptr<ast::ElseStatement> ParserImpl::else_stmt() {
next(); // Consume the peek next(); // Consume the peek
t = peek(); t = peek();
if (!t.IsBracketLeft()) { if (!t.IsBraceLeft()) {
set_error(t, "missing {"); set_error(t, "missing {");
return nullptr; return nullptr;
} }
@ -1869,7 +1869,7 @@ std::unique_ptr<ast::SwitchStatement> ParserImpl::switch_stmt() {
} }
t = next(); t = next();
if (!t.IsBracketLeft()) { if (!t.IsBraceLeft()) {
set_error(t, "missing { for switch statement"); set_error(t, "missing { for switch statement");
return nullptr; return nullptr;
} }
@ -1886,7 +1886,7 @@ std::unique_ptr<ast::SwitchStatement> ParserImpl::switch_stmt() {
} }
t = next(); t = next();
if (!t.IsBracketRight()) { if (!t.IsBraceRight()) {
set_error(t, "missing } for switch statement"); set_error(t, "missing } for switch statement");
return nullptr; return nullptr;
} }
@ -1925,7 +1925,7 @@ std::unique_ptr<ast::CaseStatement> ParserImpl::switch_body() {
} }
t = next(); t = next();
if (!t.IsBracketLeft()) { if (!t.IsBraceLeft()) {
set_error(t, "missing { for case statement"); set_error(t, "missing { for case statement");
return nullptr; return nullptr;
} }
@ -1937,7 +1937,7 @@ std::unique_ptr<ast::CaseStatement> ParserImpl::switch_body() {
stmt->set_body(std::move(body)); stmt->set_body(std::move(body));
t = next(); t = next();
if (!t.IsBracketRight()) { if (!t.IsBraceRight()) {
set_error(t, "missing } for case statement"); set_error(t, "missing } for case statement");
return nullptr; return nullptr;
} }
@ -1990,7 +1990,7 @@ std::unique_ptr<ast::LoopStatement> ParserImpl::loop_stmt() {
next(); // Consume the peek next(); // Consume the peek
t = next(); t = next();
if (!t.IsBracketLeft()) { if (!t.IsBraceLeft()) {
set_error(t, "missing { for loop"); set_error(t, "missing { for loop");
return nullptr; return nullptr;
} }
@ -2004,7 +2004,7 @@ std::unique_ptr<ast::LoopStatement> ParserImpl::loop_stmt() {
return nullptr; return nullptr;
t = next(); t = next();
if (!t.IsBracketRight()) { if (!t.IsBraceRight()) {
set_error(t, "missing } for loop"); set_error(t, "missing } for loop");
return nullptr; return nullptr;
} }
@ -2298,7 +2298,7 @@ std::unique_ptr<ast::Expression> ParserImpl::postfix_expr(
auto t = peek(); auto t = peek();
auto source = t.source(); auto source = t.source();
if (t.IsBraceLeft()) { if (t.IsBracketLeft()) {
next(); // Consume the peek next(); // Consume the peek
auto param = logical_or_expression(); auto param = logical_or_expression();
@ -2310,7 +2310,7 @@ std::unique_ptr<ast::Expression> ParserImpl::postfix_expr(
} }
t = next(); t = next();
if (!t.IsBraceRight()) { if (!t.IsBracketRight()) {
set_error(t, "missing ] for array accessor"); set_error(t, "missing ] for array accessor");
return nullptr; return nullptr;
} }

View File

@ -54,13 +54,13 @@ std::string Token::TypeToName(Type type) {
return "/"; return "/";
case Token::Type::kBang: case Token::Type::kBang:
return "!"; return "!";
case Token::Type::kBraceLeft:
return "[";
case Token::Type::kBraceRight:
return "]";
case Token::Type::kBracketLeft: case Token::Type::kBracketLeft:
return "{"; return "[";
case Token::Type::kBracketRight: case Token::Type::kBracketRight:
return "]";
case Token::Type::kBraceLeft:
return "{";
case Token::Type::kBraceRight:
return "}"; return "}";
case Token::Type::kColon: case Token::Type::kColon:
return ":"; return ":";

View File

@ -66,13 +66,13 @@ class Token {
/// A '!' /// A '!'
kBang, kBang,
/// A '[' /// A '['
kBraceLeft,
/// A ']'
kBraceRight,
/// A '{'
kBracketLeft, kBracketLeft,
/// A '}' /// A ']'
kBracketRight, kBracketRight,
/// A '{'
kBraceLeft,
/// A '}'
kBraceRight,
/// A ':' /// A ':'
kColon, kColon,
/// A ',' /// A ','
@ -375,13 +375,13 @@ class Token {
/// @returns true if token is a '!' /// @returns true if token is a '!'
bool IsBang() const { return type_ == Type::kBang; } bool IsBang() const { return type_ == Type::kBang; }
/// @returns true if token is a '[' /// @returns true if token is a '['
bool IsBraceLeft() const { return type_ == Type::kBraceLeft; }
/// @returns true if token is a ']'
bool IsBraceRight() const { return type_ == Type::kBraceRight; }
/// @returns true if token is a '{'
bool IsBracketLeft() const { return type_ == Type::kBracketLeft; } bool IsBracketLeft() const { return type_ == Type::kBracketLeft; }
/// @returns true if token is a '}' /// @returns true if token is a ']'
bool IsBracketRight() const { return type_ == Type::kBracketRight; } bool IsBracketRight() const { return type_ == Type::kBracketRight; }
/// @returns true if token is a '{'
bool IsBraceLeft() const { return type_ == Type::kBraceLeft; }
/// @returns true if token is a '}'
bool IsBraceRight() const { return type_ == Type::kBraceRight; }
/// @returns true if token is a ':' /// @returns true if token is a ':'
bool IsColon() const { return type_ == Type::kColon; } bool IsColon() const { return type_ == Type::kColon; }
/// @returns true if token is a ',' /// @returns true if token is a ','