mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Use "using" instead of "gtk" and "import"
- Having one keyword for both is less syntax to remember - I might use "include" as a keyword in the future, which would make "import" confusing, so use "using" instead
This commit is contained in:
parent
78a9481631
commit
b3c28ce3d4
5 changed files with 27 additions and 13 deletions
|
@ -30,9 +30,9 @@ def parse(tokens) -> ast.UI:
|
|||
gtk_directive = Group(
|
||||
ast.GtkDirective,
|
||||
Sequence(
|
||||
Keyword("gtk"),
|
||||
Fail(UseNumber(None), "Version number must be in quotation marks"),
|
||||
UseQuoted("version").expected("a version number for GTK"),
|
||||
Keyword("using"),
|
||||
Keyword("Gtk"),
|
||||
UseNumberText("version").expected("a version number for GTK"),
|
||||
StmtEnd().expected("`;`"),
|
||||
)
|
||||
)
|
||||
|
@ -40,10 +40,9 @@ def parse(tokens) -> ast.UI:
|
|||
import_statement = Group(
|
||||
ast.Import,
|
||||
Sequence(
|
||||
Keyword("import"),
|
||||
Keyword("using"),
|
||||
UseIdent("namespace").expected("a GIR namespace"),
|
||||
Fail(UseNumber(None), "Version number must be in quotation marks"),
|
||||
UseQuoted("version").expected("a version number"),
|
||||
UseNumberText("version").expected("a version number"),
|
||||
StmtEnd().expected("`;`"),
|
||||
)
|
||||
).recover()
|
||||
|
@ -173,7 +172,7 @@ def parse(tokens) -> ast.UI:
|
|||
ui = Group(
|
||||
ast.UI,
|
||||
Sequence(
|
||||
gtk_directive.err("File must start with a gtk directive (e.g. `gtk 4.0;`)"),
|
||||
gtk_directive.err("File must start with a \"using gtk\" directive (e.g. `using Gtk 4.0;`)"),
|
||||
ZeroOrMore(import_statement),
|
||||
ZeroOrMore(AnyOf(
|
||||
template,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue