Better error handling for incomplete syntax

This commit is contained in:
James Westman 2021-10-30 20:31:52 -05:00
parent c155ba7b15
commit c79d8dc396
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
4 changed files with 33 additions and 5 deletions

View file

@ -30,8 +30,8 @@ def parse(tokens) -> T.Tuple[ast.UI, T.Optional[MultipleErrors]]:
gtk_directive = Group(
ast.GtkDirective,
Statement(
Keyword("using").err("File must start with a \"using gtk\" directive (e.g. `using Gtk 4.0;`)"),
Keyword("Gtk").err("File must start with a \"using gtk\" directive (e.g. `using Gtk 4.0;`)"),
Keyword("using").err("File must start with a \"using Gtk\" directive (e.g. `using Gtk 4.0;`)"),
Keyword("Gtk").err("File must start with a \"using Gtk\" directive (e.g. `using Gtk 4.0;`)"),
UseNumberText("version").expected("a version number for GTK"),
)
)
@ -298,7 +298,7 @@ def parse(tokens) -> T.Tuple[ast.UI, T.Optional[MultipleErrors]]:
ui = Group(
ast.UI,
Sequence(
gtk_directive.err("File must start with a \"using Gtk\" directive (e.g. `using Gtk 4.0;`)"),
gtk_directive,
ZeroOrMore(import_statement),
Until(AnyOf(
template,