class documentation

class Modula2Lexer(RegexLexer):

View In Hierarchy

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.
New in version 1.3.
Changed in version 2.1: Added multi-dialect support.
Method __init__ Undocumented
Method analyse​_text It's Pascal-like, but does not use FUNCTION -- uses PROCEDURE instead.
Method get​_dialect​_from​_dialect​_tag Undocumented
Method get​_tokens​_unprocessed Split text into (tokentype, text) pairs.
Method set​_dialect Undocumented
Class Variable aglet​_additional​_builtins Undocumented
Class Variable aglet​_additional​_pseudo​_builtins Undocumented
Class Variable aglet​_additional​_reserved​_words Undocumented
Class Variable aliases Undocumented
Class Variable builtins​_db Undocumented
Class Variable common​_builtins Undocumented
Class Variable common​_pseudo​_builtins Undocumented
Class Variable common​_reserved​_words Undocumented
Class Variable dialects Undocumented
Class Variable filenames Undocumented
Class Variable flags Undocumented
Class Variable gm2​_additional​_builtins Undocumented
Class Variable gm2​_additional​_pseudo​_builtins Undocumented
Class Variable gm2​_additional​_reserved​_words Undocumented
Class Variable iso​_additional​_builtins Undocumented
Class Variable iso​_additional​_pseudo​_builtins Undocumented
Class Variable iso​_additional​_reserved​_words Undocumented
Class Variable iso​_lexemes​_to​_reject Undocumented
Class Variable iso​_stdlib​_const​_identifiers Undocumented
Class Variable iso​_stdlib​_module​_identifiers Undocumented
Class Variable iso​_stdlib​_proc​_identifiers Undocumented
Class Variable iso​_stdlib​_type​_identifiers Undocumented
Class Variable iso​_stdlib​_var​_identifiers Undocumented
Class Variable lexemes​_to​_reject​_db Undocumented
Class Variable m2r10​_additional​_builtins Undocumented
Class Variable m2r10​_additional​_pseudo​_builtins Undocumented
Class Variable m2r10​_additional​_reserved​_words Undocumented
Class Variable m2r10​_lexemes​_to​_reject Undocumented
Class Variable m2r10​_stdlib​_adt​_identifiers Undocumented
Class Variable m2r10​_stdlib​_blueprint​_identifiers Undocumented
Class Variable m2r10​_stdlib​_const​_identifiers Undocumented
Class Variable m2r10​_stdlib​_module​_identifiers Undocumented
Class Variable m2r10​_stdlib​_proc​_identifiers Undocumented
Class Variable m2r10​_stdlib​_type​_identifiers Undocumented
Class Variable m2r10​_stdlib​_var​_identifiers Undocumented
Class Variable mimetypes Undocumented
Class Variable name Undocumented
Class Variable objm2​_additional​_builtins Undocumented
Class Variable objm2​_additional​_pseudo​_builtins Undocumented
Class Variable objm2​_additional​_reserved​_words Undocumented
Class Variable objm2​_lexemes​_to​_reject Undocumented
Class Variable p1​_additional​_builtins Undocumented
Class Variable p1​_additional​_pseudo​_builtins Undocumented
Class Variable p1​_additional​_reserved​_words Undocumented
Class Variable pim​_additional​_builtins Undocumented
Class Variable pim​_additional​_pseudo​_builtins Undocumented
Class Variable pim​_additional​_reserved​_words Undocumented
Class Variable pim​_lexemes​_to​_reject Undocumented
Class Variable pim​_stdlib​_const​_identifiers Undocumented
Class Variable pim​_stdlib​_module​_identifiers Undocumented
Class Variable pim​_stdlib​_proc​_identifiers Undocumented
Class Variable pim​_stdlib​_type​_identifiers Undocumented
Class Variable pim​_stdlib​_var​_identifiers Undocumented
Class Variable pseudo​_builtins​_db Undocumented
Class Variable reserved​_words​_db Undocumented
Class Variable stdlib​_adts​_db Undocumented
Class Variable stdlib​_constants​_db Undocumented
Class Variable stdlib​_modules​_db Undocumented
Class Variable stdlib​_procedures​_db Undocumented
Class Variable stdlib​_types​_db Undocumented
Class Variable stdlib​_variables​_db Undocumented
Class Variable tokens Undocumented
Class Variable xds​_additional​_builtins Undocumented
Class Variable xds​_additional​_pseudo​_builtins Undocumented
Class Variable xds​_additional​_reserved​_words Undocumented
Instance Variable adts Undocumented
Instance Variable algol​_publication​_mode Undocumented
Instance Variable builtins Undocumented
Instance Variable constants Undocumented
Instance Variable dialect Undocumented
Instance Variable dialect​_set​_by​_tag Undocumented
Instance Variable lexemes​_to​_reject Undocumented
Instance Variable modules Undocumented
Instance Variable procedures Undocumented
Instance Variable pseudo​_builtins Undocumented
Instance Variable reserved​_words Undocumented
Instance Variable treat​_stdlib​_adts​_as​_builtins Undocumented
Instance Variable types Undocumented
Instance Variable variables Undocumented

Inherited from Lexer (via RegexLexer):

Method get​_tokens Return an iterable of (tokentype, value) pairs generated from text. If unfiltered is set to True, the filtering mechanism is bypassed even if filters are defined.
Class Variable alias​_filenames Undocumented
Method __repr__ Undocumented
Method add​_filter Add a new stream filter to this lexer.
Class Variable priority Undocumented
Instance Variable encoding Undocumented
Instance Variable ensurenl Undocumented
Instance Variable filters Undocumented
Instance Variable options Undocumented
Instance Variable stripall Undocumented
Instance Variable stripnl Undocumented
Instance Variable tabsize Undocumented
def __init__(self, **options):

Undocumented

def analyse_text(text):
It's Pascal-like, but does not use FUNCTION -- uses PROCEDURE instead.
def get_dialect_from_dialect_tag(self, dialect_tag):

Undocumented

def get_tokens_unprocessed(self, text):

Split text into (tokentype, text) pairs.

stack is the inital stack (default: ['root'])

def set_dialect(self, dialect_id):

Undocumented

aglet_additional_builtins: tuple[str, ...] =

Undocumented

aglet_additional_pseudo_builtins: tuple =

Undocumented

aglet_additional_reserved_words: tuple =

Undocumented

aliases: list[str] =

Undocumented

builtins_db =

Undocumented

common_builtins: tuple[str, ...] =

Undocumented

common_pseudo_builtins: tuple[str, ...] =

Undocumented

common_reserved_words: tuple[str, ...] =

Undocumented

dialects: tuple[str, ...] =

Undocumented

filenames: list[str] =

Undocumented

flags =

Undocumented

gm2_additional_builtins: tuple[str, ...] =

Undocumented

gm2_additional_pseudo_builtins: tuple =

Undocumented

gm2_additional_reserved_words: tuple[str, ...] =

Undocumented

iso_additional_builtins: tuple[str, ...] =

Undocumented

iso_additional_pseudo_builtins: tuple[str, ...] =

Undocumented

iso_additional_reserved_words: tuple[str, ...] =

Undocumented

iso_lexemes_to_reject: tuple[str, ...] =

Undocumented

iso_stdlib_const_identifiers: tuple =

Undocumented

iso_stdlib_module_identifiers: tuple =

Undocumented

iso_stdlib_proc_identifiers: tuple =

Undocumented

iso_stdlib_type_identifiers: tuple =

Undocumented

iso_stdlib_var_identifiers: tuple =

Undocumented

lexemes_to_reject_db =

Undocumented

m2r10_additional_builtins: tuple[str, ...] =

Undocumented

m2r10_additional_pseudo_builtins: tuple[str, ...] =

Undocumented

m2r10_additional_reserved_words: tuple[str, ...] =

Undocumented

m2r10_lexemes_to_reject: tuple[str, ...] =

Undocumented

m2r10_stdlib_adt_identifiers: tuple[str, ...] =

Undocumented

m2r10_stdlib_blueprint_identifiers: tuple[str, ...] =

Undocumented

m2r10_stdlib_const_identifiers: tuple[str, ...] =

Undocumented

m2r10_stdlib_module_identifiers: tuple[str, ...] =

Undocumented

m2r10_stdlib_proc_identifiers: tuple[str, ...] =

Undocumented

m2r10_stdlib_type_identifiers: tuple[str, ...] =

Undocumented

m2r10_stdlib_var_identifiers: tuple[str, ...] =

Undocumented

mimetypes: list[str] =

Undocumented

name: str =

Undocumented

objm2_additional_builtins: tuple[str, ...] =

Undocumented

objm2_additional_pseudo_builtins: tuple =

Undocumented

objm2_additional_reserved_words: tuple[str, ...] =

Undocumented

objm2_lexemes_to_reject: tuple[str, ...] =

Undocumented

p1_additional_builtins: tuple =

Undocumented

p1_additional_pseudo_builtins: tuple[str, ...] =

Undocumented

p1_additional_reserved_words: tuple =

Undocumented

pim_additional_builtins: tuple[str, ...] =

Undocumented

pim_additional_pseudo_builtins: tuple[str, ...] =

Undocumented

pim_additional_reserved_words: tuple[str, ...] =

Undocumented

pim_lexemes_to_reject: tuple[str, ...] =

Undocumented

pim_stdlib_const_identifiers: tuple[str, ...] =

Undocumented

pim_stdlib_module_identifiers: tuple[str, ...] =

Undocumented

pim_stdlib_proc_identifiers: tuple[str, ...] =

Undocumented

pim_stdlib_type_identifiers: tuple[str, ...] =

Undocumented

pim_stdlib_var_identifiers: tuple[str, ...] =

Undocumented

pseudo_builtins_db =

Undocumented

reserved_words_db =

Undocumented

stdlib_adts_db =

Undocumented

stdlib_constants_db =

Undocumented

stdlib_modules_db =

Undocumented

stdlib_procedures_db =

Undocumented

stdlib_types_db =

Undocumented

stdlib_variables_db =

Undocumented

tokens =

Undocumented

xds_additional_builtins: tuple[str, ...] =

Undocumented

xds_additional_pseudo_builtins: tuple[str, ...] =

Undocumented

xds_additional_reserved_words: tuple[str, ...] =

Undocumented

adts =

Undocumented

algol_publication_mode: bool =

Undocumented

builtins =

Undocumented

constants =

Undocumented

dialect =

Undocumented

dialect_set_by_tag: bool =

Undocumented

lexemes_to_reject =

Undocumented

modules =

Undocumented

procedures =

Undocumented

pseudo_builtins =

Undocumented

reserved_words =

Undocumented

treat_stdlib_adts_as_builtins =

Undocumented

types =

Undocumented

variables =

Undocumented