Pop_TokenStack Subroutine

public subroutine Pop_TokenStack(stack, tok)

Arguments

TypeIntentOptionalAttributesName
class(TokenStack), intent(inout) :: stack
type(Token), intent(out) :: tok

Contents

Source Code


Source Code

  subroutine Pop_TokenStack(stack,tok)
    class(TokenStack),intent(inout) :: stack
    type(Token),intent(out)        :: tok

    if(stack%top_index <= 0) then
      print*,"Attempt to pop from empty token stack"
    else
      tok%tokenString = stack%tokens(stack%top_index)%tokenString
      tok%tokenType = stack%tokens(stack%top_index)%tokenType
      tok%tokenIndex = stack%tokens(stack%top_index)%tokenIndex
      stack%top_index = stack%top_index-1
    endif

  endsubroutine Pop_TokenStack