Skip to content

Commit 1d99034

Browse files
committed
More grammar
1 parent f23426a commit 1d99034

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

parser/grammar.y

+4-7
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ atom:
10911091
}
10921092
| NAME
10931093
{
1094-
$$ = &ast.Name{ExprBase: ast.ExprBase{$<pos>$}, Id: ast.Identifier($1)}
1094+
$$ = &ast.Name{ExprBase: ast.ExprBase{$<pos>$}, Id: ast.Identifier($1), Ctx: ast.Load}
10951095
}
10961096
| NUMBER
10971097
{
@@ -1105,22 +1105,19 @@ atom:
11051105
}
11061106
| ELIPSIS
11071107
{
1108-
// FIXME
1109-
$$ = nil
1108+
$$ = &ast.Ellipsis{ExprBase: ast.ExprBase{$<pos>$}}
11101109
}
11111110
| NONE
11121111
{
1113-
// FIXME
1114-
$$ = nil
1112+
$$ = &ast.NameConstant{ExprBase: ast.ExprBase{$<pos>$}, Value: py.None}
11151113
}
11161114
| TRUE
11171115
{
11181116
$$ = &ast.NameConstant{ExprBase: ast.ExprBase{$<pos>$}, Value: py.True}
11191117
}
11201118
| FALSE
11211119
{
1122-
// FIXME
1123-
$$ = nil
1120+
$$ = &ast.NameConstant{ExprBase: ast.ExprBase{$<pos>$}, Value: py.False}
11241121
}
11251122

11261123
testlist_comp:

parser/grammar_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ func TestGrammar(t *testing.T) {
2121
{"()", "exec", "Module(body=[Expr(value=Tuple(elts=[], ctx=Load()))])"},
2222
{"[ ]", "exec", "Module(body=[Expr(value=List(elts=[], ctx=Load()))])"},
2323
{"True\n", "eval", "Expression(body=NameConstant(value=True))"},
24+
{"False\n", "eval", "Expression(body=NameConstant(value=False))"},
25+
{"None\n", "eval", "Expression(body=NameConstant(value=None))"},
26+
{"...", "eval", "Expression(body=Ellipsis())"},
27+
{"abc123", "eval", "Expression(body=Name(id='abc123', ctx=Load()))"},
2428
// END TESTS
2529
} {
2630
Ast, err := ParseString(test.in, test.mode)

parser/make_grammar_test.py

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
("()", "exec"),
1414
("[ ]", "exec"),
1515
("True\n", "eval"),
16+
("False\n", "eval"),
17+
("None\n", "eval"),
18+
("...", "eval"),
19+
("abc123", "eval"),
1620
]
1721

1822
def dump(source, mode):

0 commit comments

Comments
 (0)