MCPcopy Index your code
hub / github.com/nodejs/node / compile_rules

Function compile_rules

tools/inspector_protocol/jinja2/lexer.py:196–216  ·  view source on GitHub ↗

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

(environment)

Source from the content-addressed store, hash-verified

194
195
196def compile_rules(environment):
197 """Compiles all the rules from the environment into a list of rules."""
198 e = re.escape
199 rules = [
200 (len(environment.comment_start_string), 'comment',
201 e(environment.comment_start_string)),
202 (len(environment.block_start_string), 'block',
203 e(environment.block_start_string)),
204 (len(environment.variable_start_string), 'variable',
205 e(environment.variable_start_string))
206 ]
207
208 if environment.line_statement_prefix is not None:
209 rules.append((len(environment.line_statement_prefix), 'linestatement',
210 r'^[ \t\v]*' + e(environment.line_statement_prefix)))
211 if environment.line_comment_prefix is not None:
212 rules.append((len(environment.line_comment_prefix), 'linecomment',
213 r'(?:^|(?<=\S))[^\S\r\n]*' +
214 e(environment.line_comment_prefix)))
215
216 return [x[1:] for x in sorted(rules, reverse=True)]
217
218
219class Failure(object):

Callers 1

__init__Method · 0.70

Calls 3

sortedFunction · 0.85
eFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected