
    8Sj                        S SK Jr  S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SKJ
r
  S SKJr  S S	KJr  S S
KJr  S SKJr  \" SS9 " S S5      5       r\" SSS9 " S S\5      5       r\" SSS9 " S S\5      5       r\ " S S5      5       r\ " S S5      5       r\ " S S5      5       r\ " S S5      5       r\ " S S5      5       r\ " S  S!5      5       r\ " S" S#5      5       r\ " S$ S%5      5       r\ " S& S'5      5       r\ " S( S)5      5       r\ " S* S+5      5       r " S, S-\5      r\ " S. S/5      5       r\ " S0 S15      5       r \ " S2 S35      5       r!\ " S4 S55      5       r"\ " S6 S75      5       r#\ " S8 S95      5       r$\ " S: S;5      5       r%\ " S< S=5      5       r& " S> S?\'5      r(S@\SA\)SB\&4SC jr* " SD SE5      r+gF)G    )	dataclass)field)Enum)Path)Dict)List)NoReturn)Optional)Sequence)Tuple)LexerT)frozenc                       \ rS rSr% \\S'   Sr\\S'   \" \	SSS9r
\\\4   \S'   S\4S jrS\SS 4S	 jrSS
 jrS\S    4S jrS\4S jrS\4S jrS\S   4S jrS\S    4S jrSrg)IDLType   nameFnullable)default_factorycomparehashextended_attributesreturnc                 L    U R                   (       a  SOSnU R                   U 3$ N? )r   r   selfnullable_suffixs     F/mnt/mint/home/seanl/public/Repos/ladybird/Meta/Utils/webidl_parser.py__str__IDLType.__str__   s#    !%#B))_-..    c                 B    [        U R                  XR                  5      $ N)r   r   r   r   r   s     r    clone_with_nullableIDLType.clone_with_nullable   s    tyy(,D,DEEr#   c                 $    U R                  S5      $ )NF)r'   r   s    r    without_nullableIDLType.without_nullable    s    ''..r#   c                     U /$ r%    r*   s    r    flattened_member_typesIDLType.flattened_member_types#   s	    vr#   c                      U R                   S:H  $ )N	undefinedr   r*   s    r    includes_undefinedIDLType.includes_undefined&   s    yyK''r#   c                     U R                   $ r%   )r   r*   s    r    includes_nullable_typeIDLType.includes_nullable_type)   s    }}r#   )r   .c                     g)Nr.   r.   r*   s    r    child_typesIDLType.child_types,   s    r#   c                 x    U /nU R                  5        H"  nUR                  UR                  5       5        M$     U$ r%   )r:   extendnested_types)r   r>   
child_types      r    r>   IDLType.nested_types/   s9    )-**,J
 7 7 9: -r#   r.   N)r   r   )__name__
__module____qualname____firstlineno__str__annotations__r   boolr   dictr   r   r!   r'   r+   r   r/   r4   r7   r   r:   r>   __static_attributes__r.   r#   r    r   r      s    
IHd*/eZ_*`c3h`/ /FD FY F/Y (D ( U>2 d9o r#   r   F)initr   c            
          ^  \ rS rSr% \\S4   \S'     SS\\   S\S\	\
\\4      SS4U 4S jjjr\S\\   S\4S	 j5       rS\4S
 jrS\SS 4S jrS\\   4S jrS\4S jrS\4S jrS\\S4   4S jrSrU =r$ )IDLUnionType6   .member_typesNr   r   r   c                    > [         R                  U S[        U5      5        [        TU ]  U R                  U5      X#=(       d    0 5        g )NrN   )object__setattr__tuplesuper__init__name_for_member_types)r   rN   r   r   	__class__s       r    rT   IDLUnionType.__init__:   s<     	4|1DE33LA8Mfdfgr#   c                 :    SSR                  S U  5       5       S3$ )N(z or c              3   8   #    U  H  n[        U5      v   M     g 7fr%   rE   .0member_types     r    	<genexpr>5IDLUnionType.name_for_member_types.<locals>.<genexpr>E   s     P<Ks;//<   ))joinrN   s    r    rU   "IDLUnionType.name_for_member_typesC   s"    6;;P<PPQQRSSr#   c                 j    U R                   (       a  SOSnU R                  U R                  5       U 3$ r   )r   rU   rN   r   s     r    r!   IDLUnionType.__str__G   s1    !%#B,,T->->?@@QRRr#   c                 B    [        U R                  XR                  5      $ r%   )rL   rN   r   r&   s     r    r'    IDLUnionType.clone_with_nullableK   s    D--x9Q9QRRr#   c                 n    / nU R                    H"  nUR                  UR                  5       5        M$     U$ r%   )rN   r=   r/   )r   r/   r^   s      r    r/   #IDLUnionType.flattened_member_typesN   s5    02,,K"))+*L*L*NO -%%r#   c                 :    [        S U R                   5       5      $ )Nc              3   @   #    U  H  oR                  5       v   M     g 7fr%   )r4   r\   s     r    r_   2IDLUnionType.includes_undefined.<locals>.<genexpr>U   s     YGX1133GX   )anyrN   r*   s    r    r4   IDLUnionType.includes_undefinedT   s    YtGXGXYYYr#   c                 `    U R                   =(       d    [        S U R                   5       5      $ )Nc              3   @   #    U  H  oR                  5       v   M     g 7fr%   )r7   r\   s     r    r_   6IDLUnionType.includes_nullable_type.<locals>.<genexpr>X   s     #n\m[$F$F$H$H\mro   )r   rp   rN   r*   s    r    r7   #IDLUnionType.includes_nullable_typeW   s#    }}n#n\`\m\m#n nnr#   c                     U R                   $ r%   rd   r*   s    r    r:   IDLUnionType.child_typesZ   s       r#   r.   FN)rA   rB   rC   rD   r   r   rF   r   rG   r
   r   rE   rT   staticmethodrU   r!   r'   r   r/   r4   r7   r:   rI   __classcell__rV   s   @r    rL   rL   6   s    %%
 8<	hw'h h &d38n5	h
 
h h THW,= T# T TS SSD S^ S&W &ZD Zo o!U7C<0 ! !r#   rL   c                      ^  \ rS rSr% \\S4   \S'     SS\S\\   S\	S\
\\\4      SS4
U 4S	 jjjrS\4S
 jrS\	SS 4S jrS\\S4   4S jrSrU =r$ )IDLParameterizedType^   .
parametersNr   r   r   r   c                 x   > [         R                  U S[        U5      5        [        TU ]  XU=(       d    0 5        g )Nr   )rP   rQ   rR   rS   rT   )r   r   r   r   r   rV   s        r    rT   IDLParameterizedType.__init__b   s1     	4uZ/@A)<)BCr#   c                     U R                   (       a  SOSnU R                   SSR                  S U R                   5       5       SU 3$ )Nr   r   <z, c              3   8   #    U  H  n[        U5      v   M     g 7fr%   r[   )r]   	parameters     r    r_   /IDLParameterizedType.__str__.<locals>.<genexpr>n   s     'X9Ira   >)r   r   rc   r   r   s     r    r!   IDLParameterizedType.__str__l   sA    !%#B))Adii'X'XXYYZ[jZkllr#   c                 X    [        U R                  U R                  XR                  5      $ r%   )r}   r   r   r   r&   s     r    r'   (IDLParameterizedType.clone_with_nullablep   s    #DIItJbJbccr#   c                     U R                   $ r%   )r   r*   s    r    r:    IDLParameterizedType.child_typess   s    r#   r.   rx   )rA   rB   rC   rD   r   r   rF   rE   r   rG   r
   r   rT   r!   r'   r:   rI   rz   r{   s   @r    r}   r}   ^   s    gsl## 8<DD W%D 	D
 &d38n5D 
D Dm mdD d5K dU7C<0  r#   r}   c                   4    \ rS rSr% \\S'   \\S'   \\S'   Srg)Constantw   typer   valuer.   N)rA   rB   rC   rD   r   rF   rE   rI   r.   r#   r    r   r   w   s    
M
IJr#   r   c                   z    \ rS rSr% \\S'   \\S'   Sr\\S'   Sr	\
\   \S'   Sr\\S'   \" \S	9r\\\4   \S
'   Srg)OperationParameter~   r   r   FoptionalNdefault_valuevariadicr   r   r.   )rA   rB   rC   rD   rE   rF   r   r   rG   r   r
   r   r   rH   r   r   rI   r.   r#   r    r   r   ~   sF    
I
MHd#'M8C='Hd*/*Ec3hEr#   r   c                   d    \ rS rSr% \\S'   \\S'   \\S'   \\   \S'   \	" \
S9r\\\4   \S'   Srg	)
SpecialOperation   identifier_typereturn_typer   r   r   r   r.   N)rA   rB   rC   rD   r   rF   rE   r   r   r   rH   r   r   rI   r.   r#   r    r   r      s7    
I'((*/*Ec3hEr#   r   c                   h    \ rS rSr% \\S'   \\S'   \\   \S'   \	" \
S9r\\\4   \S'   S\4S jrS	rg
)	Operation   r   r   r   r   r   r   c                 4    U R                   R                  S:H  $ )NPromise)r   r   r*   s    r    return_type_is_promise Operation.return_type_is_promise   s    $$	11r#   r.   N)rA   rB   rC   rD   rE   rF   r   r   r   r   rH   r   r   rG   r   rI   r.   r#   r    r   r      s=    
I'((*/*Ec3hE2 2r#   r   c                   F    \ rS rSr% \\   \S'   \" \S9r	\
\\4   \S'   Srg)Constructor   r   r   r   r.   N)rA   rB   rC   rD   r   r   rF   r   rH   r   r   rE   rI   r.   r#   r    r   r      s&    '((*/*Ec3hEr#   r   c                   4    \ rS rSr% \\S'   Sr\\   \S'   Srg)IterableDeclaration   
value_typeNkey_typer.   )	rA   rB   rC   rD   r   rF   r   r
   rI   r.   r#   r    r   r      s    "&Hhw&r#   r   c                   P    \ rS rSr% \\S'   \" \S9r\	\
   \S'   Sr\\   \S'   Srg)AsyncIterableDeclaration   r   r   r   Nr   r.   )rA   rB   rC   rD   r   rF   r   listr   r   r   r   r
   rI   r.   r#   r    r   r      s,    +0+FJ'(F"&Hhw&r#   r   c                   8    \ rS rSr% \\S'   \\S'   Sr\\S'   Srg)MaplikeDeclaration   r   r   Freadonlyr.   N	rA   rB   rC   rD   r   rF   r   rG   rI   r.   r#   r    r   r      s    Hdr#   r   c                   .    \ rS rSr% \\S'   Sr\\S'   Srg)SetlikeDeclaration   r   Fr   r.   Nr   r.   r#   r    r   r      s    Hdr#   r   c                   f    \ rS rSr% \\S'   \\S'   Sr\\S'   Sr	\\S'   \
" \S9r\\\4   \S'   S	rg
)	Attribute   r   r   Fr   inheritr   r   r.   N)rA   rB   rC   rD   rE   rF   r   r   rG   r   r   rH   r   r   rI   r.   r#   r    r   r      s8    
I
MHdGT*/*Ec3hEr#   r   c                   J    \ rS rSr% \" \S9r\\\4   \	S'   Sr
\\   \	S'   Srg)Stringifier   r   r   N	attributer.   )rA   rB   rC   rD   r   rH   r   r   rE   rF   r   r
   r   rI   r.   r#   r    r   r      s)    */*Ec3hE%)Ix	")r#   r   c                        \ rS rSrSrSrSrSrg)InterfaceKind   	interface	namespacecallback interfacer.   N)rA   rB   rC   rD   	Interface	NamespaceCallbackInterfacerI   r.   r#   r    r   r      s    II,r#   r   c                      \ rS rSr% \\S'   \\S'   \" \S9r	\
\\4   \S'   \R                  r\\S'   Sr\\S'   \" \S9r\\   \S	'   \" \S9r\\   \S
'   \" \S9r\\   \S'   \" \S9r\\   \S'   \" \S9r\\   \S'   \" \S9r\\   \S'   Sr\\   \S'   Sr\\   \S'   Sr \\!   \S'   Sr"\\#   \S'   Sr$\\#   \S'   Sr%\\#   \S'   Sr&\\#   \S'   Sr'\\#   \S'   Sr(\\)   \S'   Sr*\\+   \S'   \,S\-4S j5       r.\,S\-4S j5       r/\,S\-4S j5       r0\,S\4S j5       r1\,S\4S j5       r2\,S\4S  j5       r3\,S\4S! j5       r4\,S\4S" j5       r5\,S\-4S# j5       r6S$r7g)%r      r   pathr   r   kindr   parent_name	constantsregular_attributesstatic_attributesregular_operationsstatic_operationsconstructorsNstringifieriterableasync_iterablenamed_property_getterindexed_property_getternamed_property_setternamed_property_deleterindexed_property_settermaplikesetliker   c                 <    U R                   [        R                  :H  $ r%   )r   r   r   r*   s    r    is_namespaceInterface.is_namespace   s    yyM3333r#   c                 <    U R                   [        R                  :H  $ r%   )r   r   r   r*   s    r    is_callback_interfaceInterface.is_callback_interface   s    yyM;;;;r#   c                     U R                   S L=(       d8    U R                  S L=(       d#    U R                  S L=(       d    U R                  S L$ r%   )r   r   r   r   r*   s    r    has_special_memberInterface.has_special_member   sL     MM% (""$.(||4'( ||4'		
r#   c                     U R                   R                  S5      nU(       a  U SU R                   3$ U R                  $ )NLegacyNamespace.r   getr   )r   legacy_namespaces     r    namespaced_nameInterface.namespaced_name   s=    33778IJ&'q44yyr#   c                 N    U R                   R                  SU R                  5      $ )NImplementedAsr   r*   s    r    implemented_nameInterface.implemented_name  s    ''++OTYYGGr#   c                      U R                    S3$ )Nr   r   r*   s    r    constructor_classInterface.constructor_class  s    ''(44r#   c                      U R                    S3$ )N	Prototyper   r*   s    r    prototype_classInterface.prototype_class	  s    ''(	22r#   c                      U R                    S3$ )Nr   r3   r*   s    r    namespace_classInterface.namespace_class  s    ))I&&r#   c                     U R                   S L$ r%   )r   r*   s    r    supports_named_properties#Interface.supports_named_properties  s    ))55r#   r.   )8rA   rB   rC   rD   rE   rF   r   r   rH   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   propertyrG   r   r   r   r   r   r   r   r   r   rI   r.   r#   r    r   r      sM   
I
J*/*Ec3hE'11D-1K %d ;ItH~;*/*EYE).t)DtID*/*EYE).t)DtID&+D&AL${#A)-K+&-.2Hh*+29=NH56=8<8$45<:>X&67>8<8$45<9=H%56=:>X&67>,0GX()0,0GX()04d 4 4 <t < < 
D 
 
    H# H H 53 5 5 3 3 3 ' ' ' 64 6 6r#   r   c                   t    \ rS rSr% \\S'   \\S'   Sr\\S'   \" \	S9r
\S   \S'   \" \S9r\\\4   \S	'   S
rg)
Dictionaryi  r   r   r   r   r   DictionaryMembermembersr   r.   N)rA   rB   rC   rD   rE   rF   r   r   r   r   r  r   rH   r   r   rI   r.   r#   r    r  r    sC    
I
JK(-d(CGT$%C*/*Ec3hEr#   r  c                   l    \ rS rSr% \\S'   \\S'   Sr\\S'   Sr	\
\   \S'   \" \S9r\\\4   \S	'   S
rg)r  i  r   r   FrequiredNr   r   r   r.   )rA   rB   rC   rD   rE   rF   r   r  rG   r   r
   r   rH   r   r   rI   r.   r#   r    r  r    s<    
