Skip to content

stringifor_regex ​

StringiFor, regular expressions: a Pike VM, linear in the subject.

A pattern is parsed into a syntax tree, compiled into a program of a small virtual machine and run by a Pike VM: a simulation of the Thompson NFA that carries the capture positions with each thread. The time is O(n m), n the length of the subject and m the size of the program, whatever the pattern: there is no backtracking. Among the matches starting at the leftmost position the VM picks the one a backtracking engine (Perl, Python) would find first.

Matching is by unit, as the rest of StringiFor: a well-formed UTF-8 sequence, or a single byte that is not part of one. Internally a unit is a code: its codepoint, or U+DC00 + b for an ill-formed byte b, as Python's surrogateescape.

Source: src/lib/stringifor_regex.F90

Dependencies

Contents ​

Variables ​

NameTypeAttributesDescription
MAX_PROGRAMintegerparameterLargest program, in instructions.
MAX_DEPTHintegerparameterDeepest nesting of groups.
MAX_REPEATintegerparameterLargest count of a {m,n} quantifier.
MAX_GROUPSintegerparameterMost capturing groups.
MAX_CODEintegerparameterLargest code of a unit (U+10FFFF).
BYTE_BASEintegerparameterCode of the ill-formed byte b: BYTE_BASE + b (U+DC00 + b).
BACKSLASHcharacter(len=1)parameterBackslash (nvfortran reads backslash escapes in literals).
OP_CHARintegerparameterMatch the unit of code arg1.
OP_CHARIintegerparameterMatch the unit of code arg1, ASCII case ignored (arg1 is lowercase).
OP_ANYintegerparameterMatch any unit but LF.
OP_ANYNLintegerparameterMatch any unit.
OP_CLASSintegerparameterMatch a unit of the class arg1.
OP_SPLITintegerparameterContinue at arg1 (preferred) and at arg2.
OP_JMPintegerparameterContinue at arg1.
OP_SAVEintegerparameterSave the position into the slot arg1.
OP_ASSERTintegerparameterContinue if the assertion arg1 holds at the position.
OP_MARKintegerparameterSave the position into the register arg1 (start of a loop iteration).
OP_CHECKintegerparameterContinue at arg2 if the iteration was empty (register arg1 = position), else at arg3.
OP_MATCHintegerparameterA match.
AS_BOTintegerparameter\A, and ^ without m: start of the subject.
AS_EOTintegerparameter\z (\Z): end of the subject.
AS_MBOLintegerparameter^ with m: start of a line.
AS_EOLintegerparameter$ without m: end of the subject, or before a LF ending it.
AS_MEOLintegerparameter$ with m: end of a line.
AS_WORDBintegerparameter\b: a word boundary (ASCII word characters).
AS_NWORDBintegerparameter\B: not a word boundary.
N_EMPTYintegerparameterNothing.
N_LITintegerparameterA unit, code val1.
N_ANYintegerparameterThe dot.
N_CLASSintegerparameterA class, index val1.
N_ASSERTintegerparameterAn assertion, kind val1.
N_GROUPintegerparameterA group, capturing if val1 > 0 (its number): one child.
N_CATintegerparameterA concatenation of the children.
N_ALTintegerparameterAn alternation of the children.
N_REPEATintegerparameterThe child repeated val1 to val2 times (val2 < 0: no limit), greedy if val3 = 1.

Derived Types ​

regex ​

A compiled regular expression.

Compile it with compile, then match it with search, match or fullmatch.

Components ​

NameTypeAttributesDescription
compiledlogicalTrue once compiled.
ngroupsintegerNumber of capturing groups.
nregsintegerNumber of loop registers.
opintegerallocatableInstructions.
arg1integerallocatableFirst argument of the instructions.
arg2integerallocatableSecond argument of the instructions.
arg3integerallocatableThird argument of the instructions.
rangesinteger(kind=I4P)allocatableRanges [first, last] of codes of all the classes.
class_firstintegerallocatableFirst range of each class.
class_lastintegerallocatableLast range of each class.
class_negatedlogicalallocatableTrue if the class is negated.
namestype(string)allocatableName of each group, null if unnamed.

Type-Bound Procedures ​

NameAttributesDescription
compilepass(self)Compile a pattern.
is_compiledpass(self)Return true if the regex is compiled.
group_countpass(self)Return the number of capturing groups.
group_indexpass(self)Return the number of a named group, 0 if there is none.
searchSearch the leftmost match.
matchMatch at the start.
fullmatchMatch the whole subject.
finditerReturn all the matches.
findallReturn the text of a group of all the matches.
splitSplit the subject at the matches.
subReplace the matches.
search_characterpass(self)Search the leftmost match in a character.
search_stringpass(self)Search the leftmost match in a string.
match_characterpass(self)Match at the start of a character.
match_stringpass(self)Match at the start of a string.
fullmatch_characterpass(self)Match the whole character.
fullmatch_stringpass(self)Match the whole string.
finditer_characterpass(self)All the matches in a character.
finditer_stringpass(self)All the matches in a string.
findall_characterpass(self)Group texts of all the matches in a character.
findall_stringpass(self)Group texts of all the matches in a string.
split_characterpass(self)Split a character.
split_stringpass(self)Split a string.
sub_characterpass(self)Replace the matches in a character.
sub_stringpass(self)Replace the matches in a string.

regex_match ​

The result of a match: whether it was found, and the position and the text of each group.

Components ​

NameTypeAttributesDescription
foundlogicalTrue if there is a match.
spansintegerallocatableFirst and last byte of each group 0..n; [0, -1] if it did not match.
textstype(string)allocatableText of each group 0..n; not allocated if it did not match.
namestype(string)allocatableName of each group 1..n, null if unnamed.

Type-Bound Procedures ​

NameAttributesDescription
spanReturn the first and last byte of a group.
groupReturn the text of a group.
groupspass(self)Return the texts of the groups 1..n.
span_numberpass(self)Span of a group by number.
span_namepass(self)Span of a group by name.
group_numberpass(self)Text of a group by number.
group_namepass(self)Text of a group by name.

parser ​

State of the parser and of the compiler of a pattern.

Components ​

NameTypeAttributesDescription
patterncharacter(kind=CK, len=:)allocatableThe pattern.
ipintegerPosition in the pattern.
nocaselogicalFlag i.
multilinelogicalFlag m.
dotalllogicalFlag s.
nnodesintegerNumber of nodes.
kindintegerallocatableKind of each node.
val1integerallocatableFirst value of each node.
val2integerallocatableSecond value of each node.
val3integerallocatableThird value of each node.
childintegerallocatableFirst child of each node.
siblingintegerallocatableNext sibling of each node.
nrangesintegerNumber of ranges.
rangesinteger(kind=I4P)allocatableRanges of the classes.
nclassesintegerNumber of classes.
class_firstintegerallocatableFirst range of each class.
class_lastintegerallocatableLast range of each class.
class_negatedlogicalallocatableTrue if the class is negated.
ngroupsintegerNumber of capturing groups.
namestype(string)allocatableNames of the groups.
nregsintegerNumber of loop registers.
npcintegerSize of the program.
opintegerallocatableInstructions.
arg1integerallocatableFirst arguments.
arg2integerallocatableSecond arguments.
arg3integerallocatableThird arguments.
errorintegerPosition of the first error, 0 if none.
messagecharacter(len=:)allocatableMessage of the first error.

Interfaces ​

Overloading of re_search for character and string subjects, character and compiled patterns.

Module procedures: re_search_cc, re_search_cr, re_search_sc, re_search_sr

re_fullmatch ​

Overloading of re_fullmatch for character and string subjects, character and compiled patterns.

Module procedures: re_fullmatch_cc, re_fullmatch_cr, re_fullmatch_sc, re_fullmatch_sr

re_findall ​

Overloading of re_findall for character and string subjects, character and compiled patterns.

Module procedures: re_findall_cc, re_findall_cr, re_findall_sc, re_findall_sr

re_split ​

Overloading of re_split for character and string subjects, character and compiled patterns.

Module procedures: re_split_cc, re_split_cr, re_split_sc, re_split_sr

re_sub ​

Overloading of re_sub for character and string subjects, character and compiled patterns.

Module procedures: re_sub_cc, re_sub_cr, re_sub_sc, re_sub_sr

Subroutines ​

compile ​

Compile a pattern.

flags holds the letters of the flags: i (ASCII case ignored), m (multiline: ^ and $ at the line ends), s (the dot matches LF too); they can also start the pattern, as (?im). On a malformed pattern iostat is the byte position of the error and iomsg says what it is, and the regex is left not compiled; without iostat the program stops with that message.

fortran
 type(regex) :: re
 integer     :: iostat
 character(len=99) :: iomsg
 logical     :: test_passed(6)
 call re%compile('(\d+)-(\d+)', iostat=iostat)
 test_passed(1) = iostat==0.and.re%group_count()==2
 call re%compile('a(b', iostat=iostat, iomsg=iomsg)
 test_passed(2) = iostat==4.and.trim(iomsg)=='missing ), unterminated group opened at byte 2'
 call re%compile('x{2,1}', iostat=iostat)
 test_passed(3) = iostat==2
 call re%compile('a{1001}', iostat=iostat, iomsg=iomsg)
 test_passed(4) = iostat==2.and.trim(iomsg)=='repeat count above 1000'
 call re%compile(repeat('(', 300)//repeat(')', 300), iostat=iostat, iomsg=iomsg)
 test_passed(5) = iostat==201.and.trim(iomsg)=='groups nested too deep'
 call re%compile('(a{1000}){1000}', iostat=iostat, iomsg=iomsg)
 test_passed(6) = iostat==1.and.index(iomsg, 'pattern too large')==1.and..not.re%is_compiled()
 print '(L1)', all(test_passed)
fortran
subroutine compile(self, pattern, flags, iostat, iomsg)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inoutThe regex.
patterncharacter(len=*)inThe pattern.
flagscharacter(len=*)inoptionalFlags: letters i, m, s.
iostatintegeroutoptionalByte position of the error, 0 if none.
iomsgcharacter(len=*)inoutoptionalMessage of the error.

Call graph

add_thread ​

Add to a list the threads reached from the instruction pc0 at the position pos, in priority order.

The epsilon closure is followed with an explicit stack, so a long program never overflows the call stack. A negative entry restores a slot when the branch that set it is done.

Attributes: pure

fortran
subroutine add_thread(self, subject, stack, mark, caps, list_pc, list_cap, count, gen, pc0, pos)

Arguments

NameTypeIntentAttributesDescription
selftype(regex)inThe regex.
subjectcharacter(len=*)inThe subject.
stackintegerinoutStack: (instruction or -slot, value).
markintegerinoutGeneration in which each instruction was added.
capsintegerinoutSlots of the thread being added, restored on exit.
list_pcintegerinoutInstructions of the list.
list_capintegerinoutSlots of the list.
countintegerinoutThreads in the list.
genintegerinGeneration of the list.
pc0integerinFirst instruction.
posintegerinPosition.

Call graph

all_matches ​

Find the matches left to right from the byte start, at most limit of them (0: no limit), as Python's finditer: the search goes on at the end of each match, and after an empty match the next one may not be empty at that position.

Attributes: pure

fortran
subroutine all_matches(self, subject, start, limit, matches, n)

Arguments

NameTypeIntentAttributesDescription
selftype(regex)inThe regex.
subjectcharacter(len=*)inThe subject.
startintegerinoptionalFirst byte, default 1.
limitintegerinMost matches, 0 if no limit.
matchestype(regex_match)outallocatableThe matches, the first n used.
nintegeroutNumber of matches.

Call graph

parse_template ​

Parse a replacement template into pieces: a text (group -1) or the text of a group.

Attributes: pure

fortran
subroutine parse_template(self, repl, piece_group, piece_text, error, message)

Arguments

NameTypeIntentAttributesDescription
selftype(regex)inThe regex.
replcharacter(len=*)inTemplate.
piece_groupintegeroutallocatableGroup of each piece, -1 for a text.
piece_texttype(string)outallocatableText of each piece.
errorintegeroutPosition of the first error, 0 if none.
messagecharacter(len=:)outallocatableMessage of the error.

Call graph

add_piece ​

Close the text collected so far as a piece, if any, then add the group (if group >= 0) as a piece.

Attributes: pure

fortran
subroutine add_piece(piece_group, piece_text, text, group)

Arguments

NameTypeIntentAttributesDescription
piece_groupintegerinoutallocatableGroup of each piece, -1 for a text.
piece_texttype(string)inoutallocatableText of each piece.
textcharacter(len=:)inoutallocatableText collected, emptied.
groupintegerinGroup, -1 to close the text only.

Call graph

fail ​

Record the first error.

Attributes: pure

fortran
subroutine fail(p, pos, message)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
posintegerinByte position of the error.
messagecharacter(len=*)inWhat is wrong.

Call graph

set_flag ​

Set a flag from its letter.

Attributes: pure

fortran
subroutine set_flag(p, letter, pos)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
lettercharacter(len=1)inLetter of the flag.
posintegerinPosition of the letter in the pattern, 0 if in the flags argument.

Call graph

parse_global_flags ​

Parse the flags (?ims) at the start of the pattern.

Attributes: pure

fortran
subroutine parse_global_flags(p)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.

Call graph

new_node ​

Add a node to the tree.

Attributes: pure

fortran
subroutine new_node(p, node, kind, val1, val2, val3)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
nodeintegeroutThe node.
kindintegerinKind of node.
val1integerinoptionalFirst value.
val2integerinoptionalSecond value.
val3integerinoptionalThird value.

Call graph

add_child ​

Append a child to a node; last is its last child so far (0 if none), updated.

Attributes: pure

fortran
subroutine add_child(p, parent, last, node)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
parentintegerinParent node.
lastintegerinoutLast child.
nodeintegerinNew child.

Call graph

parse_alternation ​

Parse concatenation ( '|' concatenation )*.

Attributes: pure, recursive

fortran
subroutine parse_alternation(p, depth, node)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
depthintegerinNesting depth of the groups.
nodeintegeroutThe node.

Call graph

parse_concatenation ​

Parse a sequence of repeated atoms, up to |, ) or the end.

