prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add level 2 to hedy_translation.py
  Now that the keywords from level 1 can be translated, new levels can be added.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `hedy_translation.py`
  Content:
  ```
  1 from lark import Transformer, Tree
  2 from hedy import get_keywords_for_language, ExtractAST, get_parser
  3 
  4 
  5 TRANSPILER_LOOKUP = {}
  6 
  7 
  8 def keywords_to_dict(to_lang="nl"):
  9     """"Return a dictionary of keywords from language of choice. Key is english value is lang of choice"""
  10     keywords = {}
  11     keywords_from = get_keywords_for_language("en").replace("\n\n", "\n").splitlines()
  12 
  13     keywords_to = get_keywords_for_language(to_lang).replace("\n\n", "\n").splitlines()
  14     keywords_from_withoutlvl = []
  15     for line in keywords_from:
  16         if line[0] != '/':
  17             keywords_from_withoutlvl.append(line)
  18 
  19     keywords_to_withoutlvl = []
  20     for line in keywords_to:
  21         if line[0] != '/':
  22             keywords_to_withoutlvl.append(line)
  23 
  24     for line in range(len(keywords_from_withoutlvl)):
  25         keywords[(keywords_from_withoutlvl[line].split('"'))[1]] = keywords_to_withoutlvl[line].split('"')[1]
  26 
  27     return keywords
  28 
  29 
  30 def translate_keywords(input_string, from_lang="nl", to_lang="nl", level=1):
  31     """"Return code with keywords translated to language of choice in level of choice"""
  32     parser = get_parser(level, from_lang)
  33 
  34     punctuation_symbols = ['!', '?', '.']
  35 
  36     keywordDict = keywords_to_dict(to_lang)
  37     program_root = parser.parse(input_string + '\n').children[0]
  38     abstract_syntaxtree = ExtractAST().transform(program_root)
  39     translator = TRANSPILER_LOOKUP[level]
  40     abstract_syntaxtree = translator(keywordDict, punctuation_symbols).transform(program_root)
  41 
  42     return abstract_syntaxtree
  43 
  44 
  45 def hedy_translator(level):
  46     def decorating(c):
  47         TRANSPILER_LOOKUP[level] = c
  48         c.level = level
  49         return c
  50 
  51     return decorating
  52 
  53 
  54 @hedy_translator(level=1)
  55 class ConvertToLang1(Transformer):
  56 
  57     def __init__(self, keywords, punctuation_symbols):
  58         self.keywords = keywords
  59         self.punctuation_symbols = punctuation_symbols
  60         __class__.level = 1
  61 
  62     def command(self, args):
  63         return args[0]
  64 
  65     def program(self, args):
  66         return '\n'.join([str(c) for c in args])
  67 
  68     def text(self, args):
  69         return ''.join([str(c) for c in args])
  70 
  71     def invalid_space(self, args):
  72         return " " + ''.join([str(c) for c in args])
  73 
  74     def print(self, args):
  75         return self.keywords["print"] + " " + "".join([str(c) for c in args])
  76 
  77     def echo(self, args):
  78         all_args = self.keywords["echo"]
  79         if args:
  80             all_args += " "
  81         return all_args + "".join([str(c) for c in args])
  82 
  83     def ask(self, args):
  84         return self.keywords["ask"] + " " + "".join([str(c) for c in args])
  85 
  86     def turn(self, args):
  87         return self.keywords["turn"] + " " + "".join([str(c) for c in args])
  88 
  89     def forward(self, args):
  90         return self.keywords["forward"] + " " + "".join([str(c) for c in args])
  91 
  92     def random(self, args):
  93         return self.keywords["random"] + "".join([str(c) for c in args])
  94 
  95     def invalid(self, args):
  96         return ' '.join([str(c) for c in args])
  97 
  98     def __default__(self, data, children, meta):
  99         return Tree(data, children, meta)
  100
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/hedy_translation.py b/hedy_translation.py
  --- a/hedy_translation.py
  +++ b/hedy_translation.py
  @@ -1,5 +1,5 @@
   from lark import Transformer, Tree
  -from hedy import get_keywords_for_language, ExtractAST, get_parser
  +import hedy
   
   
   TRANSPILER_LOOKUP = {}
  @@ -8,9 +8,9 @@
   def keywords_to_dict(to_lang="nl"):
       """"Return a dictionary of keywords from language of choice. Key is english value is lang of choice"""
       keywords = {}
  -    keywords_from = get_keywords_for_language("en").replace("\n\n", "\n").splitlines()
  +    keywords_from = hedy.get_keywords_for_language("en").replace("\n\n", "\n").splitlines()
   
  -    keywords_to = get_keywords_for_language(to_lang).replace("\n\n", "\n").splitlines()
  +    keywords_to = hedy.get_keywords_for_language(to_lang).replace("\n\n", "\n").splitlines()
       keywords_from_withoutlvl = []
       for line in keywords_from:
           if line[0] != '/':
  @@ -29,13 +29,13 @@
   
   def translate_keywords(input_string, from_lang="nl", to_lang="nl", level=1):
       """"Return code with keywords translated to language of choice in level of choice"""
  -    parser = get_parser(level, from_lang)
  +    parser = hedy.get_parser(level, from_lang)
   
       punctuation_symbols = ['!', '?', '.']
   
       keywordDict = keywords_to_dict(to_lang)
       program_root = parser.parse(input_string + '\n').children[0]
  -    abstract_syntaxtree = ExtractAST().transform(program_root)
  +    abstract_syntaxtree = hedy.ExtractAST().transform(program_root)
       translator = TRANSPILER_LOOKUP[level]
       abstract_syntaxtree = translator(keywordDict, punctuation_symbols).transform(program_root)
   
  @@ -97,3 +97,50 @@
   
       def __default__(self, data, children, meta):
           return Tree(data, children, meta)
  +
  +@hedy_translator(level=2)
  +class ConvertToLang2(ConvertToLang1):
  +
  +    def assign(self, args):
  +        return args[0] + " " + self.keywords["is"] + " " + ''.join([str(c) for c in args[1:]])
  +
  +    def print(self, args):
  +
  +        argument_string = ""
  +        i = 0
  +
  +        for argument in args:
  +            # escape quotes if kids accidentally use them at level 2
  +            argument = hedy.process_characters_needing_escape(argument)
  +
  +            # final argument and punctuation arguments do not have to be separated with a space, other do
  +            if i == len(args) - 1 or args[i + 1] in self.punctuation_symbols:
  +                space = ''
  +            else:
  +                space = " "
  +
  +            argument_string += argument + space
  +
  +            i = i + 1
  +
  +        return self.keywords["print"] + " " + argument_string
  +
  +    def punctuation(self, args):
  +        return ''.join([str(c) for c in args])
  +
  +    def var(self, args):
  +        var = args[0]
  +        all_parameters = ["'" + hedy.process_characters_needing_escape(a) + "'" for a in args[1:]]
  +        return var + ''.join(all_parameters)
  +
  +    def ask(self, args):
  +        var = args[0]
  +        all_parameters = [hedy.process_characters_needing_escape(a) for a in args]
  +
  +        return all_parameters[0] + " " + self.keywords["is"] + " " + self.keywords["ask"] + " " + ''.join(all_parameters[1:])
  +
  +    def ask_dep_2(self, args):
  +        return self.keywords["ask"] + " " + ''.join([str(c) for c in args])
  +
  +    def echo_dep_2(self, args):
  +        return self.keywords["echo"] + " " + ''.join([str(c) for c in args])
  
verification_info: {"golden_diff": "diff --git a/hedy_translation.py b/hedy_translation.py\n--- a/hedy_translation.py\n+++ b/hedy_translation.py\n@@ -1,5 +1,5 @@\n from lark import Transformer, Tree\n-from hedy import get_keywords_for_language, ExtractAST, get_parser\n+import hedy\n \n \n TRANSPILER_LOOKUP = {}\n@@ -8,9 +8,9 @@\n def keywords_to_dict(to_lang=\"nl\"):\n     \"\"\"\"Return a dictionary of keywords from language of choice. Key is english value is lang of choice\"\"\"\n     keywords = {}\n-    keywords_from = get_keywords_for_language(\"en\").replace(\"\\n\\n\", \"\\n\").splitlines()\n+    keywords_from = hedy.get_keywords_for_language(\"en\").replace(\"\\n\\n\", \"\\n\").splitlines()\n \n-    keywords_to = get_keywords_for_language(to_lang).replace(\"\\n\\n\", \"\\n\").splitlines()\n+    keywords_to = hedy.get_keywords_for_language(to_lang).replace(\"\\n\\n\", \"\\n\").splitlines()\n     keywords_from_withoutlvl = []\n     for line in keywords_from:\n         if line[0] != '/':\n@@ -29,13 +29,13 @@\n \n def translate_keywords(input_string, from_lang=\"nl\", to_lang=\"nl\", level=1):\n     \"\"\"\"Return code with keywords translated to language of choice in level of choice\"\"\"\n-    parser = get_parser(level, from_lang)\n+    parser = hedy.get_parser(level, from_lang)\n \n     punctuation_symbols = ['!', '?', '.']\n \n     keywordDict = keywords_to_dict(to_lang)\n     program_root = parser.parse(input_string + '\\n').children[0]\n-    abstract_syntaxtree = ExtractAST().transform(program_root)\n+    abstract_syntaxtree = hedy.ExtractAST().transform(program_root)\n     translator = TRANSPILER_LOOKUP[level]\n     abstract_syntaxtree = translator(keywordDict, punctuation_symbols).transform(program_root)\n \n@@ -97,3 +97,50 @@\n \n     def __default__(self, data, children, meta):\n         return Tree(data, children, meta)\n+\n+@hedy_translator(level=2)\n+class ConvertToLang2(ConvertToLang1):\n+\n+    def assign(self, args):\n+        return args[0] + \" \" + self.keywords[\"is\"] + \" \" + ''.join([str(c) for c in args[1:]])\n+\n+    def print(self, args):\n+\n+        argument_string = \"\"\n+        i = 0\n+\n+        for argument in args:\n+            # escape quotes if kids accidentally use them at level 2\n+            argument = hedy.process_characters_needing_escape(argument)\n+\n+            # final argument and punctuation arguments do not have to be separated with a space, other do\n+            if i == len(args) - 1 or args[i + 1] in self.punctuation_symbols:\n+                space = ''\n+            else:\n+                space = \" \"\n+\n+            argument_string += argument + space\n+\n+            i = i + 1\n+\n+        return self.keywords[\"print\"] + \" \" + argument_string\n+\n+    def punctuation(self, args):\n+        return ''.join([str(c) for c in args])\n+\n+    def var(self, args):\n+        var = args[0]\n+        all_parameters = [\"'\" + hedy.process_characters_needing_escape(a) + \"'\" for a in args[1:]]\n+        return var + ''.join(all_parameters)\n+\n+    def ask(self, args):\n+        var = args[0]\n+        all_parameters = [hedy.process_characters_needing_escape(a) for a in args]\n+\n+        return all_parameters[0] + \" \" + self.keywords[\"is\"] + \" \" + self.keywords[\"ask\"] + \" \" + ''.join(all_parameters[1:])\n+\n+    def ask_dep_2(self, args):\n+        return self.keywords[\"ask\"] + \" \" + ''.join([str(c) for c in args])\n+\n+    def echo_dep_2(self, args):\n+        return self.keywords[\"echo\"] + \" \" + ''.join([str(c) for c in args])\n", "issue": "Add level 2 to hedy_translation.py\nNow that the keywords from level 1 can be translated, new levels can be added.\n", "before_files": [{"content": "from lark import Transformer, Tree\nfrom hedy import get_keywords_for_language, ExtractAST, get_parser\n\n\nTRANSPILER_LOOKUP = {}\n\n\ndef keywords_to_dict(to_lang=\"nl\"):\n    \"\"\"\"Return a dictionary of keywords from language of choice. Key is english value is lang of choice\"\"\"\n    keywords = {}\n    keywords_from = get_keywords_for_language(\"en\").replace(\"\\n\\n\", \"\\n\").splitlines()\n\n    keywords_to = get_keywords_for_language(to_lang).replace(\"\\n\\n\", \"\\n\").splitlines()\n    keywords_from_withoutlvl = []\n    for line in keywords_from:\n        if line[0] != '/':\n            keywords_from_withoutlvl.append(line)\n\n    keywords_to_withoutlvl = []\n    for line in keywords_to:\n        if line[0] != '/':\n            keywords_to_withoutlvl.append(line)\n\n    for line in range(len(keywords_from_withoutlvl)):\n        keywords[(keywords_from_withoutlvl[line].split('\"'))[1]] = keywords_to_withoutlvl[line].split('\"')[1]\n\n    return keywords\n\n\ndef translate_keywords(input_string, from_lang=\"nl\", to_lang=\"nl\", level=1):\n    \"\"\"\"Return code with keywords translated to language of choice in level of choice\"\"\"\n    parser = get_parser(level, from_lang)\n\n    punctuation_symbols = ['!', '?', '.']\n\n    keywordDict = keywords_to_dict(to_lang)\n    program_root = parser.parse(input_string + '\\n').children[0]\n    abstract_syntaxtree = ExtractAST().transform(program_root)\n    translator = TRANSPILER_LOOKUP[level]\n    abstract_syntaxtree = translator(keywordDict, punctuation_symbols).transform(program_root)\n\n    return abstract_syntaxtree\n\n\ndef hedy_translator(level):\n    def decorating(c):\n        TRANSPILER_LOOKUP[level] = c\n        c.level = level\n        return c\n\n    return decorating\n\n\n@hedy_translator(level=1)\nclass ConvertToLang1(Transformer):\n\n    def __init__(self, keywords, punctuation_symbols):\n        self.keywords = keywords\n        self.punctuation_symbols = punctuation_symbols\n        __class__.level = 1\n\n    def command(self, args):\n        return args[0]\n\n    def program(self, args):\n        return '\\n'.join([str(c) for c in args])\n\n    def text(self, args):\n        return ''.join([str(c) for c in args])\n\n    def invalid_space(self, args):\n        return \" \" + ''.join([str(c) for c in args])\n\n    def print(self, args):\n        return self.keywords[\"print\"] + \" \" + \"\".join([str(c) for c in args])\n\n    def echo(self, args):\n        all_args = self.keywords[\"echo\"]\n        if args:\n            all_args += \" \"\n        return all_args + \"\".join([str(c) for c in args])\n\n    def ask(self, args):\n        return self.keywords[\"ask\"] + \" \" + \"\".join([str(c) for c in args])\n\n    def turn(self, args):\n        return self.keywords[\"turn\"] + \" \" + \"\".join([str(c) for c in args])\n\n    def forward(self, args):\n        return self.keywords[\"forward\"] + \" \" + \"\".join([str(c) for c in args])\n\n    def random(self, args):\n        return self.keywords[\"random\"] + \"\".join([str(c) for c in args])\n\n    def invalid(self, args):\n        return ' '.join([str(c) for c in args])\n\n    def __default__(self, data, children, meta):\n        return Tree(data, children, meta)\n", "path": "hedy_translation.py"}], "after_files": [{"content": "from lark import Transformer, Tree\nimport hedy\n\n\nTRANSPILER_LOOKUP = {}\n\n\ndef keywords_to_dict(to_lang=\"nl\"):\n    \"\"\"\"Return a dictionary of keywords from language of choice. Key is english value is lang of choice\"\"\"\n    keywords = {}\n    keywords_from = hedy.get_keywords_for_language(\"en\").replace(\"\\n\\n\", \"\\n\").splitlines()\n\n    keywords_to = hedy.get_keywords_for_language(to_lang).replace(\"\\n\\n\", \"\\n\").splitlines()\n    keywords_from_withoutlvl = []\n    for line in keywords_from:\n        if line[0] != '/':\n            keywords_from_withoutlvl.append(line)\n\n    keywords_to_withoutlvl = []\n    for line in keywords_to:\n        if line[0] != '/':\n            keywords_to_withoutlvl.append(line)\n\n    for line in range(len(keywords_from_withoutlvl)):\n        keywords[(keywords_from_withoutlvl[line].split('\"'))[1]] = keywords_to_withoutlvl[line].split('\"')[1]\n\n    return keywords\n\n\ndef translate_keywords(input_string, from_lang=\"nl\", to_lang=\"nl\", level=1):\n    \"\"\"\"Return code with keywords translated to language of choice in level of choice\"\"\"\n    parser = hedy.get_parser(level, from_lang)\n\n    punctuation_symbols = ['!', '?', '.']\n\n    keywordDict = keywords_to_dict(to_lang)\n    program_root = parser.parse(input_string + '\\n').children[0]\n    abstract_syntaxtree = hedy.ExtractAST().transform(program_root)\n    translator = TRANSPILER_LOOKUP[level]\n    abstract_syntaxtree = translator(keywordDict, punctuation_symbols).transform(program_root)\n\n    return abstract_syntaxtree\n\n\ndef hedy_translator(level):\n    def decorating(c):\n        TRANSPILER_LOOKUP[level] = c\n        c.level = level\n        return c\n\n    return decorating\n\n\n@hedy_translator(level=1)\nclass ConvertToLang1(Transformer):\n\n    def __init__(self, keywords, punctuation_symbols):\n        self.keywords = keywords\n        self.punctuation_symbols = punctuation_symbols\n        __class__.level = 1\n\n    def command(self, args):\n        return args[0]\n\n    def program(self, args):\n        return '\\n'.join([str(c) for c in args])\n\n    def text(self, args):\n        return ''.join([str(c) for c in args])\n\n    def invalid_space(self, args):\n        return \" \" + ''.join([str(c) for c in args])\n\n    def print(self, args):\n        return self.keywords[\"print\"] + \" \" + \"\".join([str(c) for c in args])\n\n    def echo(self, args):\n        all_args = self.keywords[\"echo\"]\n        if args:\n            all_args += \" \"\n        return all_args + \"\".join([str(c) for c in args])\n\n    def ask(self, args):\n        return self.keywords[\"ask\"] + \" \" + \"\".join([str(c) for c in args])\n\n    def turn(self, args):\n        return self.keywords[\"turn\"] + \" \" + \"\".join([str(c) for c in args])\n\n    def forward(self, args):\n        return self.keywords[\"forward\"] + \" \" + \"\".join([str(c) for c in args])\n\n    def random(self, args):\n        return self.keywords[\"random\"] + \"\".join([str(c) for c in args])\n\n    def invalid(self, args):\n        return ' '.join([str(c) for c in args])\n\n    def __default__(self, data, children, meta):\n        return Tree(data, children, meta)\n\n@hedy_translator(level=2)\nclass ConvertToLang2(ConvertToLang1):\n\n    def assign(self, args):\n        return args[0] + \" \" + self.keywords[\"is\"] + \" \" + ''.join([str(c) for c in args[1:]])\n\n    def print(self, args):\n\n        argument_string = \"\"\n        i = 0\n\n        for argument in args:\n            # escape quotes if kids accidentally use them at level 2\n            argument = hedy.process_characters_needing_escape(argument)\n\n            # final argument and punctuation arguments do not have to be separated with a space, other do\n            if i == len(args) - 1 or args[i + 1] in self.punctuation_symbols:\n                space = ''\n            else:\n                space = \" \"\n\n            argument_string += argument + space\n\n            i = i + 1\n\n        return self.keywords[\"print\"] + \" \" + argument_string\n\n    def punctuation(self, args):\n        return ''.join([str(c) for c in args])\n\n    def var(self, args):\n        var = args[0]\n        all_parameters = [\"'\" + hedy.process_characters_needing_escape(a) + \"'\" for a in args[1:]]\n        return var + ''.join(all_parameters)\n\n    def ask(self, args):\n        var = args[0]\n        all_parameters = [hedy.process_characters_needing_escape(a) for a in args]\n\n        return all_parameters[0] + \" \" + self.keywords[\"is\"] + \" \" + self.keywords[\"ask\"] + \" \" + ''.join(all_parameters[1:])\n\n    def ask_dep_2(self, args):\n        return self.keywords[\"ask\"] + \" \" + ''.join([str(c) for c in args])\n\n    def echo_dep_2(self, args):\n        return self.keywords[\"echo\"] + \" \" + ''.join([str(c) for c in args])\n", "path": "hedy_translation.py"}]}