This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch eolian/improvements
in repository efl.
View the commit online.
commit a5b70cf51d8642b021724b45f4b8bd5d3f124386
Author: Cedric BAIL <[email protected]>
AuthorDate: Tue Aug 18 23:21:09 2026 -0600
doc: write the eolian language reference, and check it stays true
Eolian has never had a grammar document. What a keyword means has lived in
eo_lexer.h, eo_parser.c and the heads of the people who wrote them, and
everyone else has learned the language by grepping .eo files for something
that looks close enough. That is how you end up with `ptr(const(X))
@optional` used to mean "may be NULL" in one file and a plain class handle
meaning the same thing in the next.
doc/eolian/grammar.md covers file structure, the class kinds and the four
inheritance keywords, the six-list property model and what keys and values
actually do, events, parts, constructors, every builtin type with its C
mapping, the documentation syntax, and every @ annotation with its meaning --
including which of them are statements about representation and which, like
@nullable, are statements about values.
It also writes down the two rules that cost an afternoon each: @since must
be the last thing in a doc block, and doc references do not work in .eot
files.
A hand-written reference drifts the moment someone adds a keyword to the
lexer and not to the document. scripts/check-grammar-doc.py extracts the
inventory from the KEYWORDS macro -- the definition eolian itself compiles
against -- and fails if any of the 109 keywords goes unmentioned. Confirmed
non-vacuous by removing one and watching it fail.
Co-Authored-By: Claude Opus 5 <[email protected]>
---
doc/eolian/grammar.md | 410 +++++++++++++++++++++++++++++++++++++++++++
scripts/check-grammar-doc.py | 81 +++++++++
2 files changed, 491 insertions(+)
diff --git a/doc/eolian/grammar.md b/doc/eolian/grammar.md
new file mode 100644
index 0000000000..37fad42c07
--- /dev/null
+++ b/doc/eolian/grammar.md
@@ -0,0 +1,410 @@
+# The Eolian language
+
+Eolian is the interface definition language EFL classes are written in. A `.eo` or
+`.eot` file declares types, classes, their methods and properties, and the eolian
+generator turns that into C headers, C dispatch code, and the database that binding
+generators read.
+
+This is a reference for the language itself. It is hand-written and describes every
+keyword the lexer accepts (`src/lib/eolian/eo_lexer.h`); `scripts/check-grammar-doc.py`
+fails the build if a keyword exists that this file does not mention.
+
+For the rules that apply specifically to *stable* API — which types are allowed, what
+`@since` means, what a binding is entitled to assume — see the conventions document that
+governs the API, and `doc/eolian-c-conventions.md` for the C the generator produces.
+
+## 1. Files
+
+Two extensions, and the difference matters:
+
+| | |
+|---|---|
+| `.eo` | declares exactly one class, and may declare types alongside it |
+| `.eot` | declares types only, no class |
+
+A file is named after what it declares, lowercased with dots turned into underscores:
+`Efl.Gfx.Buffer` lives in `efl_gfx_buffer.eo`.
+
+### Pulling in other files
+
+```eo
+import efl_gfx_types; // record a dependency, and use its declarations
+parse efl_ui_types; // use its declarations without recording a dependency
+```
+
+`import` is what you almost always want. `parse` reads the file so its names resolve but
+does not record the dependency, which matters only to tooling that walks the dependency
+graph.
+
+### Unit header
+
+A file may open with a header block, before anything else:
+
+```eo
+#version 1;
+```
+
+`#version` selects the language version the file is written against. It is the only
+header keyword, and it is a syntax error anywhere but the header.
+
+## 2. Documentation
+
+Documentation is written in `[[double square brackets]]` and attaches to whatever
+precedes it, or to the enclosing block when it is the first thing inside it.
+
+```eo
+@property size {
+ [[The size of the thing.
+
+ A blank line starts the description; everything after the first
+ paragraph is detail rather than summary.
+
+ @since 1.30
+ ]]
+}
+```
+
+Inside a doc block:
+
+| Syntax | Meaning |
+|---|---|
+| `@Efl.Ui.Button` | a reference to another declaration; `@.method` refers within the current class |
+| `$name` | a parameter, value or literal, rendered as code |
+| `$true`, `$false`, `$NULL` | the usual literals, rendered as code |
+| `@since 1.30` | the version this entity became stable |
+
+Two rules the parser enforces and that cost time when forgotten:
+
+- **`@since` must be the last thing in the block.** Anything after it is reported as
+ "mangled documentation".
+- **Doc references do not work in `.eot` files** parsed through
+ `eolian_state_all_eot_files_parse()`. Write the name without the `@`.
+
+## 3. Types
+
+### Builtin scalar types
+
+Integers, in the spellings eolian accepts:
+
+```
+byte ubyte short ushort int uint long ulong llong ullong
+int8 uint8 int16 uint16 int32 uint32 int64 uint64 int128 uint128
+size ssize intptr uintptr ptrdiff
+```
+
+And the rest:
+
+```
+float double bool char time void
+```
+
+`time` is a calendar time, `void` is the absence of a value (a method with no return, an
+event with no payload).
+
+### Builtin string and buffer types
+
+| Type | C | Notes |
+|---|---|---|
+| `string` | `const char *` | borrowed, NUL-terminated |
+| `mstring` | `char *` | mutable; usually `@move` |
+| `stringshare` | `Eina_Stringshare *` | refcounted interned string |
+| `strbuf` | `Eina_Strbuf *` | growable string buffer |
+| `binbuf` | `Eina_Binbuf *` | growable byte buffer |
+| `slice<T>` | `Eina_Slice` | a borrowed, read-only run of `T` |
+| `rw_slice<T>` | `Eina_Rw_Slice` | the writable counterpart |
+
+A slice's `len` is in **bytes**, not elements — `EINA_SLICE_ARRAY()` computes it for you.
+
+### Builtin container types
+
+| Type | C | |
+|---|---|---|
+| `array<T>` | `Eina_Array *` | |
+| `iterator<T>` | `Eina_Iterator *` | forward-only, single pass |
+| `accessor<T>` | `Eina_Accessor *` | random access by index |
+| `future<T>` | `Eina_Future *` | a value that will arrive later |
+| `list<T>` | `Eina_List *` | **banned in stable API** |
+| `hash<K, V>` | `Eina_Hash *` | **banned in stable API** |
+
+### Other builtins
+
+| Type | Meaning |
+|---|---|
+| `any_value` | an `Eina_Value` by value |
+| `any_value_ref` | an `Eina_Value *` |
+| `event` | an event handle |
+| `function` | a callback; expands to `(data, cb, free_cb)` in C |
+| `ptr(T)` | a pointer to `T` |
+| `void_ptr` | `void *`; **banned in stable API** |
+| `__undefined_type` | a placeholder for something not expressible; **banned in stable API** |
+
+A builtin is more than a spelling convenience: it is the marker that says *every binding
+implements this natively*. Reaching for an `@extern` struct where a builtin exists tells
+every generator it is on its own.
+
+### Type aliases
+
+```eo
+type Efl.Ui.Something: int; // a named alias
+type @extern Eina.Rectangle: __undefined_type; // declared elsewhere in C
+type @free(free_it) Handle: ptr(void); // with a free function
+```
+
+### Structs
+
+```eo
+struct Efl.Gfx.Buffer_Plane {
+ [[One plane of a buffer. @since 1.30]]
+ pixels: slice<ubyte>; [[This plane's memory.]]
+ stride: int; [[Length in bytes of one row.]]
+ size: Eina.Size2D; [[This plane's dimensions.]]
+}
+
+struct @extern Eina.Rect; // declared in C, opaque here
+struct @free(thing_free) Thing { ... } // with a free function
+```
+
+Struct fields take `@by_ref`, `@move` and `@nullable` (see §7).
+
+### Enums
+
+```eo
+enum Efl.Gfx.Buffer_Access_Mode {
+ [[Graphics buffer access mode. @since 1.30]]
+ none = 0x0, [[No access.]]
+ read = 0x1, [[Read access.]]
+ write = 0x2, [[Write access.]]
+}
+
+enum Something {
+ legacy: ELM_SOMETHING; // prefix for the generated legacy names
+ first,
+ second,
+}
+```
+
+Values may be given explicitly or left to run from 0. `legacy:` sets the C prefix for
+generated legacy constants.
+
+### Constants
+
+```eo
+const Efl.Version_Major: int = 1;
+```
+
+### Errors
+
+```eo
+error Efl.Model_Error_Not_Supported ("Operation not supported");
+error @beta @c_name(EFL_MODEL_ERROR_X) Efl.Model_Error_X ("...");
+```
+
+An error declaration produces an `Eina_Error` value. It takes `@extern`, `@beta` and
+`@c_name`.
+
+## 4. Classes
+
+Four kinds:
+
+| Keyword | What it is |
+|---|---|
+| `class` | a concrete, instantiable class |
+| `abstract` | a class that cannot be instantiated on its own |
+| `mixin` | adds behaviour and may carry data, mixed into a class |
+| `interface` | a contract with no data of its own |
+
+```eo
+class Efl.Ui.Button extends Efl.Ui.Layout_Base implements Efl.Ui.Clickable,
+ Efl.Text
+{
+ [[A button. @since 1.30]]
+ c_prefix: efl_ui_button;
+ event_c_prefix: efl_ui_button;
+ data: Efl_Ui_Button_Data;
+ implements { ... }
+ constructors { ... }
+ methods { ... }
+ events { ... }
+ parts { ... }
+}
+```
+
+### Inheritance keywords
+
+| Keyword | Meaning |
+|---|---|
+| `extends` | the single parent class |
+| `implements` | interfaces and mixins this class provides |
+| `composites` | interfaces provided by an object this one holds, not by itself |
+| `requires` | interfaces a class using this mixin must already provide |
+
+### Class body keywords
+
+| Keyword | Meaning |
+|---|---|
+| `c_prefix` | prefix for generated C function names |
+| `event_c_prefix` | prefix for generated event constant names |
+| `data` | the C type of the class's private data, or `null` for none |
+| `implements` | the block listing which inherited members this class defines |
+| `constructors` | which parent constructors must be called |
+| `constructor` | declares a constructing method |
+| `destructor` | declares the destructor |
+| `methods` | the block of methods and properties |
+| `events` | the block of events |
+| `parts` | the block of named sub-objects |
+
+`data: null` says the class carries no private data. It is required, not optional — a
+class that stores nothing must say so.
+
+## 5. Methods and properties
+
+### Methods
+
+```eo
+methods {
+ do_something @protected @const {
+ [[Does something.]]
+ params {
+ @in name: string; [[What to do it to.]]
+ @out result: int; [[Filled in on success.]]
+ @inout budget: int; [[Reduced by what was spent.]]
+ }
+ return: bool; [[$true on success.]]
+ }
+}
+```
+
+Parameter directions are `@in` (the default), `@out` and `@inout`.
+
+### Properties
+
+A property is declared once and generates up to two C functions. The six lists:
+
+```eo
+@property size {
+ [[Doc for the property as a whole.]]
+ get {
+ [[Doc for the getter only.]]
+ return: bool; [[Getter-specific return.]]
+ }
+ set {
+ [[Doc for the setter only.]]
+ return: bool; [[Setter-specific return.]]
+ }
+ keys {
+ part: string; [[Which part. A key is an input to both halves.]]
+ }
+ values {
+ sz: Eina.Size2D; [[The value itself.]]
+ }
+}
+```
+
+- `keys` are inputs to both getter and setter — the index of an indexed property.
+- `values` are the property's value: outputs of the getter, inputs of the setter.
+- Declaring only `get { }` makes it read-only; only `set { }` makes it write-only.
+- A getter with exactly one value **returns** it rather than filling an out-parameter.
+ This is a convention every binding generator must implement.
+
+### The implements block
+
+```eo
+implements {
+ Efl.Object.constructor;
+ Efl.Gfx.Entity.size { get; set; }
+ Efl.Gfx.Entity.position { set @auto; }
+ Efl.Ui.Widget.theme_apply;
+ class.destructor;
+}
+```
+
+`@auto` generates a trivial accessor that reads or writes the private data field
+directly. `@empty` generates an implementation that does nothing. Both attach to a
+property half, or to the whole implement to apply to both. Eolian's grammar cannot split
+them across the two halves of one property in a single statement.
+
+## 6. Events
+
+```eo
+events {
+ clicked: void; [[Nothing to pass.]]
+ changed: Efl.Gfx.Entity @nullable; [[The new value, or $NULL.]]
+ pressed @hot @protected: Efl.Input.Key; [[Cannot be frozen.]]
+ restarted @restart: void;
+}
+```
+
+| Qualifier | Meaning |
+|---|---|
+| `@beta` | not stable API |
+| `@hot` | cannot be frozen by event freezing |
+| `@restart` | restarts event propagation |
+| `@private`, `@protected` | scope |
+| `@nullable` | the payload may be `NULL` — goes *after* the type, since it describes the payload |
+
+## 7. Annotations
+
+Every `@` keyword, and what it means.
+
+### On classes, types and declarations
+
+| Annotation | Applies to | Meaning |
+|---|---|---|
+| `@beta` | classes, types, methods, properties, events, struct fields | not stable API; hidden unless `EFL_BETA_API_SUPPORT` is defined |
+| `@extern` | types, structs, errors | declared in C elsewhere; eolian generates no definition |
+| `@c_name(NAME)` | types, structs, enums, errors, classes | override the generated C name |
+| `@free(func)` | types, structs | the function that releases a value of this type |
+
+### On methods and properties
+
+| Annotation | Meaning |
+|---|---|
+| `@protected` | callable by subclasses, not by applications |
+| `@private` | internal |
+| `@const` | does not modify the object |
+| `@static` | no object receiver; a package-level function |
+| `@pure_virtual` | declared here, implemented by whoever inherits |
+| `@property` | introduces a property rather than a method |
+| `@auto` | in an `implements` block: generate a trivial accessor |
+| `@empty` | in an `implements` block: generate a do-nothing implementation |
+| `@get`, `@set` | select a property half |
+
+### On parameters, returns, values and struct fields
+
+| Annotation | Meaning |
+|---|---|
+| `@in`, `@out`, `@inout` | parameter direction |
+| `@by_ref` | passed by reference rather than by value |
+| `@move` | ownership passes to the receiver, who must free it |
+| `@optional` | may be omitted; trailing parameters only |
+| `@nullable` | `NULL` is a meaningful value here |
+| `@no_unused` | the caller must not discard the return value |
+| `@const` | the pointed-to value is not modified |
+
+`@nullable` says nothing about representation: a nullable `Efl.Object` return is still
+`Efl_Object *`, so an existing signature can gain the annotation without any consumer
+noticing. It requires a type that can actually be `NULL` — a string, a class handle, or a
+value type taken `@by_ref`. Annotating a by-value `int` is an error, because there is no
+`NULL` for it to be.
+
+## 8. Parts
+
+```eo
+parts {
+ icon: Efl.Ui.Button_Part_Icon; [[The icon shown beside the label.]]
+}
+```
+
+A part is a named sub-object reachable through `efl_part(obj, "icon")`. Declaring it
+tells bindings the name exists and what class comes back.
+
+## 9. Literals
+
+`true`, `false`, `null`, integers, floats, characters and strings, plus `.` and `:` for
+qualified names.
+
+## 10. Reserved words
+
+`class`, `const`, `enum`, `return`, `struct` and the keywords above fill the token's
+keyword field but remain usable as identifiers — eolian resolves by position, not by
+reserving the word.
diff --git a/scripts/check-grammar-doc.py b/scripts/check-grammar-doc.py
new file mode 100755
index 0000000000..72674ea72d
--- /dev/null
+++ b/scripts/check-grammar-doc.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+"""Check that doc/eolian/grammar.md still describes every eolian keyword.
+
+The grammar reference is hand-written, so it drifts the moment someone adds a
+keyword to the lexer and not to the document. This extracts the keyword
+inventory from src/lib/eolian/eo_lexer.h -- the definition eolian itself
+compiles against -- and asserts each keyword appears somewhere in the document.
+
+A keyword counts as documented if the file mentions it in any of the spellings
+the language uses: bare (`extends`), at-prefixed (`@nullable`), hash-prefixed
+(`#version`), or as a type name inside a generic (`slice<T>`).
+
+Usage: scripts/check-grammar-doc.py
+"""
+
+import os
+import re
+import sys
+
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+LEXER = os.path.join(ROOT, 'src', 'lib', 'eolian', 'eo_lexer.h')
+DOC = os.path.join(ROOT, 'doc', 'eolian', 'grammar.md')
+
+# Keywords that are token machinery rather than language the user writes.
+EXEMPT = {
+ # every literal is covered by the "Literals" section as a group
+}
+
+
+def keywords():
+ text = open(LEXER, encoding='utf-8').read()
+ start = text.index('#define KEYWORDS')
+ # the macro body runs until the first line that does not end in a backslash
+ body = []
+ for line in text[start:].split('\n'):
+ body.append(line)
+ if not line.rstrip().endswith('\\'):
+ break
+ body = '\n'.join(body)
+
+ out = []
+ for kind, name in re.findall(r'\b(KW|KWAT|KWH)\(([a-z_0-9]+)\)', body):
+ prefix = {'KW': '', 'KWAT': '@', 'KWH': '#'}[kind]
+ out.append((prefix, name))
+ return out
+
+
+def main():
+ if not os.path.exists(DOC):
+ sys.exit('%s does not exist' % DOC)
+
+ doc = open(DOC, encoding='utf-8').read()
+
+ missing = []
+ total = 0
+ for prefix, name in keywords():
+ if name in EXEMPT:
+ continue
+ total += 1
+ spellings = [prefix + name]
+ if not prefix:
+ # a type keyword may only ever appear as `slice<T>` or in a table cell
+ spellings += ['`%s`' % name, '%s<' % name, '`%s<' % name]
+ if not any(s in doc for s in spellings):
+ missing.append(prefix + name)
+
+ print('checked %d eolian keywords against %s'
+ % (total, os.path.relpath(DOC, ROOT)))
+
+ if missing:
+ print(' %d keyword(s) the grammar document does not mention:' % len(missing))
+ for kw in missing:
+ print(' %s' % kw)
+ return 1
+
+ print('the grammar document mentions every keyword')
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.