Attributes: pure, recursive

fortran
subroutine parse_concatenation(p, depth, node)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
depthintegerinNesting depth of the groups.
nodeintegeroutThe node.

Call graph

parse_repeat ​

Parse an atom and its quantifier, if any: *, +, ?, {m}, {m,}, {,n}, {m,n}, each followed by an optional ? (lazy).

Attributes: pure, recursive

fortran
subroutine parse_repeat(p, depth, node)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
depthintegerinNesting depth of the groups.
nodeintegeroutThe node.

Call graph

quantifier ​

Read the quantifier at pos, if any. A { that does not start {m}, {m,}, {,n}, {m,n} or {,} is a literal.

Attributes: pure

fortran
subroutine quantifier(p, pos, is_quantifier, lo, hi, after)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inParser.
posintegerinPosition.
is_quantifierlogicaloutTrue if a quantifier is there.
lointegeroutMinimum count.
hiintegeroutMaximum count, -1 if none.
afterintegeroutPosition after the quantifier.

Call graph

read_count ​

Read decimal digits at j, saturated above MAX_REPEAT + 1; j moves after them.

Attributes: pure

fortran
subroutine read_count(text, j, value, has_digits)

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)inText.
jintegerinoutPosition.
valueintegeroutValue.
has_digitslogicaloutTrue if there was at least one digit.

Call graph

parse_atom ​

Parse an atom: a group, a class, the dot, an anchor, an escape or a unit.

Attributes: pure, recursive

fortran
subroutine parse_atom(p, depth, node)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
depthintegerinNesting depth of the groups.
nodeintegeroutThe node.

Call graph

new_group ​

Number a new capturing group.

Attributes: pure

fortran
subroutine new_group(p, name, pos, group)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
namecharacter(len=*)inName, empty if unnamed.
posintegerinPosition, for the errors.
groupintegeroutNumber of the group.

Call graph

grow_names ​

Double the room for the names of the groups; the new ones are not allocated (unnamed).

Attributes: pure

fortran
subroutine grow_names(p)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.

Call graph

parse_escape ​

Parse an escape outside a class.

Attributes: pure

fortran
subroutine parse_escape(p, node)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
nodeintegeroutThe node.

Call graph

escape_code ​

Parse the escape of a single unit at p%ip (the backslash) and move after it.

Attributes: pure

fortran
subroutine escape_code(p, code)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
codeinteger(kind=I4P)outCode of the unit.

Call graph

new_class ​

Open a new class.

Attributes: pure

fortran
subroutine new_class(p, k)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
kintegeroutThe class.

Call graph

add_range ​

Add a range of codes to the class being built.

Attributes: pure

fortran
subroutine add_range(p, first, last)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
firstinteger(kind=I4P)inFirst code.
lastinteger(kind=I4P)inLast code.

Call graph

add_escape_class ​

Add the ranges of \d, \w, \s to the class being built; for \D, \W, \S the complement if negated is not wanted by the caller (inside brackets), else the plain ranges with negated true.

