---input---
## core string functions ##

length(s::String) = error("you must implement length(",typeof(s),")")
next(s::String, i::Int) = error("you must implement next(",typeof(s),",Int)")
next(s::DirectIndexString, i::Int) = (s[i],i+1)
next(s::String, i::Integer) = next(s,int(i))

## generic supplied functions ##

start(s::String) = 1
done(s::String,i) = (i > length(s))
isempty(s::String) = done(s,start(s))
ref(s::String, i::Int) = next(s,i)[1]
ref(s::String, i::Integer) = s[int(i)]
ref(s::String, x::Real) = s[iround(x)]
ref{T<:Integer}(s::String, r::Range1{T}) = s[int(first(r)):int(last(r))]

symbol(s::String) = symbol(cstring(s))
string(s::String) = s

print(s::String) = for c=s; print(c); end
print(x...) = for i=x; print(i); end
println(args...) = print(args..., '\n')

show(s::String) = print_quoted(s)

(*)(s::String...) = strcat(s...)
(^)(s::String, r::Integer) = repeat(s,r)

size(s::String) = (length(s),)
size(s::String, d::Integer) = d==1 ? length(s) :
    error("in size: dimension ",d," out of range")

strlen(s::DirectIndexString) = length(s)
function strlen(s::String)
    i = start(s)
    if done(s,i)
        return 0
    end
    n = 1
    while true
        c, j = next(s,i)
        if done(s,j)
            return n
        end
        n += 1
        i = j
    end
end

isvalid(s::DirectIndexString, i::Integer) = (start(s) <= i <= length(s))
function isvalid(s::String, i::Integer)
    try
        next(s,i)
        true
    catch
        false
    end
end

prevind(s::DirectIndexString, i::Integer) = i-1
thisind(s::DirectIndexString, i::Integer) = i
nextind(s::DirectIndexString, i::Integer) = i+1

prevind(s::String, i::Integer) = thisind(s,thisind(s,i)-1)

function thisind(s::String, i::Integer)
    for j = i:-1:1
        if isvalid(s,j)
            return j
        end
    end
    return 0 # out of range
end

function nextind(s::String, i::Integer)
    for j = i+1:length(s)
        if isvalid(s,j)
            return j
        end
    end
    length(s)+1 # out of range
end

ind2chr(s::DirectIndexString, i::Integer) = i
chr2ind(s::DirectIndexString, i::Integer) = i

function ind2chr(s::String, i::Integer)
    s[i] # throws error if invalid
    j = 1
    k = start(s)
    while true
        c, l = next(s,k)
        if i <= k
            return j
        end
        j += 1
        k = l
    end
end

function chr2ind(s::String, i::Integer)
    if i < 1
        return i
    end
    j = 1
    k = start(s)
    while true
        c, l = next(s,k)
        if i == j
            return k
        end
        j += 1
        k = l
    end
end

function strchr(s::String, c::Char, i::Integer)
    i = nextind(s,i)
    while !done(s,i)
        d, j = next(s,i)
        if c == d
            return i
        end
        i = j
    end
    return 0
end
strchr(s::String, c::Char) = strchr(s, c, start(s))
contains(s::String, c::Char) = (strchr(s,c)!=0)

function chars(s::String)
    cx = Array(Char,strlen(s))
    i = 0
    for c in s
        cx[i += 1] = c
    end
    return cx
end

function cmp(a::String, b::String)
    i = start(a)
    j = start(b)
    while !done(a,i) && !done(b,i)
        c, i = next(a,i)
        d, j = next(b,j)
        if c != d
            return c < d ? -1 : +1
        end
    end
    done(a,i) && !done(b,j) ? -1 :
    !done(a,i) && done(b,j) ? +1 : 0
end

isequal(a::String, b::String) = cmp(a,b) == 0
isless(a::String, b::String)  = cmp(a,b) <  0

# faster comparisons for byte strings

cmp(a::ByteString, b::ByteString)     = lexcmp(a.data, b.data)
isequal(a::ByteString, b::ByteString) = length(a)==length(b) && cmp(a,b)==0

## character column width function ##

charwidth(c::Char) = max(0,int(ccall(:wcwidth, Int32, (Char,), c)))
strwidth(s::String) = (w=0; for c in s; w += charwidth(c); end; w)
strwidth(s::ByteString) = ccall(:u8_strwidth, Int, (Ptr{Uint8},), s.data)
# TODO: implement and use u8_strnwidth that takes a length argument

## generic string uses only length and next ##

type GenericString <: String
    string::String
end

length(s::GenericString) = length(s.string)
next(s::GenericString, i::Int) = next(s.string, i)

## plain old character arrays ##

type CharString <: String
    chars::Array{Char,1}

    CharString(a::Array{Char,1}) = new(a)
    CharString(c::Char...) = new([ c[i] | i=1:length(c) ])
end
CharString(x...) = CharString(map(char,x)...)

next(s::CharString, i::Int) = (s.chars[i], i+1)
length(s::CharString) = length(s.chars)
strlen(s::CharString) = length(s)

string(c::Char) = CharString(c)
string(c::Char, x::Char...) = CharString(c, x...)

## substrings reference original strings ##

type SubString <: String
    string::String
    offset::Int
    length::Int

    SubString(s::String, i::Int, j::Int) = new(s, i-1, j-i+1)
    SubString(s::SubString, i::Int, j::Int) =
        new(s.string, i-1+s.offset, j-i+1)
end
SubString(s::String, i::Integer, j::Integer) = SubString(s, int(i), int(j))

function next(s::SubString, i::Int)
    if i < 1 || i > s.length
        error("string index out of bounds")
    end
    c, i = next(s.string, i+s.offset)
    c, i-s.offset
end

length(s::SubString) = s.length
# TODO: strlen(s::SubString) = ??
# default implementation will work but it's slow
# can this be delegated efficiently somehow?
# that may require additional string interfaces

function ref(s::String, r::Range1{Int})
    if first(r) < 1 || length(s) < last(r)
        error("in substring slice: index out of range")
    end
    SubString(s, first(r), last(r))
end

## efficient representation of repeated strings ##

type RepString <: String
    string::String
    repeat::Integer
end

length(s::RepString) = length(s.string)*s.repeat
strlen(s::RepString) = strlen(s.string)*s.repeat

function next(s::RepString, i::Int)
    if i < 1 || i > length(s)
        error("string index out of bounds")
    end
    j = mod1(i,length(s.string))
    c, k = next(s.string, j)
    c, k-j+i
end

function repeat(s::String, r::Integer)
    r <  0 ? error("can't repeat a string ",r," times") :
    r == 0 ? "" :
    r == 1 ? s  :
    RepString(s,r)
end

## reversed strings without data movement ##

type RevString <: String
    string::String
end

length(s::RevString) = length(s.string)
strlen(s::RevString) = strlen(s.string)

start(s::RevString) = (n=length(s); n-thisind(s.string,n)+1)
function next(s::RevString, i::Int)
    n = length(s); j = n-i+1
    (s.string[j], n-thisind(s.string,j-1)+1)
end

reverse(s::String) = RevString(s)
reverse(s::RevString) = s.string

## ropes for efficient concatenation, etc. ##

# Idea: instead of this standard binary tree structure,
# how about we keep an array of substrings, with an
# offset array. We can do binary search on the offset
# array so we get O(log(n)) indexing time still, but we
# can compute the offsets lazily and avoid all the
# futzing around while the string is being constructed.

type RopeString <: String
    head::String
    tail::String
    depth::Int32
    length::Int

    RopeString(h::RopeString, t::RopeString) =
        depth(h.tail) + depth(t) < depth(h.head) ?
            RopeString(h.head, RopeString(h.tail, t)) :
            new(h, t, max(h.depth,t.depth)+1, length(h)+length(t))

    RopeString(h::RopeString, t::String) =
        depth(h.tail) < depth(h.head) ?
            RopeString(h.head, RopeString(h.tail, t)) :
            new(h, t, h.depth+1, length(h)+length(t))

    RopeString(h::String, t::RopeString) =
        depth(t.head) < depth(t.tail) ?
            RopeString(RopeString(h, t.head), t.tail) :
            new(h, t, t.depth+1, length(h)+length(t))

    RopeString(h::String, t::String) =
        new(h, t, 1, length(h)+length(t))
end

depth(s::String) = 0
depth(s::RopeString) = s.depth

function next(s::RopeString, i::Int)
    if i <= length(s.head)
        return next(s.head, i)
    else
        c, j = next(s.tail, i-length(s.head))
        return c, j+length(s.head)
    end
end

length(s::RopeString) = s.length
strlen(s::RopeString) = strlen(s.head) + strlen(s.tail)

strcat() = ""
strcat(s::String) = s
strcat(x...) = strcat(map(string,x)...)
strcat(s::String, t::String...) =
    (t = strcat(t...); isempty(s) ? t : isempty(t) ? s : RopeString(s, t))

print(s::RopeString) = print(s.head, s.tail)

## transformed strings ##

type TransformedString <: String
    transform::Function
    string::String
end

length(s::TransformedString) = length(s.string)
strlen(s::TransformedString) = strlen(s.string)

function next(s::TransformedString, i::Int)
    c, j = next(s.string,i)
    c = s.transform(c, i)
    return c, j
end

## uppercase and lowercase transformations ##

uppercase(c::Char) = ccall(:towupper, Char, (Char,), c)
lowercase(c::Char) = ccall(:towlower, Char, (Char,), c)

uppercase(s::String) = TransformedString((c,i)->uppercase(c), s)
lowercase(s::String) = TransformedString((c,i)->lowercase(c), s)

ucfirst(s::String) = TransformedString((c,i)->i==1 ? uppercase(c) : c, s)
lcfirst(s::String) = TransformedString((c,i)->i==1 ? lowercase(c) : c, s)

const uc = uppercase
const lc = lowercase

## string map ##

function map(f::Function, s::String)
    out = memio(length(s))
    for c in s
        write(out, f(c)::Char)
    end
    takebuf_string(out)
end

## conversion of general objects to strings ##

string(x) = print_to_string(show, x)
cstring(x...) = print_to_string(print, x...)

function cstring(p::Ptr{Uint8})
    p == C_NULL ? error("cannot convert NULL to string") :
    ccall(:jl_cstr_to_string, Any, (Ptr{Uint8},), p)::ByteString
end

## string promotion rules ##

promote_rule(::Type{UTF8String} , ::Type{ASCIIString}) = UTF8String
promote_rule(::Type{UTF8String} , ::Type{CharString} ) = UTF8String
promote_rule(::Type{ASCIIString}, ::Type{CharString} ) = UTF8String

## printing literal quoted string data ##

# TODO: this is really the inverse of print_unbackslashed

function print_quoted_literal(s::String)
    print('"')
    for c = s; c == '"' ? print("\\\"") : print(c); end
    print('"')
end

## string escaping & unescaping ##

escape_nul(s::String, i::Int) =
    !done(s,i) && '0' <= next(s,i)[1] <= '7' ? L"\x00" : L"\0"

is_hex_digit(c::Char) = '0'<=c<='9' || 'a'<=c<='f' || 'A'<=c<='F'
need_full_hex(s::String, i::Int) = !done(s,i) && is_hex_digit(next(s,i)[1])

function print_escaped(s::String, esc::String)
    i = start(s)
    while !done(s,i)
        c, j = next(s,i)
        c == '\0'       ? print(escape_nul(s,j)) :
        c == '\e'       ? print(L"\e") :
        c == '\\'       ? print("\\\\") :
        contains(esc,c) ? print('\\', c) :
        iswprint(c)     ? print(c) :
        7 <= c <= 13    ? print('\\', "abtnvfr"[c-6]) :
        c <= '\x7f'     ? print(L"\x", hex(c, 2)) :
        c <= '\uffff'   ? print(L"\u", hex(c, need_full_hex(s,j) ? 4 : 2)) :
                          print(L"\U", hex(c, need_full_hex(s,j) ? 8 : 4))
        i = j
    end
end

escape_string(s::String) = print_to_string(length(s), print_escaped, s, "\"")
print_quoted(s::String) = (print('"'); print_escaped(s, "\"\$"); print('"'))
#"  # work around syntax highlighting problem
quote_string(s::String) = print_to_string(length(s)+2, print_quoted, s)

# bare minimum unescaping function unescapes only given characters

function print_unescaped_chars(s::String, esc::String)
    if !contains(esc,'\\')
        esc = strcat("\\", esc)
    end
    i = start(s)
    while !done(s,i)
        c, i = next(s,i)
        if c == '\\' && !done(s,i) && contains(esc,s[i])
            c, i = next(s,i)
        end
        print(c)
    end
end

unescape_chars(s::String, esc::String) =
    print_to_string(length(s), print_unescaped_chars, s, esc)

# general unescaping of traditional C and Unicode escape sequences

function print_unescaped(s::String)
    i = start(s)
    while !done(s,i)
        c, i = next(s,i)
        if !done(s,i) && c == '\\'
            c, i = next(s,i)
            if c == 'x' || c == 'u' || c == 'U'
                n = k = 0
                m = c == 'x' ? 2 :
                    c == 'u' ? 4 : 8
                while (k+=1) <= m && !done(s,i)
                    c, j = next(s,i)
                    n = '0' <= c <= '9' ? n<<4 + c-'0' :
                        'a' <= c <= 'f' ? n<<4 + c-'a'+10 :
                        'A' <= c <= 'F' ? n<<4 + c-'A'+10 : break
                    i = j
                end
                if k == 1
                    error("\\x used with no following hex digits")
                end
                if m == 2 # \x escape sequence
                    write(uint8(n))
                else
                    print(char(n))
                end
            elseif '0' <= c <= '7'
                k = 1
                n = c-'0'
                while (k+=1) <= 3 && !done(s,i)
                    c, j = next(s,i)
                    n = '0' <= c <= '7' ? n<<3 + c-'0' : break
                    i = j
                end
                if n > 255
                    error("octal escape sequence out of range")
                end
                write(uint8(n))
            else
                print(c == 'a' ? '\a' :
                      c == 'b' ? '\b' :
                      c == 't' ? '\t' :
                      c == 'n' ? '\n' :
                      c == 'v' ? '\v' :
                      c == 'f' ? '\f' :
                      c == 'r' ? '\r' :
                      c == 'e' ? '\e' : c)
            end
        else
            print(c)
        end
    end
end

unescape_string(s::String) = print_to_string(length(s), print_unescaped, s)

## checking UTF-8 & ACSII validity ##

byte_string_classify(s::ByteString) =
    ccall(:u8_isvalid, Int32, (Ptr{Uint8}, Int), s.data, length(s))
    # 0: neither valid ASCII nor UTF-8
    # 1: valid ASCII
    # 2: valid UTF-8

is_valid_ascii(s::ByteString) = byte_string_classify(s) == 1
is_valid_utf8 (s::ByteString) = byte_string_classify(s) != 0

check_ascii(s::ByteString) = is_valid_ascii(s) ? s : error("invalid ASCII sequence")
check_utf8 (s::ByteString) = is_valid_utf8(s)  ? s : error("invalid UTF-8 sequence")

## string interpolation parsing ##

function _jl_interp_parse(s::String, unescape::Function, printer::Function)
    sx = {}
    i = j = start(s)
    while !done(s,j)
        c, k = next(s,j)
        if c == '$'
            if !isempty(s[i:j-1])
                push(sx, unescape(s[i:j-1]))
            end
            ex, j = parseatom(s,k)
            push(sx, ex)
            i = j
        elseif c == '\\' && !done(s,k)
            if s[k] == '$'
                if !isempty(s[i:j-1])
                    push(sx, unescape(s[i:j-1]))
                end
                i = k
            end
            c, j = next(s,k)
        else
            j = k
        end
    end
    if !isempty(s[i:])
        push(sx, unescape(s[i:j-1]))
    end
    length(sx) == 1 && isa(sx[1],ByteString) ? sx[1] :
        expr(:call, :print_to_string, printer, sx...)
end

_jl_interp_parse(s::String, u::Function) = _jl_interp_parse(s, u, print)
_jl_interp_parse(s::String) = _jl_interp_parse(s, x->check_utf8(unescape_string(x)))

function _jl_interp_parse_bytes(s::String)
    writer(x...) = for w=x; write(w); end
    _jl_interp_parse(s, unescape_string, writer)
end

## core string macros ##

macro   str(s); _jl_interp_parse(s); end
macro S_str(s); _jl_interp_parse(s); end
macro I_str(s); _jl_interp_parse(s, x->unescape_chars(x,"\"")); end
macro E_str(s); check_utf8(unescape_string(s)); end
macro B_str(s); _jl_interp_parse_bytes(s); end
macro b_str(s); ex = _jl_interp_parse_bytes(s); :(($ex).data); end

## shell-like command parsing ##

function _jl_shell_parse(s::String, interp::Bool)

    in_single_quotes = false
    in_double_quotes = false

    args = {}
    arg = {}
    i = start(s)
    j = i

    function update_arg(x)
        if !isa(x,String) || !isempty(x)
            push(arg, x)
        end
    end
    function append_arg()
        if isempty(arg); arg = {"",}; end
        push(args, arg)
        arg = {}
    end

    while !done(s,j)
        c, k = next(s,j)
        if !in_single_quotes && !in_double_quotes && iswspace(c)
            update_arg(s[i:j-1])
            append_arg()
            j = k
            while !done(s,j)
                c, k = next(s,j)
                if !iswspace(c)
                    i = j
                    break
                end
                j = k
            end
        elseif interp && !in_single_quotes && c == '$'
            update_arg(s[i:j-1]); i = k; j = k
            if done(s,k)
                error("\$ right before end of command")
            end
            if iswspace(s[k])
                error("space not allowed right after \$")
            end
            ex, j = parseatom(s,j)
            update_arg(ex); i = j
        else
            if !in_double_quotes && c == '\''
                in_single_quotes = !in_single_quotes
                update_arg(s[i:j-1]); i = k
            elseif !in_single_quotes && c == '"'
                in_double_quotes = !in_double_quotes
                update_arg(s[i:j-1]); i = k
            elseif c == '\\'
                if in_double_quotes
                    if done(s,k)
                        error("unterminated double quote")
                    end
                    if s[k] == '"' || s[k] == '$'
                        update_arg(s[i:j-1]); i = k
                        c, k = next(s,k)
                    end
                elseif !in_single_quotes
                    if done(s,k)
                        error("dangling backslash")
                    end
                    update_arg(s[i:j-1]); i = k
                    c, k = next(s,k)
                end
            end
            j = k
        end
    end

    if in_single_quotes; error("unterminated single quote"); end
    if in_double_quotes; error("unterminated double quote"); end

    update_arg(s[i:])
    append_arg()

    if !interp
        return args
    end

    # construct an expression
    exprs = {}
    for arg in args
        push(exprs, expr(:tuple, arg))
    end
    expr(:tuple,exprs)
end
_jl_shell_parse(s::String) = _jl_shell_parse(s,true)

function shell_split(s::String)
    parsed = _jl_shell_parse(s,false)
    args = String[]
    for arg in parsed
       push(args, strcat(arg...))
    end
    args
end

