Skip to content

Commit 8ba1325

Browse files
committed
Convert some more code to make use of ParserState::EOF and UnexpectedEOFException
1 parent 8b62f7f commit 8ba1325

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

lib/Sabberworm/CSS/CSSList/CSSList.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,12 @@ private static function parseAtRule(ParserState $oParserState) {
114114
if (!$oParserState->comes(';')) {
115115
$sMediaQuery = trim($oParserState->consumeUntil(array(';', ParserState::EOF)));
116116
}
117-
if (!$oParserState->isEnd()) {
118-
$oParserState->consume(';');
119-
}
117+
$oParserState->consumeUntil(array(';', ParserState::EOF), true, true);
120118
return new Import($oLocation, $sMediaQuery, $iIdentifierLineNum);
121119
} else if ($sIdentifier === 'charset') {
122120
$sCharset = CSSString::parse($oParserState);
123121
$oParserState->consumeWhiteSpace();
124-
if (!$oParserState->isEnd()) {
125-
$oParserState->consume(';');
126-
}
122+
$oParserState->consumeUntil(array(';', ParserState::EOF), true, true);
127123
return new Charset($sCharset, $iIdentifierLineNum);
128124
} else if (self::identifierIs($sIdentifier, 'keyframes')) {
129125
$oResult = new KeyFrame($iIdentifierLineNum);
@@ -141,9 +137,7 @@ private static function parseAtRule(ParserState $oParserState) {
141137
$sPrefix = $mUrl;
142138
$mUrl = Value::parsePrimitiveValue($oParserState);
143139
}
144-
if (!$oParserState->isEnd()) {
145-
$oParserState->consume(';');
146-
}
140+
$oParserState->consumeUntil(array(';', ParserState::EOF), true, true);
147141
if ($sPrefix !== null && !is_string($sPrefix)) {
148142
throw new UnexpectedTokenException('Wrong namespace prefix', $sPrefix, 'custom', $iIdentifierLineNum);
149143
}

lib/Sabberworm/CSS/Parsing/ParserState.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false, a
237237
}
238238

239239
$this->iCurrentPosition = $start;
240-
throw new UnexpectedTokenException('One of ("'.implode('","', $aEnd).'")', $this->peek(5), 'search', $this->iLineNo);
240+
throw new UnexpectedEOFException('One of ("'.implode('","', $aEnd).'")', $this->peek(5), 'search', $this->iLineNo);
241241
}
242242

243243
private function inputLeft() {

0 commit comments

Comments
 (0)