diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-08 12:59:59 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-16 10:59:54 +0200 |
| commit | bf02d49e848e331ba8bf3d14e3b3443bc68ab7f3 (patch) | |
| tree | 5650df816441c05dd0416fcd347957f851d6f0af /src/libsyntax/parse/parser.rs | |
| parent | d420d719c4c44c3c6d02b5fafba4f2cf5e837dba (diff) | |
| download | rust-bf02d49e848e331ba8bf3d14e3b3443bc68ab7f3.tar.gz rust-bf02d49e848e331ba8bf3d14e3b3443bc68ab7f3.zip | |
move SeqSep to parser.rs
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 64ec943294a..79901177d18 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -15,7 +15,7 @@ use crate::ast::{ self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Ident, IsAsync, MacDelimiter, Mutability, StrStyle, Visibility, VisibilityKind, Unsafety, }; -use crate::parse::{PResult, Directory, DirectoryOwnership, SeqSep}; +use crate::parse::{PResult, Directory, DirectoryOwnership}; use crate::parse::lexer::UnmatchedBrace; use crate::parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration}; use crate::parse::token::{self, Token, TokenKind, DelimToken}; @@ -329,6 +329,30 @@ enum TokenExpectType { NoExpect, } +/// A sequence separator. +struct SeqSep { + /// The separator token. + sep: Option<TokenKind>, + /// `true` if a trailing separator is allowed. + trailing_sep_allowed: bool, +} + +impl SeqSep { + fn trailing_allowed(t: TokenKind) -> SeqSep { + SeqSep { + sep: Some(t), + trailing_sep_allowed: true, + } + } + + fn none() -> SeqSep { + SeqSep { + sep: None, + trailing_sep_allowed: false, + } + } +} + impl<'a> Parser<'a> { pub fn new( sess: &'a ParseSess, |