I
MHd#'M8C='*/*Ec3hEr#   r  c                   p    \ rS rSr% \\S'   \\S'   \\S'   \" \	S9r
\\   \S'   \" \S9r\\\4   \S'   Srg	)
CallbackFunctioni(  r   r   r   r   r   r   r.   N)rA   rB   rC   rD   rE   rF   r   r   r   r   r   r   r   rH   r   r   rI   r.   r#   r    r
  r
  (  s?    
I
J+0+FJ'(F*/*Ec3hEr#   r
  c                   Z    \ rS rSr% \\S'   \\S'   \\   \S'   \" \	S9r
\\\4   \S'   Srg)	Enumerationi1  r   r   valuesr   r   r.   N)rA   rB   rC   rD   rE   rF   r   r   r   rH   r   r   rI   r.   r#   r    r  r  1  s.    
I
JI*/*Ec3hEr#   r  c                   4    \ rS rSr% \\S'   \\S'   \\S'   Srg)Typedefi9  r   r   r   r.   N)	rA   rB   rC   rD   rE   rF   r   r   rI   r.   r#   r    r  r  9  s    
I
J
Mr#   r  c                   *    \ rS rSr% \\S'   \\S'   Srg)IncludedMixini@  interface_name
mixin_namer.   N)rA   rB   rC   rD   rE   rF   rI   r.   r#   r    r  r  @  s    Or#   r  c                   0   \ rS rSr% \\S'   Sr\\   \S'   \	" \
S9r\\   \S'   \	" \
S9r\\   \S'   \	" \
S9r\\   \S'   \	" \
S9r\\   \S	'   \	" \
S9r\\   \S
'   \	" \
S9r\\   \S'   \	" \
S9r\\   \S'   \	" \
S9r\\   \S'   \	" \
S9r\\   \S'   Srg)ModuleiF  r   Nr   r   partial_interfacesmixinspartial_mixinsincluded_mixinscallback_functionsdictionariespartial_dictionariesenumerationstypedefsr.   )rA   rB   rC   rD   r   rF   r   r
   r   r   r   r  r   r  r  r  r  r  r
  r  r  r  r  r  r  r  rI   r.   r#   r    r  r  F  s    
J%)Ix	")*/*EYE#D9FDO9&+D&ANDOA+0+FOT-(F16t1L-.L%*4%@L$z"@-24-H$z*H&+D&AL${#A#D9Hd7m9r#   r  c                       \ rS rSrSrg)
ParseErroriU  r.   N)rA   rB   rC   rD   rI   r.   r#   r    r   r   U  s    r#   r   r   contentsr   c                 4    [        X5      R                  5       $ r%   )Parserparse)r   r!  s     r    parse_moduler%  Y  s    $!''))r#   c            	       `   \ rS rSrS\S\SS4S jrS\4S jrS\S	\	\\4   SS4S
 jr
