Commit graph

69 commits

Author SHA1 Message Date
James Westman
a2eaaa26fe Rename property to avoid conflict
TranslatedWithContext.context conflicted with AstNode.context
2023-04-28 20:49:22 -05:00
James Westman
ec844b10ca Add ScopeCtx instead of root.objects_by_id
This allows us to introduce new scopes, such as in
GtkBuilderListItemFactory templates.
2023-04-28 20:49:22 -05:00
James Westman
dd3c75d2c7 Update menu syntax
Sections and submenus can have IDs. Also, change the code to better
reflect the documented grammar.
2023-04-12 21:44:07 -05:00
James Westman
75055ac967 Move bindings out of the Value syntax
They're only valid in properties, so they should just be there. Same
with object values.
2023-04-12 21:44:07 -05:00
James Westman
ac2a7d9282 Add StringValue
Makes the grammar more specific in a few places that take only a string
literal or translated string.
2023-04-12 21:44:07 -05:00
James Westman
02796fd830 Use <> instead of () for casts & typeof
This makes it clearer that they aren't functions, and it eliminates
syntactic ambiguity with closure expressions.
2023-04-10 09:39:34 -05:00
James Westman
88f5b4f1c7
Fix template types 2023-04-08 20:10:16 -05:00
Cameron Dehning
a2fb86bc31 Builder list factory 2023-04-08 01:34:47 +00:00
James Westman
0cf9a8e4fc
Add Adw.MessageDialog responses extension 2023-03-28 12:43:53 -05:00
James Westman
749ee03e86 Fix misleading error message for missing semicolon
Fixes #105.
2023-03-28 10:10:37 -05:00
Cameron Dehning
7e20983b44 Lsp hotfix 2023-03-24 16:27:22 +00:00
James Westman
bc605c5df8
Reduce errors when a namespace is not found
When the typelib for a namespace is not found, don't emit "namespace not
imported" errors. Just emit the one error on the import statement.
2023-03-21 11:31:02 -05:00
James Westman
402677f687
performance: Cache some properties 2023-03-20 13:34:17 -05:00
James Westman
90001bd885 Fix mypy errors & other bugs 2023-03-12 21:49:36 -05:00
James Westman
98ba7d467a Improve expression type checking 2023-03-12 16:12:16 -05:00
James Westman
b636d9ed71 Fix bugs in number literals 2023-03-12 14:58:35 -05:00
James Westman
0f5f08ade9 Fix flag syntax
Unlike commas, no trailing "|" is allowed.
2023-03-11 21:24:52 -06:00
James Westman
8874cf60b3 parse_tree: Remove Pratt parser
It isn't actually needed; the way we parse expressions as a prefix
followed by zero or more suffixes is enough.
2023-03-11 21:05:27 -06:00
James Westman
1df46b5a06
Change the way values work
Change the parsing for values to make them more reusable, in particular
for when I implement extensions.
2023-01-12 15:49:19 -06:00
James Westman
6938267952
Add properties to AST types
I want to have a cleaner API that relies less on the specifics of the
grammar and parser.
2023-01-12 15:49:19 -06:00
James Westman
122b049ce9
language: Use new extern syntax in signal handlers 2023-01-12 15:49:19 -06:00
James Westman
0b402db4d5
language: Change extern type syntax
Use a '$' instead of a '.' to indicate a type provided in application
code.

