Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions parser/make_grammar_test.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@

import sys
import ast
import datetime
import subprocess

inp = [
Expand DownExpand Up@@ -57,6 +58,7 @@
("[1,]", "eval"),
("[1,2]", "eval"),
("[1,2,]", "eval"),
("[e for e in (1,2,3)]", "eval"),

# tuple
("( a for a in ab )", "eval"),
Expand DownExpand Up@@ -375,6 +377,9 @@
("a, b = *a", "exec"),
("a = yield a", "exec"),
('''a.b = 1''', "exec"),
("[e for e in [1, 2, 3]] = 3", "exec", SyntaxError),
("{e for e in [1, 2, 3]} = 3", "exec", SyntaxError),
("{e: e**2 for e in [1, 2, 3]} = 3", "exec", SyntaxError),
('''f() = 1''', "exec", SyntaxError),
('''lambda: x = 1''', "exec", SyntaxError),
('''(a + b) = 1''', "exec", SyntaxError),
Expand DownExpand Up@@ -493,21 +498,26 @@ def escape(x):
def main():
"""Write grammar_data_test.go"""
path = "grammar_data_test.go"
out = ["""// Test data generated by make_grammar_test.py - do not edit
year = datetime.datetime.now().year
out = ["""// Copyright{year} The go-python Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Test data generated by make_grammar_test.py - do not edit

package parser

import (
"github.com/go-python/gpython/py"
)

var grammarTestData = []struct{
var grammarTestData = []struct{{
in string
mode string
out string
exceptionType *py.Type
errString string
}{"""]
}}{{""".format(year=year)]
for x in inp:
source, mode = x[:2]
if len(x) > 2:
Expand Down