S\4S jr\R                  4S	\	\\4   S\S\4S jjrS	\	\\4   S\4S jrS	\	\\4   S\4S jrS\4S jrS\4S jrS7S	\\	\\4      S\4S jjrS\4S jrS\\\4   4S jrS	\	\\4   S\4S jrS\SS4S jr S\!4S jr"S\#4S jr$S\\\   \4   4S jr%S\&\   4S jr'S8S\(S\)4S jjr*S8S\(S\+4S jjr,S\S	\	\\4   S\-4S  jr.S\&\/   4S! jr0S\&\/   4S" jr1S	\	\\4   S\24S# jr3S	\	\\4   S\44S$ jr5S\64S% jr7  S9S	\	\\4   S\(S&\(S\84S' jjr9S\	\\4   4S( jr:S\	\\4   4S) jr;S:S* jr<S+\S\4S, jr=S\4S- jr>S:S. jr?S\S\(4S/ jr@S\S\(4S0 jrAS\SS4S1 jrBS2\SS4S3 jrCS4\S\D4S5 jrES6rFg);r#  i]  r   r!  r   Nc                 <    Xl         X l        [        U5      U l        g r%   )r   r!  r   lexer)r   r   r!  s      r    rT   Parser.__init__^  s    	 8_
r#   c                 *   [        U R                  S9nU R                  5         U R                  R	                  5       (       dP  U R                  XR                  5       5        U R                  5         U R                  R	                  5       (       d  MP  U$ )N)r   )r  r   consume_whitespacer(  is_eofparse_module_declaration!parse_leading_extended_attributes)r   modules     r    r$  Parser.parsec  sn    TYY'!**##%%))&2X2X2Z[##% **##%% r#   r/  r   c                 N   U R                  S5      (       a+  UR                  R                  U R                  U5      5        g U R                  S5      (       a+  UR                  R                  U R                  U5      5        g U R                  S5      (       a+  UR
                  R                  U R                  U5      5        g U R                  S5      (       a*  UR                  R                  U R                  5       5        g U R                  S5      (       a+  UR                  R                  U R                  U5      5        g U R                  S5      (       a+  UR                  R                  U R                  U5      5        g U R                  S5      (       a+  UR                  R                  U R                  U5      5        g U R                  S5      (       a:  UR                  R                  U R                  U[        R                  5      5        g U R                  S	5      (       a&  U R                  U[        R                  5      Ul        g U R                  S
5      (       a+  UR"                  R                  U R%                  U5      5        g U R                  S5      (       a&  U R                  U[        R                  5      Ul        g U R                  S5      (       a  U R                  U5      Ul        g UR&                  R                  U R)                  5       5        g )N
dictionaryzpartial dictionaryenumtypedefzpartial interface mixinzpartial interfacezinterface mixinzpartial namespacer   callbackr   r   )consume_optional_keywordr  appendparse_dictionaryr  r  parse_enumerationr  parse_typedefr  parse_interface_declarationr  r  r   r   r   r   r  parse_callback_functionr  parse_includes_statement)r   r/  r   s      r    r-  Parser.parse_module_declarationm  s   ((66&&t'<'<=P'QR(()=>>''..t/D/DEX/YZ((00&&t'='=>Q'RS((33OO""4#5#5#78(()BCC!!(()I)IJ])^_(()<==%%,,T-M-MNa-bc(():;;MM  !A!ABU!VW(()<==%%,,001DmF]F]^ (()=>>#??@SUbUtUtuF((44%%,,T-I-IJ]-^_((55#??@SUbUlUlmF((55#??@STF%%d&C&C&EFr#   c                 F   U R                  5       nU R                  5         U R                  S5      (       d  U R                  S5        U R	                  S5        U R                  5         U R                  5       nU R                  5         U R                  S5        [        XS9$ )Nincludesz/expected a declaration or an includes statement;)r  r  )parse_identifierr+  next_is_keywordraise_parse_errorconsume_keywordassert_specificr  )r   r  r  s      r    r=  Parser.parse_includes_statement  s    ..0!##J//""#TUZ(!**,
!S!NRRr#   r   c                     U R                  5       u  p4[        UU R                  UUUS9nU R                  U5        U R	                  5         U R                  S5        U$ )N)r   r   r   r   r   rA  )parse_named_body_headerr   r   parse_interface_bodyr+  rF  )r   r   r   r   r   r   s         r    r;  "Parser.parse_interface_declaration  sb     !88: 3#
	 	!!),!S!r#   c           
      v   UnU R                  5       u  p4/ n U R                  5         U R                  R                  S5      (       a#  U R                  5         U R	                  S5        GO)U R                  5       nU R                  S5      nUR                  U R                  5       5        U R                  5       nU R                  5         U R                  5       n	U R                  5         S n
U R                  R                  S5      (       aW  U(       a  U R                  S5        U R                  5         U R                  S5      R                  5       n
U R                  5         U R	                  S5        UR                  [        U	UUU
US95        GM|  UR                  S S9  [!        UU R"                  UUUS	9$ )
N}rA  r  =z8required dictionary member must not have a default value)r   r   r  r   r   c                     U R                   $ r%   r3   )members    r    <lambda>)Parser.parse_dictionary.<locals>.<lambda>  s    r#   )key)r   r   r   r  r   )rI  r+  r(  consume_specificrF  r.  r6  update
parse_typerB  rD  consume_until_top_levelstripr7  r  sortr  r   )r   r   dictionary_extended_attributesdictionary_namer   r  member_extended_attributesr  r^   member_namer   s              r    r8  Parser.parse_dictionary  s   )<&'+'C'C'E$*,##%zz**3//'')$$S))-)O)O)Q&44Z@H&--d.T.T.VW//+K##%//1K##%+/Mzz**3//**+ef'') $ < <S A G G I'')  %NN $$%"/(B; N 	34 # >
 	
r#   c                 4   U R                  5       nU R                  5         U R                  S5        U R                  5         U R                  5       nU R                  5         U R	                  5       nU R                  S5        [        UU R                  UUUS9$ )NrN  rA  )r   r   r   r   r   )rB  r+  rF  rV  parse_parenthesized_parametersr
  r   )r   r   r   r   r   s        r    r<  Parser.parse_callback_function  s    $$&!S!!oo'!88:
S!#! 3
 	
r#   c                     U R                  5       nU R                  5         U R                  5       nU R                  5         U R                  S5        [	        X R
                  US9$ )NrA  )r   r   r   )rV  r+  rB  rF  r  r   )r   typedef_typer   s      r    r:  Parser.parse_typedef
  sS    (!$$&!S!Dyy|DDr#   c                 |   U R                  5       nU R                  R                  S5      (       a  U R                  U5      $ U R	                  5       n/ nU R                  R                  S5      (       a  U R                  5       nU R                  R                  S5      nU(       a  [        X#XA5      $ [        X$U5      $ )NrY   r   r   )	r.  r(  rT  parse_union_typeparse_type_namenext_isparse_type_parametersr}   r   )r   r   	type_namer   r   s        r    rV  Parser.parse_type  s    "DDF::&&s++(()<==((*	$&
::c""335J::..s3'	x]]y,?@@r#   c                 R   U R                  5       /nU R                  5         U R                  S5        U R                  5         UR                  U R                  5       5        U R                  5         U R                  R                  S5      (       aa  U R                  5         UR                  U R                  5       5        U R                  5         U R                  R                  S5      (       a  Ma  U R                  S5        [        X R                  R                  S5      U5      $ )Norrb   r   )rV  r+  rE  r7  r(  rT  rF  rL   )r   r   rN   s      r    rf  Parser.parse_union_type#  s    )*!T"!DOO-.!jj))$//##% 12##% jj))$//
 	S!L***E*Ec*JL_``r#   c                 N   / nU R                  S5      (       a  UR                  S5        U R                  S5      (       a  UR                  S5        U R                  R                  S 5      nU(       d  U R	                  S5        UR                  U5        UR                  5       S:X  al  U R                  R                  5       nU R                  5         U R                  R                  S5      (       a  UR                  S5        OX0R                  l	        SR                  U5      $ )Nunsignedunrestrictedc                 :    U R                  5       =(       d    U S:H  $ )N_isalnum	characters    r    rQ  (Parser.parse_type_name.<locals>.<lambda>:  s    ):K:K:M:aQZ^aQa:ar#   ztype can't be an empty stringlong )r6  r7  r(  consume_whilerD  lowertellr+  rT  positionrc   )r   
type_wordsr   position_before_whitespaces       r    rg  Parser.parse_type_name3  s     "
((44j)((88n-zz''(ab""#BC$::<6!)-):&##%zz**622!!&)&@

#xx
##r#   c                    U R                  5       nU R                  5         SnU R                  R                  S5      (       a0  U R                  5         U R                  5       nU R                  5         U R	                  S5        X4$ )Nr   :{)rB  r+  r(  rT  rF  )r   r   r   s      r    rI  Parser.parse_named_body_headerI  ss    $$&!::&&s++##%//1K##%S!  r#   c                    U R                  5       nU R                  5         U R                  S5        / nU R                  R	                  5       (       d  U R                  5         U R                  R                  S5      (       a  OU R                  S5        U R                  R                  S 5      nU R                  S5        U R                  5         UR                  U5        U R                  5         U R                  R                  S5      (       a  M  U R                  S5        U R                  R	                  5       (       d  M  U R                  5         U R                  S5        [        UU R                  UUS9$ )Nr  rM  "c                     U S:H  $ )Nr  r.   rv  s    r    rQ  *Parser.parse_enumeration.<locals>.<lambda>c  s	    yC?Or#   ,rA  )r   r   r  r   )rB  r+  rF  r(  r,  rT  consume_untilr7  rh  r  r   )r   r   r   r  r   s        r    r9  Parser.parse_enumerationV  s/   $$&!S!**##%%##%zz**3//  %JJ,,-OPE  %##%MM% ##%zz!!#&&  % **##%%" 	!S! 3	
 	
r#   r   c                 x   U R                   R                  5       (       Gd  U R                  5         U R                   R                  S5      (       a  g U R	                  5       nU R                  5         U R                  S5      (       a+  UR                  R                  U R                  5       5        M  U R                  S5      (       a  U R                  S5      nU(       d  U R                  S5      (       a)  UR                  R                  U R                  X#S95        O*UR                  R                  U R                  U5      5        GML  U R                  S5      (       a  U R                  S5      nU(       d  U R                  S5      (       a=  U R                  X#S9nUR                  R                  U5        [        X$5      Ul        GM  U R#                  5         [        U5      Ul        GM  U R                  S5      (       a,  UR                  R                  U R                  US	S
95        GM2  U R                  S5      nU R                  S5      (       a,  UR                  R                  U R                  UUS95        GM  U R                  S5      (       a  U R%                  US9Ul        GM  U R                  S5      (       a  U R)                  US9Ul        GM  U(       a,  UR                  R                  U R                  US	S95        GM  U R                  S5      (       a-  UR,                  R                  U R/                  U5      5        GMU  U R                  S5      (       a  U R1                  5       Ul        GM  U R                  S5      (       a  U R5                  5       Ul        GM  U R                  S5      (       a  U R9                  SU5      nUR:                  nUR<                  S;   a  UR>                  (       d  XQl         O=UR<                  S:X  a  UR>                  (       d  XQl!        OU RE                  SU S35        GMM  U R                  S5      (       a  U R9                  SU5      nUR:                  nUR<                  S;   a  UR>                  (       d  XQl#        O=UR<                  S:X  a  UR>                  (       d  XQl$        OU RE                  SU S35        GM  U R                  S5      (       a^  U R9                  SU5      nUR:                  nUR<                  S;   a  UR>                  (       d  XQl%        OU RE                  SU S35        GM]  URL                  R                  U R                  U5      5        U R                   R                  5       (       d  GM  U RE                  S5        g )NrM  conststaticr   r   )r   r   r   T)r   r   r   constructorr   asyncgetter)	DOMStringUtf16DOMStringzunsigned longzHnamed/indexed property getter must use DOMString or unsigned long, got ''setterzHnamed/indexed property setter must use DOMString or unsigned long, got 'deleterz0named property deleter must use DOMString, got 'zunterminated interface body)'r(  r,  r+  rT  r.  rC  r   r7  parse_constantr6  r   parse_attributer   parse_operationr   r   r   consume_member_semicolonparse_maplike_declarationr   parse_setlike_declarationr   r   parse_constructorparse_iterable_declarationr    parse_async_iterable_declarationr   parse_special_operationr   r   r   r   r   rD  r   r   r   r   )r   r   r   r   r   special_operationr   s          r    rJ  Parser.parse_interface_bodyx  s   **##%%##%zz**3//"&"H"H"J##%##G,,##**4+>+>+@A,,X6688Dt33K@@//66t7K7KL_7K7st//66t7K7KL_7`a,,];;88Dt33K@@ $ 4 45H 4 \I0077	B,78K,WI)--/(34G(H	%,,Y77,,33D4H4HI\fj4H4kl44Z@H##K00,,33((+!) )  ##I..$($B$BH$B$U	!##I..$($B$BH$B$U	!,,33D4H4HI\gk4H4lm##M22&&--d.D.DEX.YZ##J//%)%D%D%F	"##G,,+/+P+P+R	(##H--$($@$@K^$_!"3"C"C"''+JJSbSkSk6G3$))_<_E]E]8I5**bcrbsstu ##H--$($@$@K^$_!"3"C"C"''+JJSbSkSk6G3$))_<_E]E]8I5**bcrbsstu ##I..$($@$@L_$`!"3"C"C"''+JJSbSkSk7H4**-]^m]nno+pq((//0D0DEX0YZY **##%%\ 	<=r#   c                 |    U R                  S5        U R                  5       u  pU R                  5         [        UUS9$ )Nr   )r   r   )rE  parse_iterable_type_parametersr  r   )r   r   r   s      r    r  !Parser.parse_iterable_declaration  s@    Z(#BBD%%'"!
 	
r#   c                 D   U R                  S5        U R                  5         U R                  S5        U R                  5       u  pU R                  5         / nU R                  R	                  S5      (       a  U R                  5       nU R                  5         [        UUUS9$ )Nr  r   rY   )r   r   r   )rE  r+  r  r(  rh  r`  r  r   )r   r   r   r   s       r    r  'Parser.parse_async_iterable_declaration  s    W%!Z(#BBD!/1
::c""<<>J%%''!!
 	
r#   c                     U R                  5       n[        U5      S:X  a  S US   4$ [        U5      S:X  a
  US   US   4$ U R                  S5        g )N   r      z,expected one or two iterable type parameters)ri  lenrD  r   r   s     r    r  %Parser.parse_iterable_type_parameters  sY    //1
z?aA&&z?aa=*Q-//MNr#   c                    U R                  S5        U R                  5       /nU R                  5         U R                  R	                  S5      (       aa  U R                  5         UR                  U R                  5       5        U R                  5         U R                  R	                  S5      (       a  Ma  U R                  S5        U$ )Nr   r  r   )rF  rV  r+  r(  rT  r7  r  s     r    ri  Parser.parse_type_parameters  s    S!oo'(
!jj))#..##%doo/0##% jj))#..
 	S!r#   r   c                     U R                  S5        U R                  5       n[        U5      S:w  a  U R                  S5        U R	                  5         [        US   US   US9$ )Nr   r  z$expected two maplike type parametersr   r  )r   r   r   )rE  ri  r  rD  r  r   r   r   r   s      r    r   Parser.parse_maplike_declaration  sc    Y'//1
z?a""#IJ%%'!]!!}
 	
r#   c                     U R                  S5        U R                  5       n[        U5      S:w  a  U R                  S5        U R	                  5         [        US   US9$ )Nr   r  z#expected one setlike type parameterr   )r   r   )rE  ri  r  rD  r  r   r  s      r    r   Parser.parse_setlike_declaration(  s\    Y'//1
z?a""#HI%%'!!!}
 	
r#   keywordc                    U R                  U5        U R                  5         U R                  5       nU R                  5         SnU R                  R	                  S5      (       d   U R                  5       nU R                  5         U R                  5       nU R                  5         U(       d  U R                  S5        [        US   R                  UUUUS9$ )Nr   rY   z3special operation must have an identifier parameterr   )r   r   r   r   r   )rE  r+  rV  r(  rh  rB  r`  r  rD  r   r   )r   r  r   r   r   r   s         r    r  Parser.parse_special_operation4  s    
 	W%!oo'!zz!!#&&((*D##%88:
%%'""#XY&qM..#! 3
 	
r#   c                    U R                  S5        U R                  5         / nU R                  R                  S5      (       d   U R	                  5       nU R                  5         U R                  S5        U R                  5         U$ )NrY   rb   )rF  r+  r(  rh  parse_operation_parametersr  s     r    r`  %Parser.parse_parenthesized_parametersR  sp    S!!/1
zz!!#&&88:J##%S!!r#   c                 L   / nU R                  5         U R                  R                  S5      (       Gdp  U R                  5       nU R	                  S5      nUR                  U R                  5       5        U R                  5       nU R                  5         U R                  R                  S5      nU R                  5         U R                  5       nU R                  5         S nU R                  R                  S5      (       a0  U R                  SS5      R                  5       nU R                  5         UR                  [        UUUUUUS95        U R                  R                  S5      (       d   U$ U R                  5         U R                  R                  S5      (       d  GMp  U$ )Nrb   r   z...rN  r  )r   r   r   r   r   r   )r+  r(  rh  r.  r6  rU  rV  rT  rB  rW  rX  r7  r   )r   r   r   r   parameter_typer   parameter_namer   s           r    r  !Parser.parse_operation_parameters_  sj   /1
!**$$S))"&"H"H"J44Z@H&&t'M'M'OP!__.N##%zz2259H##%!224N##%+/Mzz**3// $ < <S# F L L N'')"''%"/%(;	 ::..s33  ##%A **$$S))D r#   c                     U R                  5       nU R                  5         U R                  5       nU R                  5         U R                  5       nU R	                  5         [        UUUUS9$ )N)r   r   r   r   )rV  r+  rB  r`  r  r   )r   r   r   r   r   s        r    r  Parser.parse_operation  sg    oo'!$$&!88:
%%'#! 3	
 	
r#   c                     U R                  S5        U R                  5         U R                  5       nU R                  5         [	        UUS9$ )Nr  )r   r   )rE  r+  r`  r  r   )r   r   r   s      r    r  Parser.parse_constructor  sI    ]+!88:
%%'! 3
 	
r#   c                 z   U R                  S5        U R                  5         U R                  5       nU R                  5         U R                  5       nU R                  5         U R	                  S5        U R                  5         U R                  S5      R                  5       nU R                  5         [        UUUS9$ )Nr  rN  rA  )r   r   r   )	rE  r+  rV  rB  rF  rW  rX  r  r   )r   constant_typer   r   s       r    r  Parser.parse_constant  s    W%!)!$$&!S!!,,S1779%%'
 	
r#   r   c                     U R                  S5        U R                  5         U R                  5       nU R                  5         U R                  5       nU R	                  5         [        UUUUUS9$ )Nr   )r   r   r   r   r   )rE  r+  rV  rB  r  r   )r   r   r   r   attribute_typer   s         r    r  Parser.parse_attribute  sl     	[)!*!$$&%%' 3
 	
r#   c                 t   0 n U R                  5         U R                  R                  S5      (       a  OsU R                  5       nSnU R                  R                  S5      (       a   U R	                  SS5      R                  5       nX1U'   U R                  R                  S5        M  U R                  5         U$ )N]r   rN  r  )r+  r(  rT  rB  rW  rX  )r   r   r   r   s       r    parse_extended_attributes Parser.parse_extended_attributes  s    .0##%zz**3//((*DEzz**3//44S#>DDF(-%JJ'',  	!""r#   c                     U R                  5         U R                  R                  S5      (       a  U R                  5       $ 0 $ )N[)r+  r(  rT  r  r*   s    r    r.  (Parser.parse_leading_extended_attributes  s7    !::&&s++1133	r#   c                 F    U R                  5         U R                  S5        g )NrA  )r+  rF  r*   s    r    r  Parser.consume_member_semicolon  s    !S!r#   terminatorsc                    U R                   R                  5       n/ nSnSSSSS.nU R                   R                  5       (       Gd  U R                   R                  5       nU(       a#  U R                   R	                  5         Xd:X  a  SnMd  US;   a  UnU R                   R	                  5         M  Xa;   a-  U(       d&  U R
                  X R                   R                  5        $ U R                   R	                  5       nXe;   a  UR                  XV   5        OU(       a  XcS   :X  a  UR                  5         U R                   R                  5       (       d  GM  U R
                  X R                   R                  5        $ )	Nr   rb   r  rM  r   )rY   r  r  r   )r  r  )r(  r}  r,  peekconsumer!  r7  pop)r   r  startdelimiter_stackactive_quotematching_delimiterrw  s          r    rW  Parser.consume_until_top_level  s,   

!%'	
 **##%%

)I

""$,#%LJ&(

""$'}}UZZ__->??

**,I.&&'9'DE Y"2E%E##%+ **##%%. }}UZZ__%677r#   c                     U R                   R                  S 5      nU(       d  U R                  S5        UR                  S5      $ )Nc                 :    U R                  5       =(       d    U S;   $ )Nz_-rt  rv  s    r    rQ  )Parser.parse_identifier.<locals>.<lambda>  s    	@Q@Q@S@hW`dhWh@hr#   zexpected identifierrs  )r(  r{  rD  lstrip)r   
identifiers     r    rB  Parser.parse_identifier  s:    ZZ--.hi
""#89  %%r#   c                 |   SnU(       a  SnU R                   R                  [        R                  5      nU(       a  SnU R                   R	                  S5      (       aU  U R                   R                  S5        U R                   R                  5       S:X  a  U R                   R                  5         SnU(       a  M  g g )NTFz//
)r(  r{  rE   isspacerT  ignore_untilr  ignore)r   consumed
whitespaces      r    r+  Parser.consume_whitespace  s    H11#++>Jzz**400

''-::??$,JJ%%' hr#   c                    U R                   R                  U5      (       d  gU R                   R                  5       [        U5      -   nU[        U R                  5      :  a  gU R                  U   nUR                  5       =(       d    US;   $ )NFTz{([;:<)r(  rh  r}  r  r!  r  )r   r  endtrailing_characters       r    rC  Parser.next_is_keyword#  sp    zz!!'**jjoo#g,.#dmm$$!]]3/!))+M/AX/MMr#   c                 t    U R                  U5      (       d  gU R                  U5        U R                  5         g)NFT)rC  rE  r+  r   r  s     r    r6  Parser.consume_optional_keyword.  s3    ##G,,W%!r#   c                     U R                  U5      (       d  U R                  SU S35        U R                  R                  [	        U5      5        g Nz
expected 'r  )rC  rD  r(  r  r  r  s     r    rE  Parser.consume_keyword6  s@    ##G,,""Zy#:;

#g,'r#   expected_characterc                 p    U R                   R                  U5      (       d  U R                  SU S35        g g r  )r(  rT  rD  )r   r  s     r    rF  Parser.assert_specific;  s6    zz**+=>>""Z0B/C1#EF ?r#   messagec           	          SnSn[        U R                  5       H8  u  pEX@R                  R                  5       :X  a    OUS:X  a	  US-  nSnM3  US-  nM:     [	        U R
                   SU SU SU 35      e)Nr  r  r  z	: error: )	enumerater!  r(  r}  r   r   )r   r  line_numbercolumn_numberindexrw  s         r    rD  Parser.raise_parse_error?  s     )$-- 8E

))D q  !" !9 DII;a}Am_IgYWXXr#   )r!  r(  r   r%   )F)FF)r   N)GrA   rB   rC   rD   r   rE   rT   r  r$  r   r-  r  r=  r   r   r;  r  r8  r
  r<  r  r:  r   rV  r
   rL   rf  rg  r   rI  r  r9  rJ  r   r  r   r  r  r   ri  rG   r   r  r   r  r   r  r   r`  r  r   r  r   r  r   r  r   r  r  r.  r  rW  rB  r+  rC  r6  rE  rF  r	   rD  rI   r.   r#   r    r#  r#  ]  sR   %T %S %T %
v 3Gv 3GDQTVYQYN 3G_c 3GjS- S JWI`I`#'S>9F	"4
DcN 4
z 4
l
4S> 
N^ 
&Ew EAG AaHT#s(^4L aXd a $ $,!sCx ! 
T#s(^  
  
Do>i o>D o>b
,? 

2J 
&Ohw6G6P0Q OtG} 
$ 
CU 


$ 

CU 



 "#s(^
 
	
<5G0H &D1C,D &P
4S> 
i 
	
T#s(^ 	
 	

 
0 	
!#s(^
 
 	

 

.#4S> #&4S> ""8C "8C "8H&# & 	Ns 	Nt 	N  (s (t (
G# G$ GY Y Yr#   r#  N),dataclassesr   r   r3  r   pathlibr   typingr   r   r	   r
   r   r   Utils.lexerr   r   rL   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r  RuntimeErrorr   rE   r%  r#  r.   r#   r    <module>r     s  
 "           $  D d#$!7 $! $$!N d#7  $0    F F F F F F 2 2 2 F F F
 ' ' '
 ' ' '      
 F F F * * *
-D - A6 A6 A6H F F F F F F F F F F F F      
 : : :	 	*t *s *v *oY oYr#   