1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
U
L±d ã@sTddlZGdd„deƒZGdd„deƒZGdd„deƒZdd    „Zd
d „Zd d „ZdS)éNc@s&eZdZdZdZddd„Zdd„ZdS)    ÚCoordzž Coordinates of a syntactic element. Consists of:
            - File name
            - Line number
            - (optional) column number, for the Lexer
    )ÚfileÚlineÚcolumnÚ __weakref__NcCs||_||_||_dS©N©rrr)Úselfrrr©r
úJd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pycparser/plyparser.pyÚ__init__szCoord.__init__cCs(d|j|jf}|jr$|d|j7}|S)Nz%s:%sz:%sr)r    Ústrr
r
r Ú__str__sz Coord.__str__)N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú    __slots__r rr
r
r
r r s
rc@s eZdZdS)Ú
ParseErrorN)rrrr
r
r
r rsrc@s.eZdZdd„Zd
dd„Zdd„Zdd    „ZdS) Ú    PLYParsercCs<|d}dd„}d||f|_d||_t|j|j|ƒdS)zŽ Given a rule name, creates an optional ply.yacc rule
            for it. The name of the optional rule is
            <rulename>_opt
        Z_optcSs|d|d<dS)Nérr
©r    Úpr
r
r Úoptrule*sz+PLYParser._create_opt_rule.<locals>.optrulez%s : empty
| %szp_%sN)rrÚsetattrÚ    __class__)r    ZrulenameÚoptnamerr
r
r Ú_create_opt_rule#s
 
zPLYParser._create_opt_ruleNcCst|jj||dS)Nr)rZclexÚfilename)r    Úlinenorr
r
r Ú_coord1s
ýzPLYParser._coordcCsF|jjj dd| |¡¡}|dkr&d}| |¡|}| | |¡|¡S)z× Returns the coordinates for the YaccProduction object 'p' indexed
            with 'token_idx'. The coordinate includes the 'lineno' and
            'column'. Both follow the lex semantic, starting from 1.
        Ú
réÿÿÿÿ)ÚlexerZlexdataÚrfindZlexposr r)r    rZ    token_idxZlast_crrr
r
r Ú _token_coord7s
zPLYParser._token_coordcCstd||fƒ‚dS)Nz%s: %s)r)r    ÚmsgZcoordr
r
r Ú _parse_errorBszPLYParser._parse_error)N)rrrrr r%r'r
r
r
r r"s
 rcs‡fdd„}|S)aÞ Decorator to create parameterized rules.
 
    Parameterized rule methods must be named starting with 'p_' and contain
    'xxx', and their docstrings may contain 'xxx' and 'yyy'. These will be
    replaced by the given parameter tuples. For example, ``p_xxx_rule()`` with
    docstring 'xxx_rule  : yyy' when decorated with
    ``@parameterized(('id', 'ID'))`` produces ``p_id_rule()`` with the docstring
    'id_rule  : ID'. Using multiple tuples produces multiple rules.
    cs
ˆ|_|Sr)Ú_params)Z    rule_func©Úparamsr
r ÚdecoratePszparameterized.<locals>.decorater
)r*r+r
r)r Ú parameterizedFs
r,cCsld}t|ƒD]Z}| d¡r t||ƒ}t|dƒr t||ƒ|jdk    rNt||ƒq |s tjdt    ddd}q |S)    z Class decorator to generate rules from parameterized rule templates.
 
    See `parameterized` for more information on parameterized rules.
    FZp_r(Nz@parsing methods must have __doc__ for pycparser to work properlyé)Ú
stacklevelT)
ÚdirÚ
startswithÚgetattrÚhasattrÚdelattrrÚ_create_param_rulesÚwarningsÚwarnÚRuntimeWarning)ÚclsZissued_nodoc_warningÚ    attr_nameÚmethodr
r
r ÚtemplateVs  
 
 
 
 
 ýr;csVˆjD]J\}}‡fdd„}ˆj d|¡ d|¡|_ˆj d|¡|_t||j|ƒqdS)a Create ply.yacc rules based on a parameterized rule function
 
    Generates new methods (one per each pair of parameters) based on the
    template rule function `func`, and attaches them to `cls`. The rule
    function's parameters must be accessible via its `_params` attribute.
    csˆ||ƒdSrr
r©Úfuncr
r Ú
param_rule}sz'_create_param_rules.<locals>.param_ruleÚxxxÚyyyN)r(rÚreplacerr)r8r=r?r@r>r
r<r r4ts
 r4)    r5ÚobjectrÚ    Exceptionrrr,r;r4r
r
r
r Ú<module> s $