Parse syn::File
diff --git a/src/attr.rs b/src/attr.rs
index 7b1cfa9..a925ecf 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -416,7 +416,7 @@
pub fn parse_inner(input: ParseStream) -> Result<Vec<Self>> {
let mut attrs = Vec::new();
- while input.peek(Token![#]) {
+ while input.peek(Token![#]) && input.peek2(Token![!]) {
attrs.push(input.parse_synom(Attribute::old_parse_inner)?);
}
Ok(attrs)
diff --git a/src/file.rs b/src/file.rs
index a3ce02b..d692f11 100644
--- a/src/file.rs
+++ b/src/file.rs
@@ -88,21 +88,21 @@
pub mod parsing {
use super::*;
- use synom::Synom;
+ use parse::{Parse, ParseStream, Result};
- impl Synom for File {
- named!(parse -> Self, do_parse!(
- attrs: many0!(Attribute::old_parse_inner) >>
- items: many0!(Item::parse) >>
- (File {
+ impl Parse for File {
+ fn parse(input: ParseStream) -> Result<Self> {
+ Ok(File {
shebang: None,
- attrs: attrs,
- items: items,
+ attrs: input.call(Attribute::parse_inner)?,
+ items: {
+ let mut items = Vec::new();
+ while !input.is_empty() {
+ items.push(input.parse_synom(Item::parse)?);
+ }
+ items
+ },
})
- ));
-
- fn description() -> Option<&'static str> {
- Some("crate")
}
}
}