toml_context Derived Type

type, public :: toml_context

Container storing tokens


Components

Type Visibility Attributes Name Initial
character(kind=tfc, len=:), public, allocatable :: filename

Filename of the input

character(kind=tfc, len=:), public, allocatable :: source

Actual source

type(toml_token), public, allocatable :: token(:)

Stack of stored tokens

integer, public :: top = 0

Last stored token


Type-Bound Procedures

procedure, public :: push_back

Push a new token to the stack

  • private subroutine push_back(self, token)

    Push a new token to the stack

    Arguments

    Type IntentOptional Attributes Name
    class(toml_context), intent(inout) :: self

    Instance of the token storage

    type(toml_token), intent(in) :: token

    New token to be added

generic, public :: report => report1, report2

Create a report

  • private pure function report1(self, message, origin, label, level, color) result(string)

    Create a report with a single label

    Arguments

    Type IntentOptional Attributes Name
    class(toml_context), intent(in) :: self

    Instance of the token storage

    character(kind=tfc, len=*), intent(in) :: message

    Message for the report

    integer, intent(in) :: origin

    Position to report at

    character(kind=tfc, len=*), intent(in), optional :: label

    String for the label

    integer, intent(in), optional :: level

    Highlight level

    type(toml_terminal), intent(in), optional :: color

    Color terminal

    Return Value character(kind=tfc, len=:), allocatable

    Final rendered report

  • private pure function report2(self, message, origin1, origin2, label1, label2, level1, level2, color) result(string)

    Create a report with two labels

    Arguments

    Type IntentOptional Attributes Name
    class(toml_context), intent(in) :: self

    Instance of the token storage

    character(kind=tfc, len=*), intent(in) :: message

    Message for the report

    integer, intent(in) :: origin1

    Position to report at

    integer, intent(in) :: origin2

    Position to report at

    character(kind=tfc, len=*), intent(in), optional :: label1

    String for the label

    character(kind=tfc, len=*), intent(in), optional :: label2

    String for the label

    integer, intent(in), optional :: level1

    Highlight level

    integer, intent(in), optional :: level2

    Highlight level

    type(toml_terminal), intent(in), optional :: color

    Color terminal

    Return Value character(kind=tfc, len=:), allocatable

    Final rendered report

procedure, public :: report1

Create a report with a single label

  • private pure function report1(self, message, origin, label, level, color) result(string)

    Create a report with a single label

    Arguments

    Type IntentOptional Attributes Name
    class(toml_context), intent(in) :: self

    Instance of the token storage

    character(kind=tfc, len=*), intent(in) :: message

    Message for the report

    integer, intent(in) :: origin

    Position to report at

    character(kind=tfc, len=*), intent(in), optional :: label

    String for the label

    integer, intent(in), optional :: level

    Highlight level

    type(toml_terminal), intent(in), optional :: color

    Color terminal

    Return Value character(kind=tfc, len=:), allocatable

    Final rendered report

procedure, public :: report2

Create a report with a two labels

  • private pure function report2(self, message, origin1, origin2, label1, label2, level1, level2, color) result(string)

    Create a report with two labels

    Arguments

    Type IntentOptional Attributes Name
    class(toml_context), intent(in) :: self

    Instance of the token storage

    character(kind=tfc, len=*), intent(in) :: message

    Message for the report

    integer, intent(in) :: origin1

    Position to report at

    integer, intent(in) :: origin2

    Position to report at

    character(kind=tfc, len=*), intent(in), optional :: label1

    String for the label

    character(kind=tfc, len=*), intent(in), optional :: label2

    String for the label

    integer, intent(in), optional :: level1

    Highlight level

    integer, intent(in), optional :: level2

    Highlight level

    type(toml_terminal), intent(in), optional :: color

    Color terminal

    Return Value character(kind=tfc, len=:), allocatable

    Final rendered report

Source Code

   type :: toml_context
      !> Filename of the input
      character(:, tfc), allocatable :: filename
      !> Actual source
      character(:, tfc), allocatable :: source
      !> Stack of stored tokens
      type(toml_token), allocatable :: token(:)
      !> Last stored token
      integer :: top = 0
   contains
      !> Push a new token to the stack
      procedure :: push_back
      !> Create a report
      generic :: report => report1, report2
      !> Create a report with a single label
      procedure :: report1
      !> Create a report with a two labels
      procedure :: report2
   end type toml_context