o aJ@srdZddlZddlmZmZddlmZmZddlm Z m Z m Z m Z m Z mZmZmZmZdgZGdddeZdS)z pygments.lexers.modula2 ~~~~~~~~~~~~~~~~~~~~~~~ Multi-Dialect Lexer for Modula-2. :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. N) RegexLexerinclude) get_bool_opt get_list_opt) TextCommentOperatorKeywordNameStringNumber PunctuationError Modula2Lexerc@seZdZdZdZddgZddgZdgZej ej BZ de fd e fgd e jfd e jfd e jfd e jfde jfde jfde jfde jfgdefgdejfdejfgdejfdejfdejfgdejfdejfdejfgdejfdejfgdefdefdefd efd!efd"efd#efd$efd%efd&efg d'efd(efd)efd*efd+efd,efd-efd.efd/efg d0efd1efd2efd3efd4efd5efd6efgd7efd8efd9efgd:e jfd;e jfde jfged?ed@edAedBedCedDedEedFedGedHedIedJedKg dLZdMZdNZ dOZ!dPZ"dQZ#dRZ$dSZ%dTZ&dUZ'dVZ(dWZ)dXZ*dYZ+dZZ,d[Z-d\Z.d]Z/d^Z0d_Z1d_Z2d`Z3d_Z4daZ5dbZ6d_Z7d_Z8d_Z9dcZ:ddZ;deZdhZ?diZ@djZAdkZBd_ZCd_ZDd_ZEd_ZFd_ZGdlZHdmZIdnZJdoZKdpZLdqZMdrZNdsZOd_e"fe&fe*fe.fe&fe"fe&fe&fds ZPee#e'e+fee#fee'fee+fee+e/fee'e2fee#e5fee'e8fee'e;fds ZQe e$e(e,fe e$fe e(fe e,fe e,e0fe e(e3fe e$e6fe e(e9fe e(efeCfeIeJeHfeIeJfeCfe>feCfeCfds ZUd_e?feDfeKfeKfeDfe?feDfeDfds ZVd_e@feEfeLfeLfeEfe@feEfeEfds ZWd_eAfeFfeMfeMfeFfeAfeFfeFfds ZXd_eBfeGfeNfeNfeGfeBfeGfeGfds ZYdtduZZdvdwZ[dxdyZ\dzd{Z]d|d}Z^d~S)ra 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. .. versionadded:: 1.3 .. versionchanged:: 2.1 Added multi-dialect support. zModula-2modula2m2z*.defz*.modztext/x-modula2z\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$]*)z0b[01]+(\'[01]+)*z0[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 dialecttagspragmascomments identifierssuffixed_number_literalsprefixed_number_literalsplain_number_literalsstring_literalsdigraph_punctuationdigraph_operatorsunigraph_punctuationunigraph_operators)r"r#r&r(r)r'r*r,r.r+r-r%r$root)%ANDARRAYBEGINBYCASECONST DEFINITIONDIVDOELSEELSIFENDEXITFORFROMIFIMPLEMENTATIONIMPORTINLOOPMODMODULENOTOFORPOINTER PROCEDURERECORDREPEATRETURNSETTHENTOTYPEUNTILVARWHILE)ABSBOOLEANCARDINALCHARCHRFALSEINTEGERLONGINTLONGREALMAXMINNILODDORDREALTRUE)ADDRESSBYTEWORDADR)r!rr$%?\r++rr*.+>rrr|#r )EXPORT QUALIFIEDWITH)BITSETCAPDECDISPOSEEXCLFLOATHALTHIGHINCINCLNEWr`PROCSIZETRUNCVAL)SYSTEMPROCESSTSIZE NEWPROCESSTRANSFER)rrirjrkrlrrmrrrnrorrrrpr )EXCEPTrqFINALLYFORWARD PACKEDSETrrREMRETRYrsABSTRACTASCLASSGUARDINHERITOVERRIDEREADONLYREVEALTRACED UNSAFEGUARDED)rtruCMPLXCOMPLEXrvrwrxryrzr{IMr|r}INT INTERRUPTIBLELENGTHLFLOAT LONGCOMPLEXr~r PROTECTIONRErrUNINTERRUBTIBLErCREATEDESTROYEMPTYISMEMBERSELF):r BITSPERLOC LOCSPERBYTE LOCSPERWORDLOCADDADRSUBADRDIFADRMAKEADRrhROTATESHIFTCASTr COROUTINESATTACH COROUTINECURRENTDETACHHANDLERINTERRUPTSOURCE IOTRANSFER IsATTACHEDLISTEN NEWCOROUTINEPROTr EXCEPTIONSAllocateSource CurrentNumberExceptionNumberExceptionSource GetMessageIsCurrentSourceIsExceptionalExecutionRAISE TERMINATION IsTerminating HasHalted M2EXCEPTION M2Exceptions M2Exception IsM2ExceptionindexExceptionrangeExceptioncaseSelectExceptioninvalidLocationfunctionExceptionwholeValueExceptionwholeDivExceptionrealValueExceptionrealDivExceptioncomplexValueExceptioncomplexDivException protException sysException coException exException)r!rrrirjrr)ALIASARGLIST BLUEPRINTCOPYGENLIB INDETERMINATEr~NONEOPAQUE REFERENTIALRELEASERETAINASMREG)rWCOUNTrEXISTSINSERTrLONGCARDOCTETPTRPREDREADREADNEWREMOVERETRIEVESORTSTORESUBSETSUCCTLIMITTMAXTMINrdrUNICHARWRITEWRITEF)K TPROPERTIESPROPERTYLITERAL TPROPERTYTLITERALTBUILTINTDYNTREFCTNILTBASE TPRECISIONTMAXEXPTMINEXP CONVERSIONTSXFSIZESXFrUNSAFEr INTRINSICAVAILADDSUBADDCSUBCFETCHADDFETCHSUBSHLSHRASHRROTLROTRROTLCROTRCBWNOTBWANDBWORBWXORBWNANDBWNORSETBITTESTBITLSBITMSBITCSBITSBAILrzTODOFFIADDRVARGLISTVARGCATOMICrrSWAPCASr|rvr!r$r"r#COMPILERDEBUGMODNAMEPROCNAMELINENUMDEFAULTHASH ASSEMBLERREGISTERSETREGGETREGCODE)r!rirjrr)BYCOPYBYREFrCONTINUECRITICALINOUTMETHODONOPTIONALOUTPRIVATE PROTECTEDPROTOCOLPUBLICSUPERTRY)OBJECTNOYES) BITSET8BITSET16BITSET32 CARDINAL8 CARDINAL16 CARDINAL32INTEGER8 INTEGER16 INTEGER32) r __ATTRIBUTE__ __BUILTIN__ __COLUMN____DATE____FILE__ __FUNCTION____LINE__ __MODULE__VOLATILE)rSrTrUrVrWrX CARDINAL64 COMPLEX32 COMPLEX64 COMPLEX96 COMPLEX128rYrZr[ INTEGER64REAL8REAL16REAL32REAL96REAL128THROW)BCD)SEQ) ASHASSERT DIFFADR_TYPEENTIERINDEXLENr SHORTCARDSHORTINT)rrBOOL8BOOL16BOOL32CARD8CARD16CARD32INT8INT16INT32REFMOVEFILLGETPUTCCintunsignedsize_t voidCOMPILEROPTIONEQUATION)Terminal FileSystemInOut RealInOutMathLib0Storage) FlagFlagSetResponseCommandLock Permission MediumTypeFileFileProc DirectoryProc FileCommandDirectoryCommand)9ReadBusyRead ReadAgainWrite WriteStringWriteLnCreateLookupCloseDeleteRenameSetReadSetWrite SetModifySetOpenDoioSetPosGetPosLengthResetAgainReadWord WriteWordReadChar WriteChar CreateMedium DeleteMedium AssignName DeassignName ReadMedium LookupMedium OpenInput OpenOutput CloseInput CloseOutput ReadStringReadIntReadCardReadWrdWriteInt WriteCardWriteOctWriteHexWriteWrdReadReal WriteReal WriteFixPt WriteRealOctsqrtexplnsincosarctanentierALLOCATE DEALLOCATE)DonetermCHinout)EOL)0rqLONGBCDrt SHORTBITSET LONGBITSETLONGLONGBITSETrrry LONGLONGCARDrz LONGLONGINTPOSINT SHORTPOSINT LONGPOSINTLONGLONGPOSINTrSrTrUBITSET64 BITSET128BS8BS16BS32BS64BS128rVrWrXre CARDINAL128r~rrCARD64CARD128rYrZr[rj INTEGER128rrrINT64INT128STRING UNISTRING) ProtoRootProtoComputational ProtoNumeric ProtoScalarProtoNonScalar ProtoCardinal ProtoInteger ProtoReal ProtoComplex ProtoVector ProtoTupleProtoCompArrayProtoCollectionProtoStaticArrayProtoStaticSetProtoStaticString ProtoArray ProtoStringProtoSet ProtoMultiSetProtoDictionaryProtoMultiDictProtoExtensionProtoIO ProtoCardMath ProtoIntMath ProtoRealMath)ASCII BooleanIOCharIO UnicharIOOctetIO CardinalIO LongCardIO IntegerIO LongIntIORealIO LongRealIOBCDIO LongBCDIOCardMath LongCardMathIntMath LongIntMathRealMath LongRealMathBCDMath LongBCDMathFileIOrr IOSupport)rStatus)rrr)stdInstdOutstdErr)pitau) unknownm2pimm2isom2r10objm2z m2iso+agletz m2pim+gm2zm2iso+p1z m2iso+xdscKst|dg}|D]}||jddvr||nq|dd|_t|dg}d|vs1d|vr5d |_nd|_t|d d |_tj|fi|dS) Ndialectr1Fstylealgolalgol_nuTtreat_stdlib_adts_as_builtins) rdialects set_dialectdialect_set_by_tagalgol_publication_moderr<r__init__)selfoptionsr=dialect_optionstylesrRrR9/usr/lib/python3/dist-packages/pygments/lexers/modula2.pyrAs    zModula2Lexer.__init__cCs||jvrd}n|}t}|j|D] }|t|qt}|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||_||_||_||_||_||_| |_| |_| |_| |_| |_dS)Nr1)r=setlexemes_to_reject_dbupdatereserved_words_db builtins_db differencepseudo_builtins_dbstdlib_adts_dbstdlib_modules_dbstdlib_types_dbstdlib_procedures_dbstdlib_variables_dbstdlib_constants_dbr6lexemes_to_rejectreserved_wordsbuiltinspseudo_builtinsadtsmodulestypes procedures variables constants)rB dialect_idr6lexemes_to_reject_setlist reswords_set builtins_setpseudo_builtins_setadts_set modules_set types_setprocedures_set variables_set constants_setrRrRrFr>sX  zModula2Lexer.set_dialectc Csd}d}t|}t|}|}| }t|||krA||rA||rA|||}tdt|jD] } ||j| kr>|Sq1dSdS)Nz(*!*)r7r1)len startswithendswithranger=) rB dialect_tagleft_tag_delimright_tag_delimleft_tag_delim_lenright_tag_delim_lenindicator_start indicator_end indicatorindexrRrRrFget_dialect_from_dialect_tag|s$  z)Modula2Lexer.get_dialect_from_dialect_tagccst||D]N\}}}|js&|tjkr&||}|dkr&||d|_|tur||jvr;t j }|j r9| }n||j vrLtj}|j rJ| }n||jvr]tjj}|j r\| }n||jvru|jsitj}ntjj}|j rt| }n||jvr~tj}n||jvrtj}n||jvrtj}n||jvrtj}n||jvrtj}n|tvr|jdvrd|vs|dddvrt}n|jdvr|tj urt}n|tj!urd |vrt}n}|tj"urd |vrt}nq|tvr|tj#ur|jdvrt}|tj$ur|%d r|j%d rt}nJ|%d r|jdkr|j%d stj&}n3||j'vr%t}|j rP|dkr1d}n|dkr9d}n|dkrAd}n|dkrId}n|dkrPd}|||fVqdS)Nr1T)r1r4r5'r)0b0x0u)r4r5HEz<*r2z(*$#u≠ru≤ru≥ru≡rnu•)(rget_tokens_unprocessedr?rSpecialrxr>r rUr Reservedr@lowerrVBuiltinrWPseudorXr< NamespacerYrZClassr[Functionr\Variabler]Constantr r6rOctHexFloatSinglePreprocrl MultilinerT)rBtextrwtokenvalueindicated_dialectrRrRrFrs                             z#Modula2Lexer.get_tokens_unprocessedcCsHd|vr d|vr d|vsdSd}td|r|d7}td|r"d }|S) zNIt's Pascal-like, but does not use FUNCTION -- uses PROCEDURE instead.z(*rjrNrz \bPROCEDURE\bg333333?z \bFUNCTION\bg)research)rresultrRrRrF analyse_texts  zModula2Lexer.analyse_textN)___name__ __module__ __qualname____doc__namealiases filenames mimetypesr MULTILINEDOTALLflagsrrrr r BinrrIntegerrr Doublerrr rrrtokenscommon_reserved_wordscommon_builtinscommon_pseudo_builtinspim_lexemes_to_rejectpim_additional_reserved_wordspim_additional_builtinspim_additional_pseudo_builtinsiso_lexemes_to_rejectiso_additional_reserved_wordsiso_additional_builtinsiso_additional_pseudo_builtinsm2r10_lexemes_to_rejectm2r10_additional_reserved_wordsm2r10_additional_builtins m2r10_additional_pseudo_builtinsobjm2_lexemes_to_rejectobjm2_additional_reserved_wordsobjm2_additional_builtins objm2_additional_pseudo_builtinsaglet_additional_reserved_wordsaglet_additional_builtins aglet_additional_pseudo_builtinsgm2_additional_reserved_wordsgm2_additional_builtinsgm2_additional_pseudo_builtinsp1_additional_reserved_wordsp1_additional_builtinsp1_additional_pseudo_builtinsxds_additional_reserved_wordsxds_additional_builtinsxds_additional_pseudo_builtinspim_stdlib_module_identifierspim_stdlib_type_identifierspim_stdlib_proc_identifierspim_stdlib_var_identifierspim_stdlib_const_identifiersiso_stdlib_module_identifiersiso_stdlib_type_identifiersiso_stdlib_proc_identifiersiso_stdlib_var_identifiersiso_stdlib_const_identifiersm2r10_stdlib_adt_identifiers"m2r10_stdlib_blueprint_identifiersm2r10_stdlib_module_identifiersm2r10_stdlib_type_identifiersm2r10_stdlib_proc_identifiersm2r10_stdlib_var_identifiersm2r10_stdlib_const_identifiersr=rHrJrKrMrNrOrPrQrRrSrAr>rxrrrRrRrRrFrs      %             + C C B141111&f0 n)rrpygments.lexerrr pygments.utilrrpygments.tokenrrrr r r r r r__all__rrRrRrRrFs ,