namespace eval gen_erl {


variable keywords {
after
and
andalso
band
bagin
bnot
bor
bsl
bsr
bxor
case
catch
cond
div
end
fun
if
let
not
of
or
orelse
query
receive
rem
try
when
xor
}

# Autogenerated with DRAKON Editor 1.29

proc highlight { tokens } {
    #item 16
    set result {}
    #item 17
    set state "idle"
    #item 63
    variable keywords
    foreach token $tokens {
        #item 124
        lassign $token type text
        #item 180001
        if {$state == "idle"} {
            #item 350001
            if {$text == "\""} {
                #item 64
                lappend result \
                  $colors::syntax_string
                #item 43
                set state "string"
            } else {
                #item 350002
                if {$text == "'"} {
                    #item 65
                    lappend result \
                      $colors::syntax_string
                    #item 46
                    set state "atom"
                } else {
                    #item 350003
                    if {$text == "%"} {
                        #item 118
                        lappend result \
                          $colors::syntax_comment
                        #item 117
                        set state "comment"
                    } else {
                        #item 470001
                        if {$type == "op"} {
                            #item 55
                            lappend result \
                              $colors::syntax_operator
                        } else {
                            #item 470002
                            if {$type == "number"} {
                                #item 54
                                lappend result \
                                  $colors::syntax_number
                            } else {
                                #item 470003
                                if {($type == "token") && ([contains $keywords $text])} {
                                    #item 59
                                    lappend result \
                                      $colors::syntax_keyword
                                } else {
                                    #item 56
                                    lappend result \
                                      $colors::syntax_identifier
                                }
                            }
                        }
                    }
                }
            }
        } else {
            #item 180002
            if {$state == "string"} {
                #item 790001
                if {$text == "\""} {
                    #item 86
                    lappend result \
                      $colors::syntax_string
                    #item 87
                    set state "idle"
                } else {
                    #item 790002
                    if {$text == "\\"} {
                        #item 125
                        lappend result \
                          $colors::syntax_string
                        #item 88
                        set state "escaping"
                    } else {
                        #item 790003
                        if {$text == "\n"} {
                            #item 126
                            lappend result \
                              $colors::syntax_string
                            #item 91
                            set state "idle"
                        } else {
                            #item 790004
                            if {$text == "~"} {
                                #item 130
                                lappend result \
                                  $colors::syntax_operator
                            } else {
                                #item 127
                                lappend result \
                                  $colors::syntax_string
                            }
                        }
                    }
                }
            } else {
                #item 180003
                if {$state == "escaping"} {
                    #item 93
                    lappend result $colors::syntax_string
                    #item 109
                    if {$text == "\n"} {
                        #item 111
                        set state "idle"
                    } else {
                        #item 92
                        set state "string"
                    }
                } else {
                    #item 180004
                    if {$state == "atom"} {
                        #item 101
                        lappend result $colors::syntax_string
                        #item 940001
                        if {$text == "'"} {
                            #item 102
                            set state "idle"
                        } else {
                            #item 940002
                            if {$text == "\\"} {
                                #item 103
                                set state "atom escaping"
                            } else {
                                #item 940003
                                if {$text == "\n"} {
                                    #item 106
                                    set state "idle"
                                } else {
                                    
                                }
                            }
                        }
                    } else {
                        #item 180005
                        if {$state == "atom escaping"} {
                            #item 108
                            lappend result \
                             $colors::syntax_string
                            #item 112
                            if {$text == "\n"} {
                                #item 114
                                set state "idle"
                            } else {
                                #item 107
                                set state "atom"
                            }
                        } else {
                            #item 180006
                            if {$state == "comment"} {
                                
                            } else {
                                #item 180007
                                error "Unexpected switch value: $state"
                            }
                            #item 119
                            lappend result \
                              $colors::syntax_comment
                            #item 120
                            if {$text == "\n"} {
                                #item 122
                                set state "idle"
                            } else {
                                
                            }
                        }
                    }
                }
            }
        }
    }
    #item 15
    return $result
}

proc is_atom { text } {
    #item 72
    set lower [ string tolower $text ]
    #item 73
    if {$lower == $text} {
        #item 76
        return 1
    } else {
        #item 77
        return 0
    }
}

}
