Commit graph

135 commits

Author SHA1 Message Date
Coleman McFarland
2d6558c769 Use FromIterator<_> for TokenStream
Also remove conservative_impl_trait feature flag, as this is now a
stable feature.

Refs 
2018-04-16 00:54:32 -07:00
Coleman McFarland
0f453a5568 Refactor to keep up with changes to proc_macro
Instead of a `kind` field containting a `TokenNode` variant, a
TokenTree is now an enum with variants of different types (Literal, Op,
Term, etc). Note that a TokenTree could be a sequence of TokenTrees if it is a
Group variant.

Other notes:

I'm unsure about the set_span call in Builder::emit_if, but I did not want to
throw away the passed in Span.

Parsing relies on destructuring references to the values associated with
TokenTree enum variants

It doesn't seem as easy to compose/chain TokenStreams as it is to
collect a Vec<TokenTree> into a TokenStream. There is probably some
iterator API I could use instead. See `match_arms` and build.rs

Refs 
2018-04-12 14:19:26 -07:00
Chris Wong
cc833dd624 Update to rustc 1.23.0-nightly (6160040d8 2017-11-18) 2017-11-19 19:55:11 +13:00
Chris Wong
9674865846 Combine .push_str() calls across blocks
This also disallows `@let` in non-block contexts, e.g.

    img src=@let foo = bar; ;

This yields a 20 - 50 ns speedup in benchmarks, as well as reducing code
size by a slight amount.
2017-10-07 14:17:38 +13:00
Chris Wong
5cd51481c9 Rename Renderer to Builder 2017-08-12 17:41:54 +12:00
Chris Wong
a902c97091 Allow braces in toggled classes 2017-08-12 16:50:54 +12:00
Chris Wong
9487dbc3a7 Move some code around 2017-08-12 16:21:13 +12:00
Chris Wong
1785071f1b Allow terminating void elements with semicolons (;)
When Rust and HTML syntax differ, Maud tends to side with Rust syntax.
This can be seen with string literals, for example, where we use
backslash escapes instead of HTML entities. Using `;` to terminate void
elements is consistent with this idea.

Moreover, this reduces confusion around the generated code. Maud does
not insert an extra slash into the HTML output (as per the spec) but
the syntax may imply otherwise.

This confusion may have been the cause of a [bug I found in the
wild][1], where the code omitted the trailing slash on an `input`
element. I suspect that this is because the author thought that a
trailing slash in the Maud template would lead to one in the HTML
output. Switching to semicolons would prevent this misconception.

[1]: https://github.com/anowell/quasar/pull/3
2017-08-04 20:58:02 +12:00
Chris Wong
21d19adb13 Add some more comments 2017-07-31 22:25:00 +12:00
Chris Wong
c57d41e1a6 Handle conditions which contain braces 2017-07-31 22:03:50 +12:00
Chris Wong
d3586a28f3 Remove braces from let expressions
Also improve spans by passing more of the input through directly
2017-07-31 21:48:11 +12:00
Chris Wong
4f7189375e Avoid using quote! in parser 2017-07-30 13:59:35 +12:00
Chris Wong
7dcc7d7063 Fix Clippy warnings 2017-07-29 20:06:28 +12:00
Chris Wong
37419d9781 Implement match expressions and remove debugging stuff 2017-07-29 14:33:10 +12:00
Chris Wong
fd7e000cda TokenTreeIter values can be cloned now 2017-07-29 13:24:40 +12:00
Chris Wong
513d7f3d73 Implement for expressions 2017-07-23 14:08:19 +12:00
Chris Wong
cd113be71b Implement while expressions 2017-07-23 14:03:23 +12:00
Chris Wong
798f9baee8 Implement if expressions 2017-07-23 13:58:42 +12:00
Chris Wong
af57ac41ce Refactor backtracking mechanism 2017-07-23 13:58:42 +12:00
Chris Wong
748ce69f4d Use loop-break-value
It's stable now!
2017-07-23 13:58:42 +12:00
Chris Wong
3d1e82b20e Implement let expressions 2017-07-23 13:58:42 +12:00
Chris Wong
e61385645e Don't throw away spans 2017-07-23 13:58:42 +12:00
Chris Wong
e0c7fcf055 Initial stab at porting to new proc macro interface 2017-07-23 13:58:42 +12:00
Chris Wong
a51a16bdc7 Minor tweaks 2017-06-03 12:42:36 +12:00
Alisha
61bbcfdb69 Remove error macro and make error function 2017-05-30 01:59:18 +10:00
Chris Wong
0ec0950c5f Remove FlattenNtFolder
The tests pass without it, so 🤷
2017-04-22 17:29:56 +12:00
Chris Wong
dde603757d Rename PResult to ParseResult 2017-04-22 17:29:56 +12:00
Chris Wong
dfe721c6b7 Update to rustc 1.18.0-nightly (1785bca51 2017-04-21)
Closes 
2017-04-22 17:29:56 +12:00
Sander Maijers
fc13564a42 Update to rustc 1.17.0-nightly (b1e31766d 2017-03-03)
Closes 

