Skip to content

Commit

Permalink
Reserve asterisk (*) as a punctuation token
Browse files Browse the repository at this point in the history
Summary: Currently unused but reserving for potential future use.

Reviewed By: thedavekwon

Differential Revision: D67920813

fbshipit-source-id: 4d7915f37cd75d552f84b551577363f8b033729f
  • Loading branch information
praihan authored and facebook-github-bot committed Jan 8, 2025
1 parent 95f7e48 commit 1a911bd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion thrift/compiler/whisker/test/lexer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ TEST_F(LexerTest, multiple_identifiers) {
}

TEST_F(LexerTest, ids_and_punctuations) {
auto lexer = make_lexer("{{ |. ! bas ^> = ic /# }}{{()}}");
auto lexer = make_lexer("{{ |. ! bas ^> =* ic /# }}{{()}}");
const std::vector<token_description> expected = {
{tok::open, {}},
{tok::pipe, {}},
Expand All @@ -193,6 +193,7 @@ TEST_F(LexerTest, ids_and_punctuations) {
{tok::caret, {}},
{tok::gt, {}},
{tok::eq, {}},
{tok::star, {}},
{tok::identifier, "ic"},
{tok::slash, {}},
{tok::pound, {}},
Expand Down
1 change: 1 addition & 0 deletions thrift/compiler/whisker/token.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ constexpr token_kind_info info[] = {
{tok::pipe, "`|`"},
{tok::gt, "`>`"},
{tok::eq, "`=`"},
{tok::star, "`*`"},

#define WHISKER_KEYWORD(kw) {tok::kw_##kw, "`" #kw "`"},
WHISKER_KEYWORDS()
Expand Down
2 changes: 2 additions & 0 deletions thrift/compiler/whisker/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum class tok : unsigned {
pipe, // "|"
gt, // ">"
eq, // "="
star, // "*"
// clang-format on

// Literals:
Expand Down Expand Up @@ -114,6 +115,7 @@ constexpr tok to_tok(char c) {
case '|': return tok::pipe;
case '>': return tok::gt;
case '=': return tok::eq;
case '*': return tok::star;
default:
return tok::error;
}
Expand Down

0 comments on commit 1a911bd

Please sign in to comment.