Skip to content

Commit bf02d49

Browse files
committed
move SeqSep to parser.rs
1 parent d420d71 commit bf02d49

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::ast;
44
use crate::parse::parser::{Parser, emit_unclosed_delims};
5-
use crate::parse::token::{Nonterminal, TokenKind};
5+
use crate::parse::token::Nonterminal;
66
use crate::tokenstream::{self, TokenStream, TokenTree};
77
use crate::print::pprust;
88
use crate::sess::ParseSess;
@@ -271,30 +271,6 @@ pub fn stream_to_parser_with_base_dir<'a>(
271271
Parser::new(sess, stream, Some(base_dir), true, false, None)
272272
}
273273

274-
/// A sequence separator.
275-
pub struct SeqSep {
276-
/// The separator token.
277-
pub sep: Option<TokenKind>,
278-
/// `true` if a trailing separator is allowed.
279-
pub trailing_sep_allowed: bool,
280-
}
281-
282-
impl SeqSep {
283-
pub fn trailing_allowed(t: TokenKind) -> SeqSep {
284-
SeqSep {
285-
sep: Some(t),
286-
trailing_sep_allowed: true,
287-
}
288-
}
289-
290-
pub fn none() -> SeqSep {
291-
SeqSep {
292-
sep: None,
293-
trailing_sep_allowed: false,
294-
}
295-
}
296-
}
297-
298274
// NOTE(Centril): The following probably shouldn't be here but it acknowledges the
299275
// fact that architecturally, we are using parsing (read on below to understand why).
300276

src/libsyntax/parse/parser.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::ast::{
1515
self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Ident,
1616
IsAsync, MacDelimiter, Mutability, StrStyle, Visibility, VisibilityKind, Unsafety,
1717
};
18-
use crate::parse::{PResult, Directory, DirectoryOwnership, SeqSep};
18+
use crate::parse::{PResult, Directory, DirectoryOwnership};
1919
use crate::parse::lexer::UnmatchedBrace;
2020
use crate::parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
2121
use crate::parse::token::{self, Token, TokenKind, DelimToken};
@@ -329,6 +329,30 @@ enum TokenExpectType {
329329
NoExpect,
330330
}
331331

332+
/// A sequence separator.
333+
struct SeqSep {
334+
/// The separator token.
335+
sep: Option<TokenKind>,
336+
/// `true` if a trailing separator is allowed.
337+
trailing_sep_allowed: bool,
338+
}
339+
340+
impl SeqSep {
341+
fn trailing_allowed(t: TokenKind) -> SeqSep {
342+
SeqSep {
343+
sep: Some(t),
344+
trailing_sep_allowed: true,
345+
}
346+
}
347+
348+
fn none() -> SeqSep {
349+
SeqSep {
350+
sep: None,
351+
trailing_sep_allowed: false,
352+
}
353+
}
354+
}
355+
332356
impl<'a> Parser<'a> {
333357
pub fn new(
334358
sess: &'a ParseSess,

src/libsyntax/parse/parser/attr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
use super::{SeqSep, PResult, Parser, TokenType, PathStyle};
12
use crate::attr;
23
use crate::ast;
3-
use crate::parse::{SeqSep, PResult};
44
use crate::parse::token::{self, Nonterminal, DelimToken};
5-
use crate::parse::parser::{Parser, TokenType, PathStyle};
65
use crate::tokenstream::{TokenStream, TokenTree};
76
use crate::source_map::Span;
87

src/libsyntax/parse/parser/diagnostics.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
use super::{
2+
BlockMode, PathStyle, SemiColonMode, TokenType, TokenExpectType,
3+
SeqSep, PResult, Parser
4+
};
15
use crate::ast::{
26
self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item, ItemKind,
37
Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind,
48
};
5-
use crate::parse::{SeqSep, PResult, Parser};
6-
use crate::parse::parser::{BlockMode, PathStyle, SemiColonMode, TokenType, TokenExpectType};
79
use crate::parse::token::{self, TokenKind};
810
use crate::print::pprust;
911
use crate::ptr::P;

0 commit comments

Comments
 (0)