Skip to content

Commit de00131

Browse files
authored
parser: Remove the line-number-offset mechanism. (#355)
It can be implemented on top of the parser anyways, and after bug 1847440 we won't use it anymore.
1 parent 0dd3140 commit de00131

File tree

3 files changed

+2
-62
lines changed

3 files changed

+2
-62
lines changed

src/parser.rs

-9
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,6 @@ impl<'i> ParserInput<'i> {
213213
}
214214
}
215215

216-
/// Create a new input for a parser. Line numbers in locations
217-
/// are offset by the given value.
218-
pub fn new_with_line_number_offset(input: &'i str, first_line_number: u32) -> ParserInput<'i> {
219-
ParserInput {
220-
tokenizer: Tokenizer::with_first_line_number(input, first_line_number),
221-
cached_token: None,
222-
}
223-
}
224-
225216
#[inline]
226217
fn cached_token_ref(&self) -> &Token<'i> {
227218
&self.cached_token.as_ref().unwrap().token

src/tests.rs

-46
Original file line numberDiff line numberDiff line change
@@ -1288,52 +1288,6 @@ fn parser_maintains_current_line() {
12881288
assert_eq!(parser.current_line(), "ident");
12891289
}
12901290

1291-
#[test]
1292-
fn parser_with_line_number_offset() {
1293-
let mut input = ParserInput::new_with_line_number_offset("ident\nident", 72);
1294-
let mut parser = Parser::new(&mut input);
1295-
assert_eq!(
1296-
parser.current_source_location(),
1297-
SourceLocation {
1298-
line: 72,
1299-
column: 1
1300-
}
1301-
);
1302-
assert_eq!(
1303-
parser.next_including_whitespace_and_comments(),
1304-
Ok(&Token::Ident("ident".into()))
1305-
);
1306-
assert_eq!(
1307-
parser.current_source_location(),
1308-
SourceLocation {
1309-
line: 72,
1310-
column: 6
1311-
}
1312-
);
1313-
assert_eq!(
1314-
parser.next_including_whitespace_and_comments(),
1315-
Ok(&Token::WhiteSpace("\n".into()))
1316-
);
1317-
assert_eq!(
1318-
parser.current_source_location(),
1319-
SourceLocation {
1320-
line: 73,
1321-
column: 1
1322-
}
1323-
);
1324-
assert_eq!(
1325-
parser.next_including_whitespace_and_comments(),
1326-
Ok(&Token::Ident("ident".into()))
1327-
);
1328-
assert_eq!(
1329-
parser.current_source_location(),
1330-
SourceLocation {
1331-
line: 73,
1332-
column: 6
1333-
}
1334-
);
1335-
}
1336-
13371291
#[test]
13381292
fn cdc_regression_test() {
13391293
let mut input = ParserInput::new("-->x");

src/tokenizer.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,11 @@ enum SeenStatus {
230230
impl<'a> Tokenizer<'a> {
231231
#[inline]
232232
pub fn new(input: &str) -> Tokenizer {
233-
Tokenizer::with_first_line_number(input, 0)
234-
}
235-
236-
#[inline]
237-
pub fn with_first_line_number(input: &str, first_line_number: u32) -> Tokenizer {
238233
Tokenizer {
239234
input,
240235
position: 0,
241236
current_line_start_position: 0,
242-
current_line_number: first_line_number,
237+
current_line_number: 0,
243238
var_or_env_functions: SeenStatus::DontCare,
244239
source_map_url: None,
245240
source_url: None,
@@ -541,7 +536,7 @@ impl SourcePosition {
541536
/// The line and column number for a given position within the input.
542537
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
543538
pub struct SourceLocation {
544-
/// The line number, starting at 0 for the first line, unless `with_first_line_number` was used.
539+
/// The line number, starting at 0 for the first line.
545540
pub line: u32,
546541

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

0 commit comments

Comments
 (0)