2012-12-03 16:48:01 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-04-27 22:05:41 -04:00
|
|
|
//! Common routines shared by parser mods
|
|
|
|
|
2012-12-23 17:41:37 -05:00
|
|
|
use parse::token;
|
|
|
|
|
2014-06-09 13:12:30 -07:00
|
|
|
/// SeqSep : a sequence separator (token)
|
|
|
|
/// and whether a trailing separator is allowed.
|
2013-02-21 00:16:31 -08:00
|
|
|
pub struct SeqSep {
|
2014-03-27 15:39:48 -07:00
|
|
|
pub sep: Option<token::Token>,
|
|
|
|
pub trailing_sep_allowed: bool
|
2013-02-21 00:16:31 -08:00
|
|
|
}
|
2012-05-24 12:38:45 -07:00
|
|
|
|
2013-04-17 12:15:08 -04:00
|
|
|
pub fn seq_sep_trailing_allowed(t: token::Token) -> SeqSep {
|
2013-02-21 00:16:31 -08:00
|
|
|
SeqSep {
|
2013-02-24 15:41:54 -08:00
|
|
|
sep: Some(t),
|
|
|
|
trailing_sep_allowed: true,
|
2013-02-21 00:16:31 -08:00
|
|
|
}
|
2012-05-24 12:38:45 -07:00
|
|
|
}
|
2014-11-30 17:39:50 +13:00
|
|
|
|
2013-02-21 00:16:31 -08:00
|
|
|
pub fn seq_sep_none() -> SeqSep {
|
|
|
|
SeqSep {
|
2013-02-24 15:41:54 -08:00
|
|
|
sep: None,
|
|
|
|
trailing_sep_allowed: false,
|
2013-02-21 00:16:31 -08:00
|
|
|
}
|
2012-05-24 12:38:45 -07:00
|
|
|
}
|