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:
|
looks like ported to this new format:
|
||||||
|
|
||||||
```
|
```
|
||||||
@gtk 4.0;
|
gtk 4.0;
|
||||||
|
|
||||||
@import Adw 1.0;
|
import Adw 1.0;
|
||||||
@import Shumate 1.0;
|
import Shumate 1.0;
|
||||||
|
|
||||||
@template ShumateDemoWindow : Gtk.ApplicationWindow {
|
template ShumateDemoWindow : Gtk.ApplicationWindow {
|
||||||
can-focus: yes;
|
can-focus: yes;
|
||||||
title: _("Shumate Demo");
|
title: _("Shumate Demo");
|
||||||
default-width: 800;
|
default-width: 800;
|
||||||
|
|
|
@ -330,15 +330,6 @@ class Optional(ParseNode):
|
||||||
return True
|
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):
|
class StaticToken(ParseNode):
|
||||||
""" Base class for ParseNodes that match a token type without inspecting
|
""" Base class for ParseNodes that match a token type without inspecting
|
||||||
the token's contents. """
|
the token's contents. """
|
||||||
|
|
|
@ -30,7 +30,7 @@ def parse(tokens) -> ast.UI:
|
||||||
gtk_directive = Group(
|
gtk_directive = Group(
|
||||||
ast.GtkDirective,
|
ast.GtkDirective,
|
||||||
Sequence(
|
Sequence(
|
||||||
Directive("gtk"),
|
Keyword("gtk"),
|
||||||
Fail(UseNumber(None), "Version number must be in quotation marks"),
|
Fail(UseNumber(None), "Version number must be in quotation marks"),
|
||||||
UseQuoted("version").expected("a version number for GTK"),
|
UseQuoted("version").expected("a version number for GTK"),
|
||||||
StmtEnd().expected("`;`"),
|
StmtEnd().expected("`;`"),
|
||||||
|
@ -40,7 +40,7 @@ def parse(tokens) -> ast.UI:
|
||||||
import_statement = Group(
|
import_statement = Group(
|
||||||
ast.Import,
|
ast.Import,
|
||||||
Sequence(
|
Sequence(
|
||||||
Directive("import"),
|
Keyword("import"),
|
||||||
UseIdent("namespace").expected("a GIR namespace"),
|
UseIdent("namespace").expected("a GIR namespace"),
|
||||||
Fail(UseNumber(None), "Version number must be in quotation marks"),
|
Fail(UseNumber(None), "Version number must be in quotation marks"),
|
||||||
UseQuoted("version").expected("a version number"),
|
UseQuoted("version").expected("a version number"),
|
||||||
|
@ -162,7 +162,7 @@ def parse(tokens) -> ast.UI:
|
||||||
template = Group(
|
template = Group(
|
||||||
ast.Template,
|
ast.Template,
|
||||||
Sequence(
|
Sequence(
|
||||||
Directive("template"),
|
Keyword("template"),
|
||||||
UseIdent("name").expected("template class name"),
|
UseIdent("name").expected("template class name"),
|
||||||
Op(":").expected("`:`"),
|
Op(":").expected("`:`"),
|
||||||
class_name.expected("parent class"),
|
class_name.expected("parent class"),
|
||||||
|
@ -173,7 +173,7 @@ def parse(tokens) -> ast.UI:
|
||||||
ui = Group(
|
ui = Group(
|
||||||
ast.UI,
|
ast.UI,
|
||||||
Sequence(
|
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(import_statement),
|
||||||
ZeroOrMore(AnyOf(
|
ZeroOrMore(AnyOf(
|
||||||
template,
|
template,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue