....................................../////.===Hehe-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 172.67.169.23  /  Your IP : 216.73.217.46
Web Server : nginx/1.28.3
System : Linux 4e27b89abc44 6.8.0-147-generic #147-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 24 11:33:16 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /sites/xo-fab.com/www/plugins/system/helixultimate/vendor/scssphp/scssphp/src/Parser/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /sites/xo-fab.com/www/plugins/system/helixultimate/vendor/scssphp/scssphp/src/Parser/Parser.php
<?php

/**
 * SCSSPHP
 *
 * @copyright 2012-2020 Leaf Corcoran
 *
 * @license http://opensource.org/licenses/MIT MIT
 *
 * @link http://scssphp.github.io/scssphp
 */

namespace ScssPhp\ScssPhp\Parser;

use League\Uri\Contracts\UriInterface;
use ScssPhp\ScssPhp\Exception\MultiSpanSassFormatException;
use ScssPhp\ScssPhp\Exception\SassFormatException;
use ScssPhp\ScssPhp\Exception\SimpleSassFormatException;
use ScssPhp\ScssPhp\Logger\LoggerInterface;
use ScssPhp\ScssPhp\Logger\QuietLogger;
use ScssPhp\ScssPhp\SourceSpan\LazyFileSpan;
use ScssPhp\ScssPhp\Util\Character;
use ScssPhp\ScssPhp\Util\ParserUtil;
use SourceSpan\FileLocation;
use SourceSpan\FileSpan;

/**
 * @internal
 */
class Parser
{
    protected readonly StringScanner $scanner;

    protected readonly LoggerInterface $logger;

    /**
     * A map used to map source spans in the text being parsed back to their
     * original locations in the source file, if this isn't being parsed directly
     * from source.
     */
    private readonly ?InterpolationMap $interpolationMap;

    /**
     * Parses $text as a CSS identifier and returns the result.
     *
     * @throws SassFormatException if parsing fails.
     */
    public static function parseIdentifier(string $text, ?LoggerInterface $logger = null): string
    {
        return (new Parser($text, $logger))->doParseIdentifier();
    }

    /**
     * Returns whether $text is a valid CSS identifier.
     */
    public static function isIdentifier(string $text, ?LoggerInterface $logger = null): bool
    {
        try {
            self::parseIdentifier($text, $logger);

            return true;
        } catch (SassFormatException) {
            return false;
        }
    }

    public function __construct(string $contents, ?LoggerInterface $logger = null, ?UriInterface $sourceUrl = null, ?InterpolationMap $interpolationMap = null)
    {
        $this->scanner = new StringScanner($contents, $sourceUrl);
        $this->logger = $logger ?? new QuietLogger();
        $this->interpolationMap = $interpolationMap;
    }

    /**
     * @throws SassFormatException
     */
    private function doParseIdentifier(): string
    {
        return $this->wrapSpanFormatException(function () {
            $result = $this->identifier();
            $this->scanner->expectDone();

            return $result;
        });
    }

    /**
     * Consumes whitespace, including any comments.
     */
    protected function whitespace(): void
    {
        do {
            $this->whitespaceWithoutComments();
        } while ($this->scanComment());
    }

    /**
     * Consumes whitespace, but not comments.
     */
    protected function whitespaceWithoutComments(): void
    {
        while (!$this->scanner->isDone() && Character::isWhitespace($this->scanner->peekChar())) {
            $this->scanner->readChar();
        }
    }

    /**
     * Consumes spaces and tabs.
     */
    protected function spaces(): void
    {
        while (!$this->scanner->isDone() && Character::isSpaceOrTab($this->scanner->peekChar())) {
            $this->scanner->readChar();
        }
    }

    /**
     * Consumes and ignores a comment if possible.
     *
     * Returns whether the comment was consumed.
     */
    protected function scanComment(): bool
    {
        if ($this->scanner->peekChar() !== '/') {
            return false;
        }

        $next = $this->scanner->peekChar(1);

        if ($next === '/') {
            return $this->silentComment();
        }

        if ($next === '*') {
            $this->loudComment();
            return true;
        }

        return false;
    }

    /**
     * Like {@see whitespace}, but throws an error if no whitespace is consumed.
     */
    protected function expectWhitespace(): void
    {
        if ($this->scanner->isDone() || !(Character::isWhitespace($this->scanner->peekChar()) || $this->scanComment())) {
            $this->scanner->error('Expected whitespace.');
        }

        $this->whitespace();
    }

    /**
     * Consumes and ignores a single silent (Sass-style) comment, not including
     * the trailing newline.
     *
     * Returns whether the comment was consumed.
     */
    protected function silentComment(): bool
    {
        $this->scanner->expect('//');

        while (!$this->scanner->isDone() && !Character::isNewline($this->scanner->peekChar())) {
            $this->scanner->readChar();
        }

        return true;
    }

    /**
     * Consumes and ignores a loud (CSS-style) comment.
     */
    protected function loudComment(): void
    {
        $this->scanner->expect('/*');

        while (true) {
            $next = $this->scanner->readChar();

            if ($next !== '*') {
                continue;
            }

            do {
                $next = $this->scanner->readChar();
            } while ($next === '*');

            if ($next === '/') {
                break;
            }
        }
    }

    /**
     * Consumes a plain CSS identifier.
     *
     * If $normalize is `true`, this converts underscores into hyphens.
     *
     * If $unit is `true`, this doesn't parse a `-` followed by a digit. This
     * ensures that `1px-2px` parses as subtraction rather than the unit
     * `px-2px`.
     */
    protected function identifier(bool $normalize = false, bool $unit = false): string
    {
        $text = '';

        if ($this->scanner->scanChar('-')) {
            $text .= '-';


            if ($this->scanner->scanChar('-')) {
                $text .= '-';
                $text .= $this->consumeIdentifierBody($normalize, $unit);

                return $text;
            }
        }

        $first = $this->scanner->peekChar();

        if ($first === null) {
            $this->scanner->error('Expected identifier.');
        }

        if ($normalize && $first === '_') {
            $this->scanner->readChar();
            $text .= '-';
        } elseif (Character::isNameStart($first)) {
            $text .= $this->scanner->readUtf8Char();
        } elseif ($first === '\\') {
            $text .= $this->escape(true);
        } else {
            $this->scanner->error('Expected identifier.');
        }

        $text .= $this->consumeIdentifierBody($normalize, $unit);

        return $text;
    }

    /**
     * Consumes a chunk of a plain CSS identifier after the name start.
     */
    public function identifierBody(): string
    {
        $text = $this->consumeIdentifierBody();

        if ($text === '') {
            $this->scanner->error('Expected identifier body.');
        }

        return $text;
    }

    private function consumeIdentifierBody(bool $normalize = false, bool $unit = false): string
    {
        $text = '';

        while (true) {
            $next = $this->scanner->peekChar();

            if ($next === null) {
                break;
            }

            if ($unit && $next === '-') {
                $second = $this->scanner->peekChar(1);

                if ($second !== null && ($second === '.' || Character::isDigit($second))) {
                    break;
                }

                $text .= $this->scanner->readChar();
            } elseif ($normalize && $next === '_') {
                $this->scanner->readChar();
                $text .= '-';
            } elseif (Character::isName($next)) {
                $text .= $this->scanner->readUtf8Char();
            } elseif ($next === '\\') {
                $text .= $this->escape();
            } else {
                break;
            }
        }

        return $text;
    }

    /**
     * Consumes a plain CSS string.
     *
     * This returns the parsed contents of the string—that is, it doesn't include
     * quotes and its escapes are resolved.
     */
    protected function string(): string
    {
        $quote = $this->scanner->readChar();

        if ($quote !== '"' && $quote !== "'") {
            $this->scanner->error('Expected string.');
        }

        $buffer = '';

        while (true) {
            $next = $this->scanner->peekChar();

            if ($next === $quote) {
                $this->scanner->readChar();
                break;
            }

            if ($next === null || Character::isNewline($next)) {
                $this->scanner->error("Expected $quote.");
            }

            if ($next === '\\') {
                $second = $this->scanner->peekChar(1);

                if ($second !== null && Character::isNewline($second)) {
                    $this->scanner->readChar();
                    $this->scanner->readChar();
                } else {
                    $buffer .= $this->escapeCharacter();
                }
            } else {
                $buffer .= $this->scanner->readUtf8Char();
            }
        }

        return $buffer;
    }

    /**
     * Consumes and returns a natural number (that is, a non-negative integer) as a double.
     *
     * Doesn't support scientific notation.
     */
    protected function naturalNumber(): float
    {
        $first = $this->scanner->readChar();

        if (!Character::isDigit($first)) {
            $this->scanner->error('Expected digit.', $this->scanner->getPosition() - 1);
        }

        $number = (float) intval($first);

        while (Character::isDigit($this->scanner->peekChar())) {
            $number *= 10;
            $number += intval($this->scanner->readChar());
        }

        return $number;
    }

    /**
     * Consumes tokens until it reaches a top-level `";"`, `")"`, `"]"`,
     * or `"}"` and returns their contents as a string.
     *
     * If $allowEmpty is `false` (the default), this requires at least one token.
     */
    protected function declarationValue(bool $allowEmpty = false): string
    {
        $buffer = '';
        $brackets = [];
        $wroteNewline = false;

        while (true) {
            $next = $this->scanner->peekChar();

            if ($next === null) {
                break;
            }

            switch ($next) {
                case '\\':
                    $buffer .= $this->escape(true);
                    $wroteNewline = false;
                    break;

                case '"':
                case "'":
                    $buffer .= $this->rawText($this->string(...));
                    $wroteNewline = false;
                    break;

                case '/':
                    if ($this->scanner->peekChar(1) === '*') {
                        $buffer .= $this->rawText($this->loudComment(...));
                    } else {
                        $buffer .= $this->scanner->readChar();
                    }
                    $wroteNewline = false;
                    break;

                case ' ':
                case "\t":
                    $second = $this->scanner->peekChar(1);
                    if ($wroteNewline || $second === null || !Character::isWhitespace($second)) {
                        $buffer .= ' ';
                    }
                    $this->scanner->readChar();
                    break;

                case "\n":
                case "\r":
                case "\f":
                    $prev = $this->scanner->peekChar(-1);
                    if ($prev === null || !Character::isNewline($prev)) {
                        $buffer .= "\n";
                    }
                    $this->scanner->readChar();
                    $wroteNewline = true;
                    break;

                case '(':
                case '{':
                case '[':
                    $buffer .= $next;
                    $brackets[] = Character::opposite($this->scanner->readChar());
                    $wroteNewline = false;
                    break;

                case ')':
                case '}':
                case ']':
                    if (empty($brackets)) {
                        break 2;
                    }

                    $buffer .= $next;
                    $this->scanner->expectChar(array_pop($brackets));
                    $wroteNewline = false;
                    break;

                case ';':
                    if (empty($brackets)) {
                        break 2;
                    }

                    $buffer .= $this->scanner->readChar();
                    break;

                case 'u':
                case 'U':
                    $url = $this->tryUrl();

                    if ($url !== null) {
                        $buffer .= $url;
                    } else {
                        $buffer .= $this->scanner->readChar();
                    }

                    $wroteNewline = false;
                    break;

                default:
                    if ($this->lookingAtIdentifier()) {
                        $buffer .= $this->identifier();
                    } else {
                        $buffer .= $this->scanner->readUtf8Char();
                    }
                    $wroteNewline = false;
                    break;
            }
        }

        if (!empty($brackets)) {
            $this->scanner->expectChar(array_pop($brackets));
        }

        if (!$allowEmpty && $buffer === '') {
            $this->scanner->error('Expected token.');
        }

        return $buffer;
    }

    /**
     * Consumes a `url()` token if possible, and returns `null` otherwise.
     */
    protected function tryUrl(): ?string
    {
        $start = $this->scanner->getPosition();

        if (!$this->scanIdentifier('url')) {
            return null;
        }

        if (!$this->scanner->scanChar('(')) {
            $this->scanner->setPosition($start);

            return null;
        }

        $this->whitespace();

        $buffer = 'url(';

        while (true) {
            $next = $this->scanner->peekChar();

            if ($next === null) {
                break;
            }

            $nextCharCode = \ord($next);

            if ($next === '\\') {
                $buffer .= $this->escape();
            } elseif ($next === '%' || $next === '&' || $next === '#' || ($nextCharCode >= \ord('*') && $nextCharCode <= \ord('~')) || $nextCharCode >= 0x80) {
                $buffer .= $this->scanner->readUtf8Char();
            } elseif (Character::isWhitespace($next)) {
                $this->whitespace();

                if ($this->scanner->peekChar() !== ')') {
                    break;
                }
            } elseif ($next === ')') {
                $buffer .= $this->scanner->readChar();

                return $buffer;
            } else {
                break;
            }
        }

        $this->scanner->setPosition($start);

        return null;
    }

    /**
     * Consumes a Sass variable name, and returns its name without the dollar sign.
     */
    protected function variableName(): string
    {
        $this->scanner->expectChar('$');

        return $this->identifier(true);
    }

    /**
     * Consumes an escape sequence and returns the text that defines it.
     *
     * If $identifierStart is true, this normalizes the escape sequence as
     * though it were at the beginning of an identifier.
     */
    protected function escape(bool $identifierStart = false): string
    {
        $start = $this->scanner->getPosition();

        $this->scanner->expectChar('\\');

        $first = $this->scanner->peekChar();

        if ($first === null) {
            $this->scanner->error('Expected escape sequence.');
        }

        if (Character::isNewline($first)) {
            $this->scanner->error('Expected escape sequence.');
        }

        if (Character::isHex($first)) {
            $value = 0;
            for ($i = 0; $i < 6; $i++) {
                $next = $this->scanner->peekChar();

                if ($next === null || !Character::isHex($next)) {
                    break;
                }

                $value *= 16;
                $value += hexdec($this->scanner->readChar());
                assert(\is_int($value));
            }

            $this->scanCharIf(Character::isWhitespace(...));
            $valueText = mb_chr($value, 'UTF-8');
        } else {
            $valueText = $this->scanner->readUtf8Char();
            $value = mb_ord($valueText, 'UTF-8');
        }

        if ($valueText === false) {
            $this->scanner->error('Invalid Unicode code point.', $start);
        }

        if ($identifierStart ? Character::isNameStart($valueText) : Character::isName($valueText)) {
            if ($value > 0x10ffff) {
                $this->scanner->error('Invalid Unicode code point.', $start);
            }

            return $valueText;
        }

        if ($value <= 0x1f || $valueText === "\x7f" || ($identifierStart && Character::isDigit($valueText))) {
            $hexValueText = $value === 0 ? '0' : ltrim(bin2hex($valueText), '0');
            return '\\' . $hexValueText . ' ';
        }

        return '\\' . $valueText;
    }

    /**
     * Consumes an escape sequence and returns the character it represents.
     */
    protected function escapeCharacter(): string
    {
        return ParserUtil::consumeEscapedCharacter($this->scanner);
    }

    /**
     * @param callable(string): bool $condition
     *
     * @param-immediately-invoked-callable $condition
     *
     * @phpstan-impure
     */
    protected function scanCharIf(callable $condition): bool
    {
        $next = $this->scanner->peekChar();

        if ($next === null || !$condition($next)) {
            return false;
        }

        $this->scanner->readChar();

        return true;
    }

    /**
     * Consumes the next character or escape sequence if it matches $character.
     *
     * Matching will be case-insensitive unless $caseSensitive is true.
     * When matching case-insensitively, $character must be passed in lowercase.
     *
     * This only supports ASCII identifier characters.
     */
    protected function scanIdentChar(string $character, bool $caseSensitive = false): bool
    {
        $matches = function (string $actual) use ($character, $caseSensitive): bool {
            if ($caseSensitive) {
                return $actual === $character;
            }

            return \strtolower($actual) === $character;
        };

        $next = $this->scanner->peekChar();

        if ($next !== null && $matches($next)) {
            $this->scanner->readChar();

            return true;
        }

        if ($next === '\\') {
            $start = $this->scanner->getPosition();

            if ($matches($this->escapeCharacter())) {
                return true;
            }

            $this->scanner->setPosition($start);
        }

        return false;
    }

    /**
     * Consumes the next character or escape sequence and asserts it matches $char.
     *
     * Matching will be case-insensitive unless $caseSensitive is true.
     * When matching case-insensitively, $char must be passed in lowercase.
     *
     * This only supports ASCII identifier characters.
     */
    protected function expectIdentChar(string $char, bool $caseSensitive = false): void
    {
        if ($this->scanIdentChar($char, $caseSensitive)) {
            return;
        }

        $this->scanner->error("Expected \"$char\"");
    }

    /**
     * Returns whether the scanner is immediately before a number.
     *
     * This follows [the CSS algorithm][].
     *
     * [the CSS algorithm]: https://drafts.csswg.org/css-syntax-3/#starts-with-a-number
     */
    protected function lookingAtNumber(): bool
    {
        $first = $this->scanner->peekChar();

        if ($first === null) {
            return false;
        }

        if (Character::isDigit($first)) {
            return true;
        }

        if ($first === '.') {
            $second = $this->scanner->peekChar(1);

            return $second !== null && Character::isDigit($second);
        }

        if ($first === '+' || $first === '-') {
            $second = $this->scanner->peekChar(1);

            if ($second === null) {
                return false;
            }

            if (Character::isDigit($second)) {
                return true;
            }

            if ($second !== '.') {
                return false;
            }

            $third = $this->scanner->peekChar(2);

            return $third !== null && Character::isDigit($third);
        }

        return false;
    }

    /**
     * Returns whether the scanner is immediately before a plain CSS identifier.
     *
     * If $forward is passed, this looks that many characters forward instead.
     *
     * This is based on [the CSS algorithm][], but it assumes all backslashes
     * start escapes.
     *
     * [the CSS algorithm]: https://drafts.csswg.org/css-syntax-3/#would-start-an-identifier
     */
    protected function lookingAtIdentifier(int $forward = 0): bool
    {
        $first = $this->scanner->peekChar($forward);

        if ($first === null) {
            return false;
        }

        if ($first === '\\' || Character::isNameStart($first)) {
            return true;
        }

        if ($first !== '-') {
            return false;
        }

        $second = $this->scanner->peekChar($forward + 1);

        if ($second === null) {
            return false;
        }

        return $second === '\\' || $second === '-' || Character::isNameStart($second);
    }

    /**
     * Returns whether the scanner is immediately before a sequence of characters
     * that could be part of a plain CSS identifier body.
     */
    protected function lookingAtIdentifierBody(): bool
    {
        $next = $this->scanner->peekChar();

        return $next !== null && ($next === '\\' || Character::isName($next));
    }

    /**
     * Consumes an identifier if its name exactly matches $text.
     *
     * When matching case-insensitively, $text must be passed in lowercase.
     *
     * This only supports ASCII identifiers.
     */
    protected function scanIdentifier(string $text, bool $caseSensitive = false): bool
    {
        if (!$this->lookingAtIdentifier()) {
            return false;
        }

        $start = $this->scanner->getPosition();

        if ($this->consumeIdentifier($text, $caseSensitive) && !$this->lookingAtIdentifierBody()) {
            return true;
        }

        $this->scanner->setPosition($start);

        return false;
    }

    /**
     * Returns whether an identifier whose name exactly matches $text is at the
     * current scanner position.
     *
     * This doesn't move the scan pointer forward
     */
    protected function matchesIdentifier(string $text, bool $caseSensitive = false): bool
    {
        if (!$this->lookingAtIdentifier()) {
            return false;
        }

        $start = $this->scanner->getPosition();
        $result = $this->consumeIdentifier($text, $caseSensitive) && !$this->lookingAtIdentifierBody();
        $this->scanner->setPosition($start);

        return $result;
    }

    /**
     * Consumes $text as an identifier, but doesn't verify whether there's
     * additional identifier text afterwards.
     *
     * Returns `true` if the full $text is consumed and `false` otherwise, but
     * doesn't reset the scan pointer.
     */
    private function consumeIdentifier(string $text, bool $caseSensitive): bool
    {
        for ($i = 0; $i < \strlen($text); $i++) {
            if (!$this->scanIdentChar($text[$i], $caseSensitive)) {
                return false;
            }
        }

        return true;
    }

