Commit Graph

61 Commits

Author SHA1 Message Date
Benedikt Peetz 39864ab737
chore(parser/docs/grammar.pdf): Update file 2024-03-24 21:19:13 +01:00
Benedikt Peetz a0ae2a1762
build(flake): Update 2024-03-24 21:17:58 +01:00
Benedikt Peetz 0ec81972eb
feat(example/valgrind): Add a script to test the c example with valgrind 2024-03-24 21:13:46 +01:00
Benedikt Peetz 648348bd38
fix(types): Improve support for generic rust types
The support might be improved, but I still sort of want to remove
generic types, as the current implementation is just _bad_.
2024-03-24 21:11:58 +01:00
Benedikt Peetz 2ed6ed7f58
docs(example): Update the example c and tri file to latest progress 2024-03-24 21:10:26 +01:00
Benedikt Peetz aa4391905a
chore(example): Switch to full trinitrix API 2024-03-24 21:09:52 +01:00
Benedikt Peetz 0955876cb3
fix(trixy): Add thiserror dependency, as it's used in generated code 2024-03-24 21:08:28 +01:00
Benedikt Peetz 5aaa2b43f3
fix(macros): Generate namespacesed types and convertible impls 2024-03-24 21:06:14 +01:00
Benedikt Peetz fa26bdfc6c
fix(macros/c_api): Add host generation support for structs and enums 2024-03-24 21:05:10 +01:00
Benedikt Peetz 9ec0c22e4e
feat(macros/c_api/header): Add structs and enums to the c header 2024-03-24 21:03:33 +01:00
Benedikt Peetz 1c72309677
fix(types/error): Add a pseudo error for infallible conversions 2024-03-24 20:12:04 +01:00
Benedikt Peetz f0f78f7fc7
fixup! refactor(macros/convertible_derive): Generate the `Convertible` Trait impl 2024-03-24 20:10:44 +01:00
Benedikt Peetz 25d03a3dd5
docs(parser/examples): Add various examples (also the trinitrix main api) 2024-03-24 20:07:53 +01:00
Benedikt Peetz 5b8d31e806
test(parser/checked/test): Update test case 2024-03-24 20:07:13 +01:00
Benedikt Peetz f24d6310fd
fix(parser/lexing/error): Improve the message of the `NoMatchesTaken` error
This error should only ever be raised, when we encountered a bug.
This change notifies the user, that the situation is rather likely to be
a bug and that this should be reported.
2024-03-24 20:03:58 +01:00
Benedikt Peetz f14ef1cec2
fix(parser/error): Remove multiple errors from line number calc
Errors were contextualized by finding their index in the source file.
This method is extremely flaky, as it _hopes_ that the line is not
spread over multiple lines.
The new method actually uses the span to calculate a matched line and
thus avoids any issues related to the actual position of the line in the
source file.
2024-03-24 19:59:21 +01:00
Benedikt Peetz 3c3ee23c2b
feat(parser): Associate a vector of nasps with every struct, enum, nasp
This feature makes it possible to generate these types actually in
namespaces and not only in one toplevel.
2024-03-24 19:57:32 +01:00
Benedikt Peetz 4a32f0d2f4
feat(parser): Add support for parsing function pointer types
Notably these diverge from rust, by requiring argument names. This is a
deliberate design decision, as it help users to guess what's going to be
passed into their callback.
2024-03-24 19:35:09 +01:00
Benedikt Peetz e984cdc66f
feat(parser/bin): Allow `lex` as an alias to `tokenize` 2024-03-24 19:28:27 +01:00
Benedikt Peetz dad99d1a10
refactor(parser): Use predictable names for tokens 2024-03-24 19:27:25 +01:00
Benedikt Peetz 4da72b2655
fixup! feat(parser/lexing): Desugger doc comments by running a regex on the file 2024-03-24 19:18:23 +01:00
Benedikt Peetz 98c3b009df
feat(parser): Add support for parsing attributes 2024-03-24 19:16:52 +01:00
Benedikt Peetz bf3eb61110
feat(parser/lexing): Desugger doc comments by running a regex on the file
Previously we actually supported parsing doc comments (`///`), but
replacing them before parsing allows for simplifications in the lexer.
Precisely, that means that we can add support for attributes without
having to maintain the doc comment parser.
2024-03-24 18:09:57 +01:00
Benedikt Peetz 918ab5df6d
refactor(macros/convertible_derive): Generate the `Convertible` Trait impl
Previously this was derived in the `trixy-types-derive` create, but this
is just making debugging harder and has thus been refactored.
2024-03-24 18:04:23 +01:00
Benedikt Peetz 938e038075
refactor(types/headers/string): Don't typedef a string type
This really does not add anything, and just using `const char*` directly
keeps things more clear.
2024-03-24 17:59:19 +01:00
Benedikt Peetz 17fd954e46
fix(macros/c_api/header): Format doc comments in a c-like way
Formatting them with `/// [Comment]` is a rust convention, c uses `/**
[Comment] */`.
2024-03-24 17:56:43 +01:00
Benedikt Peetz cd5b0c9ee4
refactor(example/main/c): Deduplicate error handling function 2024-03-24 17:52:36 +01:00
Benedikt Peetz 86d00608eb
build(cog.toml): Use `nix fmt` (treefmt) instead of only `cargo fmt` 2024-03-24 17:51:07 +01:00
Benedikt Peetz 7a95fa7d81
chore(.licensure.yml): Add license spdx identifier 2024-03-24 17:46:27 +01:00
Benedikt Peetz 2f7be6fe67
chore(.licensure.yml): Also add the license text to markdown files 2024-03-24 16:39:01 +01:00
Benedikt Peetz 5ce46a1568
fix(trixy/examples/main): Improve c code 2024-02-19 20:58:21 +01:00
Benedikt Peetz d904a19f48
style(treewide): Reformat with treefmt (`nix fmt`) 2024-02-19 20:53:11 +01:00
Benedikt Peetz 8104e802e7
build(update.sh): Add a shebang 2024-02-19 20:52:10 +01:00
Benedikt Peetz 7c27cdc0e0
fix(trixy-macros): Format the generated header with in the GNU style 2024-02-19 20:51:33 +01:00
Benedikt Peetz 1b8a33c919
build(flake): Add treefmt
This only adds this as nix module. So running `nix fmt` will now format
all files under the repo root.

If you want to run this as non-nix user feel free to take a look at the
generated `treefmt.toml`.
2024-02-19 20:48:50 +01:00
Benedikt Peetz 03f8eda241
style(treewide): Reformat 2024-02-19 16:15:18 +01:00
Benedikt Peetz 5a7bb00548
chore(treewide): Add the new license header 2024-02-19 16:13:55 +01:00
Benedikt Peetz 6e26bec209
build(licensure): Add c headers to known files 2024-02-19 16:13:53 +01:00
Benedikt Peetz 7ac6edb752
chore(treewide): Remove old license header
This was done with:
```bash
fd --type file . | xargs grep 'Copyright (C) 2023  The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>' | awk 'BEGIN{ FS=":"} {print $1}' | xargs sed -i '1,19d'
```
2024-02-19 16:13:48 +01:00
Benedikt Peetz 1a2267b748
build(licensure): Update to a better license template 2024-02-19 16:03:07 +01:00
Benedikt Peetz e52f74b0c1
feat(treewide): Finalize basic c API
See the example under `./example/main/` for more details.
2024-02-19 15:50:30 +01:00
Benedikt Peetz e205ea4625
docs(lib): Add a description to the oneshot-senders 2024-02-18 13:37:34 +01:00
Benedikt Peetz 80c6dd4057
build(update.sh): Add an update script 2024-02-18 13:37:09 +01:00
Benedikt Peetz 88aa3c3ad7
docs(trixy-parser): Update the railroad diagrams 2024-02-18 13:36:37 +01:00
Benedikt Peetz 86b946b540
fix(trixy-types): Conform to the api provided by the headers
See the previous commit for an explanation
2024-02-18 13:35:40 +01:00
Benedikt Peetz f699ca24a9
fix(trixy-types): Rework c header files
The old implementation tried to provide rust types in c—like the
result or option types. This implementation now removes this source of
complexity by ensuring, that these types are unwrapped on the rust->c
boundary.

This first commit changes the header files to conform to the new api.
2024-02-18 13:30:03 +01:00
Benedikt Peetz a077ef1466
fix(trixy-parser): Remove the `void` type 2024-02-18 13:27:31 +01:00
Benedikt Peetz dc8a7ecb33
test(trixy-parser): Restore test functionality after nasp -> mod rename 2024-02-18 13:17:34 +01:00
Benedikt Peetz 3e59d53b8b
build(flake): De-duplicate the `flake.lock` file 2024-02-18 13:11:33 +01:00
Benedikt Peetz b6799877bb
feat(trixy-parser): Adapt Trixy to be a complete subset of rust
This changes two important things:
- Firstly it renames the `nasp` keyword to `mod`:
        This change removes the not required deviation from rust.
- Secondly it removes the semicolon after an enumeration or structure
  declaration, which is pointless in these positions.
2024-02-17 19:54:43 +01:00