Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,6 @@ impl<'i> ParserInput<'i> {
}
}

/// Create a new input for a parser. Line numbers in locations
/// are offset by the given value.
pub fn new_with_line_number_offset(input: &'i str, first_line_number: u32) -> ParserInput<'i> {
ParserInput {
tokenizer: Tokenizer::with_first_line_number(input, first_line_number),
cached_token: None,
}
}

#[inline]
fn cached_token_ref(&self) -> &Token<'i> {
&self.cached_token.as_ref().unwrap().token
Expand Down
46 changes: 0 additions & 46 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,52 +1288,6 @@ fn parser_maintains_current_line() {
assert_eq!(parser.current_line(), "ident");
}

#[test]
fn parser_with_line_number_offset() {
let mut input = ParserInput::new_with_line_number_offset("ident\nident", 72);
let mut parser = Parser::new(&mut input);
assert_eq!(
parser.current_source_location(),
SourceLocation {
line: 72,
column: 1
}
);
assert_eq!(
parser.next_including_whitespace_and_comments(),
Ok(&Token::Ident("ident".into()))
);
assert_eq!(
parser.current_source_location(),
SourceLocation {
line: 72,
column: 6
}
);
assert_eq!(
parser.next_including_whitespace_and_comments(),
Ok(&Token::WhiteSpace("\n".into()))
);
assert_eq!(
parser.current_source_location(),
SourceLocation {
line: 73,
column: 1
}
);
assert_eq!(
parser.next_including_whitespace_and_comments(),
Ok(&Token::Ident("ident".into()))
);
assert_eq!(
parser.current_source_location(),
SourceLocation {
line: 73,
column: 6
}
);
}

#[test]
fn cdc_regression_test() {
let mut input = ParserInput::new("-->x");
Expand Down
9 changes: 2 additions & 7 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,11 @@ enum SeenStatus {
impl<'a> Tokenizer<'a> {
#[inline]
pub fn new(input: &str) -> Tokenizer {
Tokenizer::with_first_line_number(input, 0)
}

#[inline]
pub fn with_first_line_number(input: &str, first_line_number: u32) -> Tokenizer {
Tokenizer {
input,
position: 0,
current_line_start_position: 0,
current_line_number: first_line_number,
current_line_number: 0,
var_or_env_functions: SeenStatus::DontCare,
source_map_url: None,
source_url: None,
Expand Down Expand Up @@ -541,7 +536,7 @@ impl SourcePosition {
/// The line and column number for a given position within the input.
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
pub struct SourceLocation {
/// The line number, starting at 0 for the first line, unless `with_first_line_number` was used.
/// The line number, starting at 0 for the first line.
pub line: u32,

/// The column number within a line, starting at 1 for first the character of the line.
Expand Down