function print_shell_word(word::String)
    if isempty(word)
        print("''")
    end
    has_single = false
    has_special = false
    for c in word
        if iswspace(c) || c=='\\' || c=='\'' || c=='"' || c=='$'
            has_special = true
            if c == '\''
                has_single = true
            end
        end
    end
    if !has_special
        print(word)
    elseif !has_single
        print('\'', word, '\'')
    else
        print('"')
        for c in word
            if c == '"' || c == '$'
                print('\\')
            end
            print(c)
        end
        print('"')
    end
end

function print_shell_escaped(cmd::String, args::String...)
    print_shell_word(cmd)
    for arg in args
        print(' ')
        print_shell_word(arg)
    end
end

shell_escape(cmd::String, args::String...) =
    print_to_string(print_shell_escaped, cmd, args...)

## interface to parser ##

function parse(s::String, pos, greedy)
    # returns (expr, end_pos). expr is () in case of parse error.
    ex, pos = ccall(:jl_parse_string, Any,
                    (Ptr{Uint8}, Int32, Int32),
                    cstring(s), pos-1, greedy ? 1:0)
    if isa(ex,Expr) && is(ex.head,:error)
        throw(ParseError(ex.args[1]))
    end
    if ex == (); throw(ParseError("end of input")); end
    ex, pos+1 # C is zero-based, Julia is 1-based
end

parse(s::String)          = parse(s, 1, true)
parse(s::String, pos)     = parse(s, pos, true)
parseatom(s::String)      = parse(s, 1, false)
parseatom(s::String, pos) = parse(s, pos, false)

## miscellaneous string functions ##

function lpad(s::String, n::Integer, p::String)
    m = n - strlen(s)
    if m <= 0; return s; end
    l = strlen(p)
    if l==1
        return p^m * s
    end
    q = div(m,l)
    r = m - q*l
    cstring(p^q*p[1:chr2ind(p,r)]*s)
end

function rpad(s::String, n::Integer, p::String)
    m = n - strlen(s)
    if m <= 0; return s; end
    l = strlen(p)
    if l==1
        return s * p^m
    end
    q = div(m,l)
    r = m - q*l
    cstring(s*p^q*p[1:chr2ind(p,r)])
end

lpad(s, n::Integer, p) = lpad(string(s), n, string(p))
rpad(s, n::Integer, p) = rpad(string(s), n, string(p))

lpad(s, n::Integer) = lpad(string(s), n, " ")
rpad(s, n::Integer) = rpad(string(s), n, " ")

function split(s::String, delims, include_empty::Bool)
    i = 1
    strs = String[]
    len = length(s)
    while true
        tokstart = tokend = i
        while !done(s,i)
            (c,i) = next(s,i)
            if contains(delims, c)
                break
            end
            tokend = i
        end
        tok = s[tokstart:(tokend-1)]
        if include_empty || !isempty(tok)
            push(strs, tok)
        end
        if !((i <= len) || (i==len+1 && tokend!=i))
            break
        end
    end
    strs
end

split(s::String) = split(s, (' ','\t','\n','\v','\f','\r'), false)
split(s::String, x) = split(s, x, true)
split(s::String, x::Char, incl::Bool) = split(s, (x,), incl)

function print_joined(strings, delim, last)
    i = start(strings)
    if done(strings,i)
        return
    end
    str, i = next(strings,i)
    print(str)
    while !done(strings,i)
        str, i = next(strings,i)
        print(done(strings,i) ? last : delim)
        print(str)
    end
end

function print_joined(strings, delim)
    i = start(strings)
    while !done(strings,i)
        str, i = next(strings,i)
        print(str)
        if !done(strings,i)
            print(delim)
        end
    end
end
print_joined(strings) = print_joined(strings, "")

join(args...) = print_to_string(print_joined, args...)

chop(s::String) = s[1:thisind(s,length(s))-1]
chomp(s::String) = (i=thisind(s,length(s)); s[i]=='\n' ? s[1:i-1] : s)
chomp(s::ByteString) = s.data[end]==0x0a ? s[1:end-1] : s

function lstrip(s::String)
    i = start(s)
    while !done(s,i)
        c, j = next(s,i)
        if !iswspace(c)
            return s[i:end]
        end
        i = j
    end
    ""
end

function rstrip(s::String)
    r = reverse(s)
    i = start(r)
    while !done(r,i)
        c, j = next(r,i)
        if !iswspace(c)
            return s[1:end-i+1]
        end
        i = j
    end
    ""
end

strip(s::String) = lstrip(rstrip(s))

## string to integer functions ##

function parse_int{T<:Integer}(::Type{T}, s::String, base::Integer)
    if !(2 <= base <= 36); error("invalid base: ",base); end
    i = start(s)
    if done(s,i)
        error("premature end of integer (in ",show_to_string(s),")")
    end
    c,i = next(s,i)
    sgn = one(T)
    if T <: Signed && c == '-'
        sgn = -sgn
        if done(s,i)
            error("premature end of integer (in ",show_to_string(s),")")
        end
        c,i = next(s,i)
    end
    base = convert(T,base)
    n::T = 0
    while true
        d = '0' <= c <= '9' ? c-'0' :
            'A' <= c <= 'Z' ? c-'A'+10 :
            'a' <= c <= 'z' ? c-'a'+10 : typemax(Int)
        if d >= base
            error(show_to_string(c)," is not a valid digit (in ",show_to_string(s),")")
        end
        # TODO: overflow detection?
        n = n*base + d
        if done(s,i)
            break
        end
        c,i = next(s,i)
    end
    return flipsign(n,sgn)
end

parse_int(s::String, base::Integer) = parse_int(Int,s,base)
parse_int(T::Type, s::String)       = parse_int(T,s,10)
parse_int(s::String)                = parse_int(Int,s,10)

parse_bin(T::Type, s::String) = parse_int(T,s,2)
parse_oct(T::Type, s::String) = parse_int(T,s,8)
parse_hex(T::Type, s::String) = parse_int(T,s,16)

parse_bin(s::String) = parse_int(Int,s,2)
parse_oct(s::String) = parse_int(Int,s,8)
parse_hex(s::String) = parse_int(Int,s,16)

integer (s::String) = int(s)
unsigned(s::String) = uint(s)
int     (s::String) = parse_int(Int,s)
uint    (s::String) = parse_int(Uint,s)
int8    (s::String) = parse_int(Int8,s)
uint8   (s::String) = parse_int(Uint8,s)
int16   (s::String) = parse_int(Int16,s)
uint16  (s::String) = parse_int(Uint16,s)
int32   (s::String) = parse_int(Int32,s)
uint32  (s::String) = parse_int(Uint32,s)
int64   (s::String) = parse_int(Int64,s)
uint64  (s::String) = parse_int(Uint64,s)

## integer to string functions ##

const _jl_dig_syms = "0123456789abcdefghijklmnopqrstuvwxyz".data

function int2str(n::Union(Int64,Uint64), b::Integer, l::Int)
    if b < 2 || b > 36; error("int2str: invalid base ", b); end
    neg = n < 0
    n = unsigned(abs(n))
    b = convert(typeof(n), b)
    ndig = ndigits(n, b)
    sz = max(convert(Int, ndig), l) + neg
    data = Array(Uint8, sz)
    i = sz
    if ispow2(b)
        digmask = b-1
        shift = trailing_zeros(b)
        while i > neg
            ch = n & digmask
            data[i] = _jl_dig_syms[int(ch)+1]
            n >>= shift
            i -= 1
        end
    else
        while i > neg
            ch = n % b
            data[i] = _jl_dig_syms[int(ch)+1]
            n = div(n,b)
            i -= 1
        end
    end
    if neg
        data[1] = '-'
    end
    ASCIIString(data)
end
int2str(n::Integer, b::Integer)         = int2str(n, b, 0)
int2str(n::Integer, b::Integer, l::Int) = int2str(int64(n), b, l)

string(x::Signed) = dec(int64(x))
cstring(x::Signed) = dec(int64(x))

## string to float functions ##

function float64_isvalid(s::String, out::Array{Float64,1})
    s = cstring(s)
    return (ccall(:jl_strtod, Int32, (Ptr{Uint8},Ptr{Float64}), s, out)==0)
end

function float32_isvalid(s::String, out::Array{Float32,1})
    s = cstring(s)
    return (ccall(:jl_strtof, Int32, (Ptr{Uint8},Ptr{Float32}), s, out)==0)
end

begin
    local tmp::Array{Float64,1} = Array(Float64,1)
    local tmpf::Array{Float32,1} = Array(Float32,1)
    global float64, float32
    function float64(s::String)
        if !float64_isvalid(s, tmp)
            throw(ArgumentError("float64(String): invalid number format"))
        end
        return tmp[1]
    end

    function float32(s::String)
        if !float32_isvalid(s, tmpf)
            throw(ArgumentError("float32(String): invalid number format"))
        end
        return tmpf[1]
    end
end

float(x::String) = float64(x)
parse_float(x::String) = float64(x)
parse_float(::Type{Float64}, x::String) = float64(x)
parse_float(::Type{Float32}, x::String) = float32(x)

# copying a byte string (generally not needed due to "immutability")

strcpy{T<:ByteString}(s::T) = T(copy(s.data))

# lexicographically compare byte arrays (used by Latin-1 and UTF-8)

function lexcmp(a::Array{Uint8,1}, b::Array{Uint8,1})
    c = ccall(:memcmp, Int32, (Ptr{Uint8}, Ptr{Uint8}, Uint),
              a, b, min(length(a),length(b)))
    c < 0 ? -1 : c > 0 ? +1 : cmp(length(a),length(b))
end

# find the index of the first occurrence of a byte value in a byte array

function memchr(a::Array{Uint8,1}, b::Integer)
    p = pointer(a)
    q = ccall(:memchr, Ptr{Uint8}, (Ptr{Uint8}, Int32, Uint), p, b, length(a))
    q == C_NULL ? 0 : q - p + 1
end

# concatenate byte arrays into a single array

memcat() = Array(Uint8,0)
memcat(a::Array{Uint8,1}) = copy(a)

function memcat(arrays::Array{Uint8,1}...)
    n = 0
    for a in arrays
        n += length(a)
    end
    arr = Array(Uint8, n)
    ptr = pointer(arr)
    offset = 0
    for a in arrays
        ccall(:memcpy, Ptr{Uint8}, (Ptr{Uint8}, Ptr{Uint8}, Uint),
              ptr+offset, a, length(a))
        offset += length(a)
    end
    return arr
end

# concatenate the data fields of byte strings

memcat(s::ByteString) = memcat(s.data)
memcat(sx::ByteString...) = memcat(map(s->s.data, sx)...)

---tokens---
'## core string functions ##' Comment
'\n'          Text

'\n'          Text

'length'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'y'           Literal.String
'o'           Literal.String
'u'           Literal.String
' '           Literal.String
'm'           Literal.String
'u'           Literal.String
's'           Literal.String
't'           Literal.String
' '           Literal.String
'i'           Literal.String
'm'           Literal.String
'p'           Literal.String
'l'           Literal.String
'e'           Literal.String
'm'           Literal.String
'e'           Literal.String
'n'           Literal.String
't'           Literal.String
' '           Literal.String
'l'           Literal.String
'e'           Literal.String
'n'           Literal.String
'g'           Literal.String
't'           Literal.String
'h'           Literal.String
'('           Literal.String
'"'           Literal.String
','           Punctuation
'typeof'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
'"'           Literal.String
')'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'y'           Literal.String
'o'           Literal.String
'u'           Literal.String
' '           Literal.String
'm'           Literal.String
'u'           Literal.String
's'           Literal.String
't'           Literal.String
' '           Literal.String
'i'           Literal.String
'm'           Literal.String
'p'           Literal.String
'l'           Literal.String
'e'           Literal.String
'm'           Literal.String
'e'           Literal.String
'n'           Literal.String
't'           Literal.String
' '           Literal.String
'n'           Literal.String
'e'           Literal.String
'x'           Literal.String
't'           Literal.String
'('           Literal.String
'"'           Literal.String
','           Punctuation
'typeof'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
'"'           Literal.String
','           Literal.String
'I'           Literal.String
'n'           Literal.String
't'           Literal.String
')'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'DirectIndexString' Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
']'           Punctuation
','           Punctuation
'i'           Name
'+'           Operator
'1'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'int'         Name
'('           Punctuation
'i'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'## generic supplied functions ##' Comment
'\n'          Text

'\n'          Text

'start'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'done'        Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
'i'           Name
' '           Text
'>'           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'isempty'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'ref'         Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'['           Punctuation
'1'           Literal.Number.Integer
']'           Punctuation
'\n'          Text

'ref'         Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'['           Punctuation
'int'         Name
'('           Punctuation
'i'           Name
')'           Punctuation
']'           Punctuation
'\n'          Text

'ref'         Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'x'           Name
'::'          Operator
'Real'        Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'['           Punctuation
'iround'      Name
'('           Punctuation
'x'           Name
')'           Punctuation
']'           Punctuation
'\n'          Text

'ref'         Name
'{'           Punctuation
'T'           Name
'<:'          Operator
'Integer'     Keyword.Type
'}'           Punctuation
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'r'           Name
'::'          Operator
'Range1'      Name
'{'           Punctuation
'T'           Name
'}'           Punctuation
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'['           Punctuation
'int'         Name
'('           Punctuation
'first'       Name
'('           Punctuation
'r'           Name
')'           Punctuation
')'           Punctuation
':'           Operator
'int'         Name
'('           Punctuation
'last'        Name
'('           Punctuation
'r'           Name
')'           Punctuation
')'           Punctuation
']'           Punctuation
'\n'          Text

'\n'          Text

'symbol'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'symbol'      Name
'('           Punctuation
'cstring'     Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'string'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'\n'          Text

'\n'          Text

'print'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'for'         Keyword
' '           Text
'c'           Name
'='           Operator
's'           Name
';'           Punctuation
' '           Text
'print'       Name
'('           Punctuation
'c'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'print'       Name
'('           Punctuation
'x'           Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'for'         Keyword
' '           Text
'i'           Name
'='           Operator
'x'           Name
';'           Punctuation
' '           Text
'print'       Name
'('           Punctuation
'i'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'println'     Name
'('           Punctuation
'args'        Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print'       Name
'('           Punctuation
'args'        Name
'.'           Operator
'.'           Operator
'.'           Operator
','           Punctuation
' '           Text
"'\\n'"       Literal.String.Char
')'           Punctuation
'\n'          Text

'\n'          Text

