Skip to content

Commit 093c527

Browse files
committed
Support arithmetic ops (+,-,*,/) in functions
1 parent 0678cff commit 093c527

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/Value/CSSFunction.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,35 @@ public function __construct($sName, $aArguments, $sSeparator = ',', $iLineNo = 0
3333
parent::__construct($aArguments, $sSeparator, $iLineNo);
3434
}
3535

36+
/**
37+
* @param ParserState $oParserState
38+
* @param bool $bIgnoreCase
39+
*
40+
* @return string
41+
*
42+
* @throws SourceException
43+
* @throws UnexpectedEOFException
44+
* @throws UnexpectedTokenException
45+
*/
46+
public static function parseName(ParserState $oParserState, $bIgnoreCase = false)
47+
{
48+
return $oParserState->parseIdentifier($bIgnoreCase);
49+
}
50+
51+
/**
52+
* @param ParserState $oParserState
53+
*
54+
* @return array
55+
*
56+
* @throws SourceException
57+
* @throws UnexpectedEOFException
58+
* @throws UnexpectedTokenException
59+
*/
60+
public static function parseArgs(ParserState $oParserState)
61+
{
62+
return Value::parseValue($oParserState, ['=', ' ', ',', '/', '*', '+', '-']);
63+
}
64+
3665
/**
3766
* @param ParserState $oParserState
3867
* @param bool $bIgnoreCase
@@ -45,9 +74,9 @@ public function __construct($sName, $aArguments, $sSeparator = ',', $iLineNo = 0
4574
*/
4675
public static function parse(ParserState $oParserState, $bIgnoreCase = false)
4776
{
48-
$mResult = $oParserState->parseIdentifier($bIgnoreCase);
77+
$mResult = self::parseName($oParserState, $bIgnoreCase);
4978
$oParserState->consume('(');
50-
$aArguments = Value::parseValue($oParserState, ['=', ' ', ',']);
79+
$aArguments = self::parseArgs($oParserState);
5180
$mResult = new CSSFunction($mResult, $aArguments, ',', $oParserState->currentLine());
5281
$oParserState->consume(')');
5382
return $mResult;

0 commit comments

Comments
 (0)