MCPcopy Create free account
hub / github.com/nodejs/node / compile_rules

Function compile_rules

deps/v8/third_party/jinja2/lexer.py:211–249  ·  view source on GitHub ↗

Compiles all the rules from the environment into a list of rules.

(environment: "Environment")

Source from the content-addressed store, hash-verified

209
210
211def compile_rules(environment: "Environment") -> t.List[t.Tuple[str, str]]:
212 """Compiles all the rules from the environment into a list of rules."""
213 e = re.escape
214 rules = [
215 (
216 len(environment.comment_start_string),
217 TOKEN_COMMENT_BEGIN,
218 e(environment.comment_start_string),
219 ),
220 (
221 len(environment.block_start_string),
222 TOKEN_BLOCK_BEGIN,
223 e(environment.block_start_string),
224 ),
225 (
226 len(environment.variable_start_string),
227 TOKEN_VARIABLE_BEGIN,
228 e(environment.variable_start_string),
229 ),
230 ]
231
232 if environment.line_statement_prefix is not None:
233 rules.append(
234 (
235 len(environment.line_statement_prefix),
236 TOKEN_LINESTATEMENT_BEGIN,
237 r"^[ \t\v]*" + e(environment.line_statement_prefix),
238 )
239 )
240 if environment.line_comment_prefix is not None:
241 rules.append(
242 (
243 len(environment.line_comment_prefix),
244 TOKEN_LINECOMMENT_BEGIN,
245 r"(?:^|(?<=\S))[^\S\r\n]*" + e(environment.line_comment_prefix),
246 )
247 )
248
249 return [x[1:] for x in sorted(rules, reverse=True)]
250
251
252class Failure:

Callers 1

__init__Method · 0.70

Calls 3

sortedFunction · 0.85
eFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected