MCPcopy Index your code
hub / github.com/python/cpython / parse

Method parse

Tools/clinic/libclinic/dsl_parser.py:489–514  ·  view source on GitHub ↗
(self, block: Block)

Source from the content-addressed store, hash-verified

487 self.permit_long_docstring_body = True
488
489 def parse(self, block: Block) -> None:
490 self.reset()
491 self.block = block
492 self.saved_output = self.block.output
493 block.output = []
494 block_start = self.clinic.block_parser.line_number
495 lines = block.input.split('\n')
496 for line_number, line in enumerate(lines, self.clinic.block_parser.block_start_line_number):
497 if '\t' in line:
498 fail(f'Tab characters are illegal in the Clinic DSL: {line!r}',
499 line_number=block_start)
500 try:
501 self.state(line)
502 except ClinicError as exc:
503 exc.lineno = line_number
504 exc.filename = self.clinic.filename
505 raise
506
507 self.do_post_block_processing_cleanup(line_number)
508 block.output.extend(self.clinic.language.render(self.clinic, block.signatures))
509
510 if self.preserve_output:
511 if block.output:
512 fail("'preserve' only works for blocks that don't produce any output!",
513 line_number=line_number)
514 block.output = self.saved_output
515
516 def in_docstring(self) -> bool:
517 """Return true if we are processing a docstring."""

Callers 5

parseMethod · 0.95
test_trivialMethod · 0.95
test_directiveMethod · 0.95
parse_parameterMethod · 0.45

Calls 8

resetMethod · 0.95
failFunction · 0.90
enumerateFunction · 0.85
splitMethod · 0.45
stateMethod · 0.45
extendMethod · 0.45
renderMethod · 0.45

Tested by 3

parseMethod · 0.76
test_trivialMethod · 0.76
test_directiveMethod · 0.76