Skip to content

Commit 4efa142

Browse files
committed
format.
Signed-off-by: Yuchuan <[email protected]>
1 parent c462928 commit 4efa142

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

cpp/grammar_compiler.cc

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,21 @@ class GrammarMatcherForTokenMaskCache : public EarleyParser {
118118
);
119119

120120
/*! \brief Check each token in a given interval.
121-
\param tokenizer_info The tokenizer info.
122-
\param interval The interval to check.
123-
\param speculative_calculation_applied Whether to use speculative calculation.
124-
\param speculative_mask The speculative mask for speculative calculation.
125-
\param definite_accepted_bitset The definite accepted bitset for TagDispatch rules.
126-
\param is_root_rule Whether to consider the parent rule. If false, there will be
127-
no uncertain tokens. Useful for the root rule.
128-
\param fill_reject_indices Whether to fill the rejected indices.
129-
\param last_rejected_range The last rejected subtree range. If a token's index is less than
130-
this value, it will be rejected directly.
131-
\param prev_token The previous token parsed in the parser.
132-
\param prev_matched_size The matched size of the previous token.
133-
\return True if the rejected indices are filled as usual, False otherwise.
134-
\note All the tokens in the given interval will be divided into accepted, rejected and
135-
uncertain tokens.
121+
* \param tokenizer_info The tokenizer info.
122+
* \param interval The interval to check.
123+
* \param speculative_calculation_applied Whether to use speculative calculation.
124+
* \param speculative_mask The speculative mask for speculative calculation.
125+
* \param definite_accepted_bitset The definite accepted bitset for TagDispatch rules.
126+
* \param is_root_rule Whether to consider the parent rule. If false, there will be
127+
* no uncertain tokens. Useful for the root rule.
128+
* \param fill_reject_indices Whether to fill the rejected indices.
129+
* \param last_rejected_range The last rejected subtree range. If a token's index is less than
130+
* this value, it will be rejected directly.
131+
* \param prev_token The previous token parsed in the parser.
132+
* \param prev_matched_size The matched size of the previous token.
133+
* \return True if the rejected indices are filled as usual, False otherwise.
134+
* \note All the tokens in the given interval will be divided into accepted, rejected and
135+
* uncertain tokens.
136136
*/
137137
bool CheckTokensInInterval(
138138
const TokenizerInfo& tokenizer_info,
@@ -148,11 +148,11 @@ class GrammarMatcherForTokenMaskCache : public EarleyParser {
148148
);
149149

150150
/*! \brief Apply speculative calculation for a token.
151-
\param token The token to check.
152-
\param index The index of the token in the vocabulary.
153-
\param speculative_mask The speculative mask for speculative calculation.
154-
\param definite_accepted_bitset The definite accepted bitset for TagDispatch rules.
155-
\return True if the token is accepted by speculative calculation, False otherwise.
151+
* \param token The token to check.
152+
* \param index The index of the token in the vocabulary.
153+
* \param speculative_mask The speculative mask for speculative calculation.
154+
* \param definite_accepted_bitset The definite accepted bitset for TagDispatch rules.
155+
* \return True if the token is accepted by speculative calculation, False otherwise.
156156
*/
157157
bool ApplySpeculativeCalculation(
158158
const std::string& token,
@@ -162,10 +162,10 @@ class GrammarMatcherForTokenMaskCache : public EarleyParser {
162162
);
163163

164164
/*! \brief Find the common prefix size with the previous token.
165-
\param token The current token.
166-
\param prev_token The previous token.
167-
\param prev_matched_size The matched size of the previous token.
168-
\param accepted Whether the current token is accepted.
165+
* \param token The current token.
166+
* \param prev_token The previous token.
167+
* \param prev_matched_size The matched size of the previous token.
168+
* \param accepted Whether the current token is accepted.
169169
*/
170170
void FindCommonPrefixWithPreviousToken(
171171
const std::string& token,
@@ -174,21 +174,21 @@ class GrammarMatcherForTokenMaskCache : public EarleyParser {
174174
bool* accepted
175175
);
176176

177-
// The id of the initial rule.
177+
/*! \brief The id of the initial rule. */
178178
int32_t init_rule_id;
179179

180-
// The initial state of the parser.
180+
/*! \brief The initial state of the parser. */
181181
ParserState initial_state;
182182

183183
/*!
184-
\brief This is a mapping from TagDispatch rule id to the bitset used for second slicing.
185-
\note If a rule is a TagDispatch rule, then there will be an AC automaton for its triggers.
186-
Which means that it can accept a lot of tokens. However, it will be slow to check a lot of
187-
tokens. The DynamicBitset here is used to do a second slicing: if a token's substr(1, n - 1)
188-
can be accepted by the start state of the AC automaton, then it will be True in the bitset.
189-
When we check a token, we first check if its first character can transit to the start state.
190-
If yes, then we check if it is in the bitset. If yes, then we accept it directly.
191-
*/
184+
* \brief This is a mapping from TagDispatch rule id to the bitset used for second slicing.
185+
* \note If a rule is a TagDispatch rule, then there will be an AC automaton for its triggers.
186+
* Which means that it can accept a lot of tokens. However, it will be slow to check a lot of
187+
* tokens. The DynamicBitset here is used to do a second slicing: if a token's substr(1, n - 1)
188+
* can be accepted by the start state of the AC automaton, then it will be True in the bitset.
189+
* When we check a token, we first check if its first character can transit to the start state.
190+
* If yes, then we check if it is in the bitset. If yes, then we accept it directly.
191+
*/
192192
const std::unordered_map<int32_t, DynamicBitset>& tag_dispatch_rule_id_to_second_slicing_bitset;
193193

194194
// Temporary data for GetAdaptiveTokenMask.
@@ -802,7 +802,6 @@ class GrammarCompilerNoCache {
802802
const TokenizerInfo tokenizer_info_;
803803
/*! \brief The maximum number of threads to use. */
804804
const int max_threads_;
805-
/*! \brief Mapping from the rule_id to the definite accepted token mask. */
806805
};
807806

808807
CompiledGrammar GrammarCompilerNoCache::MultiThreadCompileGrammar(Grammar grammar_unoptimized) {

0 commit comments

Comments
 (0)