B
q1mv @ s d Z ddlmZ ddlZddlmZ eejej d Z eejd Z
dd edD Zd d edD Z
G d
d dZedkrdd
lmZ eddd dS )zProvide advanced parsing abilities for ParenMatch and other extensions.
HyperParser uses PyParser. PyParser mostly gives information on the
proper indentation of code. HyperParser gives additional information on
the structure of code.
) iskeywordN)pyparse_c C s g | ]}t |tkqS )chr_ASCII_ID_CHARS).0xr r 8/opt/alt/python37/lib64/python3.7/idlelib/hyperparser.py
s r c C s g | ]}t |tkqS r )r _ASCII_ID_FIRST_CHARS)r r r r r
r s c @ s\ e Zd Zdd Zdd Zdd Zdd ZdddZed
ddhZ e
dd ZdZdd Z
dS )HyperParserc
sJ | _ |j _}t|j|j}dd }|||}|jsxh|jD ]^}t || d}t
|d } d| }
||| |
d |
|| }|dk s|dkrFP qFW ||pd nF|d |}|r|d } nd
} d| }
||| |
d |d |jdd _|
_| _ fdd
tt jD _ | dS )z;To initialize, analyze the surroundings of the given index.c S s t t| S )N)intfloat)indexr r r
index2line" s z(HyperParser.__init__..index2line z.0z%d.endz
Nr Zconsolez1.0c s4 g | ],}|d ko. j | d j |d d kqS )r r )
bracketing)r i)selfr r
r K s z(HyperParser.__init__..)editwintextr ZParserZindentwidthZtabwidthr Zprompt_last_lineZnum_context_linesmaxreprZset_codegetZfind_good_parse_startZ_build_char_in_string_funcZset_loZ
tag_prevrangecoderawtextstopatindexZget_last_stmt_bracketingr rangelenisopener set_index)
r r r r parserr ZlnocontextZstartatZstartatindexr Zbodrr )r r
__init__ s:
zHyperParser.__init__c C s t | jt | j|| j }|dk r2td| || _d| _x@| jt | jd k r~| j| jd d | jk r~| jd7 _q@W | jt | jd k r| j| jd d | jkr| j | jd s| jd7 _dS )zgSet the index to which the functions relate.
The index must be in the same statement.
r z(Index %s precedes the analyzed statementr N)
r! r r r r
ValueErrorindexinrawtextindexbracketr r" )r r r) r r r
r# Q s zHyperParser.set_indexc C s&