Update docs.

This commit is contained in:
Stephen Chung
2023-03-17 06:41:44 +08:00
parent 091e16124c
commit 76ab1e290d
2 changed files with 17 additions and 11 deletions

View File

@@ -305,7 +305,7 @@ impl fmt::Display for Token {
}
}
// Table-driven keyword recognizer generated by GNU gperf on the file `tools/keywords.txt`.
// Table-driven keyword recognizer generated by GNU `gperf` on the file `tools/keywords.txt`.
//
// When adding new keywords, make sure to update `tools/keywords.txt` and re-generate this.
@@ -507,7 +507,7 @@ static KEYWORDS_LIST: [(&str, Token); 153] = [
("#{", Token::MapStart),
];
// Table-driven reserved symbol recognizer generated by GNU gperf on the file `tools/reserved.txt`.
// Table-driven reserved symbol recognizer generated by GNU `gperf` on the file `tools/reserved.txt`.
//
// When adding new reserved symbols, make sure to update `tools/reserved.txt` and re-generate this.
@@ -872,7 +872,7 @@ impl Token {
#[must_use]
pub fn lookup_symbol_from_syntax(syntax: &str) -> Option<Self> {
// This implementation is based upon a pre-calculated table generated
// by GNU gperf on the list of keywords.
// by GNU `gperf` on the list of keywords.
let utf8 = syntax.as_bytes();
let len = utf8.len();
let mut hash_val = len;
@@ -893,8 +893,8 @@ impl Token {
match KEYWORDS_LIST[hash_val] {
(_, Token::EOF) => None,
// Fail early to avoid calling memcmp()
// Since we are already working with bytes, mind as well check the first one
// Fail early to avoid calling memcmp().
// Since we are already working with bytes, mind as well check the first one.
(s, ref t) if s.len() == len && s.as_bytes()[0] == utf8[0] && s == syntax => {
Some(t.clone())
}
@@ -2312,7 +2312,7 @@ pub fn is_id_continue(x: char) -> bool {
#[must_use]
pub fn is_reserved_keyword_or_symbol(syntax: &str) -> (bool, bool, bool) {
// This implementation is based upon a pre-calculated table generated
// by GNU gperf on the list of keywords.
// by GNU `gperf` on the list of keywords.
let utf8 = syntax.as_bytes();
let len = utf8.len();
let rounds = len.min(3);
@@ -2333,8 +2333,8 @@ pub fn is_reserved_keyword_or_symbol(syntax: &str) -> (bool, bool, bool) {
match RESERVED_LIST[hash_val] {
("", ..) => (false, false, false),
(s, true, a, b) => (
// Fail early to avoid calling memcmp()
// Since we are already working with bytes, mind as well check the first one
// Fail early to avoid calling memcmp().
// Since we are already working with bytes, mind as well check the first one.
s.len() == len && s.as_bytes()[0] == utf8[0] && s == syntax,
a,
b,