28.3.3 Object classes representing semantic–version parsers input strings

Objects of class mbfl_semver_parser_input are used as “cursors” to traverse the characters of a string while parsing semantic–version specification string-representations. We create objects of this class and then hand them as parameter to mbfl_semver_parse():

mbfl_default_object_declare(PARSER_INPUT)
declare START_INDEX=0

mbfl_semver_parser_input_make _(PARSER_INPUT) "1.2.3-alpha.1" $START_INDEX
mbfl_semver_parse _(SEMVER_SPEC) _(SEMVER_PARSER) _(PARSER_INPUT)
Class: mbfl_semver_parser_input
Superclass: mbfl_default_object
Metaclass: mbfl_default_class

Class of objects representing input strings to be used in parsing semantic–version specifications string-representations.

When the data variable of an object of this class is used as parameter to function: in this documentation that parameter is named PARSER_INPUT.

Constructor on mbfl_semver_parser_input_t: mbfl_semver_parser_input_make PARSER_INPUT INPUT_STRING START_INDEX

Initialise an already declared object of class mbfl_semver_parser_input so that parsing of INPUT_STRING will start at START_INDEX. It must be:

0 <= STARTX_INDEX <= mbfl_string_len(INPUT_STRING)

If PARSER_INPUT has already been initialised by a previous call to a constructor: the old state of the object is deleted.

Predicate on mbfl_semver_parser_input_t: mbfl_semver_parser_input_is_a OBJ

Return true if OBJ is the data variable of an object of class mbfl_semver_parser; otherwise return false.

mbfl_default_object_declare(PARSER_INPUT)

mbfl_semver_parser_input_make _(PARSER_INPUT) "1.2.3-alpha.1" 0
mbfl_semver_parser_input_is_a _(PARSER_INPUT)   ⇒ 0
mbfl_semver_parser_input_is_a 'ciao'            ⇒ 1
Accessor on mbfl_semver_parser_input_t: mbfl_semver_parser_input_string_var _RV PARSER_INPUT

Accessor for the input string which is meant to contain a semantic–version specification. When successful return true; otherwise return false.

mbfl_default_object_declare(PARSER_INPUT)
mbfl_declare_varref(STR)

mbfl_semver_parser_input_make _(PARSER_INPUT) "1.2.3-alpha.1" 0
mbfl_semver_parser_input_string_var _(STR) _(PARSER_INPUT)
"$STR"  ⇒ 1.2.3-alpha.1
Accessor on mbfl_semver_parser_input_t: mbfl_semver_parser_start_index_var _RV PARSER_INPUT

Accessor for the index of the first character of the semantic–version specification in the input string. When successful return true; otherwise return false.

mbfl_default_object_declare(PARSER_INPUT)
mbfl_declare_varref(IDX)

mbfl_semver_parser_input_make _(PARSER_INPUT) "frobnicator-1.2.3-alpha.1" 12
mbfl_semver_parser_input_start_index_var _(IDX) _(PARSER_INPUT)
"$IDX"  ⇒ 12
Accessor on mbfl_semver_parser_input_t: mbfl_semver_parser_end_index_var _RV PARSER_INPUT
Mutator on mbfl_semver_parser_input_t: mbfl_semver_parser_end_index_set PARSER_INPUT END_INDEX

Accessor and mutator for index of the first character after the end of the semantic–version specification in the input string. If the input string holds further text after the semantic–version specification: we can start parsing it at this index. This value is meaningful only after a successful call to mbfl_semver_parse() applied to PARSER_INPUT. When successful return true; otherwise return false.

mbfl_default_object_declare(PARSER_INPUT)
mbfl_declare_varref(IDX)

mbfl_semver_parser_input_make _(PARSER_INPUT) "frobnicator-1.2.3-alpha.1" 12
mbfl_semver_parse _(SEMVER_SPEC) _(SEMVER_PARSER) _(PARSER_INPUT)

mbfl_semver_parser_input_end_index_var _(IDX) _(PARSER_INPUT)
"$IDX"  ⇒ 25

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.