aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/generators/c_grammar.lua
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-04-03 15:21:24 +0200
committerbfredl <bjorn.linse@gmail.com>2023-04-07 21:30:21 +0200
commitefb0896f21e03f64e3a14e7c09994e81956f47b9 (patch)
treef88cca66495b34631d037bffc3cda6a8db1329fe /src/nvim/generators/c_grammar.lua
parent04933b1ea968f958d2541dd65fd33ebb503caac3 (diff)
downloadrneovim-efb0896f21e03f64e3a14e7c09994e81956f47b9.tar.gz
rneovim-efb0896f21e03f64e3a14e7c09994e81956f47b9.tar.bz2
rneovim-efb0896f21e03f64e3a14e7c09994e81956f47b9.zip
refactor(api): make typed dicts appear as types in the source code
problem: can we have Serde? solution: we have Serde at home This by itself is just a change of notation, that could be quickly merged to avoid messy merge conflicts, but upcoming changes are planned: - keysets no longer need to be defined in one single file. `keysets.h` is just the initial automatic conversion of the previous `keysets.lua`. keysets just used in a single api/{scope}.h can be moved to that file, later on. - Typed dicts will have more specific types than Object. this will enable most of the existing manual typechecking boilerplate to be eliminated. We will need some annotation for missing value, i e a boolean will need to be represented as a TriState (none/false/true) in some cases. - Eventually: optional parameters in form of a `Dict opts` final parameter will get added in some form to metadata. this will require a discussion/desicion about type forward compatibility.
Diffstat (limited to 'src/nvim/generators/c_grammar.lua')
-rw-r--r--src/nvim/generators/c_grammar.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/nvim/generators/c_grammar.lua b/src/nvim/generators/c_grammar.lua
index 3e89b60b4a..17a224fd22 100644
--- a/src/nvim/generators/c_grammar.lua
+++ b/src/nvim/generators/c_grammar.lua
@@ -55,5 +55,11 @@ local c_proto = Ct(
fill * P(';')
)
-local grammar = Ct((c_proto + c_comment + c_preproc + ws) ^ 1)
+local c_field = Ct(Cg(c_id, 'type') * ws * Cg(c_id, 'name') * fill * P(';') * fill)
+local c_keyset = Ct(
+ P('typedef') * ws * P('struct') * fill * P('{') * fill *
+ Cg(Ct(c_field ^ 1), 'fields') *
+ P('}') * fill * P('Dict') * fill * P('(') * Cg(c_id, 'keyset_name') * fill * P(')') * P(';'))
+
+local grammar = Ct((c_proto + c_comment + c_preproc + ws + c_keyset) ^ 1)
return {grammar=grammar, typed_container=typed_container}