The reason for the change is to have a consistent "extern" symbol that
isn't widely used elsewhere and isn't ambiguous in expressions.
2023-01-12 15:49:19 -06:00
James Westman
59aa054c4c
language: Add closure expressions 2022-12-25 14:04:41 -06:00
James Westman
5cf9b63547
language: Add cast expressions 2022-12-25 14:04:40 -06:00
James Westman
2033bd9e16
types: Add UncheckedType
This allows us to remember information about an external type, such as
its name, while still marking it as unchecked.
2022-12-25 14:04:36 -06:00
James Westman
6c67e1fc5a
xml: Fix flags and enums
GtkBuilder XML uses enum nicknames, full names, or integer values, but
we accept GIR names, so passing those through doesn't work if the name
has an underscore (which traditionally turns into a dash in the
nickname). Avoid the problem by always writing the integer value of the
enum member.
2022-12-19 15:15:25 -06:00
James Westman
51d8969ced
Fix menus
- Menus require an ID
- The top level menu block can't have attributes
2022-12-19 15:15:25 -06:00
James Westman
8fee46ec68
Format using black 2022-12-19 11:52:59 -06:00
James Westman
0b8012b8e1
Support Python 3.9
Remove the '|' syntax for type unions, since it's a 3.10 feature, and
set mypy to check with version 3.9.
2022-10-27 13:16:18 -05:00
James Westman
a24f16109f
Separate output into its own module 2022-10-15 19:40:47 -05:00
James Westman
8cf793023d
Fix crash in language server 2022-10-15 11:47:42 -05:00
James Westman
447785ec8c language: Remove inline menus
Inline menus didn't work anyway--menus have to be referenced by ID
(though, curiously, you *can* put the <menu> within the <property> tag
and immediately reference it--but that's a hack, and not what
blueprint-compiler was doing).
2022-10-14 22:12:56 -05:00
James Westman
c0c40b1577
language: Support boxed types and GType
- Add support for type checking boxed types
- Remove support for converting string and number literals
- Add the `typeof()` operator for GType literals
2022-10-06 13:03:33 -05:00
James Westman
08da6f79c7
Fix referencing template by ID 2022-07-16 21:16:45 -05:00
James Westman
664fa2250b
Validate that an object can have children
Fixes #32.
2022-07-09 16:40:02 -05:00
James Westman
0a0389b1f8
grammar: Create an AST node for type names 2022-07-09 16:05:10 -05:00
Sonny Piers
2da6be7618 lsp: Fix crash when import version missing
The issue is specific to the language server, since it's trying to use
an AST that contains errors. The test would not fail but was added
anyway.
2022-07-09 20:00:10 +00:00
James Westman
b9fdc5a5f1
Fix action widgets in templates
Fixes #69.
2022-07-09 14:48:33 -05:00
James Westman
06f54c8ff8
Use typelib instead of XML
For normal compilation, use .typelib files rather than .gir XML files.
This is much faster.

Rather than using libgirepository, which would try to actually load the
libraries, we use a custom parser.

The language server will still read XML because it needs to access
documentation, which is not in the typelib, but that's generally fine
because it's a long lived process and only has to do that once.
2022-06-25 00:15:20 -05:00
James Westman
4fefa0bd73
Add lookup expressions 2022-06-24 23:16:15 -05:00
James Westman
4b7fda4f43
action widgets: Fix grammar 2022-06-08 23:55:22 -05:00
James Westman
d319cb11c1
Use the new duplicate validator for templates 2022-06-08 23:10:27 -05:00
James Westman
22edcf0c67
Remove obsolete commented-out code 2022-06-08 23:08:33 -05:00
James Westman
824476bda1
Add errors for duplicate properties and blocks 2022-06-08 23:08:15 -05:00
James Westman
42aa91d4d9 Detect when gobject-introspection is missing
Instead of a compiler bug error, show a proper error message that asks
whether gobject-introspection is installed.

Fixes #58.
2022-05-27 16:21:18 +00:00
James Westman
0da0c9399f
xml: Convert GirType to type name automatically
Makes some of the emit_xml code a bit simpler.
2022-04-30 16:41:45 -05:00
James Westman
99e428d93c validation: Disallow instantiating abstract classes 2022-04-28 23:35:34 -05:00
James Westman
f78478bea1 validation: Writable/construct-only properties
Add two new errors, one for non-writable properties and another for
binding construct-only properties.
2022-04-28 22:52:30 -05:00
James Westman
417f163a5a
Fix crash in flags value for unchecked classes 2022-04-18 15:42:55 -05:00
James Westman
3f8b38d219
Fix crash in action widget syntax 2022-04-18 15:35:19 -05:00