Squashed commit of the following:

commit f88e4dfa5a62f9d6e00ed0980b6fb6d41d36151c
Author: Chris Wong <lambda.fairy@gmail.com>
Date:   Tue Mar 7 20:54:54 2017 +1300

    Convert errant tabs to spaces

commit 65936efca738459412d8818f911601bf5a2870fa
Author: Sander Maijers <S.N.Maijers@gmail.com>
Date:   Mon Mar 6 17:15:20 2017 +0100

    Refactor to make more generic

commit dc16b665854f1d63f5dd8d4db5c3f9390b1e6cee
Author: Sander Maijers <S.N.Maijers@gmail.com>
Date:   Thu Mar 2 16:47:52 2017 +0100

    Adjust to make compatible with current `libsyntax`

    Was broken since rustc nightly 2017-03-01.
2017-03-07 20:59:51 +13:00
Chris Wong
e577411356 Update to rustc 1.16.0-nightly (83c2d9523 2017-01-24) 2017-01-26 16:59:07 +13:00
Chris Wong
1859f1635c Update Rust
rustc 1.15.0-nightly (7b3eeea22 2016-11-21)
2016-11-23 22:33:04 +13:00
Chris Wong
585ed3851b Implement toggled classes
Closes 
2016-11-19 15:59:33 +13:00
Chris Wong
68feeeff1b Change empty attribute syntax to use [square brackets]
Closes 
See 
2016-11-17 20:39:02 +13:00
Chris Wong
4b81039d2d Flatten substitutions from macro_rules expansion
This fixes a compile error with the test `misc::issue_23`.
2016-11-16 18:03:23 +13:00
Chris Wong
39602a075c Implement let expressions
Closes 
2016-11-12 14:46:49 +13:00
Chris Wong
181bb0583e Update Rust 2016-11-03 22:47:54 +13:00
Utkarsh Kukreti
553a6bc037 Add support for @while and @while let.
Fixes .
2016-10-19 21:46:37 +05:30
Chris Wong
e98d340825 Pre-allocate a buffer of (roughly) the right size
Closes 
2016-10-02 17:48:01 +13:00
Chris Wong
c05bb02d97 Remove call expressions 2016-09-23 19:36:42 +12:00
Chris Wong
f12efe4299 Rewrite everything to use Strings instead of writers
After fiddling around with zero-allocation solutions, I concluded that
all non-allocating approaches are too annoying to work with in realistic
code. Using closures leads to yak-shaving with lifetimes; and because
Iron needs to take ownership of the response body we often end up
cloning the input data anyway.

Removing this constraint has let me simplify the entire system, removing
a net 300 lines from the library. The `html!` macro no longer takes a
writer, and instead returns a `PreEscaped<String>`. This means that the
result of an `html!` can be spliced directly into another `html!`,
removing the need for the `impl Template` rigmarole.

To rub it in, benchmarks show the new code is in fact *faster* than it
was before. How lovely.
2016-09-23 19:22:22 +12:00
Chris Wong
7045191c19 Add the "call" keyword back in
This change should make the syntax look a bit less mysterious
2016-09-02 23:23:39 +12:00
Chris Wong
58650b0dd0 Remove dead code 2016-09-01 17:52:51 +12:00
Chris Wong
ed9228fa93 Require parentheses around calls
This simplifies the parser quite a bit
2016-08-22 21:53:23 +12:00
Chris Wong
97a71d7bc3 Require that all literal strings are quoted
Unquoted literals are confusing, annoying to implement, and rarely used.
We're better off without them.
2016-08-18 22:31:12 +12:00
Chris Wong
6a6b23d8ae Switch to new splice syntax using parentheses
Closes 
2016-08-18 22:12:14 +12:00
Chris Wong
61791a6aef @call yay -> @yay 2016-08-15 20:46:04 +12:00
Chris Wong
d2bf70da9a Allow names with multiple hyphens in a row
Fixes 
2016-08-07 20:39:31 +12:00
Chris Wong
4d66646ece Don't allow namespaces in class and ID names 2016-07-21 21:19:38 +12:00
msifeed
36a88bd74f Move ident parsing to separate method 2016-07-19 14:57:05 +03:00
msifeed
e222f5385d Fixed minuses in namespaces 2016-07-18 14:40:45 +03:00