26 Commits

Author SHA1 Message Date
René Kijewski
7b4f1dc907 parser: add optional {% endwhen %} 2024-09-10 04:09:40 +02:00
René Kijewski
f9932a03ff parser: When::match() matches else case 2024-09-10 03:58:15 +02:00
Guillaume Gomez
c38007cf25 Improve error message for unclosed items 2024-09-10 02:39:59 +02:00
Guillaume Gomez
71f49a8fc2 Add support for prefixes for string literals 2024-08-18 22:43:59 +02:00
Guillaume Gomez
7a7e415822 Add support for | operator in when 2024-08-15 21:10:29 +02:00
Guillaume Gomez
d5fef24ff7
Merge pull request #119 from Kijewski/pr-no-when
parser: allow `match` nodes w/o `when` if there is an `else`
2024-08-13 17:48:15 +02:00
Guillaume Gomez
9873ea065f Improve compile-time if conditions handling 2024-08-09 20:32:38 +02:00
René Kijewski
f818c582bf parser: allow match nodes w/o when if there is an else 2024-08-08 22:28:14 +02:00
René Kijewski
5efd31310f parser: understand arbitrarily mixed up end nodes 2024-08-07 20:43:18 +02:00
René Kijewski
e0a7d4df55 parser: use fail fail() where appropriate 2024-08-07 20:36:31 +02:00
René Kijewski
dec67c686b parser: tell user proper keyword to end node 2024-08-07 20:30:25 +02:00
René Kijewski
7b99783f00 parser: use memchr to speed-up skip_till()
`skip_till()` is used in the parser to find the next block `{%`,
comment `{#` or expression `{{`. At every character position, it is
tested if one of these three substrings follows. Using [`memchr3()`],
we could at least skip to the next candidate, a `{`. The syntax for
blocks, comments and expressions can be modified by the user, but that
does not matter much; we can simply supply `memchr3()` with the first
byte in each of these strings.

[`memchr3()`]: <https://docs.rs/memchr/2.7.4/memchr/fn.memrchr3.html>

```text
librustdoc/all          time:   [366.54 µs 366.78 µs 367.02 µs]
                        thrpt:  [38.475 MiB/s 38.500 MiB/s 38.525 MiB/s]
                 change:
                        time:   [-17.358% -17.065% -16.820%] (p = 0.00 < 0.05)
                        thrpt:  [+20.221% +20.576% +21.004%]
                        Performance has improved.

librustdoc/item_info    time:   [6.3315 µs 6.3400 µs 6.3495 µs]
                        thrpt:  [24.783 MiB/s 24.820 MiB/s 24.853 MiB/s]
                 change:
                        time:   [-6.5547% -6.4090% -6.2633%] (p = 0.00 < 0.05)
                        thrpt:  [+6.6818% +6.8479% +7.0144%]
                        Performance has improved.

librustdoc/item_union   time:   [39.377 µs 39.551 µs 39.720 µs]
                        thrpt:  [24.850 MiB/s 24.957 MiB/s 25.067 MiB/s]
                 change:
                        time:   [-6.9834% -6.2455% -5.5849%] (p = 0.00 < 0.05)
                        thrpt:  [+5.9153% +6.6616% +7.5077%]
                        Performance has improved.

librustdoc/page         time:   [170.83 µs 170.99 µs 171.23 µs]
                        thrpt:  [36.164 MiB/s 36.213 MiB/s 36.248 MiB/s]
                 change:
                        time:   [-12.413% -12.183% -11.968%] (p = 0.00 < 0.05)
                        thrpt:  [+13.595% +13.873% +14.173%]
                        Performance has improved.

librustdoc/print_item   time:   [21.163 µs 21.234 µs 21.322 µs]
                        thrpt:  [44.280 MiB/s 44.463 MiB/s 44.612 MiB/s]
                 change:
                        time:   [-19.848% -18.613% -17.491%] (p = 0.00 < 0.05)
                        thrpt:  [+21.198% +22.870% +24.763%]
                        Performance has improved.

librustdoc/short_item_info
                        time:   [19.781 µs 19.813 µs 19.846 µs]
                        thrpt:  [45.652 MiB/s 45.727 MiB/s 45.801 MiB/s]
                 change:
                        time:   [-18.027% -17.806% -17.574%] (p = 0.00 < 0.05)
                        thrpt:  [+21.321% +21.663% +21.991%]
                        Performance has improved.

librustdoc/sidebar      time:   [40.694 µs 40.806 µs 40.957 µs]
                        thrpt:  [30.131 MiB/s 30.242 MiB/s 30.325 MiB/s]
                 change:
                        time:   [-14.698% -14.069% -13.456%] (p = 0.00 < 0.05)
                        thrpt:  [+15.548% +16.372% +17.231%]
                        Performance has improved.

librustdoc/source       time:   [15.249 µs 15.264 µs 15.278 µs]
                        thrpt:  [48.251 MiB/s 48.295 MiB/s 48.343 MiB/s]
                 change:
                        time:   [-25.832% -25.678% -25.532%] (p = 0.00 < 0.05)
                        thrpt:  [+34.285% +34.550% +34.829%]
                        Performance has improved.

librustdoc/type_layout_size
                        time:   [9.0168 µs 9.0446 µs 9.0789 µs]
                        thrpt:  [29.832 MiB/s 29.945 MiB/s 30.038 MiB/s]
                 change:
                        time:   [-11.100% -10.437% -9.4426%] (p = 0.00 < 0.05)
                        thrpt:  [+10.427% +11.653% +12.486%]
                        Performance has improved.

librustdoc/type_layout  time:   [34.088 µs 34.114 µs 34.139 µs]
                        thrpt:  [78.860 MiB/s 78.919 MiB/s 78.979 MiB/s]
                 change:
                        time:   [-37.865% -37.723% -37.585%] (p = 0.00 < 0.05)
                        thrpt:  [+60.217% +60.573% +60.941%]
                        Performance has improved.
```
2024-07-28 18:14:57 +02:00
René Kijewski
10e67fa312 Reimplement {% filter %} block
This PR reimplements the code generation for `{% filter %}` blocks, so
that the data is written directly into its destination writer, without
using a buffer. This way it behaves like a specialized
`{{ expr|filter1|filter2 }}` would, if the `expr` was a `Template` that
contained the body of the filter block.
2024-07-13 11:11:04 +02:00
René Kijewski
e84e1a6af2 Move Target into its own file 2024-06-28 22:56:34 +02:00
René Kijewski
6b8b97672a Better error message on missing comma 2024-06-28 22:48:45 +02:00
René Kijewski
e94525f483 Add support for .. in let pattern matching for structs 2024-06-28 05:25:21 +02:00
Guillaume Gomez
4b847a27b2 Improve Level API a bit 2024-06-24 11:07:54 +02:00
Guillaume Gomez
d4e36fa59e Remove duplicated code to detect Rust keywords/identifiers 2024-06-20 23:16:52 +02:00
René Kijewski
bdc3c79e95 Test UTF-8-ness only in #[test]s 2024-06-20 22:02:39 +02:00
René Kijewski
5da686643d Deny all rust keywords as macro names 2024-06-20 21:46:20 +02:00
Guillaume Gomez
847d0bc2b9 Fix invalid "start" given to errors 2024-06-20 18:53:14 +02:00
Guillaume Gomez
20c26dbf0f Limit nested filters to avoid stack overflow 2024-06-20 18:53:14 +02:00
Guillaume Gomez
5e91d33d77 Add Node::span method 2024-06-17 17:18:55 +02:00
Guillaume Gomez
369562bbdd Update Node variants to use WithSpan 2024-06-17 17:18:55 +02:00
Guillaume Gomez
9f271fe142 Wrap Expr into WithSpan 2024-06-17 17:18:55 +02:00
Guillaume Gomez
2d80cc3524 Rename everything to rinja 2024-06-17 15:58:52 +02:00