mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibJS: Parser refactored to use constexpr precedence table
Replaced implementation dependent on HashMap with a constexpr PrecedenceTable based on array lookup.
This commit is contained in:
parent
b36ac88349
commit
5a2ec86048
3 changed files with 116 additions and 102 deletions
|
@ -153,7 +153,9 @@ enum class TokenType {
|
|||
#define __ENUMERATE_JS_TOKEN(x) x,
|
||||
ENUMERATE_JS_TOKENS
|
||||
#undef __ENUMERATE_JS_TOKEN
|
||||
_COUNT_OF_TOKENS
|
||||
};
|
||||
constexpr size_t cs_num_of_js_tokens = static_cast<size_t>(TokenType::_COUNT_OF_TOKENS);
|
||||
|
||||
class Token {
|
||||
public:
|
||||
|
@ -196,11 +198,3 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
template<>
|
||||
struct Traits<JS::TokenType> : public GenericTraits<JS::TokenType> {
|
||||
static constexpr bool is_trivial() { return true; }
|
||||
static unsigned hash(JS::TokenType t) { return int_hash((int)t); }
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue