o knh@s$UddlmZddlZddlZddlmZddlmZmZddl m Z eGdddZ Gd d d e Z id d d ddddddddddedejdddddddd d!ed"ejd#ee je jejejBd$d%d&d'd(d)d*d+d,d-d.d/Zd0ed1<Gd2d3d3ZdS)4) annotationsN) dataclass)IteratorNoReturn) Specifierc@s&eZdZUded<ded<ded<dS)TokenstrnametextintpositionN)__name__ __module__ __qualname____annotations__rr?/usr/local/lib/python3.10/dist-packages/packaging/_tokenizer.pyr s  rcs,eZdZdZd fd d Zdd d ZZS)ParserSyntaxErrorz7The provided source text could not be parsed correctly.messager sourcespantuple[int, int]returnNonecs ||_||_||_tdS)N)rrrsuper__init__)selfrrr __class__rrrszParserSyntaxError.__init__cCs>d|jdd|jd|jdd}d|j|j|gS)N r~r^z )rjoinrr)rmarkerrrr__str__"s*zParserSyntaxError.__str__)rr rr rrrr)rr )rrr__doc__rr% __classcell__rrrrrs rLEFT_PARENTHESISz\(RIGHT_PARENTHESISz\) LEFT_BRACKETz\[ RIGHT_BRACKETz\] SEMICOLON;COMMA, QUOTED_STRINGzk ( ('[^']*') | ("[^"]*") ) OPz(===|==|~=|!=|<=|>=|<|>)BOOLOPz \b(or|and)\bINz\bin\bNOTz\bnot\bVARIABLEa \b( python_version |python_full_version |os[._]name |sys[._]platform |platform_(release|system) |platform[._](version|machine|python_implementation) |python_implementation |implementation_(name|version) |extras? |dependency_groups )\b SPECIFIERATz\@URLz[^ \t]+ IDENTIFIERz\b[a-zA-Z0-9][a-zA-Z0-9._-]*\bVERSION_PREFIX_TRAILz\.\*z\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*z[ \t]+$)VERSION_LOCAL_LABEL_TRAILWSEND dict[str, str | re.Pattern[str]] DEFAULT_RULESc@sjeZdZdZd(dd Zd)d d Zd dd*ddZd+ddZd,ddZdddd-d d!Z e j d.d&d'Z dS)/ TokenizerzContext-sensitive token parsing. Provides methods to examine the input stream to check whether the next token matches. rr rulesr?rrcCs*||_dd|D|_d|_d|_dS)NcSsi|] \}}|t|qSr)recompile).0r patternrrr isz&Tokenizer.__init__..r)ritemsrB next_tokenr )rrrBrrrrbs  zTokenizer.__init__r cCs||r |dSdS)z8Move beyond provided token name, if at current position.N)checkread)rr rrrconsumeos  zTokenizer.consumeF)peekrMboolcCsz|jdusJd|d|j||jvsJd||j|}||j|j}|dur/dS|s;t||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)rIrBmatchrr r)rr rM expressionrOrrrrJts  zTokenizer.checkexpectedrcCs"||s |d||S)zsExpect a certain token name next, failing with a syntax error otherwise. The token is *not* read. z Expected )rJraise_syntax_errorrK)rr rQrrrexpects zTokenizer.expectcCs0|j}|dus J|jt|j7_d|_|S)z%Consume the next token and return it.N)rIr lenr )rtokenrrrrKs  zTokenizer.readN) span_startspan_endrrV int | NonerWrcCs4|dur|jn||dur|jn|f}t||j|d)z.Raise ParserSyntaxError at the given position.N)rr)r rr)rrrVrWrrrrrRs zTokenizer.raise_syntax_error open_token close_tokenaroundIterator[None]ccsh||r|j}|nd}dV|durdS||s.|jd|d|d||d|dS)NzExpected matching z for z, after )rV)rJr rKrR)rrYrZr[ open_positionrrrenclosing_tokenss    zTokenizer.enclosing_tokens)rr rBr?rr)r r rr)r r rMrNrrN)r r rQr rr)rr)rr rVrXrWrXrr)rYr rZr r[r rr\) rrrr&rrLrJrSrKrR contextlibcontextmanagerr^rrrrrA[s    rA) __future__rr_rC dataclassesrtypingrr specifiersrr ExceptionrrDVERBOSE_operator_regex_str_version_regex_str IGNORECASEr@rrArrrrst  &  *+,-.4