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

Method test_expr_grammar

Lib/test/test_peg_generator/test_pegen.py:118–132  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

116 )
117
118 def test_expr_grammar(self) -> None:
119 grammar = """
120 start: sum NEWLINE
121 sum: term '+' term | term
122 term: NUMBER
123 """
124 parser_class = make_parser(grammar)
125 node = parse_string("42\n", parser_class)
126 self.assertEqual(
127 node,
128 [
129 TokenInfo(NUMBER, string="42", start=(1, 0), end=(1, 2), line="42\n"),
130 TokenInfo(NEWLINE, string="\n", start=(1, 2), end=(1, 3), line="42\n"),
131 ],
132 )
133
134 def test_optional_operator(self) -> None:
135 grammar = """

Callers

nothing calls this directly

Calls 4

make_parserFunction · 0.90
parse_stringFunction · 0.90
TokenInfoClass · 0.90
assertEqualMethod · 0.45

Tested by

no test coverage detected