'show'        Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print_quoted' Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'('           Punctuation
'*'           Operator
')'           Punctuation
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'strcat'      Name
'('           Punctuation
's'           Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'('           Punctuation
'^'           Operator
')'           Punctuation
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'r'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'repeat'      Name
'('           Punctuation
's'           Name
','           Punctuation
'r'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'size'        Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
')'           Punctuation
'\n'          Text

'size'        Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'd'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'd'           Name
'=='          Operator
'1'           Literal.Number.Integer
' '           Text
'?'           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'    '        Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'i'           Literal.String
'n'           Literal.String
' '           Literal.String
's'           Literal.String
'i'           Literal.String
'z'           Literal.String
'e'           Literal.String
':'           Literal.String
' '           Literal.String
'd'           Literal.String
'i'           Literal.String
'm'           Literal.String
'e'           Literal.String
'n'           Literal.String
's'           Literal.String
'i'           Literal.String
'o'           Literal.String
'n'           Literal.String
' '           Literal.String
'"'           Literal.String
','           Punctuation
'd'           Name
','           Punctuation
'"'           Literal.String
' '           Literal.String
'o'           Literal.String
'u'           Literal.String
't'           Literal.String
' '           Literal.String
'o'           Literal.String
'f'           Literal.String
' '           Literal.String
'r'           Literal.String
'a'           Literal.String
'n'           Literal.String
'g'           Literal.String
'e'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'\n'          Text

'strlen'      Name
'('           Punctuation
's'           Name
'::'          Operator
'DirectIndexString' Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'function'    Keyword
' '           Text
'strlen'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'return'      Keyword
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'n'           Name
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'true'        Keyword.Constant
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'return'      Keyword
' '           Text
'n'           Name
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'n'           Name
' '           Text
'+='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'isvalid'     Name
'('           Punctuation
's'           Name
'::'          Operator
'DirectIndexString' Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
' '           Text
'<='          Operator
' '           Text
'i'           Name
' '           Text
'<='          Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'function'    Keyword
' '           Text
'isvalid'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'try'         Keyword
'\n'          Text

'        '    Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'true'        Keyword.Constant
'\n'          Text

'    '        Text
'catch'       Keyword
'\n'          Text

'        '    Text
'false'       Keyword.Constant
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'prevind'     Name
'('           Punctuation
's'           Name
'::'          Operator
'DirectIndexString' Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'i'           Name
'-'           Operator
'1'           Literal.Number.Integer
'\n'          Text

'thisind'     Name
'('           Punctuation
's'           Name
'::'          Operator
'DirectIndexString' Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'i'           Name
'\n'          Text

'nextind'     Name
'('           Punctuation
's'           Name
'::'          Operator
'DirectIndexString' Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'i'           Name
'+'           Operator
'1'           Literal.Number.Integer
'\n'          Text

'\n'          Text

'prevind'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'thisind'     Name
'('           Punctuation
's'           Name
','           Punctuation
'thisind'     Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'-'           Operator
'1'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'thisind'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'i'           Name
':'           Operator
'-'           Operator
'1'           Literal.Number.Integer
':'           Operator
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'isvalid'     Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'return'      Keyword
' '           Text
'j'           Name
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'return'      Keyword
' '           Text
'0'           Literal.Number.Integer
' '           Text
'# out of range' Comment
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'nextind'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'i'           Name
'+'           Operator
'1'           Literal.Number.Integer
':'           Operator
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'isvalid'     Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'return'      Keyword
' '           Text
'j'           Name
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
'+'           Operator
'1'           Literal.Number.Integer
' '           Text
'# out of range' Comment
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'ind2chr'     Name
'('           Punctuation
's'           Name
'::'          Operator
'DirectIndexString' Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'i'           Name
'\n'          Text

'chr2ind'     Name
'('           Punctuation
's'           Name
'::'          Operator
'DirectIndexString' Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'i'           Name
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'ind2chr'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
's'           Name
'['           Punctuation
'i'           Name
']'           Punctuation
' '           Text
'# throws error if invalid' Comment
'\n'          Text

'    '        Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'    '        Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'true'        Keyword.Constant
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'l'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'i'           Name
' '           Text
'<='          Operator
' '           Text
'k'           Name
'\n'          Text

'            ' Text
'return'      Keyword
' '           Text
'j'           Name
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'j'           Name
' '           Text
'+='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'l'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'chr2ind'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'i'           Name
' '           Text
'<'           Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'return'      Keyword
' '           Text
'i'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'    '        Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'true'        Keyword.Constant
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'l'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'i'           Name
' '           Text
'=='          Operator
' '           Text
'j'           Name
'\n'          Text

'            ' Text
'return'      Keyword
' '           Text
'k'           Name
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'j'           Name
' '           Text
'+='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'l'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'strchr'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'c'           Name
'::'          Operator
'Char'        Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'nextind'     Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'd'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
'd'           Name
'\n'          Text

'            ' Text
'return'      Keyword
' '           Text
'i'           Name
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'return'      Keyword
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'end'         Keyword
'\n'          Text

'strchr'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'c'           Name
'::'          Operator
'Char'        Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'strchr'      Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'c'           Name
','           Punctuation
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'contains'    Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'c'           Name
'::'          Operator
'Char'        Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
'strchr'      Name
'('           Punctuation
's'           Name
','           Punctuation
'c'           Name
')'           Punctuation
'!='          Operator
'0'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'chars'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'cx'          Name
' '           Text
'='           Operator
' '           Text
'Array'       Keyword.Type
'('           Punctuation
'Char'        Keyword.Type
','           Punctuation
'strlen'      Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'c'           Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
's'           Name
'\n'          Text

'        '    Text
'cx'          Name
'['           Punctuation
'i'           Name
' '           Text
'+='          Operator
' '           Text
'1'           Literal.Number.Integer
']'           Punctuation
' '           Text
'='           Operator
' '           Text
'c'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'return'      Keyword
' '           Text
'cx'          Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'cmp'         Name
'('           Punctuation
'a'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
'a'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
'b'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
'a'           Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'&&'          Operator
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
'b'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
'a'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'd'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
'b'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'c'           Name
' '           Text
'!='          Operator
' '           Text
'd'           Name
'\n'          Text

'            ' Text
'return'      Keyword
' '           Text
'c'           Name
' '           Text
'<'           Operator
' '           Text
'd'           Name
' '           Text
'?'           Operator
' '           Text
'-'           Operator
'1'           Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'+'           Operator
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'done'        Name
'('           Punctuation
'a'           Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'&&'          Operator
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
'b'           Name
','           Punctuation
'j'           Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
'-'           Operator
'1'           Literal.Number.Integer
' '           Text
':'           Operator
'\n'          Text

'    '        Text
'!'           Operator
'done'        Name
'('           Punctuation
'a'           Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'&&'          Operator
' '           Text
'done'        Name
'('           Punctuation
'b'           Name
','           Punctuation
'j'           Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
'+'           Operator
'1'           Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'isequal'     Name
'('           Punctuation
'a'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'cmp'         Name
'('           Punctuation
'a'           Name
','           Punctuation
'b'           Name
')'           Punctuation
' '           Text
'=='          Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'isless'      Name
'('           Punctuation
'a'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'  '          Text
'='           Operator
' '           Text
'cmp'         Name
'('           Punctuation
'a'           Name
','           Punctuation
'b'           Name
')'           Punctuation
' '           Text
'<'           Operator
'  '          Text
'0'           Literal.Number.Integer
'\n'          Text

'\n'          Text

'# faster comparisons for byte strings' Comment
'\n'          Text

'\n'          Text

'cmp'         Name
'('           Punctuation
'a'           Name
'::'          Operator
'ByteString'  Name
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
'     '       Text
'='           Operator
' '           Text
'lexcmp'      Name
'('           Punctuation
'a'           Name
'.'           Operator
'data'        Name
','           Punctuation
' '           Text
'b'           Name
'.'           Operator
'data'        Name
')'           Punctuation
'\n'          Text

'isequal'     Name
'('           Punctuation
'a'           Name
'::'          Operator
'ByteString'  Name
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
'a'           Name
')'           Punctuation
'=='          Operator
'length'      Name
'('           Punctuation
'b'           Name
')'           Punctuation
' '           Text
'&&'          Operator
' '           Text
'cmp'         Name
'('           Punctuation
'a'           Name
','           Punctuation
'b'           Name
')'           Punctuation
'=='          Operator
'0'           Literal.Number.Integer
'\n'          Text

'\n'          Text

'## character column width function ##' Comment
'\n'          Text

'\n'          Text

'charwidth'   Name
'('           Punctuation
'c'           Name
'::'          Operator
'Char'        Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'max'         Name
'('           Punctuation
'0'           Literal.Number.Integer
','           Punctuation
'int'         Name
'('           Punctuation
'ccall'       Keyword
'('           Punctuation
':'           Operator
'wcwidth'     Name
','           Punctuation
' '           Text
'Int32'       Keyword.Type
','           Punctuation
' '           Text
'('           Punctuation
'Char'        Keyword.Type
','           Punctuation
')'           Punctuation
','           Punctuation
' '           Text
'c'           Name
')'           Punctuation
')'           Punctuation
')'           Punctuation
'\n'          Text

'strwidth'    Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
'w'           Name
'='           Operator
'0'           Literal.Number.Integer
';'           Punctuation
' '           Text
'for'         Keyword
' '           Text
'c'           Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
's'           Name
';'           Punctuation
' '           Text
'w'           Name
' '           Text
'+='          Operator
' '           Text
'charwidth'   Name
'('           Punctuation
'c'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
';'           Punctuation
' '           Text
'w'           Name
')'           Punctuation
'\n'          Text

'strwidth'    Name
'('           Punctuation
's'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'ccall'       Keyword
'('           Punctuation
':'           Operator
'u8_strwidth' Name
','           Punctuation
' '           Text
'Int'         Keyword.Type
','           Punctuation
' '           Text
'('           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
')'           Punctuation
','           Punctuation
' '           Text
's'           Name
'.'           Operator
'data'        Name
')'           Punctuation
'\n'          Text

'# TODO: implement and use u8_strnwidth that takes a length argument' Comment
'\n'          Text

'\n'          Text

'## generic string uses only length and next ##' Comment
'\n'          Text

'\n'          Text

'type'        Keyword
' '           Text
'GenericString' Name
' '           Text
'<:'          Operator
' '           Text
'String'      Name
'\n'          Text

'    '        Text
'string'      Name
'::'          Operator
'String'      Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'length'      Name
'('           Punctuation
's'           Name
'::'          Operator
'GenericString' Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
')'           Punctuation
'\n'          Text

'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'GenericString' Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
','           Punctuation
' '           Text
'i'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'## plain old character arrays ##' Comment
'\n'          Text

'\n'          Text

'type'        Keyword
' '           Text
'CharString'  Name
' '           Text
'<:'          Operator
' '           Text
'String'      Name
'\n'          Text

'    '        Text
'chars'       Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Char'        Keyword.Type
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
'\n'          Text

'\n'          Text

'    '        Text
'CharString'  Name
'('           Punctuation
'a'           Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Char'        Keyword.Type
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'new'         Name
'('           Punctuation
'a'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'CharString'  Name
'('           Punctuation
'c'           Name
'::'          Operator
'Char'        Keyword.Type
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'new'         Name
'('           Punctuation
'['           Punctuation
' '           Text
'c'           Name
'['           Punctuation
'i'           Name
']'           Punctuation
' '           Text
'|'           Operator
' '           Text
'i'           Name
'='           Operator
'1'           Literal.Number.Integer
':'           Operator
'length'      Name
'('           Punctuation
'c'           Name
')'           Punctuation
' '           Text
']'           Punctuation
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'CharString'  Name
'('           Punctuation
'x'           Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'CharString'  Name
'('           Punctuation
'map'         Name
'('           Punctuation
'char'        Name
','           Punctuation
'x'           Name
')'           Punctuation
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'\n'          Text

'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'CharString'  Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
's'           Name
'.'           Operator
'chars'       Name
'['           Punctuation
'i'           Name
']'           Punctuation
','           Punctuation
' '           Text
'i'           Name
'+'           Operator
'1'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'length'      Name
'('           Punctuation
's'           Name
'::'          Operator
'CharString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
'.'           Operator
'chars'       Name
')'           Punctuation
'\n'          Text

'strlen'      Name
'('           Punctuation
's'           Name
'::'          Operator
'CharString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'string'      Name
'('           Punctuation
'c'           Name
'::'          Operator
'Char'        Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'CharString'  Name
'('           Punctuation
'c'           Name
')'           Punctuation
'\n'          Text

'string'      Name
'('           Punctuation
'c'           Name
'::'          Operator
'Char'        Keyword.Type
','           Punctuation
' '           Text
'x'           Name
'::'          Operator
'Char'        Keyword.Type
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'CharString'  Name
'('           Punctuation
'c'           Name
','           Punctuation
' '           Text
'x'           Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'\n'          Text

'## substrings reference original strings ##' Comment
'\n'          Text

'\n'          Text

'type'        Keyword
' '           Text
'SubString'   Keyword.Type
' '           Text
'<:'          Operator
' '           Text
'String'      Name
'\n'          Text

'    '        Text
'string'      Name
'::'          Operator
'String'      Name
'\n'          Text

'    '        Text
'offset'      Name
'::'          Operator
'Int'         Keyword.Type
'\n'          Text

'    '        Text
'length'      Name
'::'          Operator
'Int'         Keyword.Type
'\n'          Text

'\n'          Text

'    '        Text
'SubString'   Keyword.Type
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
','           Punctuation
' '           Text
'j'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'new'         Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'i'           Name
'-'           Operator
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'j'           Name
'-'           Operator
'i'           Name
'+'           Operator
'1'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'    '        Text
'SubString'   Keyword.Type
'('           Punctuation
's'           Name
'::'          Operator
'SubString'   Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
','           Punctuation
' '           Text
'j'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'        '    Text
'new'         Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
','           Punctuation
' '           Text
'i'           Name
'-'           Operator
'1'           Literal.Number.Integer
'+'           Operator
's'           Name
'.'           Operator
'offset'      Name
','           Punctuation
' '           Text
'j'           Name
'-'           Operator
'i'           Name
'+'           Operator
'1'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'SubString'   Keyword.Type
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Integer'     Keyword.Type
','           Punctuation
' '           Text
'j'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'SubString'   Keyword.Type
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'int'         Name
'('           Punctuation
'i'           Name
')'           Punctuation
','           Punctuation
' '           Text
'int'         Name
'('           Punctuation
'j'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'SubString'   Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'i'           Name
' '           Text
'<'           Operator
' '           Text
'1'           Literal.Number.Integer
' '           Text
'||'          Operator
' '           Text
'i'           Name
' '           Text
'>'           Operator
' '           Text
's'           Name
'.'           Operator
'length'      Name
'\n'          Text

'        '    Text
'error'       Name
'('           Punctuation
'"'           Literal.String
's'           Literal.String
't'           Literal.String
'r'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
' '           Literal.String
'i'           Literal.String
'n'           Literal.String
'd'           Literal.String
'e'           Literal.String
'x'           Literal.String
' '           Literal.String
'o'           Literal.String
'u'           Literal.String
't'           Literal.String
' '           Literal.String
'o'           Literal.String
'f'           Literal.String
' '           Literal.String
'b'           Literal.String
'o'           Literal.String
'u'           Literal.String
'n'           Literal.String
'd'           Literal.String
's'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'c'           Name
','           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
','           Punctuation
' '           Text
'i'           Name
'+'           Operator
's'           Name
'.'           Operator
'offset'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'c'           Name
','           Punctuation
' '           Text
'i'           Name
'-'           Operator
's'           Name
'.'           Operator
'offset'      Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'length'      Name
'('           Punctuation
's'           Name
'::'          Operator
'SubString'   Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'.'           Operator
'length'      Name
'\n'          Text

'# TODO: strlen(s::SubString) = ??' Comment
'\n'          Text

"# default implementation will work but it's slow" Comment
'\n'          Text

'# can this be delegated efficiently somehow?' Comment
'\n'          Text

'# that may require additional string interfaces' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'ref'         Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'r'           Name
'::'          Operator
'Range1'      Name
'{'           Punctuation
'Int'         Keyword.Type
'}'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'first'       Name
'('           Punctuation
'r'           Name
')'           Punctuation
' '           Text
'<'           Operator
' '           Text
'1'           Literal.Number.Integer
' '           Text
'||'          Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
' '           Text
'<'           Operator
' '           Text
'last'        Name
'('           Punctuation
'r'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'i'           Literal.String
'n'           Literal.String
' '           Literal.String
's'           Literal.String
'u'           Literal.String
'b'           Literal.String
's'           Literal.String
't'           Literal.String
'r'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
' '           Literal.String
's'           Literal.String
'l'           Literal.String
'i'           Literal.String
'c'           Literal.String
'e'           Literal.String
':'           Literal.String
' '           Literal.String
'i'           Literal.String
'n'           Literal.String
'd'           Literal.String
'e'           Literal.String
'x'           Literal.String
' '           Literal.String
'o'           Literal.String
'u'           Literal.String
't'           Literal.String
' '           Literal.String
'o'           Literal.String
'f'           Literal.String
' '           Literal.String
'r'           Literal.String
'a'           Literal.String
'n'           Literal.String
'g'           Literal.String
'e'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'SubString'   Keyword.Type
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'first'       Name
'('           Punctuation
'r'           Name
')'           Punctuation
','           Punctuation
' '           Text
'last'        Name
'('           Punctuation
'r'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'## efficient representation of repeated strings ##' Comment
'\n'          Text

'\n'          Text

'type'        Keyword
' '           Text
'RepString'   Keyword.Type
' '           Text
'<:'          Operator
' '           Text
'String'      Name
'\n'          Text

'    '        Text
'string'      Name
'::'          Operator
'String'      Name
'\n'          Text

'    '        Text
'repeat'      Name
'::'          Operator
'Integer'     Keyword.Type
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'length'      Name
'('           Punctuation
's'           Name
'::'          Operator
'RepString'   Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
')'           Punctuation
'*'           Operator
's'           Name
'.'           Operator
'repeat'      Name
'\n'          Text

'strlen'      Name
'('           Punctuation
's'           Name
'::'          Operator
'RepString'   Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'strlen'      Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
')'           Punctuation
'*'           Operator
's'           Name
'.'           Operator
'repeat'      Name
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'RepString'   Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'i'           Name
' '           Text
'<'           Operator
' '           Text
'1'           Literal.Number.Integer
' '           Text
'||'          Operator
' '           Text
'i'           Name
' '           Text
'>'           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'error'       Name
'('           Punctuation
'"'           Literal.String
's'           Literal.String
't'           Literal.String
'r'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
' '           Literal.String
'i'           Literal.String
'n'           Literal.String
'd'           Literal.String
'e'           Literal.String
'x'           Literal.String
' '           Literal.String
'o'           Literal.String
'u'           Literal.String
't'           Literal.String
' '           Literal.String
'o'           Literal.String
'f'           Literal.String
' '           Literal.String
'b'           Literal.String
'o'           Literal.String
'u'           Literal.String
'n'           Literal.String
'd'           Literal.String
's'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'mod1'        Name
'('           Punctuation
'i'           Name
','           Punctuation
'length'      Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'c'           Name
','           Punctuation
' '           Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
','           Punctuation
' '           Text
'j'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'c'           Name
','           Punctuation
' '           Text
'k'           Name
'-'           Operator
'j'           Name
'+'           Operator
'i'           Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'repeat'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'r'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'r'           Name
' '           Text
'<'           Operator
'  '          Text
'0'           Literal.Number.Integer
' '           Text
'?'           Operator
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'c'           Literal.String
'a'           Literal.String
'n'           Literal.String
"'"           Literal.String
't'           Literal.String
' '           Literal.String
'r'           Literal.String
'e'           Literal.String
'p'           Literal.String
'e'           Literal.String
'a'           Literal.String
't'           Literal.String
' '           Literal.String
'a'           Literal.String
' '           Literal.String
's'           Literal.String
't'           Literal.String
'r'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
' '           Literal.String
'"'           Literal.String
','           Punctuation
'r'           Name
','           Punctuation
'"'           Literal.String
' '           Literal.String
't'           Literal.String
'i'           Literal.String
'm'           Literal.String
'e'           Literal.String
's'           Literal.String
'"'           Literal.String
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'    '        Text
'r'           Name
' '           Text
'=='          Operator
' '           Text
'0'           Literal.Number.Integer
' '           Text
'?'           Operator
' '           Text
'"'           Literal.String
'"'           Literal.String
' '           Text
':'           Operator
'\n'          Text

'    '        Text
'r'           Name
' '           Text
'=='          Operator
' '           Text
'1'           Literal.Number.Integer
' '           Text
'?'           Operator
' '           Text
's'           Name
'  '          Text
':'           Operator
'\n'          Text

'    '        Text
'RepString'   Keyword.Type
'('           Punctuation
's'           Name
','           Punctuation
'r'           Name
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'## reversed strings without data movement ##' Comment
'\n'          Text

'\n'          Text

'type'        Keyword
' '           Text
'RevString'   Keyword.Type
' '           Text
'<:'          Operator
' '           Text
'String'      Name
'\n'          Text

'    '        Text
'string'      Name
'::'          Operator
'String'      Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'length'      Name
'('           Punctuation
's'           Name
'::'          Operator
'RevString'   Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
')'           Punctuation
'\n'          Text

'strlen'      Name
'('           Punctuation
's'           Name
'::'          Operator
'RevString'   Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'strlen'      Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
')'           Punctuation
'\n'          Text

'\n'          Text

'start'       Name
'('           Punctuation
's'           Name
'::'          Operator
'RevString'   Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
'n'           Name
'='           Operator
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'n'           Name
'-'           Operator
'thisind'     Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
','           Punctuation
'n'           Name
')'           Punctuation
'+'           Operator
'1'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'function'    Keyword
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'RevString'   Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'n'           Name
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'n'           Name
'-'           Operator
'i'           Name
'+'           Operator
'1'           Literal.Number.Integer
'\n'          Text

'    '        Text
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
'['           Punctuation
'j'           Name
']'           Punctuation
','           Punctuation
' '           Text
'n'           Name
'-'           Operator
'thisind'     Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
','           Punctuation
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
')'           Punctuation
'+'           Operator
'1'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'reverse'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'RevString'   Keyword.Type
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'reverse'     Name
'('           Punctuation
's'           Name
'::'          Operator
'RevString'   Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'.'           Operator
'string'      Name
'\n'          Text

'\n'          Text

'## ropes for efficient concatenation, etc. ##' Comment
'\n'          Text

'\n'          Text

'# Idea: instead of this standard binary tree structure,' Comment
'\n'          Text

'# how about we keep an array of substrings, with an' Comment
'\n'          Text

'# offset array. We can do binary search on the offset' Comment
'\n'          Text

'# array so we get O(log(n)) indexing time still, but we' Comment
'\n'          Text

'# can compute the offsets lazily and avoid all the' Comment
'\n'          Text

'# futzing around while the string is being constructed.' Comment
'\n'          Text

'\n'          Text

'type'        Keyword
' '           Text
'RopeString'  Keyword.Type
' '           Text
'<:'          Operator
' '           Text
'String'      Name
'\n'          Text

'    '        Text
'head'        Name
'::'          Operator
'String'      Name
'\n'          Text

'    '        Text
'tail'        Name
'::'          Operator
'String'      Name
'\n'          Text

'    '        Text
'depth'       Name
'::'          Operator
'Int32'       Keyword.Type
'\n'          Text

'    '        Text
'length'      Name
'::'          Operator
'Int'         Keyword.Type
'\n'          Text

'\n'          Text

'    '        Text
'RopeString'  Keyword.Type
'('           Punctuation
'h'           Name
'::'          Operator
'RopeString'  Keyword.Type
','           Punctuation
' '           Text
't'           Name
'::'          Operator
'RopeString'  Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'        '    Text
'depth'       Name
'('           Punctuation
'h'           Name
'.'           Operator
'tail'        Name
')'           Punctuation
' '           Text
'+'           Operator
' '           Text
'depth'       Name
'('           Punctuation
't'           Name
')'           Punctuation
' '           Text
'<'           Operator
' '           Text
'depth'       Name
'('           Punctuation
'h'           Name
'.'           Operator
'head'        Name
')'           Punctuation
' '           Text
'?'           Operator
'\n'          Text

'            ' Text
'RopeString'  Keyword.Type
'('           Punctuation
'h'           Name
'.'           Operator
'head'        Name
','           Punctuation
' '           Text
'RopeString'  Keyword.Type
'('           Punctuation
'h'           Name
'.'           Operator
'tail'        Name
','           Punctuation
' '           Text
't'           Name
')'           Punctuation
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'            ' Text
'new'         Name
'('           Punctuation
'h'           Name
','           Punctuation
' '           Text
't'           Name
','           Punctuation
' '           Text
'max'         Name
'('           Punctuation
'h'           Name
'.'           Operator
'depth'       Name
','           Punctuation
't'           Name
'.'           Operator
'depth'       Name
')'           Punctuation
'+'           Operator
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'length'      Name
'('           Punctuation
'h'           Name
')'           Punctuation
'+'           Operator
'length'      Name
'('           Punctuation
't'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'    '        Text
'RopeString'  Keyword.Type
'('           Punctuation
'h'           Name
'::'          Operator
'RopeString'  Keyword.Type
','           Punctuation
' '           Text
't'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'        '    Text
'depth'       Name
'('           Punctuation
'h'           Name
'.'           Operator
'tail'        Name
')'           Punctuation
' '           Text
'<'           Operator
' '           Text
'depth'       Name
'('           Punctuation
'h'           Name
'.'           Operator
'head'        Name
')'           Punctuation
' '           Text
'?'           Operator
'\n'          Text

'            ' Text
'RopeString'  Keyword.Type
'('           Punctuation
'h'           Name
'.'           Operator
'head'        Name
','           Punctuation
' '           Text
'RopeString'  Keyword.Type
'('           Punctuation
'h'           Name
'.'           Operator
'tail'        Name
','           Punctuation
' '           Text
't'           Name
')'           Punctuation
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'            ' Text
'new'         Name
'('           Punctuation
'h'           Name
','           Punctuation
' '           Text
't'           Name
','           Punctuation
' '           Text
'h'           Name
'.'           Operator
'depth'       Name
'+'           Operator
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'length'      Name
'('           Punctuation
'h'           Name
')'           Punctuation
'+'           Operator
'length'      Name
'('           Punctuation
't'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'    '        Text
'RopeString'  Keyword.Type
'('           Punctuation
'h'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
't'           Name
'::'          Operator
'RopeString'  Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'        '    Text
'depth'       Name
'('           Punctuation
't'           Name
'.'           Operator
'head'        Name
')'           Punctuation
' '           Text
'<'           Operator
' '           Text
'depth'       Name
'('           Punctuation
't'           Name
'.'           Operator
'tail'        Name
')'           Punctuation
' '           Text
'?'           Operator
'\n'          Text

'            ' Text
'RopeString'  Keyword.Type
'('           Punctuation
'RopeString'  Keyword.Type
'('           Punctuation
'h'           Name
','           Punctuation
' '           Text
't'           Name
'.'           Operator
'head'        Name
')'           Punctuation
','           Punctuation
' '           Text
't'           Name
'.'           Operator
'tail'        Name
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'            ' Text
'new'         Name
'('           Punctuation
'h'           Name
','           Punctuation
' '           Text
't'           Name
','           Punctuation
' '           Text
't'           Name
'.'           Operator
'depth'       Name
'+'           Operator
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'length'      Name
'('           Punctuation
'h'           Name
')'           Punctuation
'+'           Operator
'length'      Name
'('           Punctuation
't'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'    '        Text
'RopeString'  Keyword.Type
'('           Punctuation
'h'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
't'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'        '    Text
'new'         Name
'('           Punctuation
'h'           Name
','           Punctuation
' '           Text
't'           Name
','           Punctuation
' '           Text
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'length'      Name
'('           Punctuation
'h'           Name
')'           Punctuation
'+'           Operator
'length'      Name
'('           Punctuation
't'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'depth'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'depth'       Name
'('           Punctuation
's'           Name
'::'          Operator
'RopeString'  Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'.'           Operator
'depth'       Name
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'RopeString'  Keyword.Type
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'i'           Name
' '           Text
'<='          Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
'.'           Operator
'head'        Name
')'           Punctuation
'\n'          Text

'        '    Text
'return'      Keyword
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'.'           Operator
'head'        Name
','           Punctuation
' '           Text
'i'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'else'        Keyword
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'.'           Operator
'tail'        Name
','           Punctuation
' '           Text
'i'           Name
'-'           Operator
'length'      Name
'('           Punctuation
's'           Name
'.'           Operator
'head'        Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'        '    Text
'return'      Keyword
' '           Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
'+'           Operator
'length'      Name
'('           Punctuation
's'           Name
'.'           Operator
'head'        Name
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'length'      Name
'('           Punctuation
's'           Name
'::'          Operator
'RopeString'  Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'.'           Operator
'length'      Name
'\n'          Text

'strlen'      Name
'('           Punctuation
's'           Name
'::'          Operator
'RopeString'  Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'strlen'      Name
'('           Punctuation
's'           Name
'.'           Operator
'head'        Name
')'           Punctuation
' '           Text
'+'           Operator
' '           Text
'strlen'      Name
'('           Punctuation
's'           Name
'.'           Operator
'tail'        Name
')'           Punctuation
'\n'          Text

'\n'          Text

'strcat'      Name
'('           Punctuation
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'"'           Literal.String
'"'           Literal.String
'\n'          Text

'strcat'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'\n'          Text

'strcat'      Name
'('           Punctuation
'x'           Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'strcat'      Name
'('           Punctuation
'map'         Name
'('           Punctuation
'string'      Name
','           Punctuation
'x'           Name
')'           Punctuation
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'strcat'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
't'           Name
'::'          Operator
'String'      Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'    '        Text
'('           Punctuation
't'           Name
' '           Text
'='           Operator
' '           Text
'strcat'      Name
'('           Punctuation
't'           Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
';'           Punctuation
' '           Text
'isempty'     Name
'('           Punctuation
's'           Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
't'           Name
' '           Text
':'           Operator
' '           Text
'isempty'     Name
'('           Punctuation
't'           Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
's'           Name
' '           Text
':'           Operator
' '           Text
'RopeString'  Keyword.Type
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
't'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'print'       Name
'('           Punctuation
's'           Name
'::'          Operator
'RopeString'  Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print'       Name
'('           Punctuation
's'           Name
'.'           Operator
'head'        Name
','           Punctuation
' '           Text
's'           Name
'.'           Operator
'tail'        Name
')'           Punctuation
'\n'          Text

'\n'          Text

'## transformed strings ##' Comment
'\n'          Text

'\n'          Text

'type'        Keyword
' '           Text
'TransformedString' Name
' '           Text
'<:'          Operator
' '           Text
'String'      Name
'\n'          Text

'    '        Text
'transform'   Name
'::'          Operator
'Function'    Keyword.Type
'\n'          Text

'    '        Text
'string'      Name
'::'          Operator
'String'      Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'length'      Name
'('           Punctuation
's'           Name
'::'          Operator
'TransformedString' Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
')'           Punctuation
'\n'          Text

'strlen'      Name
'('           Punctuation
's'           Name
'::'          Operator
'TransformedString' Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'strlen'      Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'::'          Operator
'TransformedString' Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
'.'           Operator
'string'      Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'c'           Name
' '           Text
'='           Operator
' '           Text
's'           Name
'.'           Operator
'transform'   Name
'('           Punctuation
'c'           Name
','           Punctuation
' '           Text
'i'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'return'      Keyword
' '           Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'## uppercase and lowercase transformations ##' Comment
'\n'          Text

'\n'          Text

'uppercase'   Name
'('           Punctuation
'c'           Name
'::'          Operator
'Char'        Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'ccall'       Keyword
'('           Punctuation
':'           Operator
'towupper'    Name
','           Punctuation
' '           Text
'Char'        Keyword.Type
','           Punctuation
' '           Text
'('           Punctuation
'Char'        Keyword.Type
','           Punctuation
')'           Punctuation
','           Punctuation
' '           Text
'c'           Name
')'           Punctuation
'\n'          Text

'lowercase'   Name
'('           Punctuation
'c'           Name
'::'          Operator
'Char'        Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'ccall'       Keyword
'('           Punctuation
':'           Operator
'towlower'    Name
','           Punctuation
' '           Text
'Char'        Keyword.Type
','           Punctuation
' '           Text
'('           Punctuation
'Char'        Keyword.Type
','           Punctuation
')'           Punctuation
','           Punctuation
' '           Text
'c'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'uppercase'   Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'TransformedString' Name
'('           Punctuation
'('           Punctuation
'c'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'-'           Operator
'>'           Operator
'uppercase'   Name
'('           Punctuation
'c'           Name
')'           Punctuation
','           Punctuation
' '           Text
's'           Name
')'           Punctuation
'\n'          Text

'lowercase'   Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'TransformedString' Name
'('           Punctuation
'('           Punctuation
'c'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'-'           Operator
'>'           Operator
'lowercase'   Name
'('           Punctuation
'c'           Name
')'           Punctuation
','           Punctuation
' '           Text
's'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'ucfirst'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'TransformedString' Name
'('           Punctuation
'('           Punctuation
'c'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'-'           Operator
'>'           Operator
'i'           Name
'=='          Operator
'1'           Literal.Number.Integer
' '           Text
'?'           Operator
' '           Text
'uppercase'   Name
'('           Punctuation
'c'           Name
')'           Punctuation
' '           Text
':'           Operator
' '           Text
'c'           Name
','           Punctuation
' '           Text
's'           Name
')'           Punctuation
'\n'          Text

'lcfirst'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'TransformedString' Name
'('           Punctuation
'('           Punctuation
'c'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'-'           Operator
'>'           Operator
'i'           Name
'=='          Operator
'1'           Literal.Number.Integer
' '           Text
'?'           Operator
' '           Text
'lowercase'   Name
'('           Punctuation
'c'           Name
')'           Punctuation
' '           Text
':'           Operator
' '           Text
'c'           Name
','           Punctuation
' '           Text
's'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'const'       Keyword.Declaration
' '           Text
'uc'          Name
' '           Text
'='           Operator
' '           Text
'uppercase'   Name
'\n'          Text

'const'       Keyword.Declaration
' '           Text
'lc'          Name
' '           Text
'='           Operator
' '           Text
'lowercase'   Name
'\n'          Text

'\n'          Text

'## string map ##' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'map'         Name
'('           Punctuation
'f'           Name
'::'          Operator
'Function'    Keyword.Type
','           Punctuation
' '           Text
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'out'         Name
' '           Text
'='           Operator
' '           Text
'memio'       Name
'('           Punctuation
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'c'           Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
's'           Name
'\n'          Text

'        '    Text
'write'       Name
'('           Punctuation
'out'         Name
','           Punctuation
' '           Text
'f'           Name
'('           Punctuation
'c'           Name
')'           Punctuation
'::'          Operator
'Char'        Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'takebuf_string' Name
'('           Punctuation
'out'         Name
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'## conversion of general objects to strings ##' Comment
'\n'          Text

'\n'          Text

'string'      Name
'('           Punctuation
'x'           Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print_to_string' Name
'('           Punctuation
'show'        Name
','           Punctuation
' '           Text
'x'           Name
')'           Punctuation
'\n'          Text

'cstring'     Name
'('           Punctuation
'x'           Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print_to_string' Name
'('           Punctuation
'print'       Name
','           Punctuation
' '           Text
'x'           Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'cstring'     Name
'('           Punctuation
'p'           Name
'::'          Operator
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'p'           Name
' '           Text
'=='          Operator
' '           Text
'C_NULL'      Name.Builtin
' '           Text
'?'           Operator
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'c'           Literal.String
'a'           Literal.String
'n'           Literal.String
'n'           Literal.String
'o'           Literal.String
't'           Literal.String
' '           Literal.String
'c'           Literal.String
'o'           Literal.String
'n'           Literal.String
'v'           Literal.String
'e'           Literal.String
'r'           Literal.String
't'           Literal.String
' '           Literal.String
'N'           Literal.String
'U'           Literal.String
'L'           Literal.String
'L'           Literal.String
' '           Literal.String
't'           Literal.String
'o'           Literal.String
' '           Literal.String
's'           Literal.String
't'           Literal.String
'r'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
'"'           Literal.String
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'    '        Text
'ccall'       Keyword
'('           Punctuation
':'           Operator
'jl_cstr_to_string' Name
','           Punctuation
' '           Text
'Any'         Keyword.Type
','           Punctuation
' '           Text
'('           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
')'           Punctuation
','           Punctuation
' '           Text
'p'           Name
')'           Punctuation
'::'          Operator
'ByteString'  Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'## string promotion rules ##' Comment
'\n'          Text

'\n'          Text

'promote_rule' Name
'('           Punctuation
'::'          Operator
'Type'        Keyword.Type
'{'           Punctuation
'UTF8String'  Keyword.Type
'}'           Punctuation
' '           Text
','           Punctuation
' '           Text
'::'          Operator
'Type'        Keyword.Type
'{'           Punctuation
'ASCIIString' Keyword.Type
'}'           Punctuation
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'UTF8String'  Keyword.Type
'\n'          Text

'promote_rule' Name
'('           Punctuation
'::'          Operator
'Type'        Keyword.Type
'{'           Punctuation
'UTF8String'  Keyword.Type
'}'           Punctuation
' '           Text
','           Punctuation
' '           Text
'::'          Operator
'Type'        Keyword.Type
'{'           Punctuation
'CharString'  Name
'}'           Punctuation
' '           Text
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'UTF8String'  Keyword.Type
'\n'          Text

'promote_rule' Name
'('           Punctuation
'::'          Operator
'Type'        Keyword.Type
'{'           Punctuation
'ASCIIString' Keyword.Type
'}'           Punctuation
','           Punctuation
' '           Text
'::'          Operator
'Type'        Keyword.Type
'{'           Punctuation
'CharString'  Name
'}'           Punctuation
' '           Text
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'UTF8String'  Keyword.Type
'\n'          Text

'\n'          Text

'## printing literal quoted string data ##' Comment
'\n'          Text

'\n'          Text

'# TODO: this is really the inverse of print_unbackslashed' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'print_quoted_literal' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'print'       Name
'('           Punctuation
'\'"\''       Literal.String.Char
')'           Punctuation
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'c'           Name
' '           Text
'='           Operator
' '           Text
's'           Name
';'           Punctuation
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
'\'"\''       Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'print'       Name
'('           Punctuation
'"'           Literal.String
'\\\\'        Literal.String.Escape
'\\"'         Literal.String.Escape
'"'           Literal.String
')'           Punctuation
' '           Text
':'           Operator
' '           Text
'print'       Name
'('           Punctuation
'c'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'    '        Text
'print'       Name
'('           Punctuation
'\'"\''       Literal.String.Char
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'## string escaping & unescaping ##' Comment
'\n'          Text

'\n'          Text

'escape_nul'  Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'    '        Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'&&'          Operator
' '           Text
"'0'"         Literal.String.Char
' '           Text
'<='          Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'['           Punctuation
'1'           Literal.Number.Integer
']'           Punctuation
' '           Text
'<='          Operator
' '           Text
"'7'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'L'           Name
'"'           Literal.String
'\\x00'       Literal.String.Escape
'"'           Literal.String
' '           Text
':'           Operator
' '           Text
'L'           Name
'"'           Literal.String
'\\0'         Literal.String.Escape
'"'           Literal.String
'\n'          Text

'\n'          Text

'is_hex_digit' Name
'('           Punctuation
'c'           Name
'::'          Operator
'Char'        Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
"'0'"         Literal.String.Char
'<='          Operator
'c'           Name
'<='          Operator
"'9'"         Literal.String.Char
' '           Text
'||'          Operator
' '           Text
"'a'"         Literal.String.Char
'<='          Operator
'c'           Name
'<='          Operator
"'f'"         Literal.String.Char
' '           Text
'||'          Operator
' '           Text
"'A'"         Literal.String.Char
'<='          Operator
'c'           Name
'<='          Operator
"'F'"         Literal.String.Char
'\n'          Text

'need_full_hex' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'i'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'&&'          Operator
' '           Text
'is_hex_digit' Name
'('           Punctuation
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'['           Punctuation
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'print_escaped' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'esc'         Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'\\0'"       Literal.String.Char
'       '     Text
'?'           Operator
' '           Text
'print'       Name
'('           Punctuation
'escape_nul'  Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'        '    Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'\\e'"       Literal.String.Char
'       '     Text
'?'           Operator
' '           Text
'print'       Name
'('           Punctuation
'L'           Name
'"'           Literal.String
'\\'          Literal.String
'e'           Literal.String
'"'           Literal.String
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'        '    Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'\\\\'"      Literal.String.Char
'       '     Text
'?'           Operator
' '           Text
'print'       Name
'('           Punctuation
'"'           Literal.String
'\\\\'        Literal.String.Escape
'\\\\'        Literal.String.Escape
'"'           Literal.String
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'        '    Text
'contains'    Name
'('           Punctuation
'esc'         Name
','           Punctuation
'c'           Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
'print'       Name
'('           Punctuation
"'\\\\'"      Literal.String.Char
','           Punctuation
' '           Text
'c'           Name
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'        '    Text
'iswprint'    Name
'('           Punctuation
'c'           Name
')'           Punctuation
'     '       Text
'?'           Operator
' '           Text
'print'       Name
'('           Punctuation
'c'           Name
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'        '    Text
'7'           Literal.Number.Integer
' '           Text
'<='          Operator
' '           Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
'13'          Literal.Number.Integer
'    '        Text
'?'           Operator
' '           Text
'print'       Name
'('           Punctuation
"'\\\\'"      Literal.String.Char
','           Punctuation
' '           Text
'"'           Literal.String
'a'           Literal.String
'b'           Literal.String
't'           Literal.String
'n'           Literal.String
'v'           Literal.String
'f'           Literal.String
'r'           Literal.String
'"'           Literal.String
'['           Punctuation
'c'           Name
'-'           Operator
'6'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'        '    Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'\\x7f'"     Literal.String.Char
'     '       Text
'?'           Operator
' '           Text
'print'       Name
'('           Punctuation
'L'           Name
'"'           Literal.String
'\\'          Literal.String
'x'           Literal.String
'"'           Literal.String
','           Punctuation
' '           Text
'hex'         Name
'('           Punctuation
'c'           Name
','           Punctuation
' '           Text
'2'           Literal.Number.Integer
')'           Punctuation
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'        '    Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'\\uffff'"   Literal.String.Char
'   '         Text
'?'           Operator
' '           Text
'print'       Name
'('           Punctuation
'L'           Name
'"'           Literal.String
'\\'          Literal.String
'u'           Literal.String
'"'           Literal.String
','           Punctuation
' '           Text
'hex'         Name
'('           Punctuation
'c'           Name
','           Punctuation
' '           Text
'need_full_hex' Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
'4'           Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'2'           Literal.Number.Integer
')'           Punctuation
')'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'                          ' Text
'print'       Name
'('           Punctuation
'L'           Name
'"'           Literal.String
'\\'          Literal.String
'U'           Literal.String
'"'           Literal.String
','           Punctuation
' '           Text
'hex'         Name
'('           Punctuation
'c'           Name
','           Punctuation
' '           Text
'need_full_hex' Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
'8'           Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'4'           Literal.Number.Integer
')'           Punctuation
')'           Punctuation
'\n'          Text

'        '    Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'escape_string' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print_to_string' Name
'('           Punctuation
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
' '           Text
'print_escaped' Name
','           Punctuation
' '           Text
's'           Name
','           Punctuation
' '           Text
'"'           Literal.String
'\\"'         Literal.String.Escape
'"'           Literal.String
')'           Punctuation
'\n'          Text

'print_quoted' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
'print'       Name
'('           Punctuation
'\'"\''       Literal.String.Char
')'           Punctuation
';'           Punctuation
' '           Text
'print_escaped' Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'"'           Literal.String
'\\"'         Literal.String.Escape
'\\$'         Literal.String.Escape
'"'           Literal.String
')'           Punctuation
';'           Punctuation
' '           Text
'print'       Name
'('           Punctuation
'\'"\''       Literal.String.Char
')'           Punctuation
')'           Punctuation
'\n'          Text

'#"  # work around syntax highlighting problem' Comment
'\n'          Text

'quote_string' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print_to_string' Name
'('           Punctuation
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
'+'           Operator
'2'           Literal.Number.Integer
','           Punctuation
' '           Text
'print_quoted' Name
','           Punctuation
' '           Text
's'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'# bare minimum unescaping function unescapes only given characters' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'print_unescaped_chars' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'esc'         Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'!'           Operator
'contains'    Name
'('           Punctuation
'esc'         Name
','           Punctuation
"'\\\\'"      Literal.String.Char
')'           Punctuation
'\n'          Text

'        '    Text
'esc'         Name
' '           Text
'='           Operator
' '           Text
'strcat'      Name
'('           Punctuation
'"'           Literal.String
'\\\\'        Literal.String.Escape
'"'           Literal.String
','           Punctuation
' '           Text
'esc'         Name
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'\\\\'"      Literal.String.Char
' '           Text
'&&'          Operator
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'&&'          Operator
' '           Text
'contains'    Name
'('           Punctuation
'esc'         Name
','           Punctuation
's'           Name
'['           Punctuation
'i'           Name
']'           Punctuation
')'           Punctuation
'\n'          Text

'            ' Text
'c'           Name
','           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
'c'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'unescape_chars' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'esc'         Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'    '        Text
'print_to_string' Name
'('           Punctuation
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
' '           Text
'print_unescaped_chars' Name
','           Punctuation
' '           Text
's'           Name
','           Punctuation
' '           Text
'esc'         Name
')'           Punctuation
'\n'          Text

'\n'          Text

'# general unescaping of traditional C and Unicode escape sequences' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'print_unescaped' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'&&'          Operator
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'\\\\'"      Literal.String.Char
'\n'          Text

'            ' Text
'c'           Name
','           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'if'          Keyword
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'x'"         Literal.String.Char
' '           Text
'||'          Operator
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'u'"         Literal.String.Char
' '           Text
'||'          Operator
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'U'"         Literal.String.Char
'\n'          Text

'                ' Text
'n'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'                ' Text
'm'           Name
' '           Text
'='           Operator
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'x'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'2'           Literal.Number.Integer
' '           Text
':'           Operator
'\n'          Text

'                    ' Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'u'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'4'           Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'8'           Literal.Number.Integer
'\n'          Text

'                ' Text
'while'       Keyword
' '           Text
'('           Punctuation
'k'           Name
'+='          Operator
'1'           Literal.Number.Integer
')'           Punctuation
' '           Text
'<='          Operator
' '           Text
'm'           Name
' '           Text
'&&'          Operator
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'                    ' Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'                    ' Text
'n'           Name
' '           Text
'='           Operator
' '           Text
"'0'"         Literal.String.Char
' '           Text
'<='          Operator
' '           Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'9'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'n'           Name
'<<'          Operator
'4'           Literal.Number.Integer
' '           Text
'+'           Operator
' '           Text
'c'           Name
'-'           Operator
"'0'"         Literal.String.Char
' '           Text
':'           Operator
'\n'          Text

'                        ' Text
"'a'"         Literal.String.Char
' '           Text
'<='          Operator
' '           Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'f'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'n'           Name
'<<'          Operator
'4'           Literal.Number.Integer
' '           Text
'+'           Operator
' '           Text
'c'           Name
'-'           Operator
"'a'"         Literal.String.Char
'+'           Operator
'10'          Literal.Number.Integer
' '           Text
':'           Operator
'\n'          Text

'                        ' Text
"'A'"         Literal.String.Char
' '           Text
'<='          Operator
' '           Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'F'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'n'           Name
'<<'          Operator
'4'           Literal.Number.Integer
' '           Text
'+'           Operator
' '           Text
'c'           Name
'-'           Operator
"'A'"         Literal.String.Char
'+'           Operator
'10'          Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'break'       Keyword
'\n'          Text

'                    ' Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'                ' Text
'end'         Keyword
'\n'          Text

'                ' Text
'if'          Keyword
' '           Text
'k'           Name
' '           Text
'=='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'                    ' Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'\\\\'        Literal.String.Escape
'x'           Literal.String
' '           Literal.String
'u'           Literal.String
's'           Literal.String
'e'           Literal.String
'd'           Literal.String
' '           Literal.String
'w'           Literal.String
'i'           Literal.String
't'           Literal.String
'h'           Literal.String
' '           Literal.String
'n'           Literal.String
'o'           Literal.String
' '           Literal.String
'f'           Literal.String
'o'           Literal.String
'l'           Literal.String
'l'           Literal.String
'o'           Literal.String
'w'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
' '           Literal.String
'h'           Literal.String
'e'           Literal.String
'x'           Literal.String
' '           Literal.String
'd'           Literal.String
'i'           Literal.String
'g'           Literal.String
'i'           Literal.String
't'           Literal.String
's'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'                ' Text
'end'         Keyword
'\n'          Text

'                ' Text
'if'          Keyword
' '           Text
'm'           Name
' '           Text
'=='          Operator
' '           Text
'2'           Literal.Number.Integer
' '           Text
'# \\x escape sequence' Comment
'\n'          Text

'                    ' Text
'write'       Name
'('           Punctuation
'uint8'       Name
'('           Punctuation
'n'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'                ' Text
'else'        Keyword
'\n'          Text

'                    ' Text
'print'       Name
'('           Punctuation
'char'        Name
'('           Punctuation
'n'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'                ' Text
'end'         Keyword
'\n'          Text

'            ' Text
'elseif'      Keyword
' '           Text
"'0'"         Literal.String.Char
' '           Text
'<='          Operator
' '           Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'7'"         Literal.String.Char
'\n'          Text

'                ' Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'                ' Text
'n'           Name
' '           Text
'='           Operator
' '           Text
'c'           Name
'-'           Operator
"'0'"         Literal.String.Char
'\n'          Text

'                ' Text
'while'       Keyword
' '           Text
'('           Punctuation
'k'           Name
'+='          Operator
'1'           Literal.Number.Integer
')'           Punctuation
' '           Text
'<='          Operator
' '           Text
'3'           Literal.Number.Integer
' '           Text
'&&'          Operator
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'                    ' Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'                    ' Text
'n'           Name
' '           Text
'='           Operator
' '           Text
"'0'"         Literal.String.Char
' '           Text
'<='          Operator
' '           Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'7'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'n'           Name
'<<'          Operator
'3'           Literal.Number.Integer
' '           Text
'+'           Operator
' '           Text
'c'           Name
'-'           Operator
"'0'"         Literal.String.Char
' '           Text
':'           Operator
' '           Text
'break'       Keyword
'\n'          Text

'                    ' Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'                ' Text
'end'         Keyword
'\n'          Text

'                ' Text
'if'          Keyword
' '           Text
'n'           Name
' '           Text
'>'           Operator
' '           Text
'255'         Literal.Number.Integer
'\n'          Text

'                    ' Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'o'           Literal.String
'c'           Literal.String
't'           Literal.String
'a'           Literal.String
'l'           Literal.String
' '           Literal.String
'e'           Literal.String
's'           Literal.String
'c'           Literal.String
'a'           Literal.String
'p'           Literal.String
'e'           Literal.String
' '           Literal.String
's'           Literal.String
'e'           Literal.String
'q'           Literal.String
'u'           Literal.String
'e'           Literal.String
'n'           Literal.String
'c'           Literal.String
'e'           Literal.String
' '           Literal.String
'o'           Literal.String
'u'           Literal.String
't'           Literal.String
' '           Literal.String
'o'           Literal.String
'f'           Literal.String
' '           Literal.String
'r'           Literal.String
'a'           Literal.String
'n'           Literal.String
'g'           Literal.String
'e'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'                ' Text
'end'         Keyword
'\n'          Text

'                ' Text
'write'       Name
'('           Punctuation
'uint8'       Name
'('           Punctuation
'n'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'            ' Text
'else'        Keyword
'\n'          Text

'                ' Text
'print'       Name
'('           Punctuation
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'a'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
"'\\a'"       Literal.String.Char
' '           Text
':'           Operator
'\n'          Text

'                      ' Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'b'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
"'\\b'"       Literal.String.Char
' '           Text
':'           Operator
'\n'          Text

'                      ' Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'t'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
"'\\t'"       Literal.String.Char
' '           Text
':'           Operator
'\n'          Text

'                      ' Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'n'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
"'\\n'"       Literal.String.Char
' '           Text
':'           Operator
'\n'          Text

'                      ' Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'v'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
"'\\v'"       Literal.String.Char
' '           Text
':'           Operator
'\n'          Text

'                      ' Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'f'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
"'\\f'"       Literal.String.Char
' '           Text
':'           Operator
'\n'          Text

'                      ' Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'r'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
"'\\r'"       Literal.String.Char
' '           Text
':'           Operator
'\n'          Text

'                      ' Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'e'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
"'\\e'"       Literal.String.Char
' '           Text
':'           Operator
' '           Text
'c'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'        '    Text
'else'        Keyword
'\n'          Text

'            ' Text
'print'       Name
'('           Punctuation
'c'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'unescape_string' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print_to_string' Name
'('           Punctuation
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
' '           Text
'print_unescaped' Name
','           Punctuation
' '           Text
's'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'## checking UTF-8 & ACSII validity ##' Comment
'\n'          Text

'\n'          Text

'byte_string_classify' Name
'('           Punctuation
's'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'    '        Text
'ccall'       Keyword
'('           Punctuation
':'           Operator
'u8_isvalid'  Name
','           Punctuation
' '           Text
'Int32'       Keyword.Type
','           Punctuation
' '           Text
'('           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
' '           Text
'Int'         Keyword.Type
')'           Punctuation
','           Punctuation
' '           Text
's'           Name
'.'           Operator
'data'        Name
','           Punctuation
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'# 0: neither valid ASCII nor UTF-8' Comment
'\n'          Text

'    '        Text
'# 1: valid ASCII' Comment
'\n'          Text

'    '        Text
'# 2: valid UTF-8' Comment
'\n'          Text

'\n'          Text

'is_valid_ascii' Name
'('           Punctuation
's'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'byte_string_classify' Name
'('           Punctuation
's'           Name
')'           Punctuation
' '           Text
'=='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'is_valid_utf8' Name
' '           Text
'('           Punctuation
's'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'byte_string_classify' Name
'('           Punctuation
's'           Name
')'           Punctuation
' '           Text
'!='          Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'\n'          Text

'check_ascii' Name
'('           Punctuation
's'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'is_valid_ascii' Name
'('           Punctuation
's'           Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
's'           Name
' '           Text
':'           Operator
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'i'           Literal.String
'n'           Literal.String
'v'           Literal.String
'a'           Literal.String
'l'           Literal.String
'i'           Literal.String
'd'           Literal.String
' '           Literal.String
'A'           Literal.String
'S'           Literal.String
'C'           Literal.String
'I'           Literal.String
'I'           Literal.String
' '           Literal.String
's'           Literal.String
'e'           Literal.String
'q'           Literal.String
'u'           Literal.String
'e'           Literal.String
'n'           Literal.String
'c'           Literal.String
'e'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'check_utf8'  Name
' '           Text
'('           Punctuation
's'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'is_valid_utf8' Name
'('           Punctuation
's'           Name
')'           Punctuation
'  '          Text
'?'           Operator
' '           Text
's'           Name
' '           Text
':'           Operator
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'i'           Literal.String
'n'           Literal.String
'v'           Literal.String
'a'           Literal.String
'l'           Literal.String
'i'           Literal.String
'd'           Literal.String
' '           Literal.String
'U'           Literal.String
'T'           Literal.String
'F'           Literal.String
'-'           Literal.String
'8'           Literal.String
' '           Literal.String
's'           Literal.String
'e'           Literal.String
'q'           Literal.String
'u'           Literal.String
'e'           Literal.String
'n'           Literal.String
'c'           Literal.String
'e'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'\n'          Text

'## string interpolation parsing ##' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'_jl_interp_parse' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'unescape'    Name
'::'          Operator
'Function'    Keyword.Type
','           Punctuation
' '           Text
'printer'     Name
'::'          Operator
'Function'    Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'sx'          Name
' '           Text
'='           Operator
' '           Text
'{'           Punctuation
'}'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'$'"         Literal.String.Char
'\n'          Text

'            ' Text
'if'          Keyword
' '           Text
'!'           Operator
'isempty'     Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'\n'          Text

'                ' Text
'push'        Name
'('           Punctuation
'sx'          Name
','           Punctuation
' '           Text
'unescape'    Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
')'           Punctuation
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'            ' Text
'ex'          Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'parseatom'   Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'push'        Name
'('           Punctuation
'sx'          Name
','           Punctuation
' '           Text
'ex'          Name
')'           Punctuation
'\n'          Text

'            ' Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'        '    Text
'elseif'      Keyword
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'\\\\'"      Literal.String.Char
' '           Text
'&&'          Operator
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'if'          Keyword
' '           Text
's'           Name
'['           Punctuation
'k'           Name
']'           Punctuation
' '           Text
'=='          Operator
' '           Text
"'$'"         Literal.String.Char
'\n'          Text

'                ' Text
'if'          Keyword
' '           Text
'!'           Operator
'isempty'     Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'\n'          Text

'                    ' Text
'push'        Name
'('           Punctuation
'sx'          Name
','           Punctuation
' '           Text
'unescape'    Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
')'           Punctuation
'\n'          Text

'                ' Text
'end'         Keyword
'\n'          Text

'                ' Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'            ' Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'else'        Keyword
'\n'          Text

'            ' Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'!'           Operator
'isempty'     Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
']'           Punctuation
')'           Punctuation
'\n'          Text

'        '    Text
'push'        Name
'('           Punctuation
'sx'          Name
','           Punctuation
' '           Text
'unescape'    Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'length'      Name
'('           Punctuation
'sx'          Name
')'           Punctuation
' '           Text
'=='          Operator
' '           Text
'1'           Literal.Number.Integer
' '           Text
'&&'          Operator
' '           Text
'isa'         Keyword.Pseudo
'('           Punctuation
'sx'          Name
'['           Punctuation
'1'           Literal.Number.Integer
']'           Punctuation
','           Punctuation
'ByteString'  Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
'sx'          Name
'['           Punctuation
'1'           Literal.Number.Integer
']'           Punctuation
' '           Text
':'           Operator
'\n'          Text

'        '    Text
'expr'        Name
'('           Punctuation
':'           Operator
'call'        Name
','           Punctuation
' '           Text
':'           Operator
'print_to_string' Name
','           Punctuation
' '           Text
'printer'     Name
','           Punctuation
' '           Text
'sx'          Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'_jl_interp_parse' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'u'           Name
'::'          Operator
'Function'    Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'_jl_interp_parse' Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'u'           Name
','           Punctuation
' '           Text
'print'       Name
')'           Punctuation
'\n'          Text

'_jl_interp_parse' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'_jl_interp_parse' Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'x'           Name
'-'           Operator
'>'           Operator
'check_utf8'  Name
'('           Punctuation
'unescape_string' Name
'('           Punctuation
'x'           Name
')'           Punctuation
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'_jl_interp_parse_bytes' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'writer'      Name
'('           Punctuation
'x'           Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'for'         Keyword
' '           Text
'w'           Name
'='           Operator
'x'           Name
';'           Punctuation
' '           Text
'write'       Name
'('           Punctuation
'w'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'    '        Text
'_jl_interp_parse' Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'unescape_string' Name
','           Punctuation
' '           Text
'writer'      Name
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'## core string macros ##' Comment
'\n'          Text

'\n'          Text

'macro'       Keyword
'   '         Text
'str'         Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'_jl_interp_parse' Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'macro'       Keyword
' '           Text
'S_str'       Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'_jl_interp_parse' Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'macro'       Keyword
' '           Text
'I_str'       Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'_jl_interp_parse' Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'x'           Name
'-'           Operator
'>'           Operator
'unescape_chars' Name
'('           Punctuation
'x'           Name
','           Punctuation
'"'           Literal.String
'\\"'         Literal.String.Escape
'"'           Literal.String
')'           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'macro'       Keyword
' '           Text
'E_str'       Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'check_utf8'  Name
'('           Punctuation
'unescape_string' Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'macro'       Keyword
' '           Text
'B_str'       Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'_jl_interp_parse_bytes' Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'macro'       Keyword
' '           Text
'b_str'       Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'ex'          Name
' '           Text
'='           Operator
' '           Text
'_jl_interp_parse_bytes' Name
'('           Punctuation
's'           Name
')'           Punctuation
';'           Punctuation
' '           Text
':'           Operator
'('           Punctuation
'('           Punctuation
'$'           Operator
'ex'          Name
')'           Punctuation
'.'           Operator
'data'        Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'\n'          Text

'## shell-like command parsing ##' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'_jl_shell_parse' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'interp'      Name
'::'          Operator
'Bool'        Keyword.Type
')'           Punctuation
'\n'          Text

'\n'          Text

'    '        Text
'in_single_quotes' Name
' '           Text
'='           Operator
' '           Text
'false'       Keyword.Constant
'\n'          Text

'    '        Text
'in_double_quotes' Name
' '           Text
'='           Operator
' '           Text
'false'       Keyword.Constant
'\n'          Text

'\n'          Text

'    '        Text
'args'        Name
' '           Text
'='           Operator
' '           Text
'{'           Punctuation
'}'           Punctuation
'\n'          Text

'    '        Text
'arg'         Name
' '           Text
'='           Operator
' '           Text
'{'           Punctuation
'}'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'i'           Name
'\n'          Text

'\n'          Text

'    '        Text
'function'    Keyword
' '           Text
'update_arg'  Name
'('           Punctuation
'x'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'!'           Operator
'isa'         Keyword.Pseudo
'('           Punctuation
'x'           Name
','           Punctuation
'String'      Name
')'           Punctuation
' '           Text
'||'          Operator
' '           Text
'!'           Operator
'isempty'     Name
'('           Punctuation
'x'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'push'        Name
'('           Punctuation
'arg'         Name
','           Punctuation
' '           Text
'x'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'function'    Keyword
' '           Text
'append_arg'  Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'isempty'     Name
'('           Punctuation
'arg'         Name
')'           Punctuation
';'           Punctuation
' '           Text
'arg'         Name
' '           Text
'='           Operator
' '           Text
'{'           Punctuation
'"'           Literal.String
'"'           Literal.String
','           Punctuation
'}'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'        '    Text
'push'        Name
'('           Punctuation
'args'        Name
','           Punctuation
' '           Text
'arg'         Name
')'           Punctuation
'\n'          Text

'        '    Text
'arg'         Name
' '           Text
'='           Operator
' '           Text
'{'           Punctuation
'}'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'!'           Operator
'in_single_quotes' Name
' '           Text
'&&'          Operator
' '           Text
'!'           Operator
'in_double_quotes' Name
' '           Text
'&&'          Operator
' '           Text
'iswspace'    Name
'('           Punctuation
'c'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'update_arg'  Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
'\n'          Text

'            ' Text
'append_arg'  Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'            ' Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'            ' Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'                ' Text
'c'           Name
','           Punctuation
' '           Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'                ' Text
'if'          Keyword
' '           Text
'!'           Operator
'iswspace'    Name
'('           Punctuation
'c'           Name
')'           Punctuation
'\n'          Text

'                    ' Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'                    ' Text
'break'       Keyword
'\n'          Text

'                ' Text
'end'         Keyword
'\n'          Text

'                ' Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'        '    Text
'elseif'      Keyword
' '           Text
'interp'      Name
' '           Text
'&&'          Operator
' '           Text
'!'           Operator
'in_single_quotes' Name
' '           Text
'&&'          Operator
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'$'"         Literal.String.Char
'\n'          Text

'            ' Text
'update_arg'  Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
';'           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'            ' Text
'if'          Keyword
' '           Text
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'                ' Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'\\$'         Literal.String.Escape
' '           Literal.String
'r'           Literal.String
'i'           Literal.String
'g'           Literal.String
'h'           Literal.String
't'           Literal.String
' '           Literal.String
'b'           Literal.String
'e'           Literal.String
'f'           Literal.String
'o'           Literal.String
'r'           Literal.String
'e'           Literal.String
' '           Literal.String
'e'           Literal.String
'n'           Literal.String
'd'           Literal.String
' '           Literal.String
'o'           Literal.String
'f'           Literal.String
' '           Literal.String
'c'           Literal.String
'o'           Literal.String
'm'           Literal.String
'm'           Literal.String
'a'           Literal.String
'n'           Literal.String
'd'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'            ' Text
'if'          Keyword
' '           Text
'iswspace'    Name
'('           Punctuation
's'           Name
'['           Punctuation
'k'           Name
']'           Punctuation
')'           Punctuation
'\n'          Text

'                ' Text
'error'       Name
'('           Punctuation
'"'           Literal.String
's'           Literal.String
'p'           Literal.String
'a'           Literal.String
'c'           Literal.String
'e'           Literal.String
' '           Literal.String
'n'           Literal.String
'o'           Literal.String
't'           Literal.String
' '           Literal.String
'a'           Literal.String
'l'           Literal.String
'l'           Literal.String
'o'           Literal.String
'w'           Literal.String
'e'           Literal.String
'd'           Literal.String
' '           Literal.String
'r'           Literal.String
'i'           Literal.String
'g'           Literal.String
'h'           Literal.String
't'           Literal.String
' '           Literal.String
'a'           Literal.String
'f'           Literal.String
't'           Literal.String
'e'           Literal.String
'r'           Literal.String
' '           Literal.String
'\\$'         Literal.String.Escape
'"'           Literal.String
')'           Punctuation
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'            ' Text
'ex'          Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'parseatom'   Name
'('           Punctuation
's'           Name
','           Punctuation
'j'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'update_arg'  Name
'('           Punctuation
'ex'          Name
')'           Punctuation
';'           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'        '    Text
'else'        Keyword
'\n'          Text

'            ' Text
'if'          Keyword
' '           Text
'!'           Operator
'in_double_quotes' Name
' '           Text
'&&'          Operator
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'\\''"       Literal.String.Char
'\n'          Text

'                ' Text
'in_single_quotes' Name
' '           Text
'='           Operator
' '           Text
'!'           Operator
'in_single_quotes' Name
'\n'          Text

'                ' Text
'update_arg'  Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'            ' Text
'elseif'      Keyword
' '           Text
'!'           Operator
'in_single_quotes' Name
' '           Text
'&&'          Operator
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
'\'"\''       Literal.String.Char
'\n'          Text

'                ' Text
'in_double_quotes' Name
' '           Text
'='           Operator
' '           Text
'!'           Operator
'in_double_quotes' Name
'\n'          Text

'                ' Text
'update_arg'  Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'            ' Text
'elseif'      Keyword
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'\\\\'"      Literal.String.Char
'\n'          Text

'                ' Text
'if'          Keyword
' '           Text
'in_double_quotes' Name
'\n'          Text

'                    ' Text
'if'          Keyword
' '           Text
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'                        ' Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'u'           Literal.String
'n'           Literal.String
't'           Literal.String
'e'           Literal.String
'r'           Literal.String
'm'           Literal.String
'i'           Literal.String
'n'           Literal.String
'a'           Literal.String
't'           Literal.String
'e'           Literal.String
'd'           Literal.String
' '           Literal.String
'd'           Literal.String
'o'           Literal.String
'u'           Literal.String
'b'           Literal.String
'l'           Literal.String
'e'           Literal.String
' '           Literal.String
'q'           Literal.String
'u'           Literal.String
'o'           Literal.String
't'           Literal.String
'e'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'                    ' Text
'end'         Keyword
'\n'          Text

'                    ' Text
'if'          Keyword
' '           Text
's'           Name
'['           Punctuation
'k'           Name
']'           Punctuation
' '           Text
'=='          Operator
' '           Text
'\'"\''       Literal.String.Char
' '           Text
'||'          Operator
' '           Text
's'           Name
'['           Punctuation
'k'           Name
']'           Punctuation
' '           Text
'=='          Operator
' '           Text
"'$'"         Literal.String.Char
'\n'          Text

'                        ' Text
'update_arg'  Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'                        ' Text
'c'           Name
','           Punctuation
' '           Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'                    ' Text
'end'         Keyword
'\n'          Text

'                ' Text
'elseif'      Keyword
' '           Text
'!'           Operator
'in_single_quotes' Name
'\n'          Text

'                    ' Text
'if'          Keyword
' '           Text
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'                        ' Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'd'           Literal.String
'a'           Literal.String
'n'           Literal.String
'g'           Literal.String
'l'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
' '           Literal.String
'b'           Literal.String
'a'           Literal.String
'c'           Literal.String
'k'           Literal.String
's'           Literal.String
'l'           Literal.String
'a'           Literal.String
's'           Literal.String
'h'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'                    ' Text
'end'         Keyword
'\n'          Text

'                    ' Text
'update_arg'  Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'j'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'                    ' Text
'c'           Name
','           Punctuation
' '           Text
'k'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'k'           Name
')'           Punctuation
'\n'          Text

'                ' Text
'end'         Keyword
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'            ' Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'k'           Name
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'in_single_quotes' Name
';'           Punctuation
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'u'           Literal.String
'n'           Literal.String
't'           Literal.String
'e'           Literal.String
'r'           Literal.String
'm'           Literal.String
'i'           Literal.String
'n'           Literal.String
'a'           Literal.String
't'           Literal.String
'e'           Literal.String
'd'           Literal.String
' '           Literal.String
's'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
'l'           Literal.String
'e'           Literal.String
' '           Literal.String
'q'           Literal.String
'u'           Literal.String
'o'           Literal.String
't'           Literal.String
'e'           Literal.String
'"'           Literal.String
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'in_double_quotes' Name
';'           Punctuation
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'u'           Literal.String
'n'           Literal.String
't'           Literal.String
'e'           Literal.String
'r'           Literal.String
'm'           Literal.String
'i'           Literal.String
'n'           Literal.String
'a'           Literal.String
't'           Literal.String
'e'           Literal.String
'd'           Literal.String
' '           Literal.String
'd'           Literal.String
'o'           Literal.String
'u'           Literal.String
'b'           Literal.String
'l'           Literal.String
'e'           Literal.String
' '           Literal.String
'q'           Literal.String
'u'           Literal.String
'o'           Literal.String
't'           Literal.String
'e'           Literal.String
'"'           Literal.String
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'\n'          Text

'    '        Text
'update_arg'  Name
'('           Punctuation
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
']'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'append_arg'  Name
'('           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'!'           Operator
'interp'      Name
'\n'          Text

'        '    Text
'return'      Keyword
' '           Text
'args'        Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'\n'          Text

'    '        Text
'# construct an expression' Comment
'\n'          Text

'    '        Text
'exprs'       Name
' '           Text
'='           Operator
' '           Text
'{'           Punctuation
'}'           Punctuation
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'arg'         Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
'args'        Name
'\n'          Text

'        '    Text
'push'        Name
'('           Punctuation
'exprs'       Name
','           Punctuation
' '           Text
'expr'        Name
'('           Punctuation
':'           Operator
'tuple'       Name
','           Punctuation
' '           Text
'arg'         Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'expr'        Name
'('           Punctuation
':'           Operator
'tuple'       Name
','           Punctuation
'exprs'       Name
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'_jl_shell_parse' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'_jl_shell_parse' Name
'('           Punctuation
's'           Name
','           Punctuation
'true'        Keyword.Constant
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'shell_split' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'parsed'      Name
' '           Text
'='           Operator
' '           Text
'_jl_shell_parse' Name
'('           Punctuation
's'           Name
','           Punctuation
'false'       Keyword.Constant
')'           Punctuation
'\n'          Text

'    '        Text
'args'        Name
' '           Text
'='           Operator
' '           Text
'String'      Name
'['           Punctuation
']'           Punctuation
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'arg'         Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
'parsed'      Name
'\n'          Text

'       '     Text
'push'        Name
'('           Punctuation
'args'        Name
','           Punctuation
' '           Text
'strcat'      Name
'('           Punctuation
'arg'         Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'args'        Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'print_shell_word' Name
'('           Punctuation
'word'        Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'isempty'     Name
'('           Punctuation
'word'        Name
')'           Punctuation
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
'"'           Literal.String
"'"           Literal.String
"'"           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'has_single'  Name
' '           Text
'='           Operator
' '           Text
'false'       Keyword.Constant
'\n'          Text

'    '        Text
'has_special' Name
' '           Text
'='           Operator
' '           Text
'false'       Keyword.Constant
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'c'           Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
'word'        Name
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'iswspace'    Name
'('           Punctuation
'c'           Name
')'           Punctuation
' '           Text
'||'          Operator
' '           Text
'c'           Name
'=='          Operator
"'\\\\'"      Literal.String.Char
' '           Text
'||'          Operator
' '           Text
'c'           Name
'=='          Operator
"'\\''"       Literal.String.Char
' '           Text
'||'          Operator
' '           Text
'c'           Name
'=='          Operator
'\'"\''       Literal.String.Char
' '           Text
'||'          Operator
' '           Text
'c'           Name
'=='          Operator
"'$'"         Literal.String.Char
'\n'          Text

'            ' Text
'has_special' Name
' '           Text
'='           Operator
' '           Text
'true'        Keyword.Constant
'\n'          Text

'            ' Text
'if'          Keyword
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'\\''"       Literal.String.Char
'\n'          Text

'                ' Text
'has_single'  Name
' '           Text
'='           Operator
' '           Text
'true'        Keyword.Constant
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'!'           Operator
'has_special' Name
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
'word'        Name
')'           Punctuation
'\n'          Text

'    '        Text
'elseif'      Keyword
' '           Text
'!'           Operator
'has_single'  Name
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
"'\\''"       Literal.String.Char
','           Punctuation
' '           Text
'word'        Name
','           Punctuation
' '           Text
"'\\''"       Literal.String.Char
')'           Punctuation
'\n'          Text

'    '        Text
'else'        Keyword
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
'\'"\''       Literal.String.Char
')'           Punctuation
'\n'          Text

'        '    Text
'for'         Keyword
' '           Text
'c'           Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
'word'        Name
'\n'          Text

'            ' Text
'if'          Keyword
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
'\'"\''       Literal.String.Char
' '           Text
'||'          Operator
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'$'"         Literal.String.Char
'\n'          Text

'                ' Text
'print'       Name
'('           Punctuation
"'\\\\'"      Literal.String.Char
')'           Punctuation
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'            ' Text
'print'       Name
'('           Punctuation
'c'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
'\'"\''       Literal.String.Char
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'print_shell_escaped' Name
'('           Punctuation
'cmd'         Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'args'        Name
'::'          Operator
'String'      Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'    '        Text
'print_shell_word' Name
'('           Punctuation
'cmd'         Name
')'           Punctuation
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'arg'         Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
'args'        Name
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
"' '"         Literal.String.Char
')'           Punctuation
'\n'          Text

'        '    Text
'print_shell_word' Name
'('           Punctuation
'arg'         Name
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'shell_escape' Name
'('           Punctuation
'cmd'         Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'args'        Name
'::'          Operator
'String'      Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
'\n'          Text

'    '        Text
'print_to_string' Name
'('           Punctuation
'print_shell_escaped' Name
','           Punctuation
' '           Text
'cmd'         Name
','           Punctuation
' '           Text
'args'        Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'\n'          Text

'## interface to parser ##' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'parse'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'pos'         Name
','           Punctuation
' '           Text
'greedy'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'# returns (expr, end_pos). expr is () in case of parse error.' Comment
'\n'          Text

'    '        Text
'ex'          Name
','           Punctuation
' '           Text
'pos'         Name
' '           Text
'='           Operator
' '           Text
'ccall'       Keyword
'('           Punctuation
':'           Operator
'jl_parse_string' Name
','           Punctuation
' '           Text
'Any'         Keyword.Type
','           Punctuation
'\n'          Text

'                    ' Text
'('           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
' '           Text
'Int32'       Keyword.Type
','           Punctuation
' '           Text
'Int32'       Keyword.Type
')'           Punctuation
','           Punctuation
'\n'          Text

'                    ' Text
'cstring'     Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
' '           Text
'pos'         Name
'-'           Operator
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'greedy'      Name
' '           Text
'?'           Operator
' '           Text
'1'           Literal.Number.Integer
':'           Operator
'0'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'isa'         Keyword.Pseudo
'('           Punctuation
'ex'          Name
','           Punctuation
'Expr'        Keyword.Type
')'           Punctuation
' '           Text
'&&'          Operator
' '           Text
'is'          Name
'('           Punctuation
'ex'          Name
'.'           Operator
'head'        Name
','           Punctuation
':'           Operator
'error'       Name
')'           Punctuation
'\n'          Text

'        '    Text
'throw'       Name
'('           Punctuation
'ParseError'  Keyword.Type
'('           Punctuation
'ex'          Name
'.'           Operator
'args'        Name
'['           Punctuation
'1'           Literal.Number.Integer
']'           Punctuation
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'ex'          Name
' '           Text
'=='          Operator
' '           Text
'('           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
'throw'       Name
'('           Punctuation
'ParseError'  Keyword.Type
'('           Punctuation
'"'           Literal.String
'e'           Literal.String
'n'           Literal.String
'd'           Literal.String
' '           Literal.String
'o'           Literal.String
'f'           Literal.String
' '           Literal.String
'i'           Literal.String
'n'           Literal.String
'p'           Literal.String
'u'           Literal.String
't'           Literal.String
'"'           Literal.String
')'           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'    '        Text
'ex'          Name
','           Punctuation
' '           Text
'pos'         Name
'+'           Operator
'1'           Literal.Number.Integer
' '           Text
'# C is zero-based, Julia is 1-based' Comment
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'parse'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'          '  Text
'='           Operator
' '           Text
'parse'       Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'true'        Keyword.Constant
')'           Punctuation
'\n'          Text

'parse'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'pos'         Name
')'           Punctuation
'     '       Text
'='           Operator
' '           Text
'parse'       Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'pos'         Name
','           Punctuation
' '           Text
'true'        Keyword.Constant
')'           Punctuation
'\n'          Text

'parseatom'   Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'      '      Text
'='           Operator
' '           Text
'parse'       Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'1'           Literal.Number.Integer
','           Punctuation
' '           Text
'false'       Keyword.Constant
')'           Punctuation
'\n'          Text

'parseatom'   Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'pos'         Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse'       Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'pos'         Name
','           Punctuation
' '           Text
'false'       Keyword.Constant
')'           Punctuation
'\n'          Text

'\n'          Text

'## miscellaneous string functions ##' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'lpad'        Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'n'           Name
'::'          Operator
'Integer'     Keyword.Type
','           Punctuation
' '           Text
'p'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'm'           Name
' '           Text
'='           Operator
' '           Text
'n'           Name
' '           Text
'-'           Operator
' '           Text
'strlen'      Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'm'           Name
' '           Text
'<='          Operator
' '           Text
'0'           Literal.Number.Integer
';'           Punctuation
' '           Text
'return'      Keyword
' '           Text
's'           Name
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'    '        Text
'l'           Name
' '           Text
'='           Operator
' '           Text
'strlen'      Name
'('           Punctuation
'p'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'l'           Name
'=='          Operator
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'return'      Keyword
' '           Text
'p'           Name
'^'           Operator
'm'           Name
' '           Text
'*'           Operator
' '           Text
's'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'q'           Name
' '           Text
'='           Operator
' '           Text
'div'         Name
'('           Punctuation
'm'           Name
','           Punctuation
'l'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'r'           Name
' '           Text
'='           Operator
' '           Text
'm'           Name
' '           Text
'-'           Operator
' '           Text
'q'           Name
'*'           Operator
'l'           Name
'\n'          Text

'    '        Text
'cstring'     Name
'('           Punctuation
'p'           Name
'^'           Operator
'q'           Name
'*'           Operator
'p'           Name
'['           Punctuation
'1'           Literal.Number.Integer
':'           Operator
'chr2ind'     Name
'('           Punctuation
'p'           Name
','           Punctuation
'r'           Name
')'           Punctuation
']'           Punctuation
'*'           Operator
's'           Name
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'rpad'        Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'n'           Name
'::'          Operator
'Integer'     Keyword.Type
','           Punctuation
' '           Text
'p'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'm'           Name
' '           Text
'='           Operator
' '           Text
'n'           Name
' '           Text
'-'           Operator
' '           Text
'strlen'      Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'm'           Name
' '           Text
'<='          Operator
' '           Text
'0'           Literal.Number.Integer
';'           Punctuation
' '           Text
'return'      Keyword
' '           Text
's'           Name
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'    '        Text
'l'           Name
' '           Text
'='           Operator
' '           Text
'strlen'      Name
'('           Punctuation
'p'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'l'           Name
'=='          Operator
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'return'      Keyword
' '           Text
's'           Name
' '           Text
'*'           Operator
' '           Text
'p'           Name
'^'           Operator
'm'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'q'           Name
' '           Text
'='           Operator
' '           Text
'div'         Name
'('           Punctuation
'm'           Name
','           Punctuation
'l'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'r'           Name
' '           Text
'='           Operator
' '           Text
'm'           Name
' '           Text
'-'           Operator
' '           Text
'q'           Name
'*'           Operator
'l'           Name
'\n'          Text

'    '        Text
'cstring'     Name
'('           Punctuation
's'           Name
'*'           Operator
'p'           Name
'^'           Operator
'q'           Name
'*'           Operator
'p'           Name
'['           Punctuation
'1'           Literal.Number.Integer
':'           Operator
'chr2ind'     Name
'('           Punctuation
'p'           Name
','           Punctuation
'r'           Name
')'           Punctuation
']'           Punctuation
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'lpad'        Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'n'           Name
'::'          Operator
'Integer'     Keyword.Type
','           Punctuation
' '           Text
'p'           Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'lpad'        Name
'('           Punctuation
'string'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
' '           Text
'n'           Name
','           Punctuation
' '           Text
'string'      Name
'('           Punctuation
'p'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'rpad'        Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'n'           Name
'::'          Operator
'Integer'     Keyword.Type
','           Punctuation
' '           Text
'p'           Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'rpad'        Name
'('           Punctuation
'string'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
' '           Text
'n'           Name
','           Punctuation
' '           Text
'string'      Name
'('           Punctuation
'p'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'lpad'        Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'n'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'lpad'        Name
'('           Punctuation
'string'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
' '           Text
'n'           Name
','           Punctuation
' '           Text
'"'           Literal.String
' '           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'rpad'        Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'n'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'rpad'        Name
'('           Punctuation
'string'      Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
' '           Text
'n'           Name
','           Punctuation
' '           Text
'"'           Literal.String
' '           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'split'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'delims'      Name
','           Punctuation
' '           Text
'include_empty' Name
'::'          Operator
'Bool'        Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'    '        Text
'strs'        Name
' '           Text
'='           Operator
' '           Text
'String'      Name
'['           Punctuation
']'           Punctuation
'\n'          Text

'    '        Text
'len'         Name
' '           Text
'='           Operator
' '           Text
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'true'        Keyword.Constant
'\n'          Text

'        '    Text
'tokstart'    Name
' '           Text
'='           Operator
' '           Text
'tokend'      Name
' '           Text
'='           Operator
' '           Text
'i'           Name
'\n'          Text

'        '    Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'('           Punctuation
'c'           Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'if'          Keyword
' '           Text
'contains'    Name
'('           Punctuation
'delims'      Name
','           Punctuation
' '           Text
'c'           Name
')'           Punctuation
'\n'          Text

'                ' Text
'break'       Keyword
'\n'          Text

'            ' Text
'end'         Keyword
'\n'          Text

'            ' Text
'tokend'      Name
' '           Text
'='           Operator
' '           Text
'i'           Name
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'tok'         Name
' '           Text
'='           Operator
' '           Text
's'           Name
'['           Punctuation
'tokstart'    Name
':'           Operator
'('           Punctuation
'tokend'      Name
'-'           Operator
'1'           Literal.Number.Integer
')'           Punctuation
']'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'include_empty' Name
' '           Text
'||'          Operator
' '           Text
'!'           Operator
'isempty'     Name
'('           Punctuation
'tok'         Name
')'           Punctuation
'\n'          Text

'            ' Text
'push'        Name
'('           Punctuation
'strs'        Name
','           Punctuation
' '           Text
'tok'         Name
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'!'           Operator
'('           Punctuation
'('           Punctuation
'i'           Name
' '           Text
'<='          Operator
' '           Text
'len'         Name
')'           Punctuation
' '           Text
'||'          Operator
' '           Text
'('           Punctuation
'i'           Name
'=='          Operator
'len'         Name
'+'           Operator
'1'           Literal.Number.Integer
' '           Text
'&&'          Operator
' '           Text
'tokend!'     Name
'='           Operator
'i'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'            ' Text
'break'       Keyword
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'strs'        Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'split'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'split'       Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'('           Punctuation
"' '"         Literal.String.Char
','           Punctuation
"'\\t'"       Literal.String.Char
','           Punctuation
"'\\n'"       Literal.String.Char
','           Punctuation
"'\\v'"       Literal.String.Char
','           Punctuation
"'\\f'"       Literal.String.Char
','           Punctuation
"'\\r'"       Literal.String.Char
')'           Punctuation
','           Punctuation
' '           Text
'false'       Keyword.Constant
')'           Punctuation
'\n'          Text

'split'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'x'           Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'split'       Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'x'           Name
','           Punctuation
' '           Text
'true'        Keyword.Constant
')'           Punctuation
'\n'          Text

'split'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'x'           Name
'::'          Operator
'Char'        Keyword.Type
','           Punctuation
' '           Text
'incl'        Name
'::'          Operator
'Bool'        Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'split'       Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'('           Punctuation
'x'           Name
','           Punctuation
')'           Punctuation
','           Punctuation
' '           Text
'incl'        Name
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'print_joined' Name
'('           Punctuation
'strings'     Name
','           Punctuation
' '           Text
'delim'       Name
','           Punctuation
' '           Text
'last'        Name
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
'strings'     Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'done'        Name
'('           Punctuation
'strings'     Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'return'      Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'str'         Name
','           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
'strings'     Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'print'       Name
'('           Punctuation
'str'         Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
'strings'     Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'str'         Name
','           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
'strings'     Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
'done'        Name
'('           Punctuation
'strings'     Name
','           Punctuation
'i'           Name
')'           Punctuation
' '           Text
'?'           Operator
' '           Text
'last'        Name
' '           Text
':'           Operator
' '           Text
'delim'       Name
')'           Punctuation
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
'str'         Name
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'print_joined' Name
'('           Punctuation
'strings'     Name
','           Punctuation
' '           Text
'delim'       Name
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
'strings'     Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
'strings'     Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'str'         Name
','           Punctuation
' '           Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
'strings'     Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'print'       Name
'('           Punctuation
'str'         Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
'strings'     Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'print'       Name
'('           Punctuation
'delim'       Name
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'print_joined' Name
'('           Punctuation
'strings'     Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print_joined' Name
'('           Punctuation
'strings'     Name
','           Punctuation
' '           Text
'"'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'\n'          Text

'join'        Name
'('           Punctuation
'args'        Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'print_to_string' Name
'('           Punctuation
'print_joined' Name
','           Punctuation
' '           Text
'args'        Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'\n'          Text

'chop'        Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'['           Punctuation
'1'           Literal.Number.Integer
':'           Operator
'thisind'     Name
'('           Punctuation
's'           Name
','           Punctuation
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
'\n'          Text

'chomp'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'('           Punctuation
'i'           Name
'='           Operator
'thisind'     Name
'('           Punctuation
's'           Name
','           Punctuation
'length'      Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
';'           Punctuation
' '           Text
's'           Name
'['           Punctuation
'i'           Name
']'           Punctuation
'=='          Operator
"'\\n'"       Literal.String.Char
' '           Text
'?'           Operator
' '           Text
's'           Name
'['           Punctuation
'1'           Literal.Number.Integer
':'           Operator
'i'           Name
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
' '           Text
':'           Operator
' '           Text
's'           Name
')'           Punctuation
'\n'          Text

'chomp'       Name
'('           Punctuation
's'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
's'           Name
'.'           Operator
'data'        Name
'['           Punctuation
'end'         Keyword
']'           Punctuation
'=='          Operator
'0x0a'        Literal.Number.Hex
' '           Text
'?'           Operator
' '           Text
's'           Name
'['           Punctuation
'1'           Literal.Number.Integer
':'           Operator
'end'         Keyword
'-'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
' '           Text
':'           Operator
' '           Text
's'           Name
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'lstrip'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'!'           Operator
'iswspace'    Name
'('           Punctuation
'c'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'return'      Keyword
' '           Text
's'           Name
'['           Punctuation
'i'           Name
':'           Operator
'end'         Keyword
']'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'"'           Literal.String
'"'           Literal.String
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'rstrip'      Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'    '        Text
'r'           Name
' '           Text
'='           Operator
' '           Text
'reverse'     Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
'r'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'!'           Operator
'done'        Name
'('           Punctuation
'r'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
' '           Text
'j'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
'r'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'!'           Operator
'iswspace'    Name
'('           Punctuation
'c'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'return'      Keyword
' '           Text
's'           Name
'['           Punctuation
'1'           Literal.Number.Integer
':'           Operator
'end'         Keyword
'-'           Operator
'i'           Name
'+'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'j'           Name
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'"'           Literal.String
'"'           Literal.String
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'strip'       Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'lstrip'      Name
'('           Punctuation
'rstrip'      Name
'('           Punctuation
's'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'## string to integer functions ##' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'parse_int'   Name
'{'           Punctuation
'T'           Name
'<:'          Operator
'Integer'     Keyword.Type
'}'           Punctuation
'('           Punctuation
'::'          Operator
'Type'        Keyword.Type
'{'           Punctuation
'T'           Name
'}'           Punctuation
','           Punctuation
' '           Text
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'base'        Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'!'           Operator
'('           Punctuation
'2'           Literal.Number.Integer
' '           Text
'<='          Operator
' '           Text
'base'        Name
' '           Text
'<='          Operator
' '           Text
'36'          Literal.Number.Integer
')'           Punctuation
';'           Punctuation
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'i'           Literal.String
'n'           Literal.String
'v'           Literal.String
'a'           Literal.String
'l'           Literal.String
'i'           Literal.String
'd'           Literal.String
' '           Literal.String
'b'           Literal.String
'a'           Literal.String
's'           Literal.String
'e'           Literal.String
':'           Literal.String
' '           Literal.String
'"'           Literal.String
','           Punctuation
'base'        Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'start'       Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'p'           Literal.String
'r'           Literal.String
'e'           Literal.String
'm'           Literal.String
'a'           Literal.String
't'           Literal.String
'u'           Literal.String
'r'           Literal.String
'e'           Literal.String
' '           Literal.String
'e'           Literal.String
'n'           Literal.String
'd'           Literal.String
' '           Literal.String
'o'           Literal.String
'f'           Literal.String
' '           Literal.String
'i'           Literal.String
'n'           Literal.String
't'           Literal.String
'e'           Literal.String
'g'           Literal.String
'e'           Literal.String
'r'           Literal.String
' '           Literal.String
'('           Literal.String
'i'           Literal.String
'n'           Literal.String
' '           Literal.String
'"'           Literal.String
','           Punctuation
'show_to_string' Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
'"'           Literal.String
')'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'c'           Name
','           Punctuation
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'sgn'         Name
' '           Text
'='           Operator
' '           Text
'one'         Name
'('           Punctuation
'T'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'T'           Name
' '           Text
'<:'          Operator
' '           Text
'Signed'      Keyword.Type
' '           Text
'&&'          Operator
' '           Text
'c'           Name
' '           Text
'=='          Operator
' '           Text
"'-'"         Literal.String.Char
'\n'          Text

'        '    Text
'sgn'         Name
' '           Text
'='           Operator
' '           Text
'-'           Operator
'sgn'         Name
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'p'           Literal.String
'r'           Literal.String
'e'           Literal.String
'm'           Literal.String
'a'           Literal.String
't'           Literal.String
'u'           Literal.String
'r'           Literal.String
'e'           Literal.String
' '           Literal.String
'e'           Literal.String
'n'           Literal.String
'd'           Literal.String
' '           Literal.String
'o'           Literal.String
'f'           Literal.String
' '           Literal.String
'i'           Literal.String
'n'           Literal.String
't'           Literal.String
'e'           Literal.String
'g'           Literal.String
'e'           Literal.String
'r'           Literal.String
' '           Literal.String
'('           Literal.String
'i'           Literal.String
'n'           Literal.String
' '           Literal.String
'"'           Literal.String
','           Punctuation
'show_to_string' Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
'"'           Literal.String
')'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'base'        Name
' '           Text
'='           Operator
' '           Text
'convert'     Name
'('           Punctuation
'T'           Name
','           Punctuation
'base'        Name
')'           Punctuation
'\n'          Text

'    '        Text
'n'           Name
'::'          Operator
'T'           Name
' '           Text
'='           Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'    '        Text
'while'       Keyword
' '           Text
'true'        Keyword.Constant
'\n'          Text

'        '    Text
'd'           Name
' '           Text
'='           Operator
' '           Text
"'0'"         Literal.String.Char
' '           Text
'<='          Operator
' '           Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'9'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'c'           Name
'-'           Operator
"'0'"         Literal.String.Char
' '           Text
':'           Operator
'\n'          Text

'            ' Text
"'A'"         Literal.String.Char
' '           Text
'<='          Operator
' '           Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'Z'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'c'           Name
'-'           Operator
"'A'"         Literal.String.Char
'+'           Operator
'10'          Literal.Number.Integer
' '           Text
':'           Operator
'\n'          Text

'            ' Text
"'a'"         Literal.String.Char
' '           Text
'<='          Operator
' '           Text
'c'           Name
' '           Text
'<='          Operator
' '           Text
"'z'"         Literal.String.Char
' '           Text
'?'           Operator
' '           Text
'c'           Name
'-'           Operator
"'a'"         Literal.String.Char
'+'           Operator
'10'          Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'typemax'     Name
'('           Punctuation
'Int'         Keyword.Type
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'd'           Name
' '           Text
'>='          Operator
' '           Text
'base'        Name
'\n'          Text

'            ' Text
'error'       Name
'('           Punctuation
'show_to_string' Name
'('           Punctuation
'c'           Name
')'           Punctuation
','           Punctuation
'"'           Literal.String
' '           Literal.String
'i'           Literal.String
's'           Literal.String
' '           Literal.String
'n'           Literal.String
'o'           Literal.String
't'           Literal.String
' '           Literal.String
'a'           Literal.String
' '           Literal.String
'v'           Literal.String
'a'           Literal.String
'l'           Literal.String
'i'           Literal.String
'd'           Literal.String
' '           Literal.String
'd'           Literal.String
'i'           Literal.String
'g'           Literal.String
'i'           Literal.String
't'           Literal.String
' '           Literal.String
'('           Literal.String
'i'           Literal.String
'n'           Literal.String
' '           Literal.String
'"'           Literal.String
','           Punctuation
'show_to_string' Name
'('           Punctuation
's'           Name
')'           Punctuation
','           Punctuation
'"'           Literal.String
')'           Literal.String
'"'           Literal.String
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'# TODO: overflow detection?' Comment
'\n'          Text

'        '    Text
'n'           Name
' '           Text
'='           Operator
' '           Text
'n'           Name
'*'           Operator
'base'        Name
' '           Text
'+'           Operator
' '           Text
'd'           Name
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'done'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'break'       Keyword
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'c'           Name
','           Punctuation
'i'           Name
' '           Text
'='           Operator
' '           Text
'next'        Name
'('           Punctuation
's'           Name
','           Punctuation
'i'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'return'      Keyword
' '           Text
'flipsign'    Name
'('           Punctuation
'n'           Name
','           Punctuation
'sgn'         Name
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'parse_int'   Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'base'        Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int'         Keyword.Type
','           Punctuation
's'           Name
','           Punctuation
'base'        Name
')'           Punctuation
'\n'          Text

'parse_int'   Name
'('           Punctuation
'T'           Name
'::'          Operator
'Type'        Keyword.Type
','           Punctuation
' '           Text
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'       '     Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'T'           Name
','           Punctuation
's'           Name
','           Punctuation
'10'          Literal.Number.Integer
')'           Punctuation
'\n'          Text

'parse_int'   Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'                ' Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int'         Keyword.Type
','           Punctuation
's'           Name
','           Punctuation
'10'          Literal.Number.Integer
')'           Punctuation
'\n'          Text

'\n'          Text

'parse_bin'   Name
'('           Punctuation
'T'           Name
'::'          Operator
'Type'        Keyword.Type
','           Punctuation
' '           Text
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'T'           Name
','           Punctuation
's'           Name
','           Punctuation
'2'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'parse_oct'   Name
'('           Punctuation
'T'           Name
'::'          Operator
'Type'        Keyword.Type
','           Punctuation
' '           Text
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'T'           Name
','           Punctuation
's'           Name
','           Punctuation
'8'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'parse_hex'   Name
'('           Punctuation
'T'           Name
'::'          Operator
'Type'        Keyword.Type
','           Punctuation
' '           Text
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'T'           Name
','           Punctuation
's'           Name
','           Punctuation
'16'          Literal.Number.Integer
')'           Punctuation
'\n'          Text

'\n'          Text

'parse_bin'   Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int'         Keyword.Type
','           Punctuation
's'           Name
','           Punctuation
'2'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'parse_oct'   Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int'         Keyword.Type
','           Punctuation
's'           Name
','           Punctuation
'8'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'parse_hex'   Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int'         Keyword.Type
','           Punctuation
's'           Name
','           Punctuation
'16'          Literal.Number.Integer
')'           Punctuation
'\n'          Text

'\n'          Text

'integer'     Name
' '           Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'int'         Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'unsigned'    Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'uint'        Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'int'         Name
'     '       Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int'         Keyword.Type
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'uint'        Name
'    '        Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Uint'        Name
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'int8'        Name
'    '        Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int8'        Keyword.Type
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'uint8'       Name
'   '         Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Uint8'       Name
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'int16'       Name
'   '         Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int16'       Keyword.Type
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'uint16'      Name
'  '          Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Uint16'      Name
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'int32'       Name
'   '         Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int32'       Keyword.Type
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'uint32'      Name
'  '          Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Uint32'      Name
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'int64'       Name
'   '         Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Int64'       Keyword.Type
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'uint64'      Name
'  '          Text
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'parse_int'   Name
'('           Punctuation
'Uint64'      Name
','           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'## integer to string functions ##' Comment
'\n'          Text

'\n'          Text

'const'       Keyword.Declaration
' '           Text
'_jl_dig_syms' Name
' '           Text
'='           Operator
' '           Text
'"'           Literal.String
'0'           Literal.String
'1'           Literal.String
'2'           Literal.String
'3'           Literal.String
'4'           Literal.String
'5'           Literal.String
'6'           Literal.String
'7'           Literal.String
'8'           Literal.String
'9'           Literal.String
'a'           Literal.String
'b'           Literal.String
'c'           Literal.String
'd'           Literal.String
'e'           Literal.String
'f'           Literal.String
'g'           Literal.String
'h'           Literal.String
'i'           Literal.String
'j'           Literal.String
'k'           Literal.String
'l'           Literal.String
'm'           Literal.String
'n'           Literal.String
'o'           Literal.String
'p'           Literal.String
'q'           Literal.String
'r'           Literal.String
's'           Literal.String
't'           Literal.String
'u'           Literal.String
'v'           Literal.String
'w'           Literal.String
'x'           Literal.String
'y'           Literal.String
'z'           Literal.String
'"'           Literal.String
'.'           Operator
'data'        Name
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'int2str'     Name
'('           Punctuation
'n'           Name
'::'          Operator
'Union'       Keyword.Type
'('           Punctuation
'Int64'       Keyword.Type
','           Punctuation
'Uint64'      Name
')'           Punctuation
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'Integer'     Keyword.Type
','           Punctuation
' '           Text
'l'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'b'           Name
' '           Text
'<'           Operator
' '           Text
'2'           Literal.Number.Integer
' '           Text
'||'          Operator
' '           Text
'b'           Name
' '           Text
'>'           Operator
' '           Text
'36'          Literal.Number.Integer
';'           Punctuation
' '           Text
'error'       Name
'('           Punctuation
'"'           Literal.String
'i'           Literal.String
'n'           Literal.String
't'           Literal.String
'2'           Literal.String
's'           Literal.String
't'           Literal.String
'r'           Literal.String
':'           Literal.String
' '           Literal.String
'i'           Literal.String
'n'           Literal.String
'v'           Literal.String
'a'           Literal.String
'l'           Literal.String
'i'           Literal.String
'd'           Literal.String
' '           Literal.String
'b'           Literal.String
'a'           Literal.String
's'           Literal.String
'e'           Literal.String
' '           Literal.String
'"'           Literal.String
','           Punctuation
' '           Text
'b'           Name
')'           Punctuation
';'           Punctuation
' '           Text
'end'         Keyword
'\n'          Text

'    '        Text
'neg'         Name
' '           Text
'='           Operator
' '           Text
'n'           Name
' '           Text
'<'           Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'    '        Text
'n'           Name
' '           Text
'='           Operator
' '           Text
'unsigned'    Name
'('           Punctuation
'abs'         Name
'('           Punctuation
'n'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'b'           Name
' '           Text
'='           Operator
' '           Text
'convert'     Name
'('           Punctuation
'typeof'      Name
'('           Punctuation
'n'           Name
')'           Punctuation
','           Punctuation
' '           Text
'b'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'ndig'        Name
' '           Text
'='           Operator
' '           Text
'ndigits'     Name
'('           Punctuation
'n'           Name
','           Punctuation
' '           Text
'b'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'sz'          Name
' '           Text
'='           Operator
' '           Text
'max'         Name
'('           Punctuation
'convert'     Name
'('           Punctuation
'Int'         Keyword.Type
','           Punctuation
' '           Text
'ndig'        Name
')'           Punctuation
','           Punctuation
' '           Text
'l'           Name
')'           Punctuation
' '           Text
'+'           Operator
' '           Text
'neg'         Name
'\n'          Text

'    '        Text
'data'        Name
' '           Text
'='           Operator
' '           Text
'Array'       Keyword.Type
'('           Punctuation
'Uint8'       Name
','           Punctuation
' '           Text
'sz'          Name
')'           Punctuation
'\n'          Text

'    '        Text
'i'           Name
' '           Text
'='           Operator
' '           Text
'sz'          Name
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'ispow2'      Name
'('           Punctuation
'b'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'digmask'     Name
' '           Text
'='           Operator
' '           Text
'b'           Name
'-'           Operator
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'shift'       Name
' '           Text
'='           Operator
' '           Text
'trailing_zeros' Name
'('           Punctuation
'b'           Name
')'           Punctuation
'\n'          Text

'        '    Text
'while'       Keyword
' '           Text
'i'           Name
' '           Text
'>'           Operator
' '           Text
'neg'         Name
'\n'          Text

'            ' Text
'ch'          Name
' '           Text
'='           Operator
' '           Text
'n'           Name
' '           Text
'&'           Operator
' '           Text
'digmask'     Name
'\n'          Text

'            ' Text
'data'        Name
'['           Punctuation
'i'           Name
']'           Punctuation
' '           Text
'='           Operator
' '           Text
'_jl_dig_syms' Name
'['           Punctuation
'int'         Name
'('           Punctuation
'ch'          Name
')'           Punctuation
'+'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
'\n'          Text

'            ' Text
'n'           Name
' '           Text
'>>='         Operator
' '           Text
'shift'       Name
'\n'          Text

'            ' Text
'i'           Name
' '           Text
'-='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'else'        Keyword
'\n'          Text

'        '    Text
'while'       Keyword
' '           Text
'i'           Name
' '           Text
'>'           Operator
' '           Text
'neg'         Name
'\n'          Text

'            ' Text
'ch'          Name
' '           Text
'='           Operator
' '           Text
'n'           Name
' '           Text
'%'           Operator
' '           Text
'b'           Name
'\n'          Text

'            ' Text
'data'        Name
'['           Punctuation
'i'           Name
']'           Punctuation
' '           Text
'='           Operator
' '           Text
'_jl_dig_syms' Name
'['           Punctuation
'int'         Name
'('           Punctuation
'ch'          Name
')'           Punctuation
'+'           Operator
'1'           Literal.Number.Integer
']'           Punctuation
'\n'          Text

'            ' Text
'n'           Name
' '           Text
'='           Operator
' '           Text
'div'         Name
'('           Punctuation
'n'           Name
','           Punctuation
'b'           Name
')'           Punctuation
'\n'          Text

'            ' Text
'i'           Name
' '           Text
'-='          Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'if'          Keyword
' '           Text
'neg'         Name
'\n'          Text

'        '    Text
'data'        Name
'['           Punctuation
'1'           Literal.Number.Integer
']'           Punctuation
' '           Text
'='           Operator
' '           Text
"'-'"         Literal.String.Char
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'ASCIIString' Keyword.Type
'('           Punctuation
'data'        Name
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'int2str'     Name
'('           Punctuation
'n'           Name
'::'          Operator
'Integer'     Keyword.Type
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'         '   Text
'='           Operator
' '           Text
'int2str'     Name
'('           Punctuation
'n'           Name
','           Punctuation
' '           Text
'b'           Name
','           Punctuation
' '           Text
'0'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'int2str'     Name
'('           Punctuation
'n'           Name
'::'          Operator
'Integer'     Keyword.Type
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'Integer'     Keyword.Type
','           Punctuation
' '           Text
'l'           Name
'::'          Operator
'Int'         Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'int2str'     Name
'('           Punctuation
'int64'       Name
'('           Punctuation
'n'           Name
')'           Punctuation
','           Punctuation
' '           Text
'b'           Name
','           Punctuation
' '           Text
'l'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'string'      Name
'('           Punctuation
'x'           Name
'::'          Operator
'Signed'      Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'dec'         Name
'('           Punctuation
'int64'       Name
'('           Punctuation
'x'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'cstring'     Name
'('           Punctuation
'x'           Name
'::'          Operator
'Signed'      Keyword.Type
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'dec'         Name
'('           Punctuation
'int64'       Name
'('           Punctuation
'x'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'## string to float functions ##' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'float64_isvalid' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'out'         Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Float64'     Keyword.Type
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
's'           Name
' '           Text
'='           Operator
' '           Text
'cstring'     Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'return'      Keyword
' '           Text
'('           Punctuation
'ccall'       Keyword
'('           Punctuation
':'           Operator
'jl_strtod'   Name
','           Punctuation
' '           Text
'Int32'       Keyword.Type
','           Punctuation
' '           Text
'('           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Float64'     Keyword.Type
'}'           Punctuation
')'           Punctuation
','           Punctuation
' '           Text
's'           Name
','           Punctuation
' '           Text
'out'         Name
')'           Punctuation
'=='          Operator
'0'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'float32_isvalid' Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
','           Punctuation
' '           Text
'out'         Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Float32'     Keyword.Type
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
's'           Name
' '           Text
'='           Operator
' '           Text
'cstring'     Name
'('           Punctuation
's'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'return'      Keyword
' '           Text
'('           Punctuation
'ccall'       Keyword
'('           Punctuation
':'           Operator
'jl_strtof'   Name
','           Punctuation
' '           Text
'Int32'       Keyword.Type
','           Punctuation
' '           Text
'('           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Float32'     Keyword.Type
'}'           Punctuation
')'           Punctuation
','           Punctuation
' '           Text
's'           Name
','           Punctuation
' '           Text
'out'         Name
')'           Punctuation
'=='          Operator
'0'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'begin'       Keyword
'\n'          Text

'    '        Text
'local'       Keyword.Declaration
' '           Text
'tmp'         Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Float64'     Keyword.Type
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
' '           Text
'='           Operator
' '           Text
'Array'       Keyword.Type
'('           Punctuation
'Float64'     Keyword.Type
','           Punctuation
'1'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'    '        Text
'local'       Keyword.Declaration
' '           Text
'tmpf'        Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Float32'     Keyword.Type
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
' '           Text
'='           Operator
' '           Text
'Array'       Keyword.Type
'('           Punctuation
'Float32'     Keyword.Type
','           Punctuation
'1'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'    '        Text
'global'      Keyword.Declaration
' '           Text
'float64'     Name
','           Punctuation
' '           Text
'float32'     Name
'\n'          Text

'    '        Text
'function'    Keyword
' '           Text
'float64'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'!'           Operator
'float64_isvalid' Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'tmp'         Name
')'           Punctuation
'\n'          Text

'            ' Text
'throw'       Name
'('           Punctuation
'ArgumentError' Keyword.Type
'('           Punctuation
'"'           Literal.String
'f'           Literal.String
'l'           Literal.String
'o'           Literal.String
'a'           Literal.String
't'           Literal.String
'6'           Literal.String
'4'           Literal.String
'('           Literal.String
'S'           Literal.String
't'           Literal.String
'r'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
')'           Literal.String
':'           Literal.String
' '           Literal.String
'i'           Literal.String
'n'           Literal.String
'v'           Literal.String
'a'           Literal.String
'l'           Literal.String
'i'           Literal.String
'd'           Literal.String
' '           Literal.String
'n'           Literal.String
'u'           Literal.String
'm'           Literal.String
'b'           Literal.String
'e'           Literal.String
'r'           Literal.String
' '           Literal.String
'f'           Literal.String
'o'           Literal.String
'r'           Literal.String
'm'           Literal.String
'a'           Literal.String
't'           Literal.String
'"'           Literal.String
')'           Punctuation
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'return'      Keyword
' '           Text
'tmp'         Name
'['           Punctuation
'1'           Literal.Number.Integer
']'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'\n'          Text

'    '        Text
'function'    Keyword
' '           Text
'float32'     Name
'('           Punctuation
's'           Name
'::'          Operator
'String'      Name
')'           Punctuation
'\n'          Text

'        '    Text
'if'          Keyword
' '           Text
'!'           Operator
'float32_isvalid' Name
'('           Punctuation
's'           Name
','           Punctuation
' '           Text
'tmpf'        Name
')'           Punctuation
'\n'          Text

'            ' Text
'throw'       Name
'('           Punctuation
'ArgumentError' Keyword.Type
'('           Punctuation
'"'           Literal.String
'f'           Literal.String
'l'           Literal.String
'o'           Literal.String
'a'           Literal.String
't'           Literal.String
'3'           Literal.String
'2'           Literal.String
'('           Literal.String
'S'           Literal.String
't'           Literal.String
'r'           Literal.String
'i'           Literal.String
'n'           Literal.String
'g'           Literal.String
')'           Literal.String
':'           Literal.String
' '           Literal.String
'i'           Literal.String
'n'           Literal.String
'v'           Literal.String
'a'           Literal.String
'l'           Literal.String
'i'           Literal.String
'd'           Literal.String
' '           Literal.String
'n'           Literal.String
'u'           Literal.String
'm'           Literal.String
'b'           Literal.String
'e'           Literal.String
'r'           Literal.String
' '           Literal.String
'f'           Literal.String
'o'           Literal.String
'r'           Literal.String
'm'           Literal.String
'a'           Literal.String
't'           Literal.String
'"'           Literal.String
')'           Punctuation
')'           Punctuation
'\n'          Text

'        '    Text
'end'         Keyword
'\n'          Text

'        '    Text
'return'      Keyword
' '           Text
'tmpf'        Name
'['           Punctuation
'1'           Literal.Number.Integer
']'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'float'       Name
'('           Punctuation
'x'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'float64'     Name
'('           Punctuation
'x'           Name
')'           Punctuation
'\n'          Text

'parse_float' Name
'('           Punctuation
'x'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'float64'     Name
'('           Punctuation
'x'           Name
')'           Punctuation
'\n'          Text

'parse_float' Name
'('           Punctuation
'::'          Operator
'Type'        Keyword.Type
'{'           Punctuation
'Float64'     Keyword.Type
'}'           Punctuation
','           Punctuation
' '           Text
'x'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'float64'     Name
'('           Punctuation
'x'           Name
')'           Punctuation
'\n'          Text

'parse_float' Name
'('           Punctuation
'::'          Operator
'Type'        Keyword.Type
'{'           Punctuation
'Float32'     Keyword.Type
'}'           Punctuation
','           Punctuation
' '           Text
'x'           Name
'::'          Operator
'String'      Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'float32'     Name
'('           Punctuation
'x'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'# copying a byte string (generally not needed due to "immutability")' Comment
'\n'          Text

'\n'          Text

'strcpy'      Name
'{'           Punctuation
'T'           Name
'<:'          Operator
'ByteString'  Name
'}'           Punctuation
'('           Punctuation
's'           Name
'::'          Operator
'T'           Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'T'           Name
'('           Punctuation
'copy'        Name
'('           Punctuation
's'           Name
'.'           Operator
'data'        Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'\n'          Text

'# lexicographically compare byte arrays (used by Latin-1 and UTF-8)' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'lexcmp'      Name
'('           Punctuation
'a'           Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Uint8'       Name
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Uint8'       Name
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'c'           Name
' '           Text
'='           Operator
' '           Text
'ccall'       Keyword
'('           Punctuation
':'           Operator
'memcmp'      Name
','           Punctuation
' '           Text
'Int32'       Keyword.Type
','           Punctuation
' '           Text
'('           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
' '           Text
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
' '           Text
'Uint'        Name
')'           Punctuation
','           Punctuation
'\n'          Text

'              ' Text
'a'           Name
','           Punctuation
' '           Text
'b'           Name
','           Punctuation
' '           Text
'min'         Name
'('           Punctuation
'length'      Name
'('           Punctuation
'a'           Name
')'           Punctuation
','           Punctuation
'length'      Name
'('           Punctuation
'b'           Name
')'           Punctuation
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'c'           Name
' '           Text
'<'           Operator
' '           Text
'0'           Literal.Number.Integer
' '           Text
'?'           Operator
' '           Text
'-'           Operator
'1'           Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'c'           Name
' '           Text
'>'           Operator
' '           Text
'0'           Literal.Number.Integer
' '           Text
'?'           Operator
' '           Text
'+'           Operator
'1'           Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'cmp'         Name
'('           Punctuation
'length'      Name
'('           Punctuation
'a'           Name
')'           Punctuation
','           Punctuation
'length'      Name
'('           Punctuation
'b'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'# find the index of the first occurrence of a byte value in a byte array' Comment
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'memchr'      Name
'('           Punctuation
'a'           Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Uint8'       Name
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
','           Punctuation
' '           Text
'b'           Name
'::'          Operator
'Integer'     Keyword.Type
')'           Punctuation
'\n'          Text

'    '        Text
'p'           Name
' '           Text
'='           Operator
' '           Text
'pointer'     Name
'('           Punctuation
'a'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'q'           Name
' '           Text
'='           Operator
' '           Text
'ccall'       Keyword
'('           Punctuation
':'           Operator
'memchr'      Name
','           Punctuation
' '           Text
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
' '           Text
'('           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
' '           Text
'Int32'       Keyword.Type
','           Punctuation
' '           Text
'Uint'        Name
')'           Punctuation
','           Punctuation
' '           Text
'p'           Name
','           Punctuation
' '           Text
'b'           Name
','           Punctuation
' '           Text
'length'      Name
'('           Punctuation
'a'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'    '        Text
'q'           Name
' '           Text
'=='          Operator
' '           Text
'C_NULL'      Name.Builtin
' '           Text
'?'           Operator
' '           Text
'0'           Literal.Number.Integer
' '           Text
':'           Operator
' '           Text
'q'           Name
' '           Text
'-'           Operator
' '           Text
'p'           Name
' '           Text
'+'           Operator
' '           Text
'1'           Literal.Number.Integer
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'# concatenate byte arrays into a single array' Comment
'\n'          Text

'\n'          Text

'memcat'      Name
'('           Punctuation
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'Array'       Keyword.Type
'('           Punctuation
'Uint8'       Name
','           Punctuation
'0'           Literal.Number.Integer
')'           Punctuation
'\n'          Text

'memcat'      Name
'('           Punctuation
'a'           Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Uint8'       Name
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'copy'        Name
'('           Punctuation
'a'           Name
')'           Punctuation
'\n'          Text

'\n'          Text

'function'    Keyword
' '           Text
'memcat'      Name
'('           Punctuation
'arrays'      Name
'::'          Operator
'Array'       Keyword.Type
'{'           Punctuation
'Uint8'       Name
','           Punctuation
'1'           Literal.Number.Integer
'}'           Punctuation
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text

'    '        Text
'n'           Name
' '           Text
'='           Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'a'           Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
'arrays'      Name
'\n'          Text

'        '    Text
'n'           Name
' '           Text
'+='          Operator
' '           Text
'length'      Name
'('           Punctuation
'a'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'arr'         Name
' '           Text
'='           Operator
' '           Text
'Array'       Keyword.Type
'('           Punctuation
'Uint8'       Name
','           Punctuation
' '           Text
'n'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'ptr'         Name
' '           Text
'='           Operator
' '           Text
'pointer'     Name
'('           Punctuation
'arr'         Name
')'           Punctuation
'\n'          Text

'    '        Text
'offset'      Name
' '           Text
'='           Operator
' '           Text
'0'           Literal.Number.Integer
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'a'           Name
' '           Text
'in'          Keyword.Pseudo
' '           Text
'arrays'      Name
'\n'          Text

'        '    Text
'ccall'       Keyword
'('           Punctuation
':'           Operator
'memcpy'      Name
','           Punctuation
' '           Text
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
' '           Text
'('           Punctuation
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
' '           Text
'Ptr'         Keyword.Type
'{'           Punctuation
'Uint8'       Name
'}'           Punctuation
','           Punctuation
' '           Text
'Uint'        Name
')'           Punctuation
','           Punctuation
'\n'          Text

'              ' Text
'ptr'         Name
'+'           Operator
'offset'      Name
','           Punctuation
' '           Text
'a'           Name
','           Punctuation
' '           Text
'length'      Name
'('           Punctuation
'a'           Name
')'           Punctuation
')'           Punctuation
'\n'          Text

'        '    Text
'offset'      Name
' '           Text
'+='          Operator
' '           Text
'length'      Name
'('           Punctuation
'a'           Name
')'           Punctuation
'\n'          Text

'    '        Text
'end'         Keyword
'\n'          Text

'    '        Text
'return'      Keyword
' '           Text
'arr'         Name
'\n'          Text

'end'         Keyword
'\n'          Text

'\n'          Text

'# concatenate the data fields of byte strings' Comment
'\n'          Text

'\n'          Text

'memcat'      Name
'('           Punctuation
's'           Name
'::'          Operator
'ByteString'  Name
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'memcat'      Name
'('           Punctuation
's'           Name
'.'           Operator
'data'        Name
')'           Punctuation
'\n'          Text

'memcat'      Name
'('           Punctuation
'sx'          Name
'::'          Operator
'ByteString'  Name
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'memcat'      Name
'('           Punctuation
'map'         Name
'('           Punctuation
's'           Name
'-'           Operator
'>'           Operator
's'           Name
'.'           Operator
'data'        Name
','           Punctuation
' '           Text
'sx'          Name
')'           Punctuation
'.'           Operator
'.'           Operator
'.'           Operator
')'           Punctuation
'\n'          Text
