id int64 1 6.07M | name stringlengths 1 295 | code stringlengths 12 426k | language stringclasses 1
value | source_file stringlengths 5 202 | start_line int64 1 158k | end_line int64 1 158k | repo dict |
|---|---|---|---|---|---|---|---|
10,301 | main | def main() -> None:
parser = argparse.ArgumentParser(
description="Generate the Lib/keywords.py file from the grammar."
)
parser.add_argument(
"grammar", help="The file with the grammar definition in PEG format"
)
parser.add_argument(
"tokens_file", help="The file with the to... | python | Tools/peg_generator/pegen/keywordgen.py | 39 | 69 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,302 | strongly_connected_components | def strongly_connected_components(
vertices: AbstractSet[str], edges: Dict[str, AbstractSet[str]]
) -> Iterator[AbstractSet[str]]:
"""Compute Strongly Connected Components of a directed graph.
Args:
vertices: the labels for the vertices
edges: for each vertex, gives the target vertices of its o... | python | Tools/peg_generator/pegen/sccutils.py | 6 | 49 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,303 | dfs | def dfs(v: str) -> Iterator[Set[str]]:
index[v] = len(stack)
stack.append(v)
boundaries.append(index[v])
for w in edges[v]:
if w not in index:
yield from dfs(w)
elif w not in identified:
while index[w] < boundaries[-1]:
... | python | Tools/peg_generator/pegen/sccutils.py | 28 | 45 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,304 | topsort | def topsort(
data: Dict[AbstractSet[str], Set[AbstractSet[str]]]
) -> Iterable[AbstractSet[AbstractSet[str]]]:
"""Topological sort.
Args:
data: A map from SCCs (represented as frozen sets of strings) to
sets of SCCs, its dependencies. NOTE: This data structure
is modified in ... | python | Tools/peg_generator/pegen/sccutils.py | 52 | 97 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,305 | find_cycles_in_scc | def find_cycles_in_scc(
graph: Dict[str, AbstractSet[str]], scc: AbstractSet[str], start: str
) -> Iterable[List[str]]:
"""Find cycles in SCC emanating from start.
Yields lists of the form ['A', 'B', 'C', 'A'], which means there's
a path from A -> B -> C -> A. The first item is always the start
ar... | python | Tools/peg_generator/pegen/sccutils.py | 100 | 128 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,306 | dfs | def dfs(node: str, path: List[str]) -> Iterator[List[str]]:
if node in path:
yield path + [node]
return
path = path + [node] # TODO: Make this not quadratic.
for child in graph[node]:
yield from dfs(child, path) | python | Tools/peg_generator/pegen/sccutils.py | 120 | 126 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,307 | ast_dump | def ast_dump(
node: Any,
annotate_fields: bool = True,
include_attributes: bool = False,
*,
indent: Optional[str] = None,
) -> str:
def _format(node: Any, level: int = 0) -> Tuple[str, bool]:
if indent is not None:
level += 1
prefix = "\n" + indent * level
... | python | Tools/peg_generator/pegen/ast_dump.py | 12 | 69 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,308 | _format | def _format(node: Any, level: int = 0) -> Tuple[str, bool]:
if indent is not None:
level += 1
prefix = "\n" + indent * level
sep = ",\n" + indent * level
else:
prefix = ""
sep = ", "
if any(cls.__name__ == "AST" for cls in node.__class_... | python | Tools/peg_generator/pegen/ast_dump.py | 19 | 65 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,309 | start | def start(self) -> Optional[Grammar]:
# start: grammar $
mark = self._mark()
if (
(grammar := self.grammar())
and
(_endmarker := self.expect('ENDMARKER'))
):
return grammar
self._reset(mark)
return None | python | Tools/peg_generator/pegen/grammar_parser.py | 45 | 55 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,310 | grammar | def grammar(self) -> Optional[Grammar]:
# grammar: metas rules | rules
mark = self._mark()
if (
(metas := self.metas())
and
(rules := self.rules())
):
return Grammar ( rules , metas )
self._reset(mark)
if (
(rule... | python | Tools/peg_generator/pegen/grammar_parser.py | 58 | 73 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,311 | metas | def metas(self) -> Optional[MetaList]:
# metas: meta metas | meta
mark = self._mark()
if (
(meta := self.meta())
and
(metas := self.metas())
):
return [meta] + metas
self._reset(mark)
if (
(meta := self.meta())
... | python | Tools/peg_generator/pegen/grammar_parser.py | 76 | 91 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,312 | meta | def meta(self) -> Optional[MetaTuple]:
# meta: "@" NAME NEWLINE | "@" NAME NAME NEWLINE | "@" NAME STRING NEWLINE
mark = self._mark()
if (
(literal := self.expect("@"))
and
(name := self.name())
and
(_newline := self.expect('NEWLINE'))
... | python | Tools/peg_generator/pegen/grammar_parser.py | 94 | 128 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,313 | rules | def rules(self) -> Optional[RuleList]:
# rules: rule rules | rule
mark = self._mark()
if (
(rule := self.rule())
and
(rules := self.rules())
):
return [rule] + rules
self._reset(mark)
if (
(rule := self.rule())
... | python | Tools/peg_generator/pegen/grammar_parser.py | 131 | 146 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,314 | rule | def rule(self) -> Optional[Rule]:
# rule: rulename memoflag? ":" alts NEWLINE INDENT more_alts DEDENT | rulename memoflag? ":" NEWLINE INDENT more_alts DEDENT | rulename memoflag? ":" alts NEWLINE
mark = self._mark()
if (
(rulename := self.rulename())
and
(opt... | python | Tools/peg_generator/pegen/grammar_parser.py | 149 | 201 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,315 | rulename | def rulename(self) -> Optional[RuleName]:
# rulename: NAME annotation | NAME
mark = self._mark()
if (
(name := self.name())
and
(annotation := self.annotation())
):
return ( name . string , annotation )
self._reset(mark)
if ... | python | Tools/peg_generator/pegen/grammar_parser.py | 204 | 219 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,316 | memoflag | def memoflag(self) -> Optional[str]:
# memoflag: '(' "memo" ')'
mark = self._mark()
if (
(literal := self.expect('('))
and
(literal_1 := self.expect("memo"))
and
(literal_2 := self.expect(')'))
):
return "memo"
... | python | Tools/peg_generator/pegen/grammar_parser.py | 222 | 234 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,317 | alts | def alts(self) -> Optional[Rhs]:
# alts: alt "|" alts | alt
mark = self._mark()
if (
(alt := self.alt())
and
(literal := self.expect("|"))
and
(alts := self.alts())
):
return Rhs ( [alt] + alts . alts )
self.... | python | Tools/peg_generator/pegen/grammar_parser.py | 237 | 254 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,318 | more_alts | def more_alts(self) -> Optional[Rhs]:
# more_alts: "|" alts NEWLINE more_alts | "|" alts NEWLINE
mark = self._mark()
if (
(literal := self.expect("|"))
and
(alts := self.alts())
and
(_newline := self.expect('NEWLINE'))
and
... | python | Tools/peg_generator/pegen/grammar_parser.py | 257 | 280 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,319 | alt | def alt(self) -> Optional[Alt]:
# alt: items '$' action | items '$' | items action | items
mark = self._mark()
if (
(items := self.items())
and
(literal := self.expect('$'))
and
(action := self.action())
):
return Al... | python | Tools/peg_generator/pegen/grammar_parser.py | 283 | 314 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,320 | items | def items(self) -> Optional[NamedItemList]:
# items: named_item items | named_item
mark = self._mark()
if (
(named_item := self.named_item())
and
(items := self.items())
):
return [named_item] + items
self._reset(mark)
if (
... | python | Tools/peg_generator/pegen/grammar_parser.py | 317 | 332 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,321 | named_item | def named_item(self) -> Optional[NamedItem]:
# named_item: NAME annotation '=' ~ item | NAME '=' ~ item | item | forced_atom | lookahead
mark = self._mark()
cut = False
if (
(name := self.name())
and
(annotation := self.annotation())
and
... | python | Tools/peg_generator/pegen/grammar_parser.py | 335 | 381 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,322 | forced_atom | def forced_atom(self) -> Optional[Forced]:
# forced_atom: '&' '&' ~ atom
mark = self._mark()
cut = False
if (
(literal := self.expect('&'))
and
(literal_1 := self.expect('&'))
and
(cut := True)
and
(atom ... | python | Tools/peg_generator/pegen/grammar_parser.py | 384 | 400 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,323 | lookahead | def lookahead(self) -> Optional[LookaheadOrCut]:
# lookahead: '&' ~ atom | '!' ~ atom | '~'
mark = self._mark()
cut = False
if (
(literal := self.expect('&'))
and
(cut := True)
and
(atom := self.atom())
):
re... | python | Tools/peg_generator/pegen/grammar_parser.py | 403 | 433 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,324 | item | def item(self) -> Optional[Item]:
# item: '[' ~ alts ']' | atom '?' | atom '*' | atom '+' | atom '.' atom '+' | atom
mark = self._mark()
cut = False
if (
(literal := self.expect('['))
and
(cut := True)
and
(alts := self.alts())
... | python | Tools/peg_generator/pegen/grammar_parser.py | 436 | 489 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,325 | atom | def atom(self) -> Optional[Plain]:
# atom: '(' ~ alts ')' | NAME | STRING
mark = self._mark()
cut = False
if (
(literal := self.expect('('))
and
(cut := True)
and
(alts := self.alts())
and
(literal_1 := s... | python | Tools/peg_generator/pegen/grammar_parser.py | 492 | 518 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,326 | action | def action(self) -> Optional[str]:
# action: "{" ~ target_atoms "}"
mark = self._mark()
cut = False
if (
(literal := self.expect("{"))
and
(cut := True)
and
(target_atoms := self.target_atoms())
and
(lite... | python | Tools/peg_generator/pegen/grammar_parser.py | 521 | 537 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,327 | annotation | def annotation(self) -> Optional[str]:
# annotation: "[" ~ target_atoms "]"
mark = self._mark()
cut = False
if (
(literal := self.expect("["))
and
(cut := True)
and
(target_atoms := self.target_atoms())
and
... | python | Tools/peg_generator/pegen/grammar_parser.py | 540 | 556 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,328 | target_atoms | def target_atoms(self) -> Optional[str]:
# target_atoms: target_atom target_atoms | target_atom
mark = self._mark()
if (
(target_atom := self.target_atom())
and
(target_atoms := self.target_atoms())
):
return target_atom + " " + target_atom... | python | Tools/peg_generator/pegen/grammar_parser.py | 559 | 574 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,329 | target_atom | def target_atom(self) -> Optional[str]:
# target_atom: "{" ~ target_atoms? "}" | "[" ~ target_atoms? "]" | NAME "*" | NAME | NUMBER | STRING | "?" | ":" | !"}" !"]" OP
mark = self._mark()
cut = False
if (
(literal := self.expect("{"))
and
(cut := True)... | python | Tools/peg_generator/pegen/grammar_parser.py | 577 | 647 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,330 | generate_parser | def generate_parser(grammar: Grammar) -> Type[Parser]:
# Generate a parser.
out = io.StringIO()
genr = PythonParserGenerator(grammar, out)
genr.generate("<string>")
# Load the generated parser class.
ns: Dict[str, Any] = {}
exec(out.getvalue(), ns)
return ns["GeneratedParser"] | python | Tools/peg_generator/pegen/testutil.py | 26 | 35 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,331 | run_parser | def run_parser(file: IO[bytes], parser_class: Type[Parser], *, verbose: bool = False) -> Any:
# Run a parser on a file (stream).
tokenizer = Tokenizer(tokenize.generate_tokens(file.readline)) # type: ignore[arg-type] # typeshed issue #3515
parser = parser_class(tokenizer, verbose=verbose)
result = pars... | python | Tools/peg_generator/pegen/testutil.py | 38 | 45 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,332 | parse_string | def parse_string(
source: str, parser_class: Type[Parser], *, dedent: bool = True, verbose: bool = False
) -> Any:
# Run the parser on a string.
if dedent:
source = textwrap.dedent(source)
file = io.StringIO(source)
return run_parser(file, parser_class, verbose=verbose) # type: ignore[arg-t... | python | Tools/peg_generator/pegen/testutil.py | 48 | 55 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,333 | make_parser | def make_parser(source: str) -> Type[Parser]:
# Combine parse_string() and generate_parser().
grammar = parse_string(source, GrammarParser)
return generate_parser(grammar) | python | Tools/peg_generator/pegen/testutil.py | 58 | 61 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,334 | import_file | def import_file(full_name: str, path: str) -> Any:
"""Import a python module from a path"""
spec = importlib.util.spec_from_file_location(full_name, path)
assert spec is not None
mod = importlib.util.module_from_spec(spec)
# We assume this is not None and has an exec_module() method.
# See htt... | python | Tools/peg_generator/pegen/testutil.py | 64 | 75 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,335 | generate_c_parser_source | def generate_c_parser_source(grammar: Grammar) -> str:
out = io.StringIO()
genr = CParserGenerator(grammar, ALL_TOKENS, EXACT_TOKENS, NON_EXACT_TOKENS, out)
genr.generate("<string>")
return out.getvalue() | python | Tools/peg_generator/pegen/testutil.py | 78 | 82 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,336 | generate_parser_c_extension | def generate_parser_c_extension(
grammar: Grammar,
path: pathlib.PurePath,
debug: bool = False,
library_dir: Optional[str] = None,
) -> Any:
"""Generate a parser c extension for the given grammar in the given path
Returns a module object with a parse_string() method.
TODO: express that usin... | python | Tools/peg_generator/pegen/testutil.py | 85 | 113 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,337 | print_memstats | def print_memstats() -> bool:
MiB: Final = 2**20
try:
import psutil
except ImportError:
return False
print("Memory stats:")
process = psutil.Process()
meminfo = process.memory_info()
res = {}
res["rss"] = meminfo.rss / MiB
res["vms"] = meminfo.vms / MiB
if sys.pla... | python | Tools/peg_generator/pegen/testutil.py | 116 | 142 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,338 | visit_NameLeaf | def visit_NameLeaf(self, node: NameLeaf) -> bool:
name = node.value
return name.startswith("invalid") | python | Tools/peg_generator/pegen/python_generator.py | 49 | 51 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,339 | visit_StringLeaf | def visit_StringLeaf(self, node: StringLeaf) -> bool:
return False | python | Tools/peg_generator/pegen/python_generator.py | 53 | 54 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,340 | visit_NamedItem | def visit_NamedItem(self, node: NamedItem) -> bool:
return self.visit(node.item) | python | Tools/peg_generator/pegen/python_generator.py | 56 | 57 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,341 | visit_Rhs | def visit_Rhs(self, node: Rhs) -> bool:
return any(self.visit(alt) for alt in node.alts) | python | Tools/peg_generator/pegen/python_generator.py | 59 | 60 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,342 | visit_Alt | def visit_Alt(self, node: Alt) -> bool:
return any(self.visit(item) for item in node.items) | python | Tools/peg_generator/pegen/python_generator.py | 62 | 63 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,343 | lookahead_call_helper | def lookahead_call_helper(self, node: Lookahead) -> bool:
return self.visit(node.node) | python | Tools/peg_generator/pegen/python_generator.py | 65 | 66 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,344 | visit_PositiveLookahead | def visit_PositiveLookahead(self, node: PositiveLookahead) -> bool:
return self.lookahead_call_helper(node) | python | Tools/peg_generator/pegen/python_generator.py | 68 | 69 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,345 | visit_NegativeLookahead | def visit_NegativeLookahead(self, node: NegativeLookahead) -> bool:
return self.lookahead_call_helper(node) | python | Tools/peg_generator/pegen/python_generator.py | 71 | 72 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,346 | visit_Opt | def visit_Opt(self, node: Opt) -> bool:
return self.visit(node.node) | python | Tools/peg_generator/pegen/python_generator.py | 74 | 75 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,347 | visit_Repeat | def visit_Repeat(self, node: Repeat0) -> Tuple[str, str]:
return self.visit(node.node) | python | Tools/peg_generator/pegen/python_generator.py | 77 | 78 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,348 | visit_Gather | def visit_Gather(self, node: Gather) -> Tuple[str, str]:
return self.visit(node.node) | python | Tools/peg_generator/pegen/python_generator.py | 80 | 81 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,349 | visit_Group | def visit_Group(self, node: Group) -> bool:
return self.visit(node.rhs) | python | Tools/peg_generator/pegen/python_generator.py | 83 | 84 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,350 | visit_Cut | def visit_Cut(self, node: Cut) -> bool:
return False | python | Tools/peg_generator/pegen/python_generator.py | 86 | 87 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,351 | visit_Forced | def visit_Forced(self, node: Forced) -> bool:
return self.visit(node.node) | python | Tools/peg_generator/pegen/python_generator.py | 89 | 90 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,352 | __init__ | def __init__(self, parser_generator: ParserGenerator):
self.gen = parser_generator
self.cache: Dict[Any, Any] = {} | python | Tools/peg_generator/pegen/python_generator.py | 94 | 96 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,353 | visit_NameLeaf | def visit_NameLeaf(self, node: NameLeaf) -> Tuple[Optional[str], str]:
name = node.value
if name == "SOFT_KEYWORD":
return "soft_keyword", "self.soft_keyword()"
if name in ("NAME", "NUMBER", "STRING", "OP", "TYPE_COMMENT"):
name = name.lower()
return name, f"s... | python | Tools/peg_generator/pegen/python_generator.py | 98 | 108 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,354 | visit_StringLeaf | def visit_StringLeaf(self, node: StringLeaf) -> Tuple[str, str]:
return "literal", f"self.expect({node.value})" | python | Tools/peg_generator/pegen/python_generator.py | 110 | 111 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,355 | visit_Rhs | def visit_Rhs(self, node: Rhs) -> Tuple[Optional[str], str]:
if node in self.cache:
return self.cache[node]
if len(node.alts) == 1 and len(node.alts[0].items) == 1:
self.cache[node] = self.visit(node.alts[0].items[0])
else:
name = self.gen.artifical_rule_from_... | python | Tools/peg_generator/pegen/python_generator.py | 113 | 121 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,356 | visit_NamedItem | def visit_NamedItem(self, node: NamedItem) -> Tuple[Optional[str], str]:
name, call = self.visit(node.item)
if node.name:
name = node.name
return name, call | python | Tools/peg_generator/pegen/python_generator.py | 123 | 127 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,357 | lookahead_call_helper | def lookahead_call_helper(self, node: Lookahead) -> Tuple[str, str]:
name, call = self.visit(node.node)
head, tail = call.split("(", 1)
assert tail[-1] == ")"
tail = tail[:-1]
return head, tail | python | Tools/peg_generator/pegen/python_generator.py | 129 | 134 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,358 | visit_PositiveLookahead | def visit_PositiveLookahead(self, node: PositiveLookahead) -> Tuple[None, str]:
head, tail = self.lookahead_call_helper(node)
return None, f"self.positive_lookahead({head}, {tail})" | python | Tools/peg_generator/pegen/python_generator.py | 136 | 138 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,359 | visit_NegativeLookahead | def visit_NegativeLookahead(self, node: NegativeLookahead) -> Tuple[None, str]:
head, tail = self.lookahead_call_helper(node)
return None, f"self.negative_lookahead({head}, {tail})" | python | Tools/peg_generator/pegen/python_generator.py | 140 | 142 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,360 | visit_Opt | def visit_Opt(self, node: Opt) -> Tuple[str, str]:
name, call = self.visit(node.node)
# Note trailing comma (the call may already have one comma
# at the end, for example when rules have both repeat0 and optional
# markers, e.g: [rule*])
if call.endswith(","):
return ... | python | Tools/peg_generator/pegen/python_generator.py | 144 | 152 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,361 | visit_Repeat0 | def visit_Repeat0(self, node: Repeat0) -> Tuple[str, str]:
if node in self.cache:
return self.cache[node]
name = self.gen.artificial_rule_from_repeat(node.node, False)
self.cache[node] = name, f"self.{name}()," # Also a trailing comma!
return self.cache[node] | python | Tools/peg_generator/pegen/python_generator.py | 154 | 159 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,362 | visit_Repeat1 | def visit_Repeat1(self, node: Repeat1) -> Tuple[str, str]:
if node in self.cache:
return self.cache[node]
name = self.gen.artificial_rule_from_repeat(node.node, True)
self.cache[node] = name, f"self.{name}()" # But no trailing comma here!
return self.cache[node] | python | Tools/peg_generator/pegen/python_generator.py | 161 | 166 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,363 | visit_Gather | def visit_Gather(self, node: Gather) -> Tuple[str, str]:
if node in self.cache:
return self.cache[node]
name = self.gen.artifical_rule_from_gather(node)
self.cache[node] = name, f"self.{name}()" # No trailing comma here either!
return self.cache[node] | python | Tools/peg_generator/pegen/python_generator.py | 168 | 173 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,364 | visit_Group | def visit_Group(self, node: Group) -> Tuple[Optional[str], str]:
return self.visit(node.rhs) | python | Tools/peg_generator/pegen/python_generator.py | 175 | 176 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,365 | visit_Cut | def visit_Cut(self, node: Cut) -> Tuple[str, str]:
return "cut", "True" | python | Tools/peg_generator/pegen/python_generator.py | 178 | 179 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,366 | visit_Forced | def visit_Forced(self, node: Forced) -> Tuple[str, str]:
if isinstance(node.node, Group):
_, val = self.visit(node.node.rhs)
return "forced", f"self.expect_forced({val}, '''({node.node.rhs!s})''')"
else:
return (
"forced",
f"self.expect... | python | Tools/peg_generator/pegen/python_generator.py | 181 | 189 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,367 | __init__ | def __init__(
self,
grammar: grammar.Grammar,
file: Optional[IO[Text]],
tokens: Set[str] = set(token.tok_name.values()),
location_formatting: Optional[str] = None,
unreachable_formatting: Optional[str] = None,
):
tokens.add("SOFT_KEYWORD")
super().__in... | python | Tools/peg_generator/pegen/python_generator.py | 193 | 210 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,368 | generate | def generate(self, filename: str) -> None:
self.collect_rules()
header = self.grammar.metas.get("header", MODULE_PREFIX)
if header is not None:
basename = os.path.basename(filename)
self.print(header.rstrip("\n").format(filename=basename))
subheader = self.grammar... | python | Tools/peg_generator/pegen/python_generator.py | 212 | 236 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,369 | alts_uses_locations | def alts_uses_locations(self, alts: Sequence[Alt]) -> bool:
for alt in alts:
if alt.action and "LOCATIONS" in alt.action:
return True
for n in alt.items:
if isinstance(n.item, Group) and self.alts_uses_locations(n.item.rhs.alts):
return... | python | Tools/peg_generator/pegen/python_generator.py | 238 | 245 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,370 | visit_Rule | def visit_Rule(self, node: Rule) -> None:
is_loop = node.is_loop()
is_gather = node.is_gather()
rhs = node.flatten()
if node.left_recursive:
if node.leader:
self.print("@memoize_left_rec")
else:
# Non-leader rules in a cycle are not... | python | Tools/peg_generator/pegen/python_generator.py | 247 | 274 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,371 | visit_NamedItem | def visit_NamedItem(self, node: NamedItem) -> None:
name, call = self.callmakervisitor.visit(node.item)
if node.name:
name = node.name
if not name:
self.print(call)
else:
if name != "cut":
name = self.dedupe(name)
self.print... | python | Tools/peg_generator/pegen/python_generator.py | 276 | 285 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,372 | visit_Rhs | def visit_Rhs(self, node: Rhs, is_loop: bool = False, is_gather: bool = False) -> None:
if is_loop:
assert len(node.alts) == 1
for alt in node.alts:
self.visit(alt, is_loop=is_loop, is_gather=is_gather) | python | Tools/peg_generator/pegen/python_generator.py | 287 | 291 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,373 | visit_Alt | def visit_Alt(self, node: Alt, is_loop: bool, is_gather: bool) -> None:
has_cut = any(isinstance(item.item, Cut) for item in node.items)
with self.local_variable_context():
if has_cut:
self.print("cut = False")
if is_loop:
self.print("while (")
... | python | Tools/peg_generator/pegen/python_generator.py | 293 | 345 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,374 | __str__ | def __str__(self) -> str:
parts = []
parts.append(self.function)
if self.arguments:
parts.append(f"({', '.join(map(str, self.arguments))})")
if self.force_true:
parts.append(", !p->error_indicator")
if self.assigned_variable:
if self.assigned_v... | python | Tools/peg_generator/pegen/c_generator.py | 97 | 120 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,375 | __init__ | def __init__(
self,
parser_generator: ParserGenerator,
exact_tokens: Dict[str, int],
non_exact_tokens: Set[str],
):
self.gen = parser_generator
self.exact_tokens = exact_tokens
self.non_exact_tokens = non_exact_tokens
self.cache: Dict[Any, FunctionCall... | python | Tools/peg_generator/pegen/c_generator.py | 124 | 134 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,376 | keyword_helper | def keyword_helper(self, keyword: str) -> FunctionCall:
return FunctionCall(
assigned_variable="_keyword",
function="_PyPegen_expect_token",
arguments=["p", self.gen.keywords[keyword]],
return_type="Token *",
nodetype=NodeTypes.KEYWORD,
com... | python | Tools/peg_generator/pegen/c_generator.py | 136 | 144 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,377 | soft_keyword_helper | def soft_keyword_helper(self, value: str) -> FunctionCall:
return FunctionCall(
assigned_variable="_keyword",
function="_PyPegen_expect_soft_keyword",
arguments=["p", value],
return_type="expr_ty",
nodetype=NodeTypes.SOFT_KEYWORD,
comment=f... | python | Tools/peg_generator/pegen/c_generator.py | 146 | 154 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,378 | visit_NameLeaf | def visit_NameLeaf(self, node: NameLeaf) -> FunctionCall:
name = node.value
if name in self.non_exact_tokens:
if name in BASE_NODETYPES:
return FunctionCall(
assigned_variable=f"{name.lower()}_var",
function=f"_PyPegen_{name.lower()}_to... | python | Tools/peg_generator/pegen/c_generator.py | 156 | 188 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,379 | visit_StringLeaf | def visit_StringLeaf(self, node: StringLeaf) -> FunctionCall:
val = ast.literal_eval(node.value)
if re.match(r"[a-zA-Z_]\w*\Z", val): # This is a keyword
if node.value.endswith("'"):
return self.keyword_helper(val)
else:
return self.soft_keyword_h... | python | Tools/peg_generator/pegen/c_generator.py | 190 | 207 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,380 | visit_Rhs | def visit_Rhs(self, node: Rhs) -> FunctionCall:
if node in self.cache:
return self.cache[node]
if node.can_be_inlined:
self.cache[node] = self.generate_call(node.alts[0].items[0])
else:
name = self.gen.artifical_rule_from_rhs(node)
self.cache[node]... | python | Tools/peg_generator/pegen/c_generator.py | 209 | 222 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,381 | visit_NamedItem | def visit_NamedItem(self, node: NamedItem) -> FunctionCall:
call = self.generate_call(node.item)
if node.name:
call.assigned_variable = node.name
if node.type:
call.assigned_variable_type = node.type
return call | python | Tools/peg_generator/pegen/c_generator.py | 224 | 230 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,382 | lookahead_call_helper | def lookahead_call_helper(self, node: Lookahead, positive: int) -> FunctionCall:
call = self.generate_call(node.node)
if call.nodetype == NodeTypes.NAME_TOKEN:
return FunctionCall(
function=f"_PyPegen_lookahead_with_name",
arguments=[positive, call.function, *... | python | Tools/peg_generator/pegen/c_generator.py | 232 | 258 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,383 | visit_PositiveLookahead | def visit_PositiveLookahead(self, node: PositiveLookahead) -> FunctionCall:
return self.lookahead_call_helper(node, 1) | python | Tools/peg_generator/pegen/c_generator.py | 260 | 261 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,384 | visit_NegativeLookahead | def visit_NegativeLookahead(self, node: NegativeLookahead) -> FunctionCall:
return self.lookahead_call_helper(node, 0) | python | Tools/peg_generator/pegen/c_generator.py | 263 | 264 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,385 | visit_Forced | def visit_Forced(self, node: Forced) -> FunctionCall:
call = self.generate_call(node.node)
if isinstance(node.node, Leaf):
assert isinstance(node.node, Leaf)
val = ast.literal_eval(node.node.value)
assert val in self.exact_tokens, f"{node.node.value} is not a known li... | python | Tools/peg_generator/pegen/c_generator.py | 266 | 293 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,386 | visit_Opt | def visit_Opt(self, node: Opt) -> FunctionCall:
call = self.generate_call(node.node)
return FunctionCall(
assigned_variable="_opt_var",
function=call.function,
arguments=call.arguments,
force_true=True,
comment=f"{node}",
) | python | Tools/peg_generator/pegen/c_generator.py | 295 | 303 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,387 | visit_Repeat0 | def visit_Repeat0(self, node: Repeat0) -> FunctionCall:
if node in self.cache:
return self.cache[node]
name = self.gen.artificial_rule_from_repeat(node.node, False)
self.cache[node] = FunctionCall(
assigned_variable=f"{name}_var",
function=f"{name}_rule",
... | python | Tools/peg_generator/pegen/c_generator.py | 305 | 316 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,388 | visit_Repeat1 | def visit_Repeat1(self, node: Repeat1) -> FunctionCall:
if node in self.cache:
return self.cache[node]
name = self.gen.artificial_rule_from_repeat(node.node, True)
self.cache[node] = FunctionCall(
assigned_variable=f"{name}_var",
function=f"{name}_rule",
... | python | Tools/peg_generator/pegen/c_generator.py | 318 | 329 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,389 | visit_Gather | def visit_Gather(self, node: Gather) -> FunctionCall:
if node in self.cache:
return self.cache[node]
name = self.gen.artifical_rule_from_gather(node)
self.cache[node] = FunctionCall(
assigned_variable=f"{name}_var",
function=f"{name}_rule",
argumen... | python | Tools/peg_generator/pegen/c_generator.py | 331 | 342 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,390 | visit_Group | def visit_Group(self, node: Group) -> FunctionCall:
return self.generate_call(node.rhs) | python | Tools/peg_generator/pegen/c_generator.py | 344 | 345 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,391 | visit_Cut | def visit_Cut(self, node: Cut) -> FunctionCall:
return FunctionCall(
assigned_variable="_cut_var",
return_type="int",
function="1",
nodetype=NodeTypes.CUT_OPERATOR,
) | python | Tools/peg_generator/pegen/c_generator.py | 347 | 353 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,392 | generate_call | def generate_call(self, node: Any) -> FunctionCall:
return super().visit(node) | python | Tools/peg_generator/pegen/c_generator.py | 355 | 356 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,393 | __init__ | def __init__(
self,
grammar: grammar.Grammar,
tokens: Dict[int, str],
exact_tokens: Dict[str, int],
non_exact_tokens: Set[str],
file: Optional[IO[Text]],
debug: bool = False,
skip_actions: bool = False,
):
super().__init__(grammar, set(tokens.v... | python | Tools/peg_generator/pegen/c_generator.py | 360 | 377 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,394 | add_level | def add_level(self) -> None:
self.print("if (p->level++ == MAXSTACK) {")
with self.indent():
self.print("_Pypegen_stack_overflow(p);")
self.print("}") | python | Tools/peg_generator/pegen/c_generator.py | 379 | 383 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,395 | remove_level | def remove_level(self) -> None:
self.print("p->level--;") | python | Tools/peg_generator/pegen/c_generator.py | 385 | 386 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,396 | add_return | def add_return(self, ret_val: str) -> None:
for stmt in self.cleanup_statements:
self.print(stmt)
self.remove_level()
self.print(f"return {ret_val};") | python | Tools/peg_generator/pegen/c_generator.py | 388 | 392 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,397 | unique_varname | def unique_varname(self, name: str = "tmpvar") -> str:
new_var = name + "_" + str(self._varname_counter)
self._varname_counter += 1
return new_var | python | Tools/peg_generator/pegen/c_generator.py | 394 | 397 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,398 | call_with_errorcheck_return | def call_with_errorcheck_return(self, call_text: str, returnval: str) -> None:
error_var = self.unique_varname()
self.print(f"int {error_var} = {call_text};")
self.print(f"if ({error_var}) {{")
with self.indent():
self.add_return(returnval)
self.print("}") | python | Tools/peg_generator/pegen/c_generator.py | 399 | 405 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,399 | call_with_errorcheck_goto | def call_with_errorcheck_goto(self, call_text: str, goto_target: str) -> None:
error_var = self.unique_varname()
self.print(f"int {error_var} = {call_text};")
self.print(f"if ({error_var}) {{")
with self.indent():
self.print(f"goto {goto_target};")
self.print(f"}}") | python | Tools/peg_generator/pegen/c_generator.py | 407 | 413 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
10,400 | out_of_memory_return | def out_of_memory_return(
self,
expr: str,
cleanup_code: Optional[str] = None,
) -> None:
self.print(f"if ({expr}) {{")
with self.indent():
if cleanup_code is not None:
self.print(cleanup_code)
self.print("p->error_indicator = 1;")
... | python | Tools/peg_generator/pegen/c_generator.py | 415 | 427 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.