about summary refs log tree commit diff
path: root/src/libsyntax/ext/quote.rs
AgeCommit message (Collapse)AuthorLines
2014-11-20Parse and store suffixes on literals.Huon Wilson-15/+18
This adds an optional suffix at the end of a literal token: `"foo"bar`. An actual use of a suffix in a expression (or other literal that the compiler reads) is rejected in the parser. This doesn't switch the handling of numbers to this system, and doesn't outlaw illegal suffixes for them yet.
2014-11-19Switch to an independent enum for `Lit*` subtokens.Huon Wilson-18/+19
2014-11-17libsyntax: DSTify `ToSource` and `ToSourceWithHygiene`Jorge Aparicio-9/+9
2014-11-09Fix ICEs that involved quasi-quotationPiotr Czarnecki-25/+17
* fixed get_tt for doc comments * properly handle MatchNt in `quote` Fixes #18763 Fixes #18775
2014-11-05Use `TokenTree`s in lhs of macrosPiotr Czarnecki-19/+33
2014-10-30Test fixes and rebase conflictsAlex Crichton-1/+1
2014-10-30Use common variants for open and close delimitersBrendan Zabarauskas-11/+21
This common representation for delimeters should make pattern matching easier. Having a separate `token::DelimToken` enum also allows us to enforce the invariant that the opening and closing delimiters must be the same in `ast::TtDelimited`, removing the need to ensure matched delimiters when working with token trees.
2014-10-29Rename fail! to panic!Steve Klabnik-4/+4
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-28Use an enum rather than a bool in token::IdentBrendan Zabarauskas-2/+7
2014-10-28Use PascalCase for token variantsBrendan Zabarauskas-68/+67
2014-10-26Reduce the size of the TokenTreeBrendan Zabarauskas-1/+2
2014-10-26Use standard capitalisation for TokenTree variantsBrendan Zabarauskas-7/+7
2014-10-26Prevent some vector reallocationsBrendan Zabarauskas-5/+4
2014-10-26Rename TokenTree variants for clarityBrendan Zabarauskas-4/+4
This should be clearer, and fits in better with the `TTNonterminal` variant. Renames: - `TTTok` -> `TTToken` - `TTDelim` -> `TTDelimited` - `TTSeq` -> `TTSequence`
2014-10-26Add Span and separate open/close delims to TTDelimBrendan Zabarauskas-7/+10
This came up when working [on the gl-rs generator extension](https://github.com/bjz/gl-rs/blob/990383de801bd2e233159d5be07c9b5622827620/src/gl_generator/lib.rs#L135-L146). The new definition of `TTDelim` adds an associated `Span` that covers the whole token tree and enforces the invariant that a delimited sequence of token trees must have an opening and closing delimiter. A `get_span` method has also been added to `TokenTree` type to make it easier to implement better error messages for syntax extensions.
2014-10-19Remove a large amount of deprecated functionalityAlex Crichton-4/+6
Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change]
2014-10-06syntax: Parse outer attributes in quote_method!Ben Gamari-7/+2
Fixes #17782.
2014-09-29Fixed quote_method!() implementationVladimir Pouzanov-2/+6
Parser.parse_method now has a second argument, I assume ast::Inherited is the correct visibility in this case.
2014-09-16Fallout from renamingAaron Turon-1/+1
2014-09-14syntax: fix fallout from using ptr::P.Eduard Burtescu-39/+37
2014-09-08quote: Explicitly borrow the ExtCtxtKeegan McAllister-1/+3
Fixes #16992.
2014-08-27Implement generalized object and type parameter bounds (Fixes #16462)Niko Matsakis-19/+20
2014-08-13quote_expr macro: embed Ident using special encoding that preserves hygiene.Felix S. Klock II-3/+96
This adds support to `quote_expr!` and friends for round-trip hygienic preservation of Ident. Here are the pieces of the puzzle: * adding a method for encoding Ident for re-reading into token tree. * Support for reading such encoded Idents in the lexer. Note that one must peek ahead for MOD_SEP after scan_embedded_hygienic_ident. * To ensure that encoded Idents are only read when we are in the midst of expanding a `quote_expr` or similar, added a `read_embedded_ident` flag on `StringReader`. * pprust support for encoding Ident's as (uint,uint) pairs (for hygiene).
2014-08-05Fixes missing overflow lint for i64 #14269Falco Hirschenberger-4/+5
The `type_overflow` lint, doesn't catch the overflow for `i64` because the overflow happens earlier in the parse phase when the `u64` as biggest possible int gets casted to `i64` , without checking the for overflows. We can't lint in the parse phase, so a refactoring of the `LitInt` type was necessary. The types `LitInt`, `LitUint` and `LitIntUnsuffixed` where merged to one type `LitInt` which stores it's value as `u64`. An additional parameter was added which indicate the signedness of the type and the sign of the value.
2014-07-29syntax: add support for quoting armsErick Tryzelaar-0/+8
2014-07-29Fix a bug pretty printing `match { 5i } { _ => { } }`Erick Tryzelaar-0/+2
This also always puts a trailing comma on the last non-block expr.
2014-07-29syntax: allow quasiquoter to inline `Vec<Stmt>`sErick Tryzelaar-0/+2
2014-07-17syntax: Add ToTokens impl for MethodBen Gamari-0/+2
2014-07-17syntax: Add quote_method!Ben Gamari-0/+10
2014-07-16syntax: Generalize ToTokens impl for Vec<T>Ben Gamari-3/+4
It will now `flat_map` over the elements of a `Vec<T>` if `T: ToTokens`
2014-07-16syntax: Add ToTokens for Attribute_Ben Gamari-0/+7
2014-07-16syntax: Add ToTokens for Option<T>Ben Gamari-0/+9
2014-07-09ast: make Name its own typeCorey Richardson-7/+16
2014-07-09syntax: don't parse numeric literals in the lexerCorey Richardson-36/+5
This removes a bunch of token types. Tokens now store the original, unaltered numeric literal (that is still checked for correctness), which is parsed into an actual number later, as needed, when creating the AST. This can change how syntax extensions work, but otherwise poses no visible changes. [breaking-change]
2014-07-09syntax: don't process string/char/byte/binary litsCorey Richardson-2/+2
This shuffles things around a bit so that LIT_CHAR and co store an Ident which is the original, unaltered literal in the source. When creating the AST, unescape and postprocess them. This changes how syntax extensions can work, slightly, but otherwise poses no visible changes. To get a useful value out of one of these tokens, call `parse::{char_lit, byte_lit, bin_lit, str_lit}` [breaking-change]
2014-07-08std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.Richo Healey-12/+12
[breaking-change]
2014-07-03Simplify creating a parser from a token treePiotr Jawniak-6/+1
Closes #15306
2014-06-25auto merge of #15160 : alexcrichton/rust/remove-f128, r=brsonbors-1/+0
The f128 type has very little support in the compiler and the feature is basically unusable today. Supporting half-baked features in the compiler can be detrimental to the long-term development of the compiler, and hence this feature is being removed.
2014-06-24Allow splicing more things in quotesKeegan McAllister-0/+16
2014-06-24Use macros to implement syntax::ext::quote::ToSourceKeegan McAllister-125/+74
This code deserves a bigger refactor, but here's a local improvement.
2014-06-24Remove the quad_precision_float feature gateAlex Crichton-1/+0
The f128 type has very little support in the compiler and the feature is basically unusable today. Supporting half-baked features in the compiler can be detrimental to the long-term development of the compiler, and hence this feature is being removed.
2014-06-17Add a b'x' byte literal of type u8.Simon Sapin-0/+6
2014-06-14Register new snapshotsAlex Crichton-9/+0
2014-06-13syntax: parse outer attributes in `quote_item!` calls.Huon Wilson-3/+2
Fixes #14857.
2014-06-13syntax: fix quote_pat! & unignore a quotation test.Huon Wilson-3/+1
2014-06-11rustc: Move the AST from @T to Gc<T>Alex Crichton-2/+2
2014-06-11syntax: Move the AST from @T to Gc<T>Alex Crichton-24/+28
2014-06-07Implement ToSource and ToToken for ast::ArgHanno Braun-0/+7
This makes ast::Arg usable in the quote_ macros. Please note that this commit doesn't include a regression test. There are tests that use the quote macros, but all of them are ignored. Due to that, there is no obvious (to me) way to test this. Since this change is absolutely trivial and only hooks up an additional type to existing infrastructure (which presumably is tested elsewhere), I concluded it's not worth the effort to follow up on this.
2014-06-04syntax: Make quasiquoter use absolute pathsklutzy-69/+54
As part of removing `pub use` glob, two extra import globs were injected to make `quote_expr!` work. However the globs caused `unused_import` warning in some places. Quasiquoter needed the globs since it generated idents (e.g. `TyU`) rather than absolute paths (`::syntax::ast::TyU`). This patch removes the extra globs and makes quasiquoter use absolute paths. Fixes #14618
2014-06-02syntax: Remove use of `pub use` globsklutzy-8/+20
`quote_expr!` now injects two more (priv) `use` globs. This may cause extra unused_imports warning.