mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
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.
This commit is contained in:
parent
b553fc357c
commit
572db893d9
3 changed files with 8 additions and 17 deletions
|
@ -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;
|
||||
|
|
|
@ -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. """
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue