Includes tests.
Also tweak a comment in Grammar/Grammar.
# eval_input is the input for the eval() functions.
# func_type_input is a PEP 484 Python 2 function type comment
# NB: compound_stmt in single_input is followed by extra NEWLINE!
-# NB: due to the way TYPE_COMMENT is tokenized it will always be followed by a
-# NEWLINE
+# NB: due to the way TYPE_COMMENT is tokenized it will always be followed by a NEWLINE
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
file_input: (NEWLINE | stmt)* ENDMARKER
eval_input: testlist NEWLINE* ENDMARKER
small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt |
import_stmt | global_stmt | nonlocal_stmt | assert_stmt)
expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
- ('=' (yield_expr|testlist_star_expr))* [TYPE_COMMENT])
+ [('=' (yield_expr|testlist_star_expr))+ [TYPE_COMMENT]] )
annassign: ':' test ['=' (yield_expr|testlist)]
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
vardecl = """\
a = 0 # type: int
-a # type: int
"""
ignores = """\
def test_vardecl(self):
tree = self.parse(vardecl)
self.assertEqual(tree.body[0].type_comment, "int")
- # Curious fact: an expression can have a type comment but it
- # is lost in the AST, so we have this in the example source
- # code but don't test it here.
tree = self.classic_parse(vardecl)
self.assertEqual(tree.body[0].type_comment, None)
ast.parse(source, type_comments=True)
check_both_ways("pass # type: int\n")
+ check_both_ways("foo() # type: int\n")
check_both_ways("x += 1 # type: int\n")
check_both_ways("while True: # type: int\n continue\n")
check_both_ways("while True:\n continue # type: int\n")
static arc arcs_16_0[1] = {
{48, 1},
};
-static arc arcs_16_1[5] = {
+static arc arcs_16_1[4] = {
{49, 2},
{50, 3},
{32, 4},
- {28, 2},
{0, 1},
};
static arc arcs_16_2[1] = {
};
static state states_16[6] = {
{1, arcs_16_0},
- {5, arcs_16_1},
+ {4, arcs_16_1},
{1, arcs_16_2},
{2, arcs_16_3},
{2, arcs_16_4},