...
 
Commits (3)
......@@ -17,5 +17,7 @@ license = "MIT"
name = "binder"
[dependencies]
syntex_syntax = "0.32.0"
syntex_syntax = "0.42.0"
syntex_errors = "0.42.0"
syntex_pos = "0.42.0"
toml = "0.1.30"
......@@ -56,16 +56,15 @@ impl Default for Session {
fn default() -> Session {
use std::rc::Rc;
use syntax::codemap::CodeMap;
use syntax::errors::emitter::EmitterWriter;
use syntax::errors::Handler;
use errors::emitter::EmitterWriter;
use errors::Handler;
use syntax::parse::ParseSess;
let error_buffer = ErrorBuffer::default();
let code_map = Rc::new(CodeMap::new());
let emitter = Box::new(EmitterWriter::new(
Box::new(error_buffer.clone()),
None,
code_map.clone(),
Some(code_map.clone()),
));
let syntax_session = ParseSess::with_span_handler(
Handler::with_emitter(true, false, emitter),
......@@ -93,8 +92,10 @@ impl Session {
pub fn bug(&self, msg: &str) -> Stop {
// `Handler.bug` panics so we need to do it manually.
self.syntax_session.span_diagnostic.emit(None, msg, syntax::errors::Level::Bug);
self.syntax_session.span_diagnostic.bump_err_count();
self.syntax_session
.span_diagnostic
.emit(&::syntex_pos::MultiSpan::new(), msg, ::errors::Level::Bug);
self.syntax_session.span_diagnostic.bump_err_count();
Stop::Fail
}
......
......@@ -12,12 +12,20 @@ pub mod ast {
pub use syntax::ast::BareFnTy;
pub use syntax::ast::FnDecl;
pub use syntax::ast::FunctionRetTy;
pub use syntax::ast::Ident;
pub use syntax::ast::Item;
pub use syntax::ast::ItemKind;
pub use syntax::ast::Mod;
pub use syntax::ast::Mutability;
pub use syntax::ast::MutTy;
pub use syntax::ast::Path;
pub use syntax::ast::PathSegment;
pub use syntax::ast::PathListItemKind;
pub use syntax::ast::Ty;
pub use syntax::ast::TyKind;
pub use syntax::ast::StructField;
pub use syntax::ast::Crate;
pub use syntax::ast::ViewPath_;
}
pub mod codemap {
......@@ -25,3 +33,13 @@ pub mod codemap {
pub use syntax::codemap::Span;
pub use syntax::codemap::spanned;
}
pub mod parse {
pub use syntax::parse::new_parser_from_source_str;
pub use syntax::parse::ParseSess;
pub use syntax::parse::token;
}
pub mod print {
pub use syntax::print::pprust;
}
......@@ -18,6 +18,10 @@ pub use syntax::print::pprust::variant_to_string;
/// The comment characters (`///`, `/**`, or `*/`) and any remaining spaces are stripped from the
/// left- and right- sides of the lines before prepending `prepend` and appending `append` to each
/// line.
///
/// # Note
///
/// This currently only works with `///`-style doc comments.
pub fn docs_from_attrs(attrs: &[ast::Attribute], prepend: &str, append: &str) -> String {
let mut buffer = String::new();
......@@ -25,12 +29,15 @@ pub fn docs_from_attrs(attrs: &[ast::Attribute], prepend: &str, append: &str) ->
match attr.node.value.node {
ast::MetaItemKind::NameValue(ref name, ref val) if *name == "doc" => match val.node {
// Docstring attributes omit the trailing newline.
ast::LitKind::Str(ref docs, _) => buffer.push_str(&format!(
ast::LitKind::Str(ref docs, _) => {
let docs = &docs[3..];
buffer.push_str(&format!(
"{}{}{}\n",
prepend,
docs.trim(),
append,
)),
))
},
_ => unreachable!("docs must be literal strings"),
},
_ => {},
......
......@@ -51,6 +51,8 @@
//! available in `my_bindings/ruby` (or locations similar to that).
extern crate syntex_syntax as syntax;
extern crate syntex_errors as errors;
extern crate syntex_pos;
extern crate toml;
pub mod compiler;
......