Skip to content

parser: Update make_grammer_text.py #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2018
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 number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import sys
import ast
import datetime
import subprocess

inp = [
Expand Down Expand 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 Down Expand 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 Down Expand 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