We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Restrict `VERBOSE` usage in `DESCRIBE`
The only usage of `VERBOSE` flag that has any effect is with the `DESCRIBE ... AS TEXT VERBOSE`. The grammar should reflect that.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `edb/edgeql/parser/grammar/statements.py`
Content:
```
1 #
2 # This source file is part of the EdgeDB open source project.
3 #
4 # Copyright 2008-present MagicStack Inc. and the EdgeDB authors.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 
19 from __future__ import annotations
20 
21 from edb import errors
22 
23 from edb.edgeql import ast as qlast
24 from edb.edgeql import qltypes
25 
26 from .expressions import Nonterm, ListNonterm
27 from .precedence import *  # NOQA
28 from .tokens import *  # NOQA
29 from .expressions import *  # NOQA
30 
31 from . import tokens
32 
33 
34 class Stmt(Nonterm):
35     def reduce_TransactionStmt(self, *kids):
36         self.val = kids[0].val
37 
38     def reduce_DescribeStmt(self, *kids):
39         # DESCRIBE
40         self.val = kids[0].val
41 
42     def reduce_ExprStmt(self, *kids):
43         self.val = kids[0].val
44 
45 
46 class TransactionMode(Nonterm):
47     def reduce_ISOLATION_SERIALIZABLE(self, *kids):
48         self.val = (qltypes.TransactionIsolationLevel.SERIALIZABLE,
49                     kids[0].context)
50 
51     def reduce_ISOLATION_REPEATABLE_READ(self, *kids):
52         self.val = (qltypes.TransactionIsolationLevel.REPEATABLE_READ,
53                     kids[0].context)
54 
55     def reduce_READ_WRITE(self, *kids):
56         self.val = (qltypes.TransactionAccessMode.READ_WRITE,
57                     kids[0].context)
58 
59     def reduce_READ_ONLY(self, *kids):
60         self.val = (qltypes.TransactionAccessMode.READ_ONLY,
61                     kids[0].context)
62 
63     def reduce_DEFERRABLE(self, *kids):
64         self.val = (qltypes.TransactionDeferMode.DEFERRABLE,
65                     kids[0].context)
66 
67     def reduce_NOT_DEFERRABLE(self, *kids):
68         self.val = (qltypes.TransactionDeferMode.NOT_DEFERRABLE,
69                     kids[0].context)
70 
71 
72 class TransactionModeList(ListNonterm, element=TransactionMode,
73                           separator=tokens.T_COMMA):
74     pass
75 
76 
77 class OptTransactionModeList(Nonterm):
78     def reduce_TransactionModeList(self, *kids):
79         self.val = kids[0].val
80 
81     def reduce_empty(self, *kids):
82         self.val = []
83 
84 
85 class TransactionStmt(Nonterm):
86     def reduce_START_TRANSACTION_OptTransactionModeList(self, *kids):
87         modes = kids[2].val
88 
89         isolation = None
90         access = None
91         deferrable = None
92 
93         for mode, mode_ctx in modes:
94             if isinstance(mode, qltypes.TransactionIsolationLevel):
95                 if isolation is not None:
96                     raise errors.EdgeQLSyntaxError(
97                         f"only one isolation level can be specified",
98                         context=mode_ctx)
99                 isolation = mode
100 
101             elif isinstance(mode, qltypes.TransactionAccessMode):
102                 if access is not None:
103                     raise errors.EdgeQLSyntaxError(
104                         f"only one access mode can be specified",
105                         context=mode_ctx)
106                 access = mode
107 
108             else:
109                 assert isinstance(mode, qltypes.TransactionDeferMode)
110                 if deferrable is not None:
111                     raise errors.EdgeQLSyntaxError(
112                         f"deferrable mode can only be specified once",
113                         context=mode_ctx)
114                 deferrable = mode
115 
116         self.val = qlast.StartTransaction(
117             isolation=isolation, access=access, deferrable=deferrable)
118 
119     def reduce_COMMIT(self, *kids):
120         self.val = qlast.CommitTransaction()
121 
122     def reduce_ROLLBACK(self, *kids):
123         self.val = qlast.RollbackTransaction()
124 
125     def reduce_DECLARE_SAVEPOINT_Identifier(self, *kids):
126         self.val = qlast.DeclareSavepoint(name=kids[2].val)
127 
128     def reduce_ROLLBACK_TO_SAVEPOINT_Identifier(self, *kids):
129         self.val = qlast.RollbackToSavepoint(name=kids[3].val)
130 
131     def reduce_RELEASE_SAVEPOINT_Identifier(self, *kids):
132         self.val = qlast.ReleaseSavepoint(name=kids[2].val)
133 
134 
135 class DescribeFormat(Nonterm):
136 
137     def reduce_empty(self, *kids):
138         self.val = qltypes.DescribeLanguage.DDL
139 
140     def reduce_AS_DDL(self, *kids):
141         self.val = qltypes.DescribeLanguage.DDL
142 
143     def reduce_AS_SDL(self, *kids):
144         self.val = qltypes.DescribeLanguage.SDL
145 
146     def reduce_AS_TEXT(self, *kids):
147         self.val = qltypes.DescribeLanguage.TEXT
148 
149 
150 class DescribeOption(Nonterm):
151 
152     def reduce_VERBOSE(self, *kids):
153         self.val = qlast.Flag(name='VERBOSE', val=True)
154 
155 
156 class DescribeOptions(ListNonterm, element=DescribeOption):
157     def _reduce_list(self, lst, el):
158         self.val = qlast.Options(
159             options={**lst.val.options, el.val.name: el.val})
160 
161     def _reduce_el(self, el):
162         self.val = qlast.Options(options={el.val.name: el.val})
163 
164 
165 class OptDescribeOptions(Nonterm):
166 
167     def reduce_DescribeOptions(self, *kids):
168         self.val = kids[0].val
169 
170     def reduce_empty(self, *kids):
171         self.val = qlast.Options()
172 
173 
174 class DescribeStmt(Nonterm):
175 
176     def reduce_DESCRIBE_SCHEMA(self, *kids):
177         """%reduce DESCRIBE SCHEMA DescribeFormat
178                    OptDescribeOptions
179         """
180         self.val = qlast.DescribeStmt(
181             language=kids[2].val,
182             object=None,
183             options=kids[3].val,
184         )
185 
186     def reduce_DESCRIBE_SchemaItem(self, *kids):
187         """%reduce DESCRIBE SchemaItem DescribeFormat
188                    OptDescribeOptions
189         """
190         self.val = qlast.DescribeStmt(
191             language=kids[2].val,
192             object=kids[1].val,
193             options=kids[3].val,
194         )
195 
196     def reduce_DESCRIBE_OBJECT(self, *kids):
197         """%reduce DESCRIBE OBJECT NodeName DescribeFormat
198                    OptDescribeOptions
199         """
200         self.val = qlast.DescribeStmt(
201             language=kids[3].val,
202             object=kids[2].val,
203             options=kids[4].val,
204         )
205
```
--- 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()

```

diff --git a/edb/edgeql/parser/grammar/statements.py b/edb/edgeql/parser/grammar/statements.py
--- a/edb/edgeql/parser/grammar/statements.py
+++ b/edb/edgeql/parser/grammar/statements.py
@@ -18,6 +18,8 @@
 
 from __future__ import annotations
 
+import typing
+
 from edb import errors
 
 from edb.edgeql import ast as qlast
@@ -132,73 +134,68 @@
         self.val = qlast.ReleaseSavepoint(name=kids[2].val)
 
 
+class DescribeFmt(typing.NamedTuple):
+    language: typing.Optional[qltypes.DescribeLanguage] = None
+    options: qlast.Options = None
+
+
 class DescribeFormat(Nonterm):
 
     def reduce_empty(self, *kids):
-        self.val = qltypes.DescribeLanguage.DDL
+        self.val = DescribeFmt(
+            language=qltypes.DescribeLanguage.DDL,
+            options=qlast.Options(),
+        )
 
     def reduce_AS_DDL(self, *kids):
-        self.val = qltypes.DescribeLanguage.DDL
+        self.val = DescribeFmt(
+            language=qltypes.DescribeLanguage.DDL,
+            options=qlast.Options(),
+        )
 
     def reduce_AS_SDL(self, *kids):
-        self.val = qltypes.DescribeLanguage.SDL
+        self.val = DescribeFmt(
+            language=qltypes.DescribeLanguage.SDL,
+            options=qlast.Options(),
+        )
 
     def reduce_AS_TEXT(self, *kids):
-        self.val = qltypes.DescribeLanguage.TEXT
-
-
-class DescribeOption(Nonterm):
-
-    def reduce_VERBOSE(self, *kids):
-        self.val = qlast.Flag(name='VERBOSE', val=True)
-
-
-class DescribeOptions(ListNonterm, element=DescribeOption):
-    def _reduce_list(self, lst, el):
-        self.val = qlast.Options(
-            options={**lst.val.options, el.val.name: el.val})
-
-    def _reduce_el(self, el):
-        self.val = qlast.Options(options={el.val.name: el.val})
-
-
-class OptDescribeOptions(Nonterm):
-
-    def reduce_DescribeOptions(self, *kids):
-        self.val = kids[0].val
+        self.val = DescribeFmt(
+            language=qltypes.DescribeLanguage.TEXT,
+            options=qlast.Options(),
+        )
 
-    def reduce_empty(self, *kids):
-        self.val = qlast.Options()
+    def reduce_AS_TEXT_VERBOSE(self, *kids):
+        self.val = DescribeFmt(
+            language=qltypes.DescribeLanguage.TEXT,
+            options=qlast.Options(
+                options={'VERBOSE': qlast.Flag(name='VERBOSE', val=True)}
+            ),
+        )
 
 
 class DescribeStmt(Nonterm):
 
     def reduce_DESCRIBE_SCHEMA(self, *kids):
-        """%reduce DESCRIBE SCHEMA DescribeFormat
-                   OptDescribeOptions
-        """
+        """%reduce DESCRIBE SCHEMA DescribeFormat"""
         self.val = qlast.DescribeStmt(
-            language=kids[2].val,
             object=None,
-            options=kids[3].val,
+            language=kids[2].val.language,
+            options=kids[2].val.options,
         )
 
     def reduce_DESCRIBE_SchemaItem(self, *kids):
-        """%reduce DESCRIBE SchemaItem DescribeFormat
-                   OptDescribeOptions
-        """
+        """%reduce DESCRIBE SchemaItem DescribeFormat"""
         self.val = qlast.DescribeStmt(
-            language=kids[2].val,
             object=kids[1].val,
-            options=kids[3].val,
+            language=kids[2].val.language,
+            options=kids[2].val.options,
         )
 
     def reduce_DESCRIBE_OBJECT(self, *kids):
-        """%reduce DESCRIBE OBJECT NodeName DescribeFormat
-                   OptDescribeOptions
-        """
+        """%reduce DESCRIBE OBJECT NodeName DescribeFormat"""
         self.val = qlast.DescribeStmt(
-            language=kids[3].val,
             object=kids[2].val,
-            options=kids[4].val,
+            language=kids[3].val.language,
+            options=kids[3].val.options,
         )

{"golden_diff": "diff --git a/edb/edgeql/parser/grammar/statements.py b/edb/edgeql/parser/grammar/statements.py\n--- a/edb/edgeql/parser/grammar/statements.py\n+++ b/edb/edgeql/parser/grammar/statements.py\n@@ -18,6 +18,8 @@\n \n from __future__ import annotations\n \n+import typing\n+\n from edb import errors\n \n from edb.edgeql import ast as qlast\n@@ -132,73 +134,68 @@\n         self.val = qlast.ReleaseSavepoint(name=kids[2].val)\n \n \n+class DescribeFmt(typing.NamedTuple):\n+    language: typing.Optional[qltypes.DescribeLanguage] = None\n+    options: qlast.Options = None\n+\n+\n class DescribeFormat(Nonterm):\n \n     def reduce_empty(self, *kids):\n-        self.val = qltypes.DescribeLanguage.DDL\n+        self.val = DescribeFmt(\n+            language=qltypes.DescribeLanguage.DDL,\n+            options=qlast.Options(),\n+        )\n \n     def reduce_AS_DDL(self, *kids):\n-        self.val = qltypes.DescribeLanguage.DDL\n+        self.val = DescribeFmt(\n+            language=qltypes.DescribeLanguage.DDL,\n+            options=qlast.Options(),\n+        )\n \n     def reduce_AS_SDL(self, *kids):\n-        self.val = qltypes.DescribeLanguage.SDL\n+        self.val = DescribeFmt(\n+            language=qltypes.DescribeLanguage.SDL,\n+            options=qlast.Options(),\n+        )\n \n     def reduce_AS_TEXT(self, *kids):\n-        self.val = qltypes.DescribeLanguage.TEXT\n-\n-\n-class DescribeOption(Nonterm):\n-\n-    def reduce_VERBOSE(self, *kids):\n-        self.val = qlast.Flag(name='VERBOSE', val=True)\n-\n-\n-class DescribeOptions(ListNonterm, element=DescribeOption):\n-    def _reduce_list(self, lst, el):\n-        self.val = qlast.Options(\n-            options={**lst.val.options, el.val.name: el.val})\n-\n-    def _reduce_el(self, el):\n-        self.val = qlast.Options(options={el.val.name: el.val})\n-\n-\n-class OptDescribeOptions(Nonterm):\n-\n-    def reduce_DescribeOptions(self, *kids):\n-        self.val = kids[0].val\n+        self.val = DescribeFmt(\n+            language=qltypes.DescribeLanguage.TEXT,\n+            options=qlast.Options(),\n+        )\n \n-    def reduce_empty(self, *kids):\n-        self.val = qlast.Options()\n+    def reduce_AS_TEXT_VERBOSE(self, *kids):\n+        self.val = DescribeFmt(\n+            language=qltypes.DescribeLanguage.TEXT,\n+            options=qlast.Options(\n+                options={'VERBOSE': qlast.Flag(name='VERBOSE', val=True)}\n+            ),\n+        )\n \n \n class DescribeStmt(Nonterm):\n \n     def reduce_DESCRIBE_SCHEMA(self, *kids):\n-        \"\"\"%reduce DESCRIBE SCHEMA DescribeFormat\n-                   OptDescribeOptions\n-        \"\"\"\n+        \"\"\"%reduce DESCRIBE SCHEMA DescribeFormat\"\"\"\n         self.val = qlast.DescribeStmt(\n-            language=kids[2].val,\n             object=None,\n-            options=kids[3].val,\n+            language=kids[2].val.language,\n+            options=kids[2].val.options,\n         )\n \n     def reduce_DESCRIBE_SchemaItem(self, *kids):\n-        \"\"\"%reduce DESCRIBE SchemaItem DescribeFormat\n-                   OptDescribeOptions\n-        \"\"\"\n+        \"\"\"%reduce DESCRIBE SchemaItem DescribeFormat\"\"\"\n         self.val = qlast.DescribeStmt(\n-            language=kids[2].val,\n             object=kids[1].val,\n-            options=kids[3].val,\n+            language=kids[2].val.language,\n+            options=kids[2].val.options,\n         )\n \n     def reduce_DESCRIBE_OBJECT(self, *kids):\n-        \"\"\"%reduce DESCRIBE OBJECT NodeName DescribeFormat\n-                   OptDescribeOptions\n-        \"\"\"\n+        \"\"\"%reduce DESCRIBE OBJECT NodeName DescribeFormat\"\"\"\n         self.val = qlast.DescribeStmt(\n-            language=kids[3].val,\n             object=kids[2].val,\n-            options=kids[4].val,\n+            language=kids[3].val.language,\n+            options=kids[3].val.options,\n         )\n", "issue": "Restrict `VERBOSE` usage in `DESCRIBE`\nThe only usage of `VERBOSE` flag that has any effect is with the `DESCRIBE ... AS TEXT VERBOSE`. The grammar should reflect that.\n", "before_files": [{"content": "#\n# This source file is part of the EdgeDB open source project.\n#\n# Copyright 2008-present MagicStack Inc. and the EdgeDB authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\nfrom __future__ import annotations\n\nfrom edb import errors\n\nfrom edb.edgeql import ast as qlast\nfrom edb.edgeql import qltypes\n\nfrom .expressions import Nonterm, ListNonterm\nfrom .precedence import *  # NOQA\nfrom .tokens import *  # NOQA\nfrom .expressions import *  # NOQA\n\nfrom . import tokens\n\n\nclass Stmt(Nonterm):\n    def reduce_TransactionStmt(self, *kids):\n        self.val = kids[0].val\n\n    def reduce_DescribeStmt(self, *kids):\n        # DESCRIBE\n        self.val = kids[0].val\n\n    def reduce_ExprStmt(self, *kids):\n        self.val = kids[0].val\n\n\nclass TransactionMode(Nonterm):\n    def reduce_ISOLATION_SERIALIZABLE(self, *kids):\n        self.val = (qltypes.TransactionIsolationLevel.SERIALIZABLE,\n                    kids[0].context)\n\n    def reduce_ISOLATION_REPEATABLE_READ(self, *kids):\n        self.val = (qltypes.TransactionIsolationLevel.REPEATABLE_READ,\n                    kids[0].context)\n\n    def reduce_READ_WRITE(self, *kids):\n        self.val = (qltypes.TransactionAccessMode.READ_WRITE,\n                    kids[0].context)\n\n    def reduce_READ_ONLY(self, *kids):\n        self.val = (qltypes.TransactionAccessMode.READ_ONLY,\n                    kids[0].context)\n\n    def reduce_DEFERRABLE(self, *kids):\n        self.val = (qltypes.TransactionDeferMode.DEFERRABLE,\n                    kids[0].context)\n\n    def reduce_NOT_DEFERRABLE(self, *kids):\n        self.val = (qltypes.TransactionDeferMode.NOT_DEFERRABLE,\n                    kids[0].context)\n\n\nclass TransactionModeList(ListNonterm, element=TransactionMode,\n                          separator=tokens.T_COMMA):\n    pass\n\n\nclass OptTransactionModeList(Nonterm):\n    def reduce_TransactionModeList(self, *kids):\n        self.val = kids[0].val\n\n    def reduce_empty(self, *kids):\n        self.val = []\n\n\nclass TransactionStmt(Nonterm):\n    def reduce_START_TRANSACTION_OptTransactionModeList(self, *kids):\n        modes = kids[2].val\n\n        isolation = None\n        access = None\n        deferrable = None\n\n        for mode, mode_ctx in modes:\n            if isinstance(mode, qltypes.TransactionIsolationLevel):\n                if isolation is not None:\n                    raise errors.EdgeQLSyntaxError(\n                        f\"only one isolation level can be specified\",\n                        context=mode_ctx)\n                isolation = mode\n\n            elif isinstance(mode, qltypes.TransactionAccessMode):\n                if access is not None:\n                    raise errors.EdgeQLSyntaxError(\n                        f\"only one access mode can be specified\",\n                        context=mode_ctx)\n                access = mode\n\n            else:\n                assert isinstance(mode, qltypes.TransactionDeferMode)\n                if deferrable is not None:\n                    raise errors.EdgeQLSyntaxError(\n                        f\"deferrable mode can only be specified once\",\n                        context=mode_ctx)\n                deferrable = mode\n\n        self.val = qlast.StartTransaction(\n            isolation=isolation, access=access, deferrable=deferrable)\n\n    def reduce_COMMIT(self, *kids):\n        self.val = qlast.CommitTransaction()\n\n    def reduce_ROLLBACK(self, *kids):\n        self.val = qlast.RollbackTransaction()\n\n    def reduce_DECLARE_SAVEPOINT_Identifier(self, *kids):\n        self.val = qlast.DeclareSavepoint(name=kids[2].val)\n\n    def reduce_ROLLBACK_TO_SAVEPOINT_Identifier(self, *kids):\n        self.val = qlast.RollbackToSavepoint(name=kids[3].val)\n\n    def reduce_RELEASE_SAVEPOINT_Identifier(self, *kids):\n        self.val = qlast.ReleaseSavepoint(name=kids[2].val)\n\n\nclass DescribeFormat(Nonterm):\n\n    def reduce_empty(self, *kids):\n        self.val = qltypes.DescribeLanguage.DDL\n\n    def reduce_AS_DDL(self, *kids):\n        self.val = qltypes.DescribeLanguage.DDL\n\n    def reduce_AS_SDL(self, *kids):\n        self.val = qltypes.DescribeLanguage.SDL\n\n    def reduce_AS_TEXT(self, *kids):\n        self.val = qltypes.DescribeLanguage.TEXT\n\n\nclass DescribeOption(Nonterm):\n\n    def reduce_VERBOSE(self, *kids):\n        self.val = qlast.Flag(name='VERBOSE', val=True)\n\n\nclass DescribeOptions(ListNonterm, element=DescribeOption):\n    def _reduce_list(self, lst, el):\n        self.val = qlast.Options(\n            options={**lst.val.options, el.val.name: el.val})\n\n    def _reduce_el(self, el):\n        self.val = qlast.Options(options={el.val.name: el.val})\n\n\nclass OptDescribeOptions(Nonterm):\n\n    def reduce_DescribeOptions(self, *kids):\n        self.val = kids[0].val\n\n    def reduce_empty(self, *kids):\n        self.val = qlast.Options()\n\n\nclass DescribeStmt(Nonterm):\n\n    def reduce_DESCRIBE_SCHEMA(self, *kids):\n        \"\"\"%reduce DESCRIBE SCHEMA DescribeFormat\n                   OptDescribeOptions\n        \"\"\"\n        self.val = qlast.DescribeStmt(\n            language=kids[2].val,\n            object=None,\n            options=kids[3].val,\n        )\n\n    def reduce_DESCRIBE_SchemaItem(self, *kids):\n        \"\"\"%reduce DESCRIBE SchemaItem DescribeFormat\n                   OptDescribeOptions\n        \"\"\"\n        self.val = qlast.DescribeStmt(\n            language=kids[2].val,\n            object=kids[1].val,\n            options=kids[3].val,\n        )\n\n    def reduce_DESCRIBE_OBJECT(self, *kids):\n        \"\"\"%reduce DESCRIBE OBJECT NodeName DescribeFormat\n                   OptDescribeOptions\n        \"\"\"\n        self.val = qlast.DescribeStmt(\n            language=kids[3].val,\n            object=kids[2].val,\n            options=kids[4].val,\n        )\n", "path": "edb/edgeql/parser/grammar/statements.py"}], "after_files": [{"content": "#\n# This source file is part of the EdgeDB open source project.\n#\n# Copyright 2008-present MagicStack Inc. and the EdgeDB authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\nfrom __future__ import annotations\n\nimport typing\n\nfrom edb import errors\n\nfrom edb.edgeql import ast as qlast\nfrom edb.edgeql import qltypes\n\nfrom .expressions import Nonterm, ListNonterm\nfrom .precedence import *  # NOQA\nfrom .tokens import *  # NOQA\nfrom .expressions import *  # NOQA\n\nfrom . import tokens\n\n\nclass Stmt(Nonterm):\n    def reduce_TransactionStmt(self, *kids):\n        self.val = kids[0].val\n\n    def reduce_DescribeStmt(self, *kids):\n        # DESCRIBE\n        self.val = kids[0].val\n\n    def reduce_ExprStmt(self, *kids):\n        self.val = kids[0].val\n\n\nclass TransactionMode(Nonterm):\n    def reduce_ISOLATION_SERIALIZABLE(self, *kids):\n        self.val = (qltypes.TransactionIsolationLevel.SERIALIZABLE,\n                    kids[0].context)\n\n    def reduce_ISOLATION_REPEATABLE_READ(self, *kids):\n        self.val = (qltypes.TransactionIsolationLevel.REPEATABLE_READ,\n                    kids[0].context)\n\n    def reduce_READ_WRITE(self, *kids):\n        self.val = (qltypes.TransactionAccessMode.READ_WRITE,\n                    kids[0].context)\n\n    def reduce_READ_ONLY(self, *kids):\n        self.val = (qltypes.TransactionAccessMode.READ_ONLY,\n                    kids[0].context)\n\n    def reduce_DEFERRABLE(self, *kids):\n        self.val = (qltypes.TransactionDeferMode.DEFERRABLE,\n                    kids[0].context)\n\n    def reduce_NOT_DEFERRABLE(self, *kids):\n        self.val = (qltypes.TransactionDeferMode.NOT_DEFERRABLE,\n                    kids[0].context)\n\n\nclass TransactionModeList(ListNonterm, element=TransactionMode,\n                          separator=tokens.T_COMMA):\n    pass\n\n\nclass OptTransactionModeList(Nonterm):\n    def reduce_TransactionModeList(self, *kids):\n        self.val = kids[0].val\n\n    def reduce_empty(self, *kids):\n        self.val = []\n\n\nclass TransactionStmt(Nonterm):\n    def reduce_START_TRANSACTION_OptTransactionModeList(self, *kids):\n        modes = kids[2].val\n\n        isolation = None\n        access = None\n        deferrable = None\n\n        for mode, mode_ctx in modes:\n            if isinstance(mode, qltypes.TransactionIsolationLevel):\n                if isolation is not None:\n                    raise errors.EdgeQLSyntaxError(\n                        f\"only one isolation level can be specified\",\n                        context=mode_ctx)\n                isolation = mode\n\n            elif isinstance(mode, qltypes.TransactionAccessMode):\n                if access is not None:\n                    raise errors.EdgeQLSyntaxError(\n                        f\"only one access mode can be specified\",\n                        context=mode_ctx)\n                access = mode\n\n            else:\n                assert isinstance(mode, qltypes.TransactionDeferMode)\n                if deferrable is not None:\n                    raise errors.EdgeQLSyntaxError(\n                        f\"deferrable mode can only be specified once\",\n                        context=mode_ctx)\n                deferrable = mode\n\n        self.val = qlast.StartTransaction(\n            isolation=isolation, access=access, deferrable=deferrable)\n\n    def reduce_COMMIT(self, *kids):\n        self.val = qlast.CommitTransaction()\n\n    def reduce_ROLLBACK(self, *kids):\n        self.val = qlast.RollbackTransaction()\n\n    def reduce_DECLARE_SAVEPOINT_Identifier(self, *kids):\n        self.val = qlast.DeclareSavepoint(name=kids[2].val)\n\n    def reduce_ROLLBACK_TO_SAVEPOINT_Identifier(self, *kids):\n        self.val = qlast.RollbackToSavepoint(name=kids[3].val)\n\n    def reduce_RELEASE_SAVEPOINT_Identifier(self, *kids):\n        self.val = qlast.ReleaseSavepoint(name=kids[2].val)\n\n\nclass DescribeFmt(typing.NamedTuple):\n    language: typing.Optional[qltypes.DescribeLanguage] = None\n    options: qlast.Options = None\n\n\nclass DescribeFormat(Nonterm):\n\n    def reduce_empty(self, *kids):\n        self.val = DescribeFmt(\n            language=qltypes.DescribeLanguage.DDL,\n            options=qlast.Options(),\n        )\n\n    def reduce_AS_DDL(self, *kids):\n        self.val = DescribeFmt(\n            language=qltypes.DescribeLanguage.DDL,\n            options=qlast.Options(),\n        )\n\n    def reduce_AS_SDL(self, *kids):\n        self.val = DescribeFmt(\n            language=qltypes.DescribeLanguage.SDL,\n            options=qlast.Options(),\n        )\n\n    def reduce_AS_TEXT(self, *kids):\n        self.val = DescribeFmt(\n            language=qltypes.DescribeLanguage.TEXT,\n            options=qlast.Options(),\n        )\n\n    def reduce_AS_TEXT_VERBOSE(self, *kids):\n        self.val = DescribeFmt(\n            language=qltypes.DescribeLanguage.TEXT,\n            options=qlast.Options(\n                options={'VERBOSE': qlast.Flag(name='VERBOSE', val=True)}\n            ),\n        )\n\n\nclass DescribeStmt(Nonterm):\n\n    def reduce_DESCRIBE_SCHEMA(self, *kids):\n        \"\"\"%reduce DESCRIBE SCHEMA DescribeFormat\"\"\"\n        self.val = qlast.DescribeStmt(\n            object=None,\n            language=kids[2].val.language,\n            options=kids[2].val.options,\n        )\n\n    def reduce_DESCRIBE_SchemaItem(self, *kids):\n        \"\"\"%reduce DESCRIBE SchemaItem DescribeFormat\"\"\"\n        self.val = qlast.DescribeStmt(\n            object=kids[1].val,\n            language=kids[2].val.language,\n            options=kids[2].val.options,\n        )\n\n    def reduce_DESCRIBE_OBJECT(self, *kids):\n        \"\"\"%reduce DESCRIBE OBJECT NodeName DescribeFormat\"\"\"\n        self.val = qlast.DescribeStmt(\n            object=kids[2].val,\n            language=kids[3].val.language,\n            options=kids[3].val.options,\n        )\n", "path": "edb/edgeql/parser/grammar/statements.py"}]}