U `@sddlmZmZmZmZmZmZddlZddlZddl Z e e Z GdddeZGdddeZe dkreedd ZeejD]Zed ejejfqdS) )unicode_literalsprint_functionabsolute_importdivision generators nested_scopesNc@s eZdZdS)JsonPathLexerErrorN)__name__ __module__ __qualname__r r 5/tmp/pip-unpacked-wheel-e4vcopd5/jsonpath_ng/lexer.pyr src @seZdZdZdFddZddZddd d d d d dddddg ZddiZddddgee Z dddgZ dZ dZ ddZd d!Zd"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd"Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd"Zd7d8Zd9d:Zd;d<Zd=d>Z d?d@Z!dAdBZ"dCdDZ#dES)G JsonPathLexerz* A Lexical analyzer for JsonPath. FcCs||_|jdkrtddS)NzDocstrings have been removed! By design of PLY, jsonpath-rw requires docstrings. You must not use PYTHONOPTIMIZE=2 or python -OO.)debug__doc__r)selfrr r r __init__s zJsonPathLexer.__init__ccshtjj||jtd}d|_d|_|||}|dkr [token] )modulerZerrorlogrNz.Unexpected EOF in string literal or identifier) plylexrloggerlatest_newline string_valueinputtokenlexposcolr)rstringZ new_lexertr r r tokenizes  zJsonPathLexer.tokenize*.[]()$,:|&~whereZWHEREZ DOUBLEDOTNUMBERIDNAMED_OPERATOR) singlequote exclusive) doublequoter1) backquoter1z\.\.z cCs|j|jd|_|S)z[a-zA-Z_@][a-zA-Z0-9_@\-]*r.)reserved_wordsgetvaluetyperrr r r t_IDAszJsonPathLexer.t_IDcCst|j|_|S)z-?\d+)intr6r8r r r t_NUMBERFs zJsonPathLexer.t_NUMBERcCs$|jj|j_d|j_|jddS)'r<r0NlexerrZ string_startrZ push_stater8r r r t_singlequoteNs zJsonPathLexer.t_singlequotecCs|jj|j7_dS)z[^'\\]+Nr?rr6r8r r r t_singlequote_contentTsz#JsonPathLexer.t_singlequote_contentcCs|jj|jd7_dSz\\.NrAr8r r r t_singlequote_escapeXsz"JsonPathLexer.t_singlequote_escapecCs&|jj|_d|_d|j_|j|S)r=r.Nr?rr6r7Z pop_stater8r r r t_singlequote_end\s   zJsonPathLexer.t_singlequote_endcCs*td|jj|j|jj|jdfdS)NzSError on line %s, col %s while lexing singlequoted field: Unexpected character: %s rrr?linenorrr6r8r r r t_singlequote_errordsz!JsonPathLexer.t_singlequote_errorcCs$|jj|j_d|j_|jddS)"r<r2Nr>r8r r r t_doublequotejs zJsonPathLexer.t_doublequotecCs|jj|j7_dS)z[^"\\]+NrAr8r r r t_doublequote_contentpsz#JsonPathLexer.t_doublequote_contentcCs|jj|jd7_dSrCrAr8r r r t_doublequote_escapetsz"JsonPathLexer.t_doublequote_escapecCs&|jj|_d|_d|j_|j|S)rKr.NrFr8r r r t_doublequote_endxs   zJsonPathLexer.t_doublequote_endcCs*td|jj|j|jj|jdfdS)NzSError on line %s, col %s while lexing doublequoted field: Unexpected character: %s rrHr8r r r t_doublequote_errorsz!JsonPathLexer.t_doublequote_errorcCs$|jj|j_d|j_|jddS)`r<r3Nr>r8r r r t_backquotes zJsonPathLexer.t_backquotecCs|jj|jd7_dSrCrAr8r r r t_backquote_escapesz JsonPathLexer.t_backquote_escapecCs|jj|j7_dS)z[^`\\]+NrAr8r r r t_backquote_contentsz!JsonPathLexer.t_backquote_contentcCs&|jj|_d|_d|j_|j|S)rQr/NrFr8r r r t_backquote_ends   zJsonPathLexer.t_backquote_endcCs*td|jj|j|jj|jdfdS)NzTError on line %s, col %s while lexing backquoted operator: Unexpected character: %s rrHr8r r r t_backquote_errorszJsonPathLexer.t_backquote_errorcCs|jjd7_|j|j_dS)z\nrDN)r?rIrrr8r r r t_newlineszJsonPathLexer.t_newlinecCs*td|jj|j|jj|jdfdS)Nz3Error on line %s, col %s: Unexpected character: %s rrHr8r r r t_errorszJsonPathLexer.t_errorN)F)$r r r rrrliteralsr4listvaluestokensZstatesZ t_DOUBLEDOTZt_ignorer9r;Zt_singlequote_ignorer@rBrErGrJZt_doublequote_ignorerLrMrNrOrPZt_backquote_ignorerRrSrTrUrVrWrXr r r r rsD r__main__T)rz%-20s%s) __future__rrrrrrsysloggingZply.lexr getLoggerr r Exceptionrobjectr basicConfigr?rstdinreadrprintr6r7r r r r s