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
8 changes: 4 additions & 4 deletions src/parse-anplusb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ANplusBParser {
}

// Get first token
this.lexer.next_token_fast(true)
this.lexer.next_token(true)

// Handle special keywords: odd, even
if (this.lexer.token_type === TOKEN_IDENT) {
Expand Down Expand Up @@ -153,7 +153,7 @@ export class ANplusBParser {
) {
// Look ahead for 'n'
const saved = this.lexer.save_position()
this.lexer.next_token_fast(true)
this.lexer.next_token(true)

if ((this.lexer.token_type as TokenType) === TOKEN_IDENT) {
const text = this.source.substring(this.lexer.token_start, this.lexer.token_end)
Expand Down Expand Up @@ -249,7 +249,7 @@ export class ANplusBParser {
return null
}

this.lexer.next_token_fast(true)
this.lexer.next_token(true)

// Check for + or - delim
if (this.lexer.token_type === TOKEN_DELIM) {
Expand All @@ -259,7 +259,7 @@ export class ANplusBParser {
const sign = ch === CHAR_MINUS_HYPHEN ? '-' : ''
this.skip_whitespace()

this.lexer.next_token_fast(true)
this.lexer.next_token(true)

if ((this.lexer.token_type as TokenType) === TOKEN_NUMBER) {
let num_text = this.source.substring(this.lexer.token_start, this.lexer.token_end)
Expand Down
2 changes: 1 addition & 1 deletion src/parse-atrule-prelude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ export class AtRulePreludeParser {
this.lexer.token_type = TOKEN_EOF
return TOKEN_EOF
}
return this.lexer.next_token_fast(false)
return this.lexer.next_token(false)
}

// Parse @namespace prelude: [prefix] url("...") | "..."
Expand Down
2 changes: 1 addition & 1 deletion src/parse-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class ConditionParser {
this.lexer.token_type = TOKEN_EOF
return TOKEN_EOF
}
return this.lexer.next_token_fast(false)
return this.lexer.next_token(false)
}

// Scan tokens from just after an already-open '(' or function-call (depth 1) to its
Expand Down
20 changes: 10 additions & 10 deletions src/parse-declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class DeclarationParser {
// Create a fresh lexer instance for standalone parsing
const lexer = new Lexer(this.source)
lexer.seek(start, line, column)
lexer.next_token_fast(true) // skip whitespace like Parser does
lexer.next_token(true) // skip whitespace like Parser does

return this.parse_declaration_with_lexer(lexer, end)
}
Expand Down Expand Up @@ -116,7 +116,7 @@ export class DeclarationParser {
browser_hack_line = lexer.token_line
browser_hack_column = lexer.token_column

lexer.next_token_fast(true) // skip whitespace
lexer.next_token(true) // skip whitespace

if ((lexer.token_type as TokenType) === TOKEN_IDENT) {
has_browser_hack = true
Expand Down Expand Up @@ -145,7 +145,7 @@ export class DeclarationParser {
// Lookahead: save lexer state before consuming
const saved = lexer.save_position_into(this.lookahead_position)

lexer.next_token_fast(true) // consume property name, skip whitespace
lexer.next_token(true) // consume property name, skip whitespace

// Expect ':' (type assertion needed because TS doesn't know next_token mutates token_type)
if ((lexer.token_type as TokenType) !== TOKEN_COLON) {
Expand Down Expand Up @@ -207,7 +207,7 @@ export class DeclarationParser {
if (stop_ch === CHAR_SEMICOLON && paren_depth === 0) {
value_end = skip_whitespace_and_comments_backward(this.source, lexer.pos, value_start)
// Tokenize ';' so token_type reflects it, matching what the old loop left behind.
lexer.next_token_fast(false)
lexer.next_token(false)
break
}

Expand All @@ -224,7 +224,7 @@ export class DeclarationParser {
}
// Tokenize '}' (without consuming it) so peek_type() sees it - the enclosing
// block's own loop needs to see '}' to know it's done.
lexer.next_token_fast(false)
lexer.next_token(false)
break
}

Expand All @@ -239,16 +239,16 @@ export class DeclarationParser {
value_end = lexer.pos
lexer.pos++ // consume '!'
// Check if next token is an identifier (doesn't verify it's literally "important")
const next_type = lexer.next_token_fast(true) // skip whitespace
const next_type = lexer.next_token(true) // skip whitespace
if (next_type === TOKEN_IDENT) {
has_important = true
last_end = lexer.token_end
lexer.next_token_fast(true) // Advance to next token after "important", skip whitespace
lexer.next_token(true) // Advance to next token after "important", skip whitespace
break
}
// '!' wasn't followed by an identifier - treat the already-peeked token as
// ordinary content; lexer.pos is already past it, so the raw scan picks up
// naturally (an extra next_token_fast here would swallow e.g. a trailing '}').
// naturally (an extra next_token here would swallow e.g. a trailing '}').
last_end = lexer.token_end
value_end = last_end
continue
Expand All @@ -258,7 +258,7 @@ export class DeclarationParser {
// Ran out of input before finding any of the above
last_end = skip_whitespace_and_comments_backward(this.source, lexer.pos, value_start)
value_end = last_end
lexer.next_token_fast(false) // tokenize EOF so token_type reflects it
lexer.next_token(false) // tokenize EOF so token_type reflects it
break
}

Expand Down Expand Up @@ -327,7 +327,7 @@ export class DeclarationParser {
// Consume ';' if present
if ((lexer.token_type as TokenType) === TOKEN_SEMICOLON) {
last_end = lexer.token_end
lexer.next_token_fast(true) // skip whitespace
lexer.next_token(true) // skip whitespace
}

// Set declaration length
Expand Down
20 changes: 10 additions & 10 deletions src/parse-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class SelectorParser {
if (this.lexer.pos >= this.selector_end) break

// Check for comma (comments are auto-skipped by lexer)
this.lexer.next_token_fast(false)
this.lexer.next_token(false)
const token_type: TokenType = this.lexer.token_type

if (token_type === TOKEN_COMMA) {
Expand Down Expand Up @@ -194,7 +194,7 @@ export class SelectorParser {
if (allow_relative && this.lexer.pos < this.selector_end) {
const saved = this.lexer.save_position()

this.lexer.next_token_fast(false)
this.lexer.next_token(false)
const token_type = this.lexer.token_type

// Check if token is a combinator
Expand Down Expand Up @@ -263,7 +263,7 @@ export class SelectorParser {
while (this.lexer.pos < this.selector_end) {
// Save lexer state before getting token
const saved = this.lexer.save_position()
this.lexer.next_token_fast(false)
this.lexer.next_token(false)

if (this.lexer.token_start >= this.selector_end) break

Expand Down Expand Up @@ -358,7 +358,7 @@ export class SelectorParser {
namespace_prefix_length: number,
): number | null {
const saved = this.lexer.save_position()
this.lexer.next_token_fast(false)
this.lexer.next_token(false)

let node_type: number
if (this.lexer.token_type === TOKEN_IDENT) {
Expand Down Expand Up @@ -471,7 +471,7 @@ export class SelectorParser {
return null
}

this.lexer.next_token_fast(false)
this.lexer.next_token(false)

// A comma ends the selector: whitespace before it separates selectors, it is not a
// descendant combinator (`a , b` is `a` and `b`, not `a<space>` and `b`)
Expand Down Expand Up @@ -516,7 +516,7 @@ export class SelectorParser {
const saved = this.lexer.save_position()

// Next token should be identifier
this.lexer.next_token_fast(false)
this.lexer.next_token(false)
if (this.lexer.token_type !== TOKEN_IDENT) {
// Restore lexer state and return null
this.lexer.restore_position(saved)
Expand All @@ -535,7 +535,7 @@ export class SelectorParser {

// Find matching ]
while (this.lexer.pos < this.selector_end && bracket_depth > 0) {
this.lexer.next_token_fast(false)
this.lexer.next_token(false)
const token_type = this.lexer.token_type
if (token_type === TOKEN_LEFT_BRACKET) {
bracket_depth++
Expand Down Expand Up @@ -707,7 +707,7 @@ export class SelectorParser {
}

// Next token should be identifier or function
this.lexer.next_token_fast(false)
this.lexer.next_token(false)

const token_type = this.lexer.token_type
if (token_type === TOKEN_IDENT) {
Expand Down Expand Up @@ -754,7 +754,7 @@ export class SelectorParser {
let end = this.lexer.token_end

while (this.lexer.pos < this.selector_end && paren_depth > 0) {
this.lexer.next_token_fast(false)
this.lexer.next_token(false)
const token_type = this.lexer.token_type
if (token_type === TOKEN_LEFT_PAREN || token_type === TOKEN_FUNCTION) {
paren_depth++
Expand Down Expand Up @@ -850,7 +850,7 @@ export class SelectorParser {
let last_child: number | null = null

while (this.lexer.pos < end) {
this.lexer.next_token_fast(false)
this.lexer.next_token(false)
const token_type = this.lexer.token_type
const token_start = this.lexer.token_start
const token_end = this.lexer.token_end
Expand Down
2 changes: 1 addition & 1 deletion src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class Parser {

// Advance to the next token, skipping whitespace
private next_token(): void {
this.lexer.next_token_fast(true)
this.lexer.next_token(true)
}

// Peek at current token type
Expand Down
Loading
Loading