    /**
     * Consumes an identifier asserts that its name exactly matches $text.
     *
     * When matching case-insensitively, $text must be passed in lowercase.
     *
     * This only supports ASCII identifiers.
     */
    protected function expectIdentifier(string $text, ?string $name = null, bool $caseSensitive = false): void
    {
        $name ??= "\"$text\"";

        $start = $this->scanner->getPosition();

        for ($i = 0; $i < \strlen($text); $i++) {
            if ($this->scanIdentChar($text[$i], $caseSensitive)) {
                continue;
            }

            $this->scanner->error("Expected $name.", $start);
        }

        if (!$this->lookingAtIdentifierBody()) {
            return;
        }

        $this->scanner->error("Expected $name.", $start);
    }

    /**
     * Runs $consumer and returns the source text that it consumes.
     *
     * @param callable(): (mixed|void) $consumer
     *
     * @param-immediately-invoked-callable $consumer
     */
    protected function rawText(callable $consumer): string
    {
        $start = $this->scanner->getPosition();
        $consumer();

        return $this->scanner->substring($start);
    }

    /**
     * Like {@see StringScanner::spanFrom()} but passes the span through {@see $interpolationMap} if it's available.
     */
    protected function spanFrom(int $position): FileSpan
    {
        $span = $this->scanner->spanFrom($position);

        if ($this->interpolationMap === null) {
            return $span;
        }

        $interpolationMap = $this->interpolationMap;

        return new LazyFileSpan(static fn() => $interpolationMap->mapSpan($span));
    }

    /**
     * Prints a warning to standard error, associated with $span.
     */
    protected function warn(string $message, FileSpan $span): void
    {
        $this->logger->warn($message, null, $span);
    }

    /**
     * Throws an error associated with $position.
     *
     * @throws FormatException
     */
    protected function error(string $message, FileSpan $span, ?\Throwable $previous = null): never
    {
        throw new FormatException($message, $span, $previous);
    }

    /**
     * Runs $callback and wraps any {@see FormatException} it throws in a
     * {@see SassFormatException}
     *
     * @template T
     * @param callable(): T $callback
     * @return T
     *
     * @param-immediately-invoked-callable $callback
     *
     * @throws SassFormatException
     */
    protected function wrapSpanFormatException(callable $callback)
    {
        try {
            try {
                return $callback();
            } catch (FormatException $e) {
                if ($this->interpolationMap === null) {
                    throw $e;
                }

                throw $this->interpolationMap->mapException($e);
            }
        } catch (MultiSourceFormatException $error) {
            $span = $error->getSpan();
            $secondarySpans = $error->secondarySpans;

            if (0 === stripos($error->getMessage(), 'expected')) {
                $span = $this->adjustExceptionSpan($span);
                $secondarySpans = array_map(fn (FileSpan $span) => $this->adjustExceptionSpan($span), $secondarySpans);
            }

            throw new MultiSpanSassFormatException($error->getMessage(), $span, $error->primaryLabel, $secondarySpans, $error);
        } catch (FormatException $error) {
            $span = $error->getSpan();

            if (0 === stripos($error->getMessage(), 'expected')) {
                $span = $this->adjustExceptionSpan($span);
            }

            throw new SimpleSassFormatException($error->getMessage(), $span, $error);
        }
    }

    /**
     * Moves span to {@see firstNewlineBefore} if necessary.
     */
    private function adjustExceptionSpan(FileSpan $span): FileSpan
    {
        if ($span->getLength() > 0) {
            return $span;
        }

        $start = $this->firstNewlineBefore($span->getStart());

        if ($start === $span->getStart()) {
            return $span;
        }

        return $start->pointSpan();
    }

    /**
     * If $location is separated from the previous non-whitespace character in
     * `$scanner->getString()` by one or more newlines, returns the location of the last
     * separating newline.
     *
     * Otherwise returns $location.
     *
     * This helps avoid missing token errors pointing at the next closing bracket
     * rather than the line where the problem actually occurred.
     */
    private function firstNewlineBefore(FileLocation $location): FileLocation
    {
        $text = $location->getFile()->getText(0, $location->getOffset());
        $index = $location->getOffset() - 1;
        $lastNewline = null;

        while ($index >= 0) {
            $char = $text[$index];

            if (!Character::isWhitespace($char)) {
                return $lastNewline === null ? $location : $location->getFile()->location($lastNewline);
            }

            if (Character::isNewline($char)) {
                $lastNewline = $index;
            }
            $index--;
        }

        // If the document *only* contains whitespace before $location, always
        // return $location.

        return $location;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit