o
    ThP                     @   sr   d Z ddlZddlmZmZ ddlmZmZ ddlm	Z	m
Z
mZmZmZmZmZmZmZ dgZG dd deZdS )z
    pygments.lexers.modula2
    ~~~~~~~~~~~~~~~~~~~~~~~

    Multi-Dialect Lexer for Modula-2.

    :copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)
RegexLexerinclude)get_bool_optget_list_opt)	TextCommentOperatorKeywordNameStringNumberPunctuationErrorModula2Lexerc                   @   s  e Zd ZdZdZdZddgZddgZdgZd	Z	e
je
jB Zd
efdefgdejfdejfdejfdejfdejfdejfdejfdejfgdefgdejfdejfgdejfdejfdejfgdejfdejfdejfgdejfdejfgdefd efd!efd"efd#efd$efd%efd&efd'efd(efg
d)efd*efd+efd,efd-efd.efd/efd0efd1efg	d2efd3efd4efd5efd6efd7efd8efgd9efd:efd;efgd<ejfd=ejfd>ejfgd?ejfd@ejfgedAedBedCedDedEedFedGedHedIedJedKedLedMgdNZ dOZ!dPZ"dQZ#dRZ$dSZ%dTZ&dUZ'dVZ(dWZ)dXZ*dYZ+dZZ,d[Z-d\Z.d]Z/d^Z0d_Z1d`Z2daZ3daZ4dbZ5daZ6dcZ7ddZ8daZ9daZ:daZ;deZ<dfZ=dgZ>dhZ?diZ@djZAdkZBdlZCdmZDdaZEdaZFdaZGdaZHdaZIdnZJdoZKdpZLdqZMdrZNdsZOdtZPduZQdae$fe(fe,fe0fe(fe$fe(fe(fdu	ZRe!e%e)e-fe!e%fe!e)fe!e-fe!e-e1fe!e)e4fe!e%e7fe!e)e:fe!e)e=fdu	ZSe"e&e*e.fe"e&fe"e*fe"e.fe"e.e2fe"e*e5fe"e&e8fe"e*e;fe"e*e>fdu	ZTe#e'e+e/fe#e'fe#e+fe#e/fe#e/e3fe#e+e6fe#e'e9fe#e+e<fe#e+e?fdu	ZUdadadaeJfeJfdadadadadu	ZVdae@feEfeKeLeJfeKeLfeEfe@feEfeEfdu	ZWdaeAfeFfeMfeMfeFfeAfeFfeFfdu	ZXdaeBfeGfeNfeNfeGfeBfeGfeGfdu	ZYdaeCfeHfeOfeOfeHfeCfeHfeHfdu	ZZdaeDfeIfePfePfeIfeDfeIfeIfdu	Z[dvdw Z\dxdy Z]dzd{ Z^d|d} Z_d~d Z`dS )r   a  
    For Modula-2 source code.

    The Modula-2 lexer supports several dialects.  By default, it operates in
    fallback mode, recognising the *combined* literals, punctuation symbols
    and operators of all supported dialects, and the *combined* reserved words
    and builtins of PIM Modula-2, ISO Modula-2 and Modula-2 R10, while not
    differentiating between library defined identifiers.

    To select a specific dialect, a dialect option may be passed
    or a dialect tag may be embedded into a source file.

    Dialect Options:

    `m2pim`
        Select PIM Modula-2 dialect.
    `m2iso`
        Select ISO Modula-2 dialect.
    `m2r10`
        Select Modula-2 R10 dialect.
    `objm2`
        Select Objective Modula-2 dialect.

    The PIM and ISO dialect options may be qualified with a language extension.

    Language Extensions:

    `+aglet`
        Select Aglet Modula-2 extensions, available with m2iso.
    `+gm2`
        Select GNU Modula-2 extensions, available with m2pim.
    `+p1`
        Select p1 Modula-2 extensions, available with m2iso.
    `+xds`
        Select XDS Modula-2 extensions, available with m2iso.


    Passing a Dialect Option via Unix Commandline Interface

    Dialect options may be passed to the lexer using the `dialect` key.
    Only one such option should be passed. If multiple dialect options are
    passed, the first valid option is used, any subsequent options are ignored.

    Examples:

    `$ pygmentize -O full,dialect=m2iso -f html -o /path/to/output /path/to/input`
        Use ISO dialect to render input to HTML output
    `$ pygmentize -O full,dialect=m2iso+p1 -f rtf -o /path/to/output /path/to/input`
        Use ISO dialect with p1 extensions to render input to RTF output


    Embedding a Dialect Option within a source file

    A dialect option may be embedded in a source file in form of a dialect
    tag, a specially formatted comment that specifies a dialect option.

    Dialect Tag EBNF::

       dialectTag :
           OpeningCommentDelim Prefix dialectOption ClosingCommentDelim ;

       dialectOption :
           'm2pim' | 'm2iso' | 'm2r10' | 'objm2' |
           'm2iso+aglet' | 'm2pim+gm2' | 'm2iso+p1' | 'm2iso+xds' ;

       Prefix : '!' ;

       OpeningCommentDelim : '(*' ;

       ClosingCommentDelim : '*)' ;

    No whitespace is permitted between the tokens of a dialect tag.

    In the event that a source file contains multiple dialect tags, the first
    tag that contains a valid dialect option will be used and any subsequent
    dialect tags will be ignored.  Ideally, a dialect tag should be placed
    at the beginning of a source file.

    An embedded dialect tag overrides a dialect option set via command line.

    Examples:

    ``(*!m2r10*) DEFINITION MODULE Foobar; ...``
        Use Modula2 R10 dialect to render this source file.
    ``(*!m2pim+gm2*) DEFINITION MODULE Bazbam; ...``
        Use PIM dialect with GNU extensions to render this source file.


    Algol Publication Mode:

    In Algol publication mode, source text is rendered for publication of
    algorithms in scientific papers and academic texts, following the format
    of the Revised Algol-60 Language Report.  It is activated by passing
    one of two corresponding styles as an option:

    `algol`
        render reserved words lowercase underline boldface
        and builtins lowercase boldface italic
    `algol_nu`
        render reserved words lowercase boldface (no underlining)
        and builtins lowercase boldface italic

    The lexer automatically performs the required lowercase conversion when
    this mode is activated.

    Example:

    ``$ pygmentize -O full,style=algol -f latex -o /path/to/output /path/to/input``
        Render input file in Algol publication mode to LaTeX output.


    Rendering Mode of First Class ADT Identifiers:

    The rendering of standard library first class ADT identifiers is controlled
    by option flag "treat_stdlib_adts_as_builtins".

    When this option is turned on, standard library ADT identifiers are rendered
    as builtins.  When it is turned off, they are rendered as ordinary library
    identifiers.

    `treat_stdlib_adts_as_builtins` (default: On)

    The option is useful for dialects that support ADTs as first class objects
    and provide ADTs in the standard library that would otherwise be built-in.

    At present, only Modula-2 R10 supports library ADTs as first class objects
    and therefore, no ADT identifiers are defined for any other dialects.

    Example:

    ``$ pygmentize -O full,dialect=m2r10,treat_stdlib_adts_as_builtins=Off ...``
        Render standard library ADTs as ordinary library types.

    .. versionchanged:: 2.1
       Added multi-dialect support.
    zModula-2zhttp://www.modula2.org/modula2m2z*.defz*.modztext/x-modula2z1.3z\n+z\s+z\(\*!m2pim\*\)z\(\*!m2iso\*\)z\(\*!m2r10\*\)z\(\*!objm2\*\)z\(\*!m2iso\+aglet\*\)z\(\*!m2pim\+gm2\*\)z\(\*!m2iso\+p1\*\)z\(\*!m2iso\+xds\*\)z([a-zA-Z_$][\w$]*)z0b[01]+(\'[01]+)*z0[ux][0-9A-F]+(\'[0-9A-F]+)*z>[0-9]+(\'[0-9]+)*\.[0-9]+(\'[0-9]+)*[eE][+-]?[0-9]+(\'[0-9]+)*z$[0-9]+(\'[0-9]+)*\.[0-9]+(\'[0-9]+)*z[0-9]+(\'[0-9]+)*z[0-7]+Bz[0-7]+Cz
