fdoc

subroutinecontrol_directiverecursiveprivate

recursive subroutine control_directive(c, word, param, on_lines, path)

Act on control directive word.

Arguments

NameTypeIntentAttributesDescription
ctype(fypp_t)inout

the state

wordcharacter(len=*)in

the directive

paramcharacter(len=*)in

what follows it

on_lineslogicalin

true for a line directive

pathcharacter(len=*)in

the file

Calls

Source

Show the code
recursive subroutine control_directive(c, word, param, on_lines, path)
    type(fypp_t), intent(inout) :: c            !! the state
    character(len=*), intent(in) :: word        !! the directive
    character(len=*), intent(in) :: param       !! what follows it
    logical, intent(in) :: on_lines             !! true for a line directive
    character(len=*), intent(in) :: path        !! the file
    integer :: node, expr

    select case (word)
    case ('if')
        call compile(c, param, expr)
        node = new_node(c, N_IF)
        c%nodes(node)%source = param
        call add_body(c, node, expr)
        call open_block(c, node)
    case ('elif', 'else')
        expr = 0
        if (word == 'elif') call compile(c, param, expr)
        if (c%depth == 0) then
            call fail(c, word//' outside of an if block')
        else if (c%nodes(c%stack(c%depth))%kind /= N_IF) then
            call fail(c, word//' outside of an if block')
        else
            call add_body(c, c%stack(c%depth), expr)
        end if
    case ('endif')
        call close_block(c, N_IF, word)
    case ('for')
        call for_directive(c, param)
    case ('endfor')
        call close_block(c, N_FOR, word)
    case ('set')
        call set_directive(c, param)
    case ('def')
        call def_directive(c, param)
    case ('enddef')
        call close_block(c, N_DEF, word)
    case ('call', 'block')
        call call_directive(c, param, on_lines)
    case ('endcall', 'endblock')
        call close_block(c, N_CALL, word)
    case ('include')
        call include_directive(c, param, path)
    case ('mute')
        node = new_node(c, N_MUTE)
        call add_body(c, node, 0)
        call open_block(c, node)
    case ('endmute')
        call close_block(c, N_MUTE, word)
    case ('assert')
        call compile(c, param, expr)
        node = new_node(c, N_ASSERT)
        c%nodes(node)%expr = expr
        c%nodes(node)%source = param
        call append(c, node)
    case default
        call fail(c, 'the directive '//word//' is not supported')
    end select
end subroutine control_directive

Graphs

Calls

Called by