########################################
#                                      #
#   cowsay in Brainfuck by zonia3000   #
#                                      #
########################################

# read user input until newline is detected

----------
[
    ++++++++++
    >>

    # store user input
    >,

    # store 2 extra cells for performing future computation
    # cells are initialized at 1 so we can go back smoothly
    >+>+<<

    ----------
]

# cleanup extra cells
>[-]>[-]<<<[-]

# temporary reset last support cell for performing next if
<[-]

# if input is not empty
<[>+>+<<-]>[<+>-]+>
[
    # valid input detected: temporary cells cleanup
    [-]<[-]

    # restore last support cell
    +

    # go back!
    [<]<<

    # print space
    ++++++[>++++++<-]>----.
    # print underscore
    >++++++++[-<++++ ++++>]<-.

    # move underscore forward and print it
    >+>[<<[->>>+<<<]+>>>-.>>]

    # print extra underscore
    <<.>
    # print newline (10)
    ++++++++++.
    # print lt (add 50)
    [->++++++<]>.
    # print space
    <++++[->-------<]>.

    # go back to start of text
    <<[<]>>>

    # print input text (and last space)
    [.>>>]

    <<< # last cells contain 95 0 32
    # print gt (add 30 to 32)
    <++++++++++[->+++<]>.

    # print newline
    <++++++++++.
    # print space (sub 30 to 62)
    [->---<]>.

    # reset last cell
    [-]<

    # transform underscore to dash (sub 50 to 95)
    ++++++++++[-<----->]<.

    # move dash to the beginning and print it
    <[>[-<<<+>>>]+<<<-.<]>.

    # go to the end
    [>]

                      print first part of cow head

       ++++++   ++++.-   -[>+++   +>++++   ++>+++   +++++>   ++++++
      ++++>+   ++++++   +++++<   <<<<-]   >.....   ...>>>   >----.
     <<<<..   .>>>>+   +.+..-   .<<<<-   ------   ------   ------
    ---.>-   ------   ------   ---...   ......   >>>--.   <<<..+
                             +++++++.

    # reset memory
    >>>[-]<[-]<[-]<[-]<[-]<[-]

    # check if last input char is !
    <++ # current value is 3
    [-<---------->]<---

    # if char is not !
    [>+>+<<-]>[<+>-]+>
    [ # print normal cow eyes
        >
         ++++++++++[->+++++++++++<]>+..[-]<
        <
    <->[-]]< # else
    [ # print crazy cow eyes
        >>
         ++++++++[->++++++++<]>..[-]<
        <<-
    ]

                      print rest of the cow

        ++++++++            [>++++>++       ++++>       +++++
      +++>+++++++++       +>+++++++++++     +<<<<       <-]>>
     -------.>>>----     .+++.......<<<<    -----       -----
    -----        ----   ---.>--   -------   .....       .....
    ..++                +++++       +.>>>   ..<<<   +   .>>>-
    --.<                <<---       -----   -....  ...  +++++
    ++++                .>>>.       <<<++   ++++. >>>.< <<<.>
    ----                -----       -----   -................
    >>>++        ++++   +++++++   +++++++    +++++++ +++++..
     <<<++++++++++++     +....>>>-----.<      <<---   -----
      -----.>>>++++       +.<<<<.>.....        ...     ...
        .....>>>            ..<<<....           .       >

    >>..

    # reset memory
    [-]<[-]<[-]<[-]<[-]

    # black magic fix before else
    <[-]+>

# else: empty input detected
<->[-]]<
[                                       kill the cow
    >>

    |+++++\     /+++[>|   |++++>++++++>+++++|   |+++>++++++++++>++|   |++++++++++<<<<<-]|   |>>>..|
    |......\   /......|   |.................|   |......<<---------|   |-------------.>>.|   |<----|
    |-------\ /-----.>|   |+++++.>>+++++++++|   |++++.+++.++++.+++|   |++.<<<.>>>-------|   |-----|
    |----.+++ ++.++.++|   |+++.-.<<<.>>>----|   |.++.---.+++++++.-|   |------------.----|   |-.+.-|
    |.<<<+++++++++++++|   |+.---|     |-----|   |-----|     |-.>--|   |.>>++|     |+++++|   |++++.|
    |+++++|+++.<|<<.>>|   |+++++|     |+++++|   |+++++|     |++++.|   |>----|     |-.<--|   |.>+.<|
    |+++++|\++./|---.-|   |.<<.>|     |---.<|   |<.>>.|     |.....|   |.....|     |.....|   |.....|
    |.....| \./ |.....|   |.....|     |<<..>|   |.....|     |.....|   |....>|     |>>+++|   |+++++|
    |+..<<|     |<....|   |.>>>..<<<........|   |......<.>........|   |......>>>..<<<+++|
    |+++++|     |+++++|   |....>++++++++++++|   |+.<-------------.|   |>>>.<<<<.>.......|   |...++|
    |+++++|     |+.+++|   |++..----.++++++.-|   |--------------...|   |....+++++++++.+++|   |+++.>|
    |>----|     |----.|   |<<.<.>-----------|   |----..........+++|   |+++++.>>>----..<<|   |<+.++|

              ++++.--.......<.>-------------..........>>>--.<<<+++++++++++++..>>>.

    # reset memory
    [-]<[-]<[-]<[-]<[-]<
    <<-
]

# newline
++++++++++.