[0-9A-F]+Hz"(\\\\|\\[^\\]|[^"\\])*"z'(\\\\|\\[^\\]|[^'\\])*'z\*\.z\+><><=>===:::=z\+\+--z[+-]z[*/]z\\z[=#<>]z\^@&~`z\.\.<<>>->z\|###z\|\*z[()\[\]{},.:;|]!z\?z^//.*?\nz\(\*([^$].*?)\*\)z/\*(.*?)\*/z	<\*.*?\*>z\(\*\$.*?\*\)
whitespacedialecttagspragmascommentsidentifierssuffixed_number_literalsprefixed_number_literalsplain_number_literalsstring_literalsdigraph_punctuationdigraph_operatorsunigraph_punctuationunigraph_operators)r"   r#   r&   r(   r)   r'   r*   r,   r.   r+   r-   r%   r$   root)%ANDARRAYBEGINBYCASECONST
DEFINITIONDIVDOELSEELSIFENDEXITFORFROMIFIMPLEMENTATIONIMPORTINLOOPMODMODULENOTOFORPOINTER	PROCEDURERECORDREPEATRETURNSETTHENTOTYPEUNTILVARWHILE)ABSBOOLEANCARDINALCHARCHRFALSEINTEGERLONGINTLONGREALMAXMINNILODDORDREALTRUE)ADDRESSBYTEWORDADR)r!   r   r   $%?\r   ++r   r   *.+>r   r   r   |#r    )EXPORT	QUALIFIEDWITH)BITSETCAPDECDISPOSEEXCLFLOATHALTHIGHINCINCLNEWr`   PROCSIZETRUNCVAL)SYSTEMPROCESSTSIZE
NEWPROCESSTRANSFER)r   ri   rj   rk   rl   r   rm   r   r   rn   ro   r   r   r   rp   r    )EXCEPTrq   FINALLYFORWARD	PACKEDSETrr   REMRETRYrs   ABSTRACTASCLASSGUARDINHERITOVERRIDEREADONLYREVEALTRACEDUNSAFEGUARDED)rt   ru   CMPLXCOMPLEXrv   rw   rx   ry   rz   r{   IMr|   r}   INTINTERRUPTIBLELENGTHLFLOATLONGCOMPLEXr~   r   
PROTECTIONREr   r   UNINTERRUBTIBLEr   CREATEDESTROYEMPTYISMEMBERSELF):r   
BITSPERLOCLOCSPERBYTELOCSPERWORDLOCADDADRSUBADRDIFADRMAKEADRrh   ROTATESHIFTCASTr   
COROUTINESATTACH	COROUTINECURRENTDETACHHANDLERINTERRUPTSOURCE
IOTRANSFER
IsATTACHEDLISTENNEWCOROUTINEPROTr   
EXCEPTIONSAllocateSourceCurrentNumberExceptionNumberExceptionSource
GetMessageIsCurrentSourceIsExceptionalExecutionRAISETERMINATIONIsTerminating	HasHaltedM2EXCEPTIONM2ExceptionsM2ExceptionIsM2ExceptionindexExceptionrangeExceptioncaseSelectExceptioninvalidLocationfunctionExceptionwholeValueExceptionwholeDivExceptionrealValueExceptionrealDivExceptioncomplexValueExceptioncomplexDivExceptionprotExceptionsysExceptioncoExceptionexException)r!   r   r   ri   rj   r   r   )ALIASARGLIST	BLUEPRINTCOPYGENLIBINDETERMINATEr~   NONEOPAQUEREFERENTIALRELEASERETAINASMREG)rW   COUNTr   EXISTSINSERTr   LONGCARDOCTETPTRPREDREADREADNEWREMOVERETRIEVESORTSTORESUBSETSUCCTLIMITTMAXTMINrd   r   UNICHARWRITEWRITEF)KTPROPERTIESPROPERTYLITERAL	TPROPERTYTLITERALTBUILTINTDYNTREFCTNILTBASE
TPRECISIONTMAXEXPTMINEXP
CONVERSIONTSXFSIZESXFr   UNSAFEr   	INTRINSICAVAILADDSUBADDCSUBCFETCHADDFETCHSUBSHLSHRASHRROTLROTRROTLCROTRCBWNOTBWANDBWORBWXORBWNANDBWNORSETBITTESTBITLSBITMSBITCSBITSBAILrz   TODOFFIADDRVARGLISTVARGCATOMICr  r  SWAPCASr|   rv   r!  r$  r"  r#  COMPILERDEBUGMODNAMEPROCNAMELINENUMDEFAULTHASH	ASSEMBLERREGISTERSETREGGETREGCODE)r!   ri   rj   r   r   )BYCOPYBYREFr   CONTINUECRITICALINOUTMETHODONOPTIONALOUTPRIVATE	PROTECTEDPROTOCOLPUBLICSUPERTRY)OBJECTNOYES )	BITSET8BITSET16BITSET32	CARDINAL8
CARDINAL16
CARDINAL32INTEGER8	INTEGER16	INTEGER32)
r   __ATTRIBUTE____BUILTIN__
__COLUMN____DATE____FILE____FUNCTION____LINE__
__MODULE__VOLATILE)rS  rT  rU  rV  rW  rX  
CARDINAL64	COMPLEX32	COMPLEX64	COMPLEX96
COMPLEX128rY  rZ  r[  	INTEGER64REAL8REAL16REAL32REAL96REAL128THROW)BCD)SEQ)	ASHASSERTDIFFADR_TYPEENTIERINDEXLENr   	SHORTCARDSHORTINT)r   r   BOOL8BOOL16BOOL32CARD8CARD16CARD32INT8INT16INT32REFMOVEFILLGETPUTCCintunsignedsize_tvoidCOMPILEROPTIONEQUATION)Terminal
FileSystemInOut	RealInOutMathLib0Storage)FlagFlagSetResponseCommandLock
Permission
MediumTypeFileFileProcDirectoryProcFileCommandDirectoryCommand)9ReadBusyRead	ReadAgainWriteWriteStringWriteLnCreateLookupCloseDeleteRenameSetReadSetWrite	SetModifySetOpenDoioSetPosGetPosLengthResetAgainReadWord	WriteWordReadChar	WriteCharCreateMediumDeleteMedium
AssignNameDeassignName
ReadMediumLookupMedium	OpenInput
OpenOutput
CloseInputCloseOutput
ReadStringReadIntReadCardReadWrdWriteInt	WriteCardWriteOctWriteHexWriteWrdReadReal	WriteReal
WriteFixPtWriteRealOctsqrtexplnsincosarctanentierALLOCATE
DEALLOCATE)DonetermCHinout)EOL)0rq  LONGBCDrt   SHORTBITSET
LONGBITSETLONGLONGBITSETr   r   ry  LONGLONGCARDrz  LONGLONGINTPOSINTSHORTPOSINT
LONGPOSINTLONGLONGPOSINTrS  rT  rU  BITSET64	BITSET128BS8BS16BS32BS64BS128rV  rW  rX  re  CARDINAL128r~  r  r  CARD64CARD128rY  rZ  r[  rj  
INTEGER128r  r  r  INT64INT128STRING	UNISTRING)	ProtoRootProtoComputationalProtoNumericProtoScalarProtoNonScalarProtoCardinalProtoInteger	ProtoRealProtoComplexProtoVector
ProtoTupleProtoCompArrayProtoCollectionProtoStaticArrayProtoStaticSetProtoStaticString
ProtoArrayProtoStringProtoSetProtoMultiSetProtoDictionaryProtoMultiDictProtoExtensionProtoIOProtoCardMathProtoIntMathProtoRealMath)ASCII	BooleanIOCharIO	UnicharIOOctetIO
CardinalIO
LongCardIO	IntegerIO	LongIntIORealIO
LongRealIOBCDIO	LongBCDIOCardMathLongCardMathIntMathLongIntMathRealMathLongRealMathBCDMathLongBCDMathFileIOr  r  	IOSupport)r  Status)r  r  r   )stdInstdOutstdErr)pitau)	unknownm2pimm2isom2r10objm2zm2iso+agletz	m2pim+gm2zm2iso+p1z	m2iso+xdsc                 K   s   t |dg }|D ]}|| jdd v r| |  nq| d d| _t |dg }d|v s1d|v r5d	| _nd| _t|d
d	| _tj| fi | d S )Ndialect   r1  Fstylealgolalgol_nuTtreat_stdlib_adts_as_builtins)	r   dialectsset_dialectdialect_set_by_tagalgol_publication_moder   r<  r   __init__)selfoptionsr=  dialect_optionstylesrR  rR  X/home/air/segue/gemini/back/venv/lib/python3.10/site-packages/pygments/lexers/modula2.pyrA    s    

