ffmt_case Module

Letter case of keywords, dot operators, intrinsic procedures, the constants of the intrinsic modules, and kinds.

Fortran names are not reserved, so a word is only treated as a keyword where its position makes it one: the leading words of a statement (end subroutine, integer, if, else if, select case, implicit none, ...), the attributes of a declaration before ::, in/out/inout in intent(), kind=/len= in a type, then, only:, result() and bind(). A word that names something (call open(...), subroutine real, end function do) keeps its case. Changing the case of a name never changes the meaning of the code, so a misclassified word is a matter of style only.

Intrinsic procedures are recognized where they are called (followed by (, or after call), and the constants and types of iso_fortran_env and iso_c_binding wherever they are used, but not as the first word of a statement, after %, as an entity being declared, or as the name of a procedure being defined. Kinds are the values of kind=, the kind of a declaration's type (real(dp) :: x), the kind of a literal (2_int64, .true._lk, ck_'a') and exponent letters (1.0e-3).


Uses

  • module~~ffmt_case~~UsesGraph module~ffmt_case ffmt_case module~ffmt_options ffmt_options module~ffmt_case->module~ffmt_options module~ffmt_source ffmt_source module~ffmt_case->module~ffmt_source module~ffmt_statements ffmt_statements module~ffmt_case->module~ffmt_statements module~ffmt_tokens ffmt_tokens module~ffmt_case->module~ffmt_tokens module~ffmt_source->module~ffmt_statements module~ffmt_source->module~ffmt_tokens module~ffmt_directives ffmt_directives module~ffmt_source->module~ffmt_directives module~ffmt_lexer ffmt_lexer module~ffmt_source->module~ffmt_lexer module~ffmt_statements->module~ffmt_tokens module~ffmt_strings ffmt_strings module~ffmt_statements->module~ffmt_strings module~ffmt_tokens->module~ffmt_strings module~ffmt_directives->module~ffmt_statements module~ffmt_directives->module~ffmt_tokens module~ffmt_lexer->module~ffmt_tokens module~ffmt_lexer->module~ffmt_strings

Used by

  • module~~ffmt_case~~UsedByGraph module~ffmt_case ffmt_case module~ffmt_format ffmt_format module~ffmt_format->module~ffmt_case module~ffmt_layout ffmt_layout module~ffmt_format->module~ffmt_layout module~ffmt_layout->module~ffmt_case module~ffmt_cli ffmt_cli module~ffmt_cli->module~ffmt_format

Variables

Type Visibility Attributes Name Initial
character(len=*), private, parameter :: INTRINSIC_CONSTANTS(*) = [character(len=28)::'atomic_int_kind', 'atomic_logical_kind', 'c_alert', 'c_backspace', 'c_bool', 'c_carriage_return', 'c_char', 'c_double', 'c_double_complex', 'c_float', 'c_float128', 'c_float128_complex', 'c_float_complex', 'c_form_feed', 'c_funptr', 'c_horizontal_tab', 'c_int', 'c_int128_t', 'c_int16_t', 'c_int32_t', 'c_int64_t', 'c_int8_t', 'c_int_fast128_t', 'c_int_fast16_t', 'c_int_fast32_t', 'c_int_fast64_t', 'c_int_fast8_t', 'c_int_least128_t', 'c_int_least16_t', 'c_int_least32_t', 'c_int_least64_t', 'c_int_least8_t', 'c_intmax_t', 'c_intptr_t', 'c_long', 'c_long_double', 'c_long_double_complex', 'c_long_long', 'c_new_line', 'c_null_char', 'c_null_funptr', 'c_null_ptr', 'c_ptr', 'c_ptrdiff_t', 'c_short', 'c_signed_char', 'c_size_t', 'c_vertical_tab', 'character_kinds', 'character_storage_size', 'current_team', 'error_unit', 'event_type', 'file_storage_size', 'initial_team', 'input_unit', 'int16', 'int32', 'int64', 'int8', 'integer_kinds', 'iostat_end', 'iostat_eor', 'iostat_inquire_internal_unit', 'lock_type', 'logical16', 'logical32', 'logical64', 'logical8', 'logical_kinds', 'notify_type', 'numeric_storage_size', 'output_unit', 'parent_team', 'real128', 'real16', 'real32', 'real64', 'real_kinds', 'stat_failed_image', 'stat_locked', 'stat_locked_other_image', 'stat_stopped_image', 'stat_unlocked', 'stat_unlocked_failed_image', 'team_type']
character(len=*), private, parameter :: INTRINSIC_PROCEDURES(*) = [character(len=24)::'abs', 'achar', 'acos', 'acosd', 'acosh', 'acospi', 'adjustl', 'adjustr', 'aimag', 'aint', 'all', 'allocated', 'alog', 'alog10', 'amax0', 'amax1', 'amin0', 'amin1', 'amod', 'anint', 'any', 'asin', 'asind', 'asinh', 'asinpi', 'associated', 'atan', 'atan2', 'atan2d', 'atan2pi', 'atand', 'atanh', 'atanpi', 'atomic_add', 'atomic_and', 'atomic_cas', 'atomic_define', 'atomic_fetch_add', 'atomic_fetch_and', 'atomic_fetch_or', 'atomic_fetch_xor', 'atomic_or', 'atomic_ref', 'atomic_xor', 'bessel_j0', 'bessel_j1', 'bessel_jn', 'bessel_y0', 'bessel_y1', 'bessel_yn', 'bge', 'bgt', 'bit_size', 'ble', 'blt', 'btest', 'c_associated', 'c_f_pointer', 'c_f_procpointer', 'c_f_strpointer', 'c_funloc', 'c_loc', 'c_sizeof', 'cabs', 'ccos', 'ceiling', 'cexp', 'char', 'clog', 'cmplx', 'co_broadcast', 'co_max', 'co_min', 'co_reduce', 'co_sum', 'command_argument_count', 'compiler_options', 'compiler_version', 'conjg', 'cos', 'cosd', 'cosh', 'coshape', 'cospi', 'count', 'cpu_time', 'cshift', 'csin', 'csqrt', 'dabs', 'dacos', 'dasin', 'datan', 'datan2', 'date_and_time', 'dble', 'dcos', 'dcosh', 'ddim', 'dexp', 'digits', 'dim', 'dint', 'dlog', 'dlog10', 'dmax1', 'dmin1', 'dmod', 'dnint', 'dot_product', 'dprod', 'dshiftl', 'dshiftr', 'dsign', 'dsin', 'dsinh', 'dsqrt', 'dtan', 'dtanh', 'eoshift', 'epsilon', 'erf', 'erfc', 'erfc_scaled', 'event_query', 'execute_command_line', 'exp', 'exponent', 'extends_type_of', 'f_c_string', 'failed_images', 'findloc', 'float', 'floor', 'fraction', 'gamma', 'get_command', 'get_command_argument', 'get_environment_variable', 'get_team', 'huge', 'hypot', 'iabs', 'iachar', 'iall', 'iand', 'iany', 'ibclr', 'ibits', 'ibset', 'ichar', 'idim', 'idint', 'idnint', 'ieor', 'ifix', 'image_index', 'image_status', 'index', 'int', 'ior', 'iparity', 'is_contiguous', 'is_iostat_end', 'is_iostat_eor', 'ishft', 'ishftc', 'isign', 'kind', 'lbound', 'lcobound', 'leadz', 'len', 'len_trim', 'lge', 'lgt', 'lle', 'llt', 'log', 'log10', 'log_gamma', 'logical', 'maskl', 'maskr', 'matmul', 'max', 'max0', 'max1', 'maxexponent', 'maxloc', 'maxval', 'merge', 'merge_bits', 'min', 'min0', 'min1', 'minexponent', 'minloc', 'minval', 'mod', 'modulo', 'move_alloc', 'mvbits', 'nearest', 'new_line', 'nint', 'norm2', 'not', 'null', 'num_images', 'out_of_range', 'pack', 'parity', 'popcnt', 'poppar', 'precision', 'present', 'product', 'radix', 'random_init', 'random_number', 'random_seed', 'range', 'rank', 'real', 'reduce', 'repeat', 'reshape', 'rrspacing', 'same_type_as', 'scale', 'scan', 'selected_char_kind', 'selected_int_kind', 'selected_logical_kind', 'selected_real_kind', 'set_exponent', 'shape', 'shifta', 'shiftl', 'shiftr', 'sign', 'sin', 'sind', 'sinh', 'sinpi', 'size', 'sngl', 'spacing', 'split', 'spread', 'sqrt', 'stopped_images', 'storage_size', 'sum', 'system_clock', 'tan', 'tand', 'tanh', 'tanpi', 'team_number', 'this_image', 'tiny', 'tokenize', 'trailz', 'transfer', 'transpose', 'trim', 'ubound', 'ucobound', 'unpack', 'verify']
character(len=*), private, parameter :: INTRODUCERS(*) = [character(len=12)::'call', 'subroutine', 'function', 'program', 'module', 'submodule', 'use', 'entry', 'procedure', 'interface', 'go', 'goto', 'cycle', 'exit', 'data', 'common', 'namelist', 'is']
character(len=*), private, parameter :: KEYWORDS(*) = [character(len=16)::'abstract', 'allocatable', 'allocate', 'assign', 'associate', 'asynchronous', 'backspace', 'bind', 'block', 'call', 'case', 'change', 'character', 'class', 'close', 'codimension', 'common', 'complex', 'concurrent', 'contains', 'contiguous', 'continue', 'critical', 'cycle', 'data', 'deallocate', 'default', 'deferred', 'dimension', 'do', 'double', 'doubleprecision', 'elemental', 'else', 'elseif', 'elsewhere', 'end', 'endfile', 'entry', 'enum', 'enumerator', 'enumeration', 'equivalence', 'error', 'exit', 'extends', 'external', 'final', 'flush', 'forall', 'function', 'generic', 'go', 'goto', 'if', 'implicit', 'import', 'impure', 'include', 'inquire', 'integer', 'intent', 'interface', 'intrinsic', 'is', 'logical', 'module', 'namelist', 'non_intrinsic', 'non_overridable', 'non_recursive', 'none', 'nopass', 'nullify', 'open', 'optional', 'parameter', 'pass', 'pause', 'pointer', 'precision', 'print', 'private', 'procedure', 'program', 'protected', 'public', 'pure', 'rank', 'read', 'real', 'recursive', 'return', 'rewind', 'save', 'select', 'selectcase', 'selectrank', 'selecttype', 'sequence', 'simple', 'stop', 'submodule', 'subroutine', 'sync', 'target', 'team', 'then', 'type', 'use', 'value', 'volatile', 'wait', 'where', 'while', 'write']

Derived Types

type, public ::  case_marks_t

The letter case wanted for each token (CASE_KEEP, CASE_LOWER or CASE_UPPER).

Components

Type Visibility Attributes Name Initial
integer, public, allocatable :: part(:)

for the kind part of a token only (see kind_part), applied after whole

integer, public, allocatable :: whole(:)

for the whole text of each token


Functions

public function compute_case(source, views, opts) result(marks)

The letter case wanted for each token.

Arguments

Type IntentOptional Attributes Name
type(source_t), intent(in) :: source

the source

type(statement_view_t), intent(in) :: views(:)

the view of each item (see statement_views)

type(case_options_t), intent(in) :: opts

the case wanted for each category

Return Value type(case_marks_t)


Subroutines

public pure subroutine kind_part(text, kind, a, b)

Where the kind is in the text of a token of kind kind: text(a:b), or b < a if it has none. For a logical constant it is the suffix (_lk in .true._lk), for a string the prefix (ck in ck_'a'). Numbers have letters only in their exponent and kind, so they are cased whole.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text

the token's text

integer, intent(in) :: kind

its kind (TK_*)

integer, intent(out) :: a

the range of the kind in text

integer, intent(out) :: b

the range of the kind in text

private subroutine names_case(v, opts, mode)

Mark the intrinsic procedures, the constants of the intrinsic modules and the kinds named in one code statement.

Arguments

Type IntentOptional Attributes Name
type(statement_view_t), intent(in) :: v

the statement

type(case_options_t), intent(in) :: opts

the case wanted for each category

integer, intent(inout) :: mode(:)

case mode of each token, set for the names

private subroutine statement_case(v, kw_mode, mode)

Mark the keywords of one code statement with kw_mode.

Arguments

Type IntentOptional Attributes Name
type(statement_view_t), intent(in) :: v

the statement

integer, intent(in) :: kw_mode

case mode for keywords

integer, intent(inout) :: mode(:)

case mode of each token, set for the keywords