a oe@sUddlZddlZddlmZddlmZmZmZmZm Z m Z ddl m Z eGdddZ Gdd d eZd d d d ddedejddddedejee je jejejBddddddddZded<Gd d!d!ZdS)"N) dataclass)DictIteratorNoReturnOptionalTupleUnion) Specifierc@s&eZdZUeed<eed<eed<dS)TokennametextpositionN)__name__ __module__ __qualname__str__annotations__intrrHC:\Program Files\Certbot\pkgs\setuptools\_vendor\packaging\_tokenizer.pyr s r csBeZdZdZeeeeefddfdd ZedddZZ S) ParserSyntaxErrorz7The provided source text could not be parsed correctly.N)messagesourcespanreturncs ||_||_||_tdS)N)rrrsuper__init__)selfrrr __class__rrrszParserSyntaxError.__init__rcCs>d|jdd|jd|jdd}d|j|j|gS)N r~r ^z )rjoinrr)rZmarkerrrr__str__ s*zParserSyntaxError.__str__) rrr__doc__rrrrr& __classcell__rrrrrs  rz\(z\)z\[z\];,zk ( ('[^']*') | ("[^"]*") ) z(===|==|~=|!=|<=|>=|<|>)z \b(or|and)\bz\bin\bz\bnot\ba \b( python_version |python_full_version |os[._]name |sys[._]platform |platform_(release|system) |platform[._](version|machine|python_implementation) |python_implementation |implementation_(name|version) |extra )\b z\@z[^ \t]+z\b[a-zA-Z0-9][a-zA-Z0-9._-]*\bz\.\*z\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*z[ \t]+$)ZLEFT_PARENTHESISZRIGHT_PARENTHESISZ LEFT_BRACKETZ RIGHT_BRACKETZ SEMICOLONCOMMAZ QUOTED_STRINGOPZBOOLOPINZNOTZVARIABLEZ SPECIFIERATZURLZ IDENTIFIERZVERSION_PREFIX_TRAILZVERSION_LOCAL_LABEL_TRAILZWSZEND&Dict[str, Union[str, re.Pattern[str]]] DEFAULT_RULESc@seZdZdZedddddZedddd Zd d eeed d dZeee dddZ e dddZ dddee e e e edddZejeeeeddddZdS) TokenizerzContext-sensitive token parsing. Provides methods to examine the input stream to check whether the next token matches. r0N)rrulesrcCs*||_dd|D|_d|_d|_dS)NcSsi|]\}}|t|qSr)recompile).0r patternrrr fsz&Tokenizer.__init__..r)ritemsr3 next_tokenr)rrr3rrrr_s zTokenizer.__init__)r rcCs||r|dS)z8Move beyond provided token name, if at current position.N)checkread)rr rrrconsumels zTokenizer.consumeF)peek)r r>rcCsz|jdus Jd|d|j||jvs8Jd||j|}||j|j}|dur^dS|svt||d|j|_dS)zCheck whether the next token has the provided name. By default, if the check succeeds, the token *must* be read before another check. If `peek` is set to `True`, the token is not loaded and would need to be checked again. NzCannot check for z, already have zUnknown token name: FrT)r:r3matchrrr )rr r>Z expressionr?rrrr;qs zTokenizer.check)r expectedrcCs"||s|d||S)zsExpect a certain token name next, failing with a syntax error otherwise. The token is *not* read. z Expected )r;raise_syntax_errorr<)rr r@rrrexpects zTokenizer.expectr!cCs0|j}|dusJ|jt|j7_d|_|S)z%Consume the next token and return it.N)r:rlenr )rtokenrrrr<s  zTokenizer.read) span_startspan_end)rrErFrcCs8|dur|jn||dur|jn|f}t||j|ddS)z.Raise ParserSyntaxError at the given position.N)rr)rrr)rrrErFrrrrrAs zTokenizer.raise_syntax_error) open_token close_tokenaroundrccsf||r|j}|nd}dV|dur0dS||sZ|jd|d|d||d|dS)NzExpected matching z for z, after )rE)r;rr<rA)rrGrHrIZ open_positionrrrenclosing_tokenss   zTokenizer.enclosing_tokens)rrrr'rrr=boolr;r rBr<rrrrA contextlibcontextmanagerrrJrrrrr2Xs*   r2)rLr4Z dataclassesrtypingrrrrrrZ specifiersr r Exceptionrr5VERBOSEZ_operator_regex_strZ_version_regex_str IGNORECASEr1rr2rrrrsL        3