Attributes: pure

fortran
subroutine add_escape_class(p, letter, negated)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
lettercharacter(len=1)ind, D, w, W, s, S.
negatedlogicaloutTrue for D, W, S.

Call graph

add_complement ​

Replace the ranges of the class from the range first on (sorted, disjoint) with their complement in [0, MAX_CODE].

Attributes: pure

fortran
subroutine add_complement(p, first)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
firstintegerinFirst range to complement.

Call graph

close_class ​

Finish the class k: with flag i, add the other case of the ASCII letters it holds.

Attributes: pure

fortran
subroutine close_class(p, k)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
kintegerinThe class.

Call graph

parse_class ​

Parse a class [...]: ^ negates it, a ] first is a literal, a - first or last is a literal, ranges a-z, escapes as outside plus \b (backspace), and the class escapes \d \w \s \D \W \S.

Attributes: pure

fortran
subroutine parse_class(p, node)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
nodeintegeroutThe node.

Call graph

class_item ​

Parse an item of a class: a unit, an escape or a class escape (whose ranges are added at once).

Attributes: pure

fortran
subroutine class_item(p, code, is_set)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
codeinteger(kind=I4P)outCode of the unit.
is_setlogicaloutThe item was a class escape.

Call graph

sort_ranges ​

Sort the ranges of the class k by their first code (insertion sort: classes are small).

Attributes: pure

fortran
subroutine sort_ranges(p, k)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
kintegerinThe class.

Call graph

emit ​

Append an instruction to the program.

Attributes: pure

fortran
subroutine emit(p, op, a1, a2, a3)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
opintegerinInstruction.
a1integerinoptionalFirst argument.
a2integerinoptionalSecond argument.
a3integerinoptionalThird argument.

Call graph

compile_node ​

Compile a node into the program.

Attributes: pure, recursive

fortran
subroutine compile_node(p, node)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
nodeintegerinThe node.

Call graph

set_split ​

Set the targets of a split: the body first if greedy, the exit first if lazy.

Attributes: pure

fortran
subroutine set_split(p, pc, body, out, greedy)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inoutParser.
pcintegerinThe split.
bodyintegerinThe body.
outintegerinThe exit.
greedylogicalinGreedy.

Call graph

Functions ​

is_compiled ​

Return true if the regex is compiled.

Attributes: elemental

Returns: logical

