about summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
AgeCommit message (Collapse)AuthorLines
2014-02-02libsyntax: De-`@str` `MacroDef`Patrick Walton-1/+1
2014-02-02librustc: De-`@str` `NameAndSpan`Patrick Walton-1/+2
2014-02-02librustc: Fix merge fallout.Patrick Walton-6/+4
2014-02-02libsyntax: De-`@str` `get_single_str_from_tts`Patrick Walton-2/+4
2014-02-02libsyntax: De-`@str` literal strings in the ASTPatrick Walton-5/+7
2014-01-25Simplify and rename macro APISteven Fackler-82/+52
Now that procedural macros can be implemented outside of the compiler, it's more important to have a reasonable API to work with. Here are the basic changes: * Rename SyntaxExpanderTTTrait to MacroExpander, SyntaxExpanderTT to BasicMacroExpander, etc. I think "procedural macro" is the right term for these now, right? The other option would be SynExtExpander or something like that. * Stop passing the SyntaxContext to extensions. This was only ever used by macro_rules, which doesn't even use it anymore. I can't think of a context in which an external extension would need it, and removal allows the API to be significantly simpler - no more SyntaxExpanderTTItemExpanderWithoutContext wrappers to worry about.
2014-01-24auto merge of #11720 : sfackler/rust/macro-export-source, r=alexcrichtonbors-1/+1
The old method of serializing the AST gives totally bogus spans if the expansion of an imported macro causes compilation errors. The best solution seems to be to serialize the actual textual macro definition and load it the same way the std-macros are. I'm not totally confident that getting the source from the CodeMap will always do the right thing, but it seems to work in simple cases.
2014-01-23Update flip() to be rev().Sean Chalmers-2/+2
Consensus leaned in favour of using rev instead of flip.
2014-01-23Rename Invert to Flip - Issue 10632Sean Chalmers-2/+2
Renamed the invert() function in iter.rs to flip(). Also renamed the Invert<T> type to Flip<T>. Some related code comments changed. Documentation that I could find has been updated, and all the instances I could locate where the function/type were called have been updated as well.
2014-01-23Redo exported macro serializationSteven Fackler-1/+1
The old method of serializing the AST gives totally bogus spans if the expansion of an imported macro causes compilation errors. The best solution seems to be to serialize the actual textual macro definition and load it the same way the std-macros are. I'm not totally confident that getting the source from the CodeMap will always do the right thing, but it seems to work in simple cases.
2014-01-21[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behaviorSimon Sapin-1/+1
2014-01-20auto merge of #11670 : sfackler/rust/extctxt-span-note, r=alexcrichtonbors-0/+4
It was the only span_* missing.
2014-01-19Add span_note to ExtCtxtSteven Fackler-0/+4
It was the only span_* missing.
2014-01-18syntax::ext: replace span_fatal with span_err in many places.Huon Wilson-16/+60
This means that compilation continues for longer, and so we can see more errors per compile. This is mildly more user-friendly because it stops users having to run rustc n times to see n macro errors: just run it once to see all of them.
2014-01-16Load macros from external modulesSteven Fackler-62/+49
2014-01-13librustc: Remove `@` pointer patterns from the languagePatrick Walton-5/+2
2014-01-09libsyntax: Renamed types, traits and enum variants to CamelCase.Eduard Burtescu-22/+22
2014-01-05Use ~-objects instead of @-objects for syntax extsSteven Fackler-6/+6
This is necessary for #11151 to make sure dtors run before the libraries are unloaded.
2014-01-03librustc: De-`@mut` the parse sessionPatrick Walton-3/+3
2014-01-03auto merge of #11228 : sfackler/rust/syntaxenv, r=pcwaltonbors-178/+88
I'd really like to be able to do something like ```rust struct MapChain<'next, K, V> { info: BlockInfo, map: HashMap<K, V>, next: Option<&'next mut MapChain<'next, K, V> } ``` but I can't get the lifetimes to work out.
2014-01-02libsyntax: De-`@mut` `token` in the parserPatrick Walton-1/+1
2014-01-02libsyntax: Make the parser mutablePatrick Walton-3/+3
2014-01-01syntax::diagnostic: Remove unnecessary traitsklutzy-1/+0
This removes trait `handler` and `span_handler`, and renames `HandlerT` to `Handler`, `CodemapT` to `SpanHandler`.
2013-12-30Rewrite SyntaxEnvSteven Fackler-178/+88
I'd really like to be able to do something like struct MapChain<'next, K, V> { info: BlockInfo, map: HashMap<K, V>, next: Option<&'next mut MapChain<'next, K, V> } but I can't get the lifetimes to work out.
2013-12-29Remove @muts from ExtCtxtSteven Fackler-20/+20
2013-12-29Start passing around &mut ExtCtxtSteven Fackler-8/+8
2013-12-29Make ast_fold take &mut selfSteven Fackler-2/+2
2013-12-28Stop passing duplicate parameters in expandSteven Fackler-3/+2
2013-12-28Remove unecessary extern "Rust" specifiersSteven Fackler-17/+8
2013-12-28Stop using @ExtCtxtSteven Fackler-15/+15
2013-12-11Make 'self lifetime illegal.Erik Price-1/+1
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-08Remove dead codesKiet Tran-9/+1
2013-11-28Register new snapshotsAlex Crichton-3/+3
2013-11-26Support multiple item macrosSteven Fackler-1/+2
Closes #4375
2013-11-26rustc: Add lint for obsolete attributesklutzy-7/+1
This also moves `#[auto_{en,de}code]` checker from syntax to lint.
2013-11-19libsyntax: Change all uses of `&fn` to `||`.Patrick Walton-8/+15
2013-10-31Implement a concat!() format extensionAlex Crichton-0/+20
This extension can be used to concatenate string literals at compile time. C has this useful ability when placing string literals lexically next to one another, but this needs to be handled at the syntax extension level to recursively expand macros. The major use case for this is something like: macro_rules! mylog( ($fmt:expr $($arg:tt)*) => { error2!(concat!(file!(), ":", line!(), " - ", $fmt) $($arg)*); }) Where the mylog macro will automatically prepend the filename/line number to the beginning of every log message.
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-3/+3
Who doesn't like a massive renaming?
2013-10-18Remove the fmt! syntax extensionAlex Crichton-1/+1
It lived a good life, but its time has come. The groundwork is set for the official transition after the next snapshot (removal of XXX2 macros)
2013-10-09option: rewrite the API to use compositionDaniel Micay-1/+1
2013-10-08add new enum ast::StrStyle as field to ast::lit_strBenjamin Herr-2/+2
For the benefit of the pretty printer we want to keep track of how string literals in the ast were originally represented in the source code. This commit changes parser functions so they don't extract strings from the token stream without at least also returning what style of string literal it was. This is stored in the resulting ast node for string literals, obviously, for the package id in `extern mod = r"package id"` view items, for the inline asm in `asm!()` invocations. For `asm!()`'s other arguments or for `extern "Rust" fn()` items, I just the style of string, because it seemed disproportionally cumbersome to thread that information through the string processing that happens with those string literals, given the limited advantage raw string literals would provide in these positions. The other syntax extensions don't seem to store passed string literals in the ast, so they also discard the style of strings they parse.
2013-10-08add token::LIT_STR_RAW(ident, num of # symbols)Benjamin Herr-1/+2
Treat it as a synonym for LIT_STR for now.
2013-09-30syntax: Remove usage of fmt!Alex Crichton-6/+6
2013-09-30Prevent leakage of fmt! into the compilerAlex Crichton-1/+1
We're not outright removing fmt! just yet, but this prevents it from leaking into the compiler further (it's still turned on by default for all other code).
2013-09-23test: Fix rustdoc and tests.Patrick Walton-1/+2
2013-09-23libsyntax: Remove some more `@fn`s from the macro expanderPatrick Walton-79/+159
2013-09-15Reduce the amount of complexity in format!Alex Crichton-7/+1
This renames the syntax-extension file to format from ifmt, and it also reduces the amount of complexity inside by defining all other macros in terms of format_args!
2013-09-12Implement a format_args!() macroAlex Crichton-0/+2
The purpose of this macro is to further reduce the number of allocations which occur when dealing with formatting strings. This macro will perform all of the static analysis necessary to validate that a format string is safe, and then it will wrap up the "format string" into an opaque struct which can then be passed around. Two safe functions are added (write/format) which take this opaque argument structure, unwrap it, and then call the unsafe version of write/format (in an unsafe block). Other than these two functions, it is not intended for anyone to ever look inside this opaque struct. The macro looks a bit odd, but mostly because of rvalue lifetimes this is the only way for it to be safe that I know of. Example use-cases of this are: * third-party libraries can use the default formatting syntax without any forced allocations * the fail!() macro can avoid allocating the format string * the logging macros can avoid allocation any strings
2013-09-10Delay assignment of node ids until after expansion. Ensures that each AST nodeNiko Matsakis-3/+0
has a unique id. Fixes numerous bugs in macro expansion and deriving. Add two representative tests. Fixes #7971 Fixes #6304 Fixes #8367 Fixes #8754 Fixes #8852 Fixes #2543 Fixes #7654
2013-09-06quote_* macros no longer need to be capturingJohn Clements-6/+7
This is actually almost a problem, because those were my poster-child macros for "here's how to implement a capturing macro." Following this change, there will be no macros that use capturing; this will probably make life unpleasant for the first person that wants to implement a capturing macro. I should probably create a dummy_capturing macro, just to show how it works.