module Text.Highlighter.Lexers.Ocaml (lexer) where

import Text.Regex.PCRE.Light
import Text.Highlighter.Types

lexer :: Lexer
lexer = Lexer
    { lName = "\79\67\97\109\108"
    , lAliases = ["\111\99\97\109\108"]
    , lExtensions = ["\46\109\108", "\46\109\108\105", "\46\109\108\108", "\46\109\108\121"]
    , lMimetypes = ["\116\101\120\116\47\120\45\111\99\97\109\108"]
    , lStart = root'
    , lFlags = [multiline]
    }

comment' :: TokenMatcher
comment' =
    [ tok "\91\94\40\42\41\93\43" (Arbitrary "\67\111\109\109\101\110\116")
    , tokNext "\92\40\92\42" (Arbitrary "\67\111\109\109\101\110\116") Push
    , tokNext "\92\42\92\41" (Arbitrary "\67\111\109\109\101\110\116") Pop
    , tok "\91\40\42\41\93" (Arbitrary "\67\111\109\109\101\110\116")
    ]

root' :: TokenMatcher
root' =
    [ tok "\92\115\43" (Arbitrary "\84\101\120\116")
    , tok "\102\97\108\115\101\124\116\114\117\101\124\92\40\92\41\124\92\91\92\93" (Arbitrary "\78\97\109\101" :. Arbitrary "\66\117\105\108\116\105\110" :. Arbitrary "\80\115\101\117\100\111")
    , tokNext "\92\98\40\91\65\45\90\93\91\65\45\90\97\45\122\48\45\57\95\92\39\93\42\41\40\63\61\92\115\42\92\46\41" (Arbitrary "\78\97\109\101" :. Arbitrary "\78\97\109\101\115\112\97\99\101") (GoTo dotted')
    , tok "\92\98\40\91\65\45\90\93\91\65\45\90\97\45\122\48\45\57\95\92\39\93\42\41" (Arbitrary "\78\97\109\101" :. Arbitrary "\67\108\97\115\115")
    , tokNext "\92\40\92\42" (Arbitrary "\67\111\109\109\101\110\116") (GoTo comment')
    , tok "\92\98\40\97\115\124\97\115\115\101\114\116\124\98\101\103\105\110\124\99\108\97\115\115\124\99\111\110\115\116\114\97\105\110\116\124\100\111\124\100\111\110\101\124\100\111\119\110\116\111\124\101\108\115\101\124\101\110\100\124\101\120\99\101\112\116\105\111\110\124\101\120\116\101\114\110\97\108\124\102\97\108\115\101\124\102\111\114\124\102\117\110\124\102\117\110\99\116\105\111\110\124\102\117\110\99\116\111\114\124\105\102\124\105\110\124\105\110\99\108\117\100\101\124\105\110\104\101\114\105\116\124\105\110\105\116\105\97\108\105\122\101\114\124\108\97\122\121\124\108\101\116\124\109\97\116\99\104\124\109\101\116\104\111\100\124\109\111\100\117\108\101\124\109\117\116\97\98\108\101\124\110\101\119\124\111\98\106\101\99\116\124\111\102\124\111\112\101\110\124\112\114\105\118\97\116\101\124\114\97\105\115\101\124\114\101\99\124\115\105\103\124\115\116\114\117\99\116\124\116\104\101\110\124\116\111\124\116\114\117\101\124\116\114\121\124\116\121\112\101\124\118\97\108\124\118\105\114\116\117\97\108\124\119\104\101\110\124\119\104\105\108\101\124\119\105\116\104\41\92\98" (Arbitrary "\75\101\121\119\111\114\100")
    , tok "\40\33\61\124\35\124\38\124\38\38\124\92\40\124\92\41\124\92\42\124\92\43\124\44\124\45\124\45\92\46\124\45\62\124\92\46\124\92\46\92\46\124\58\124\58\58\124\58\61\124\58\62\124\59\124\59\59\124\60\124\60\45\124\61\124\62\124\62\93\124\62\125\124\92\63\124\92\63\92\63\124\92\91\124\92\91\60\124\92\91\62\124\92\91\92\124\124\93\124\95\124\96\124\123\124\123\60\124\92\124\124\92\124\93\124\125\124\126\41" (Arbitrary "\79\112\101\114\97\116\111\114")
    , tok "\40\91\61\60\62\64\94\124\38\43\92\42\47\36\37\45\93\124\91\33\63\126\93\41\63\91\33\36\37\38\42\43\92\46\47\58\60\61\62\63\64\94\124\126\45\93" (Arbitrary "\79\112\101\114\97\116\111\114")
    , tok "\92\98\40\97\110\100\124\97\115\114\124\108\97\110\100\124\108\111\114\124\108\115\108\124\108\120\111\114\124\109\111\100\124\111\114\41\92\98" (Arbitrary "\79\112\101\114\97\116\111\114" :. Arbitrary "\87\111\114\100")
    , tok "\92\98\40\117\110\105\116\124\105\110\116\124\102\108\111\97\116\124\98\111\111\108\124\115\116\114\105\110\103\124\99\104\97\114\124\108\105\115\116\124\97\114\114\97\121\41\92\98" (Arbitrary "\75\101\121\119\111\114\100" :. Arbitrary "\84\121\112\101")
    , tok "\91\94\92\87\92\100\93\91\92\119\39\93\42" (Arbitrary "\78\97\109\101")
    , tok "\92\100\91\92\100\95\93\42" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\78\117\109\98\101\114" :. Arbitrary "\73\110\116\101\103\101\114")
    , tok "\48\91\120\88\93\91\92\100\97\45\102\65\45\70\93\91\92\100\97\45\102\65\45\70\95\93\42" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\78\117\109\98\101\114" :. Arbitrary "\72\101\120")
    , tok "\48\91\111\79\93\91\48\45\55\93\91\48\45\55\95\93\42" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\78\117\109\98\101\114" :. Arbitrary "\79\99\116")
    , tok "\48\91\98\66\93\91\48\49\93\91\48\49\95\93\42" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\78\117\109\98\101\114" :. Arbitrary "\66\105\110\97\114\121")
    , tok "\45\63\92\100\91\92\100\95\93\42\40\46\91\92\100\95\93\42\41\63\40\91\101\69\93\91\43\92\45\93\63\92\100\91\92\100\95\93\42\41" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\78\117\109\98\101\114" :. Arbitrary "\70\108\111\97\116")
    , tok "\39\40\63\58\40\92\92\91\92\92\92\34\39\110\116\98\114\32\93\41\124\40\92\92\91\48\45\57\93\123\51\125\41\124\40\92\92\120\91\48\45\57\97\45\102\65\45\70\93\123\50\125\41\41\39" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\83\116\114\105\110\103" :. Arbitrary "\67\104\97\114")
    , tok "\39\46\39" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\83\116\114\105\110\103" :. Arbitrary "\67\104\97\114")
    , tok "\39" (Arbitrary "\75\101\121\119\111\114\100")
    , tokNext "\34" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\83\116\114\105\110\103" :. Arbitrary "\68\111\117\98\108\101") (GoTo string')
    , tok "\91\126\63\93\91\97\45\122\93\91\92\119\92\39\93\42\58" (Arbitrary "\78\97\109\101" :. Arbitrary "\86\97\114\105\97\98\108\101")
    ]

string' :: TokenMatcher
string' =
    [ tok "\91\94\92\92\34\93\43" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\83\116\114\105\110\103" :. Arbitrary "\68\111\117\98\108\101")
    , anyOf escapeSequence'
    , tok "\92\92\92\110" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\83\116\114\105\110\103" :. Arbitrary "\68\111\117\98\108\101")
    , tokNext "\34" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\83\116\114\105\110\103" :. Arbitrary "\68\111\117\98\108\101") Pop
    ]

escapeSequence' :: TokenMatcher
escapeSequence' =
    [ tok "\92\92\91\92\34\92\39\110\116\98\114\93" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\83\116\114\105\110\103" :. Arbitrary "\69\115\99\97\112\101")
    , tok "\92\92\91\48\45\57\93\123\51\125" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\83\116\114\105\110\103" :. Arbitrary "\69\115\99\97\112\101")
    , tok "\92\92\120\91\48\45\57\97\45\102\65\45\70\93\123\50\125" (Arbitrary "\76\105\116\101\114\97\108" :. Arbitrary "\83\116\114\105\110\103" :. Arbitrary "\69\115\99\97\112\101")
    ]

dotted' :: TokenMatcher
dotted' =
    [ tok "\92\115\43" (Arbitrary "\84\101\120\116")
    , tok "\92\46" (Arbitrary "\80\117\110\99\116\117\97\116\105\111\110")
    , tok "\91\65\45\90\93\91\65\45\90\97\45\122\48\45\57\95\92\39\93\42\40\63\61\92\115\42\92\46\41" (Arbitrary "\78\97\109\101" :. Arbitrary "\78\97\109\101\115\112\97\99\101")
    , tokNext "\91\65\45\90\93\91\65\45\90\97\45\122\48\45\57\95\92\39\93\42" (Arbitrary "\78\97\109\101" :. Arbitrary "\67\108\97\115\115") Pop
    , tokNext "\91\97\45\122\93\91\97\45\122\48\45\57\95\92\39\93\42" (Arbitrary "\78\97\109\101") Pop
    ]