fortran
function is_compiled(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.

group_count ​

Return the number of capturing groups.

Attributes: elemental

Returns: integer

fortran
function group_count(self) result(n)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.

group_index ​

Return the number of the group named name, 0 if there is none.

Attributes: elemental

Returns: integer

fortran
function group_index(self, name) result(n)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
namecharacter(len=*)inName of a group.

Call graph

search_character ​

Search the leftmost match in the subject, from the byte start (default 1).

@note As Python pattern.search(subject, start): ^ and \A still mean the start of the subject, and \b looks at the byte before start.

fortran
 type(regex)       :: re
 type(regex_match) :: m
 logical           :: test_passed(4)
 call re%compile('(?P<key>\w+)\s*=\s*(?P<value>\w*)')
 m = re%search('# x = 1, y=two')
 test_passed(1) = m%found.and.all(m%span(0) == [3, 7])
 test_passed(2) = m%group('key')=='x'.and.m%group(2)=='1'
 m = re%search('# x = 1, y=two', start=8)
 test_passed(3) = m%group(0)=='y=two'
 m = re%search('nothing here')
 test_passed(4) = .not.m%found
 print '(L1)', all(test_passed)

Attributes: pure

Returns: type(regex_match)

fortran
function search_character(self, subject, start) result(found)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjectcharacter(len=*)inThe subject.
startintegerinoptionalFirst byte of the search, default 1.

Call graph

search_string ​

Search the leftmost match in the subject, from the byte start (default 1); see search_character.

@note The doctest is not necessary, this being tested by search_character.

Attributes: pure

Returns: type(regex_match)

fortran
function search_string(self, subject, start) result(found)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjecttype(string)inThe subject.
startintegerinoptionalFirst byte of the search, default 1.

Call graph

match_character ​

Match at the byte start (default 1) of the subject only.

fortran
 type(regex)       :: re
 type(regex_match) :: m
 logical           :: test_passed(2)
 call re%compile('\d+')
 m = re%match('42 and 7')
 test_passed(1) = m%group(0)=='42'
 m = re%match('x42')
 test_passed(2) = .not.m%found
 print '(L1)', all(test_passed)

Attributes: pure

Returns: type(regex_match)

fortran
function match_character(self, subject, start) result(found)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjectcharacter(len=*)inThe subject.
startintegerinoptionalByte where the match must start, default 1.

Call graph

match_string ​

Match at the byte start (default 1) of the subject only; see match_character.

@note The doctest is not necessary, this being tested by match_character.

Attributes: pure

Returns: type(regex_match)

fortran
function match_string(self, subject, start) result(found)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjecttype(string)inThe subject.
startintegerinoptionalByte where the match must start, default 1.

Call graph

fullmatch_character ​

Match the whole subject, from the byte start (default 1) to its end.

fortran
 type(regex)       :: re
 type(regex_match) :: m
 logical           :: test_passed(3)
 call re%compile('a|ab')
 m = re%fullmatch('ab')
 test_passed(1) = m%group(0)=='ab'
 m = re%search('ab')
 test_passed(2) = m%group(0)=='a'
 call re%compile('caf'//char(92)//'u00e9|tea', flags='i')
 m = re%fullmatch('CAF'//char(195)//char(169))
 test_passed(3) = m%found
 print '(L1)', all(test_passed)

Attributes: pure

Returns: type(regex_match)

fortran
function fullmatch_character(self, subject, start) result(found)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjectcharacter(len=*)inThe subject.
startintegerinoptionalByte where the match must start, default 1.

Call graph

fullmatch_string ​

Match the whole subject, from the byte start (default 1); see fullmatch_character.

@note The doctest is not necessary, this being tested by fullmatch_character.

Attributes: pure

Returns: type(regex_match)

fortran
function fullmatch_string(self, subject, start) result(found)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjecttype(string)inThe subject.
startintegerinoptionalByte where the match must start, default 1.

Call graph

finditer_character ​

Return all the matches, left to right and not overlapping, from the byte start (default 1).

@note As Python finditer: after an empty match the next one may not be empty at the same position, and an empty match is allowed right after a non-empty one.

fortran
 type(regex)                    :: re
 type(regex_match), allocatable :: m(:)
 logical                        :: test_passed(3)
 call re%compile('\d+')
 m = re%finditer('a1 b22 c333')
 test_passed(1) = size(m)==3.and.m(3)%group(0)=='333'.and.all(m(2)%span(0)==[5, 6])
 call re%compile('x*')
 m = re%finditer('axb')
 test_passed(2) = size(m)==4 ! '' at 1, 'x' at 2, '' at 3 (after a non-empty match), '' at the end
 test_passed(3) = all(m(3)%span(0)==[3, 2]).and.all(m(4)%span(0)==[4, 3])
 print '(L1)', all(test_passed)

Attributes: pure

Returns: type(regex_match)

fortran
function finditer_character(self, subject, start) result(matches)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjectcharacter(len=*)inThe subject.
startintegerinoptionalFirst byte of the search, default 1.

Call graph

finditer_string ​

Return all the matches, left to right; see finditer_character.

@note The doctest is not necessary, this being tested by finditer_character.

Attributes: pure

Returns: type(regex_match)

fortran
function finditer_string(self, subject, start) result(matches)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjecttype(string)inThe subject.
startintegerinoptionalFirst byte of the search, default 1.

Call graph

findall_character ​

Return the text of a group of every match, left to right (see finditer_character).

@note The group is by default 1 if the regex has exactly one capturing group, else 0 (the whole match), as Python findall for 0 or 1 group; with more groups Python returns tuples, here one group is chosen with group. A group that did not match gives an empty string.

fortran
 type(regex)               :: re
 type(string), allocatable :: t(:)
 logical                   :: test_passed(3)
 call re%compile('-?\d+(?:\.\d+)?')
 t = re%findall('x=1.5, y=-2, z=30')
 test_passed(1) = size(t)==3.and.t(2)=='-2'
 call re%compile('(\w+)=')
 t = re%findall('x=1.5, y=-2')
 test_passed(2) = size(t)==2.and.t(1)=='x'.and.t(2)=='y'
 t = re%findall('x=1.5, y=-2', group=0)
 test_passed(3) = t(2)=='y='
 print '(L1)', all(test_passed)

Attributes: pure

Returns: type(string)

fortran
function findall_character(self, subject, group) result(texts)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjectcharacter(len=*)inThe subject.
groupintegerinoptionalGroup, default 1 if there is one group, else 0.

Call graph

findall_string ​

Return the text of a group of every match; see findall_character.

@note The doctest is not necessary, this being tested by findall_character.

Attributes: pure

Returns: type(string)

fortran
function findall_string(self, subject, group) result(texts)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjecttype(string)inThe subject.
groupintegerinoptionalGroup, default 1 if there is one group, else 0.

Call graph

split_character ​

Return the subject split at the matches, at most maxsplit times (default, or 0: no limit).

@note As Python re.split: the texts of the groups of each match are inserted between the pieces (a group that did not match is a not allocated string), and an empty match splits too.

fortran
 type(regex)               :: re
 type(string), allocatable :: p(:)
 logical                   :: test_passed(3)
 call re%compile('\s*[,;]\s*')
 p = re%split('a , b;c ;  d')
 test_passed(1) = size(p)==4.and.p(4)=='d'
 p = re%split('a , b;c ;  d', maxsplit=1)
 test_passed(2) = size(p)==2.and.p(2)=='b;c ;  d'
 call re%compile('([,;])')
 p = re%split('a,b;c')
 test_passed(3) = size(p)==5.and.p(2)==','.and.p(4)==';'
 print '(L1)', all(test_passed)

Attributes: pure

Returns: type(string)

fortran
function split_character(self, subject, maxsplit) result(pieces)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjectcharacter(len=*)inThe subject.
maxsplitintegerinoptionalMost splits, default 0: no limit.

Call graph

split_string ​

Return the subject split at the matches; see split_character.

@note The doctest is not necessary, this being tested by split_character.

Attributes: pure

Returns: type(string)

fortran
function split_string(self, subject, maxsplit) result(pieces)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
subjecttype(string)inThe subject.
maxsplitintegerinoptionalMost splits, default 0: no limit.

Call graph

sub_character ​

Return the subject with the matches replaced by the template repl, at most count of them (default, or 0: all).

@note In the template \1..\99 and \g<n> are the text of a group, \g<name> of a named group, \g<0> the whole match; a group that did not match gives an empty text. \\ \n \t \r \f \v \a \b are escapes, a backslash before any other character that is not an ASCII letter or a digit stays. nsub returns the number of replacements (Python subn). A malformed template (an unknown escape, a group that does not exist) sets iostat to the byte position of the error in repl and returns the subject unchanged; without iostat the program stops.

fortran
 type(regex)  :: re
 type(string) :: s
 integer      :: n
 logical      :: test_passed(3)
 call re%compile('(?P<y>\d{4})-(?P<m>\d\d)-(?P<d>\d\d)')
 s = re%sub('\g<d>/\g<m>/\g<y>', 'from 2026-10-30 to 2026-11-02', nsub=n)
 test_passed(1) = s=='from 30/10/2026 to 02/11/2026'.and.n==2
 call re%compile('\s+')
 s = re%sub(' ', '  too   many spaces ', count=2)
 test_passed(2) = s==' too many spaces '
 s = re%sub('\q', 'a b', iostat=n)
 test_passed(3) = n==1.and.s=='a b'
 print '(L1)', all(test_passed)

Returns: type(string)

fortran
function sub_character(self, repl, subject, count, nsub, iostat, iomsg) result(replaced)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
replcharacter(len=*)inTemplate of the replacement.
subjectcharacter(len=*)inThe subject.
countintegerinoptionalMost replacements, default 0: all.
nsubintegeroutoptionalNumber of replacements.
iostatintegeroutoptionalByte position of an error in repl, 0 if none.
iomsgcharacter(len=*)inoutoptionalMessage of the error.

Call graph

sub_string ​

Return the subject with the matches replaced; see sub_character.

@note The doctest is not necessary, this being tested by sub_character.

Returns: type(string)

fortran
function sub_string(self, repl, subject, count, nsub, iostat, iomsg) result(replaced)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex)inThe regex.
replcharacter(len=*)inTemplate of the replacement.
subjecttype(string)inThe subject.
countintegerinoptionalMost replacements, default 0: all.
nsubintegeroutoptionalNumber of replacements.
iostatintegeroutoptionalByte position of an error in repl, 0 if none.
iomsgcharacter(len=*)inoutoptionalMessage of the error.

Call graph

span_number ​

Return the first and the last byte of a group (0: the whole match); [0, -1] if the group did not match.

@note An empty group at byte p gives [p, p-1], so subject(span(1):span(2)) is always its text.

fortran
 type(regex)       :: re
 type(regex_match) :: m
 logical           :: test_passed(3)
 call re%compile('(a)|(b)|(x*)')
 m = re%search('b')
 test_passed(1) = all(m%span(0) == [1, 1]).and.all(m%span(2) == [1, 1])
 test_passed(2) = all(m%span(1) == [0, -1])
 m = re%search('c')
 test_passed(3) = all(m%span(3) == [1, 0])
 print '(L1)', all(test_passed)

Attributes: pure

Returns: integer

fortran
function span_number(self, group) result(span)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex_match)inThe match.
groupintegerinNumber of the group.

Call graph

span_name ​

Return the first and the last byte of a named group; [0, -1] if it did not match or there is no such group.

@note The doctest is not necessary, this being tested by search_character.

Attributes: pure

Returns: integer

fortran
function span_name(self, group) result(span)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex_match)inThe match.
groupcharacter(len=*)inName of the group.

Call graph

group_number ​

Return the text of a group (0: the whole match); a not allocated string if the group did not match.

fortran
 type(regex)       :: re
 type(regex_match) :: m
 type(string)      :: g
 logical           :: test_passed(2)
 call re%compile('(\d+)(?:\.(\d+))?')
 m = re%search('v12')
 test_passed(1) = m%group(1)=='12'
 g = m%group(2)
 test_passed(2) = .not.g%is_allocated()
 print '(L1)', all(test_passed)

Attributes: pure

Returns: type(string)

fortran
function group_number(self, group) result(text)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex_match)inThe match.
groupintegerinNumber of the group.

Call graph

group_name ​

Return the text of a named group; a not allocated string if it did not match or there is no such group.

@note The doctest is not necessary, this being tested by search_character.

Attributes: pure

Returns: type(string)

fortran
function group_name(self, group) result(text)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex_match)inThe match.
groupcharacter(len=*)inName of the group.

Call graph

groups ​

Return the texts of the groups 1..n; a group that did not match is a not allocated string.

fortran
 type(regex)               :: re
 type(regex_match)         :: m
 type(string), allocatable :: g(:)
 call re%compile('(\w+)@(\w+)\.(\w+)')
 m = re%search('mail: ann@example.org')
 g = m%groups()
 print '(L1)', size(g)==3.and.g(1)=='ann'.and.g(3)=='org'

Attributes: pure

Returns: type(string)

fortran
function groups(self) result(texts)

Arguments

NameTypeIntentAttributesDescription
selfclass(regex_match)inThe match.

name_index ​

Return the number of the group named name in a match, -1 if there is none.

Attributes: pure

Returns: integer

fortran
function name_index(self, name) result(n)

Arguments

NameTypeIntentAttributesDescription
selftype(regex_match)inThe match.
namecharacter(len=*)inName of a group.

Call graph

run ​

Run the Pike VM on the subject from the byte start.

anchored: the match must start at start; full: it must end at the end of the subject; advance: an empty match at start is not accepted (the search after an empty match, as Python's finditer, sub and split do).

Attributes: pure

Returns: type(regex_match)

fortran
function run(self, subject, start, anchored, full, advance) result(found)

Arguments

NameTypeIntentAttributesDescription
selftype(regex)inThe regex.
subjectcharacter(len=*)inThe subject.
startintegerinoptionalFirst byte of the search, default 1.
anchoredlogicalinThe match must start at start.
fulllogicalinThe match must end at the end of the subject.
advancelogicalinNo empty match at start.

Call graph

assertion ​

Return true if the assertion holds at the position pos of the subject.

Attributes: pure

Returns: logical

fortran
function assertion(kind, subject, pos) result(holds)

Arguments

NameTypeIntentAttributesDescription
kindintegerinKind of assertion.
subjectcharacter(len=*)inThe subject.
posintegerinPosition, 1 to len(subject) + 1.

Call graph

is_word ​

Return true if the byte at pos is an ASCII word character, letter, digit or underscore (false outside).

Attributes: pure

Returns: logical

fortran
function is_word(subject, pos) result(word)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
posintegerinPosition.

Call graph

fold ​

Return the code with the ASCII uppercase letters lowercased.

Attributes: elemental

Returns: integer(kind=I4P)

fortran
function fold(code) result(folded)

Arguments

NameTypeIntentAttributesDescription
codeinteger(kind=I4P)inCode of a unit.

Call graph

in_class ​

Return true if the code belongs to the class k.

Attributes: pure

Returns: logical

fortran
function in_class(self, k, code) result(inside)

Arguments

NameTypeIntentAttributesDescription
selftype(regex)inThe regex.
kintegerinClass.
codeinteger(kind=I4P)inCode of a unit.

Call graph

to_int ​

Return the value of decimal digits, saturated above MAX_GROUPS + 1.

Attributes: pure

Returns: integer

fortran
function to_int(digits) result(value)

Arguments

NameTypeIntentAttributesDescription
digitscharacter(len=*)inDigits.

Call graph

re_search_cc ​

Search the leftmost match of a pattern in a subject (see search_character).

@note A character pattern is compiled at each call (a malformed one stops the program): compile it once with compile and pass the regex to repeat the search.

fortran
 type(regex_match) :: m
 logical           :: test_passed(2)
 m = re_search('key = 42', '(\w+)\s*=\s*(\d+)')
 test_passed(1) = m%group(1)=='key'.and.m%group(2)=='42'
 m = re_search('KEY=1', 'key=(\d)', flags='i')
 test_passed(2) = m%group(1)=='1'
 print '(L1)', all(test_passed)

Returns: type(regex_match)

fortran
function re_search_cc(subject, pattern, flags, start) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterncharacter(len=*)inThe pattern.
flagscharacter(len=*)inoptionalFlags: letters i, m, s.
startintegerinoptionalFirst byte of the search, default 1.

Call graph

re_search_cr ​

Search the leftmost match of a pattern in a subject (see search_character).

@note The doctest is not necessary, this being tested by re_search_cc.

Returns: type(regex_match)

fortran
function re_search_cr(subject, pattern, start) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterntype(regex)inThe compiled pattern.
startintegerinoptionalFirst byte of the search, default 1.

Call graph

re_search_sc ​

Search the leftmost match of a pattern in a subject (see search_character).

@note The doctest is not necessary, this being tested by re_search_cc.

Returns: type(regex_match)

fortran
function re_search_sc(subject, pattern, flags, start) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterncharacter(len=*)inThe pattern.
flagscharacter(len=*)inoptionalFlags: letters i, m, s.
startintegerinoptionalFirst byte of the search, default 1.

Call graph

re_search_sr ​

Search the leftmost match of a pattern in a subject (see search_character).

@note The doctest is not necessary, this being tested by re_search_cc.

Returns: type(regex_match)

fortran
function re_search_sr(subject, pattern, start) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterntype(regex)inThe compiled pattern.
startintegerinoptionalFirst byte of the search, default 1.

Call graph

re_fullmatch_cc ​

Match a pattern against a whole subject (see fullmatch_character).

@note A character pattern is compiled at each call (a malformed one stops the program): compile it once with compile and pass the regex to repeat the search.

fortran
 logical :: test_passed(2)
 type(regex_match) :: m
 m = re_fullmatch('2026-10-30', '\d{4}-\d\d-\d\d')
 test_passed(1) = m%found
 m = re_fullmatch('2026-10-30 ', '\d{4}-\d\d-\d\d')
 test_passed(2) = .not.m%found
 print '(L1)', all(test_passed)

Returns: type(regex_match)

fortran
function re_fullmatch_cc(subject, pattern, flags) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterncharacter(len=*)inThe pattern.
flagscharacter(len=*)inoptionalFlags: letters i, m, s.

Call graph

re_fullmatch_cr ​

Match a pattern against a whole subject (see fullmatch_character).

@note The doctest is not necessary, this being tested by re_fullmatch_cc.

Returns: type(regex_match)

fortran
function re_fullmatch_cr(subject, pattern) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterntype(regex)inThe compiled pattern.

Call graph

re_fullmatch_sc ​

Match a pattern against a whole subject (see fullmatch_character).

@note The doctest is not necessary, this being tested by re_fullmatch_cc.

Returns: type(regex_match)

fortran
function re_fullmatch_sc(subject, pattern, flags) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterncharacter(len=*)inThe pattern.
flagscharacter(len=*)inoptionalFlags: letters i, m, s.

Call graph

re_fullmatch_sr ​

Match a pattern against a whole subject (see fullmatch_character).

@note The doctest is not necessary, this being tested by re_fullmatch_cc.

Returns: type(regex_match)

fortran
function re_fullmatch_sr(subject, pattern) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterntype(regex)inThe compiled pattern.

Call graph

re_findall_cc ​

Return the text of a group of every match of a pattern in a subject (see findall_character).

@note A character pattern is compiled at each call (a malformed one stops the program): compile it once with compile and pass the regex to repeat the search.

fortran
 type(string), allocatable :: words(:)
 words = re_findall('one, two;three', '\w+')
 print '(L1)', size(words)==3.and.words(3)=='three'

Returns: type(string)

fortran
function re_findall_cc(subject, pattern, flags, group) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterncharacter(len=*)inThe pattern.
flagscharacter(len=*)inoptionalFlags: letters i, m, s.
groupintegerinoptionalGroup, default 1 if there is one group, else 0.

Call graph

re_findall_cr ​

Return the text of a group of every match of a pattern in a subject (see findall_character).

@note The doctest is not necessary, this being tested by re_findall_cc.

Returns: type(string)

fortran
function re_findall_cr(subject, pattern, group) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterntype(regex)inThe compiled pattern.
groupintegerinoptionalGroup, default 1 if there is one group, else 0.

Call graph

re_findall_sc ​

Return the text of a group of every match of a pattern in a subject (see findall_character).

@note The doctest is not necessary, this being tested by re_findall_cc.

Returns: type(string)

fortran
function re_findall_sc(subject, pattern, flags, group) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterncharacter(len=*)inThe pattern.
flagscharacter(len=*)inoptionalFlags: letters i, m, s.
groupintegerinoptionalGroup, default 1 if there is one group, else 0.

Call graph

re_findall_sr ​

Return the text of a group of every match of a pattern in a subject (see findall_character).

@note The doctest is not necessary, this being tested by re_findall_cc.

Returns: type(string)

fortran
function re_findall_sr(subject, pattern, group) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterntype(regex)inThe compiled pattern.
groupintegerinoptionalGroup, default 1 if there is one group, else 0.

Call graph

re_split_cc ​

Split a subject at the matches of a pattern (see split_character).

@note A character pattern is compiled at each call (a malformed one stops the program): compile it once with compile and pass the regex to repeat the search.

fortran
 type(string), allocatable :: fields(:)
 fields = re_split('a1b22c', '\d+')
 print '(L1)', size(fields)==3.and.fields(2)=='b'

Returns: type(string)

fortran
function re_split_cc(subject, pattern, flags, maxsplit) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterncharacter(len=*)inThe pattern.
flagscharacter(len=*)inoptionalFlags: letters i, m, s.
maxsplitintegerinoptionalMost splits, default 0: no limit.

Call graph

re_split_cr ​

Split a subject at the matches of a pattern (see split_character).

@note The doctest is not necessary, this being tested by re_split_cc.

Returns: type(string)

fortran
function re_split_cr(subject, pattern, maxsplit) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterntype(regex)inThe compiled pattern.
maxsplitintegerinoptionalMost splits, default 0: no limit.

Call graph

re_split_sc ​

Split a subject at the matches of a pattern (see split_character).

@note The doctest is not necessary, this being tested by re_split_cc.

Returns: type(string)

fortran
function re_split_sc(subject, pattern, flags, maxsplit) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterncharacter(len=*)inThe pattern.
flagscharacter(len=*)inoptionalFlags: letters i, m, s.
maxsplitintegerinoptionalMost splits, default 0: no limit.

Call graph

re_split_sr ​

Split a subject at the matches of a pattern (see split_character).

@note The doctest is not necessary, this being tested by re_split_cc.

Returns: type(string)

fortran
function re_split_sr(subject, pattern, maxsplit) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterntype(regex)inThe compiled pattern.
maxsplitintegerinoptionalMost splits, default 0: no limit.

Call graph

re_sub_cc ​

Return a subject with the matches of a pattern replaced by a template (see sub_character).

@note A character pattern is compiled at each call (a malformed one stops the program): compile it once with compile and pass the regex to repeat the search.

fortran
 type(string) :: s
 s = re_sub('x=1, y=22', '(\w)=(\d+)', '\2=\1')
 print '(L1)', s=='1=x, 22=y'

Returns: type(string)

fortran
function re_sub_cc(subject, pattern, repl, flags, count) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterncharacter(len=*)inThe pattern.
replcharacter(len=*)inTemplate of the replacement (see sub_character).
flagscharacter(len=*)inoptionalFlags: letters i, m, s.
countintegerinoptionalMost replacements, default 0: all.

Call graph

re_sub_cr ​

Return a subject with the matches of a pattern replaced by a template (see sub_character).

@note The doctest is not necessary, this being tested by re_sub_cc.

Returns: type(string)

fortran
function re_sub_cr(subject, pattern, repl, count) result(found)

Arguments

NameTypeIntentAttributesDescription
subjectcharacter(len=*)inThe subject.
patterntype(regex)inThe compiled pattern.
replcharacter(len=*)inTemplate of the replacement (see sub_character).
countintegerinoptionalMost replacements, default 0: all.

Call graph

re_sub_sc ​

Return a subject with the matches of a pattern replaced by a template (see sub_character).

@note The doctest is not necessary, this being tested by re_sub_cc.

Returns: type(string)

fortran
function re_sub_sc(subject, pattern, repl, flags, count) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterncharacter(len=*)inThe pattern.
replcharacter(len=*)inTemplate of the replacement (see sub_character).
flagscharacter(len=*)inoptionalFlags: letters i, m, s.
countintegerinoptionalMost replacements, default 0: all.

Call graph

re_sub_sr ​

Return a subject with the matches of a pattern replaced by a template (see sub_character).

@note The doctest is not necessary, this being tested by re_sub_cc.

Returns: type(string)

fortran
function re_sub_sr(subject, pattern, repl, count) result(found)

Arguments

NameTypeIntentAttributesDescription
subjecttype(string)inThe subject.
patterntype(regex)inThe compiled pattern.
replcharacter(len=*)inTemplate of the replacement (see sub_character).
countintegerinoptionalMost replacements, default 0: all.

Call graph

is_identifier ​

Return true if the name is an ASCII identifier: a letter or underscore, then letters, digits, underscores.

Attributes: pure

Returns: logical

fortran
function is_identifier(name) result(ok)

Arguments

NameTypeIntentAttributesDescription
namecharacter(len=*)inName.

Call graph

hex_value ​

Return the value of exactly digits hexadecimal digits at first, -1 if they are not there.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function hex_value(text, first, digits) result(value)

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)inText.
firstintegerinPosition of the first digit.
digitsintegerinNumber of digits.

Call graph

nullable ​

Return true if the node can match the empty string.

Attributes: pure, recursive

Returns: logical

fortran
function nullable(p, node) result(empty)

Arguments

NameTypeIntentAttributesDescription
ptype(parser)inParser.
nodeintegerinThe node.

Call graph

itoa ​

Return an integer as text.

Attributes: pure

Returns: character(len=:)

fortran
function itoa(n) result(text)

Arguments

NameTypeIntentAttributesDescription
nintegerinInteger.

Call graph