zModula2Lexer.__init__c                 C   s  || j vrd}n|}t }| j| D ]	}|t| qt }| j| D ]	}|t| q$t }| j| D ]}|t|| q6t }| j| D ]}|t|| qKt }| j| D ]}|t|| q`t }	| j	| D ]}|	t|| qut }
| j
| D ]}|
t|| qt }| j| D ]}|t|| qt }| j| D ]}|t|| qt }| j| D ]}|t|| q|| _|| _|| _|| _|| _|| _|	| _|
| _|| _|| _|| _d S )Nr1  )r=  setlexemes_to_reject_dbupdatereserved_words_dbbuiltins_db
differencepseudo_builtins_dbstdlib_adts_dbstdlib_modules_dbstdlib_types_dbstdlib_procedures_dbstdlib_variables_dbstdlib_constants_dbr6  lexemes_to_rejectreserved_wordsbuiltinspseudo_builtinsadtsmodulestypes
procedures	variables	constants)rB  
dialect_idr6  lexemes_to_reject_setlistreswords_setbuiltins_setpseudo_builtins_setadts_setmodules_set	types_setprocedures_setvariables_setconstants_setrR  rR  rF  r>    sX   

zModula2Lexer.set_dialectc           
      C   s   d}d}t |}t |}|}| }t ||| krA||rA||rA||| }tdt | jD ]}	|| j|	 kr>|  S q1dS dS )Nz(*!*)r7  r1  )len
startswithendswithranger=  )
rB  dialect_tagleft_tag_delimright_tag_delimleft_tag_delim_lenright_tag_delim_lenindicator_startindicator_end	indicatorindexrR  rR  rF  get_dialect_from_dialect_tag|  s$   	z)Modula2Lexer.get_dialect_from_dialect_tagc                 c   s   t | |D ]N\}}}| js&|tjkr&| |}|dkr&| | d| _|tu r|| jv r;t	j
}| jr9| }n|| jv rLtj}| jrJ| }n|| jv r]tjj}| jr\| }n|| jv ru| jsitj}ntjj}| jrt| }n|| jv r~tj}n|| jv rtj}n|| jv rtj}n|| jv rtj}n|| jv rtj}n|tv r| jdvrd|v s|dd dv rt}n| jdv r|tj u rt}n|tj!u rd	|v rt}n}|tj"u rd
|v rt}nq|tv r|tj#u r| jdvrt}|tj$u r|%dr| j%drt}nJ|%dr| jdkr| j%dstj&}n3|| j'v r%t}| jrP|dkr1d}n|dkr9d}n|dkrAd}n|dkrId}n|dkrPd}|||fV  qd S )Nr1  T)r1  r4  r5  'r      )0b0x0u)r4  r5  HEz<*r2  z(*$#u   ≠r   u   ≤r   u   ≥r   u   ≡rn   u   •)(r   get_tokens_unprocessedr?  r   Specialrx  r>  r
   rU  r	   Reservedr@  lowerrV  BuiltinrW  PseudorX  r<  	NamespacerY  rZ  Classr[  Functionr\  Variabler]  Constantr   r6  r   OctHexFloatSinglePreprocrl  	MultilinerT  )rB  textrw  tokenvalueindicated_dialectrR  rR  rF  r    s   























z#Modula2Lexer.get_tokens_unprocessedc                 C   sH   d| v rd| v rd| v sdS d}t d| r|d7 }t d| r"d	}|S )
zNIt's Pascal-like, but does not use FUNCTION -- uses PROCEDURE
        instead.z(*rj  r   Nr   z\bPROCEDURE\bg333333?z\bFUNCTION\bg        )research)r  resultrR  rR  rF  analyse_text  s   zModula2Lexer.analyse_textN)a__name__
__module____qualname____doc__nameurlaliases	filenames	mimetypesversion_addedr  	MULTILINEDOTALLflagsr   r   r  r
   r   Binr  r  Integerr  r   Doubler  r   r   r  r  r   tokenscommon_reserved_wordscommon_builtinscommon_pseudo_builtinspim_lexemes_to_rejectpim_additional_reserved_wordspim_additional_builtinspim_additional_pseudo_builtinsiso_lexemes_to_rejectiso_additional_reserved_wordsiso_additional_builtinsiso_additional_pseudo_builtinsm2r10_lexemes_to_rejectm2r10_additional_reserved_wordsm2r10_additional_builtins m2r10_additional_pseudo_builtinsobjm2_lexemes_to_rejectobjm2_additional_reserved_wordsobjm2_additional_builtins objm2_additional_pseudo_builtinsaglet_additional_reserved_wordsaglet_additional_builtins aglet_additional_pseudo_builtinsgm2_additional_reserved_wordsgm2_additional_builtinsgm2_additional_pseudo_builtinsp1_additional_reserved_wordsp1_additional_builtinsp1_additional_pseudo_builtinsxds_additional_reserved_wordsxds_additional_builtinsxds_additional_pseudo_builtinspim_stdlib_module_identifierspim_stdlib_type_identifierspim_stdlib_proc_identifierspim_stdlib_var_identifierspim_stdlib_const_identifiersiso_stdlib_module_identifiersiso_stdlib_type_identifiersiso_stdlib_proc_identifiersiso_stdlib_var_identifiersiso_stdlib_const_identifiersm2r10_stdlib_adt_identifiers"m2r10_stdlib_blueprint_identifiersm2r10_stdlib_module_identifiersm2r10_stdlib_type_identifiersm2r10_stdlib_proc_identifiersm2r10_stdlib_var_identifiersm2r10_stdlib_const_identifiersr=  rH  rJ  rK  rM  rN  rO  rP  rQ  rR  rS  rA  r>  rx  r  r  rR  rR  rR  rF  r      s    	

  %

			
		+	C	C	B141111&f0n)r  r  pygments.lexerr   r   pygments.utilr   r   pygments.tokenr   r   r   r	   r
   r   r   r   r   __all__r   rR  rR  rR  rF  <module>   s    
,