From 572db893d9a23908a6a58c3901ee4e23a2d3cdd5 Mon Sep 17 00:00:00 2001 From: James Westman Date: Fri, 22 Oct 2021 21:57:37 -0500 Subject: [PATCH] Remove @ directives I liked how they made keywords stand out, but they're kinda ugly and I think syntax highlighting will do a better job anyway. --- README.md | 8 ++++---- gtkblueprinttool/parse_tree.py | 9 --------- gtkblueprinttool/parser.py | 8 ++++---- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index cf4c94d..2d6c2d6 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,12 @@ Here is what [the libshumate demo's UI definition](https://gitlab.gnome.org/GNOM looks like ported to this new format: ``` -@gtk 4.0; +gtk 4.0; -@import Adw 1.0; -@import Shumate 1.0; +import Adw 1.0; +import Shumate 1.0; -@template ShumateDemoWindow : Gtk.ApplicationWindow { +template ShumateDemoWindow : Gtk.ApplicationWindow { can-focus: yes; title: _("Shumate Demo"); default-width: 800; diff --git a/gtkblueprinttool/parse_tree.py b/gtkblueprinttool/parse_tree.py index 55f00f2..32b2777 100644 --- a/gtkblueprinttool/parse_tree.py +++ b/gtkblueprinttool/parse_tree.py @@ -330,15 +330,6 @@ class Optional(ParseNode): return True -class Directive(ParseNode): - """ ParseNode that matches a directive with the given name. """ - def __init__(self, name): - self.name = name - - def _parse(self, ctx: ParseContext): - return ctx.next_token().is_directive(self.name) - - class StaticToken(ParseNode): """ Base class for ParseNodes that match a token type without inspecting the token's contents. """ diff --git a/gtkblueprinttool/parser.py b/gtkblueprinttool/parser.py index 7488f65..dc5966d 100644 --- a/gtkblueprinttool/parser.py +++ b/gtkblueprinttool/parser.py @@ -30,7 +30,7 @@ def parse(tokens) -> ast.UI: gtk_directive = Group( ast.GtkDirective, Sequence( - Directive("gtk"), + Keyword("gtk"), Fail(UseNumber(None), "Version number must be in quotation marks"), UseQuoted("version").expected("a version number for GTK"), StmtEnd().expected("`;`"), @@ -40,7 +40,7 @@ def parse(tokens) -> ast.UI: import_statement = Group( ast.Import, Sequence( - Directive("import"), + Keyword("import"), UseIdent("namespace").expected("a GIR namespace"), Fail(UseNumber(None), "Version number must be in quotation marks"), UseQuoted("version").expected("a version number"), @@ -162,7 +162,7 @@ def parse(tokens) -> ast.UI: template = Group( ast.Template, Sequence( - Directive("template"), + Keyword("template"), UseIdent("name").expected("template class name"), Op(":").expected("`:`"), class_name.expected("parent class"), @@ -173,7 +173,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 gtk directive (e.g. `gtk 4.0;`)"), ZeroOrMore(import_statement), ZeroOrMore(AnyOf( template,