From 67fb64311aecbe5105eb07a96eb9f05ca178d05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=BAeen?= <3han5chou7@gmail.com> Date: Mon, 2 Dec 2019 16:17:22 +0900 Subject: [PATCH] add SML lexer (#310) --- README.md | 2 +- lexers/s/sml.go | 200 ++++++++++++++++++ lexers/testdata/sml.actual | 44 ++++ lexers/testdata/sml.expected | 391 +++++++++++++++++++++++++++++++++++ 4 files changed, 636 insertions(+), 1 deletion(-) create mode 100644 lexers/s/sml.go create mode 100644 lexers/testdata/sml.actual create mode 100644 lexers/testdata/sml.expected diff --git a/README.md b/README.md index ac51f49..2c857cd 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ O | Objective-C, OCaml, Octave, OpenSCAD, Org Mode P | PacmanConf, Perl, PHP, Pig, PkgConfig, PL/pgSQL, plaintext, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, Protocol Buffer, Puppet, Python, Python 3 Q | QBasic R | R, Racket, Ragel, react, reg, reStructuredText, Rexx, Ruby, Rust -S | Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, Snobol, Solidity, SPARQL, SQL, SquidConf, Swift, SYSTEMD, systemverilog +S | Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, SML, Snobol, Solidity, SPARQL, SQL, SquidConf, Swift, SYSTEMD, systemverilog T | TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData V | VB.net, verilog, VHDL, VimL, vue W | WDTE diff --git a/lexers/s/sml.go b/lexers/s/sml.go new file mode 100644 index 0000000..f716d92 --- /dev/null +++ b/lexers/s/sml.go @@ -0,0 +1,200 @@ +package s + +import ( + . "github.com/alecthomas/chroma" // nolint + "github.com/alecthomas/chroma/lexers/internal" +) + +// Standard ML lexer. +var StandardML = internal.Register(MustNewLexer( + &Config{ + Name: "Standard ML", + Aliases: []string{"sml"}, + Filenames: []string{"*.sml", "*.sig", "*.fun"}, + MimeTypes: []string{"text/x-standardml", "application/x-standardml"}, + }, + Rules{ + "whitespace": { + {`\s+`, Text, nil}, + {`\(\*`, CommentMultiline, Push("comment")}, + }, + "delimiters": { + {`\(|\[|\{`, Punctuation, Push("main")}, + {`\)|\]|\}`, Punctuation, Pop(1)}, + {`\b(let|if|local)\b(?!\')`, KeywordReserved, Push("main", "main")}, + {`\b(struct|sig|while)\b(?!\')`, KeywordReserved, Push("main")}, + {`\b(do|else|end|in|then)\b(?!\')`, KeywordReserved, Pop(1)}, + }, + "core": { + {`(_|\}|\{|\)|;|,|\[|\(|\]|\.\.\.)`, Punctuation, nil}, + {`#"`, LiteralStringChar, Push("char")}, + {`"`, LiteralStringDouble, Push("string")}, + {`~?0x[0-9a-fA-F]+`, LiteralNumberHex, nil}, + {`0wx[0-9a-fA-F]+`, LiteralNumberHex, nil}, + {`0w\d+`, LiteralNumberInteger, nil}, + {`~?\d+\.\d+[eE]~?\d+`, LiteralNumberFloat, nil}, + {`~?\d+\.\d+`, LiteralNumberFloat, nil}, + {`~?\d+[eE]~?\d+`, LiteralNumberFloat, nil}, + {`~?\d+`, LiteralNumberInteger, nil}, + {`#\s*[1-9][0-9]*`, NameLabel, nil}, + {`#\s*([a-zA-Z][\w']*)`, NameLabel, nil}, + {"#\\s+([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameLabel, nil}, + {`\b(datatype|abstype)\b(?!\')`, KeywordReserved, Push("dname")}, + {`(?=\b(exception)\b(?!\'))`, Text, Push("ename")}, + {`\b(functor|include|open|signature|structure)\b(?!\')`, KeywordReserved, Push("sname")}, + {`\b(type|eqtype)\b(?!\')`, KeywordReserved, Push("tname")}, + {`\'[\w\']*`, NameDecorator, nil}, + {`([a-zA-Z][\w']*)(\.)`, NameNamespace, Push("dotted")}, + {`\b(abstype|and|andalso|as|case|datatype|do|else|end|exception|fn|fun|handle|if|in|infix|infixr|let|local|nonfix|of|op|open|orelse|raise|rec|then|type|val|with|withtype|while|eqtype|functor|include|sharing|sig|signature|struct|structure|where)\b`, KeywordReserved, nil}, + {`([a-zA-Z][\w']*)`, Name, nil}, + {`\b(:|\|,=|=>|->|#|:>)\b`, KeywordReserved, nil}, + {"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Name, nil}, + }, + "dotted": { + {`([a-zA-Z][\w']*)(\.)`, NameNamespace, nil}, + // ignoring reserved words + {`([a-zA-Z][\w']*)`, Name, Pop(1)}, + // ignoring reserved words + {"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Name, Pop(1)}, + {`\s+`, Error, nil}, + {`\S+`, Error, nil}, + }, + "root": { + Default(Push("main")), + }, + "main": { + Include("whitespace"), + {`\b(val|and)\b(?!\')`, KeywordReserved, Push("vname")}, + {`\b(fun)\b(?!\')`, KeywordReserved, Push("#pop", "main-fun", "fname")}, + Include("delimiters"), + Include("core"), + {`\S+`, Error, nil}, + }, + "main-fun": { + Include("whitespace"), + {`\s`, Text, nil}, + {`\(\*`, CommentMultiline, Push("comment")}, + {`\b(fun|and)\b(?!\')`, KeywordReserved, Push("fname")}, + {`\b(val)\b(?!\')`, KeywordReserved, Push("#pop", "main", "vname")}, + {`\|`, Punctuation, Push("fname")}, + {`\b(case|handle)\b(?!\')`, KeywordReserved, Push("#pop", "main")}, + Include("delimiters"), + Include("core"), + {`\S+`, Error, nil}, + }, + "char": { + {`[^"\\]`, LiteralStringChar, nil}, + {`\\[\\"abtnvfr]`, LiteralStringEscape, nil}, + {`\\\^[\x40-\x5e]`, LiteralStringEscape, nil}, + {`\\[0-9]{3}`, LiteralStringEscape, nil}, + {`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil}, + {`\\\s+\\`, LiteralStringInterpol, nil}, + {`"`, LiteralStringChar, Pop(1)}, + }, + "string": { + {`[^"\\]`, LiteralStringDouble, nil}, + {`\\[\\"abtnvfr]`, LiteralStringEscape, nil}, + {`\\\^[\x40-\x5e]`, LiteralStringEscape, nil}, + {`\\[0-9]{3}`, LiteralStringEscape, nil}, + {`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil}, + {`\\\s+\\`, LiteralStringInterpol, nil}, + {`"`, LiteralStringDouble, Pop(1)}, + }, + "breakout": { + {`(?=\b(where|do|handle|if|sig|op|while|case|as|else|signature|andalso|struct|infixr|functor|in|structure|then|local|rec|end|fun|of|orelse|val|include|fn|with|exception|let|and|infix|sharing|datatype|type|abstype|withtype|eqtype|nonfix|raise|open)\b(?!\'))`, Text, Pop(1)}, + }, + "sname": { + Include("whitespace"), + Include("breakout"), + {`([a-zA-Z][\w']*)`, NameNamespace, nil}, + Default(Pop(1)), + }, + "fname": { + Include("whitespace"), + {`\'[\w\']*`, NameDecorator, nil}, + {`\(`, Punctuation, Push("tyvarseq")}, + {`([a-zA-Z][\w']*)`, NameFunction, Pop(1)}, + {"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameFunction, Pop(1)}, + Default(Pop(1)), + }, + "vname": { + Include("whitespace"), + {`\'[\w\']*`, NameDecorator, nil}, + {`\(`, Punctuation, Push("tyvarseq")}, + {"([a-zA-Z][\\w']*)(\\s*)(=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+))", ByGroups(NameVariable, Text, Punctuation), Pop(1)}, + {"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)(\\s*)(=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+))", ByGroups(NameVariable, Text, Punctuation), Pop(1)}, + {`([a-zA-Z][\w']*)`, NameVariable, Pop(1)}, + {"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameVariable, Pop(1)}, + Default(Pop(1)), + }, + "tname": { + Include("whitespace"), + Include("breakout"), + {`\'[\w\']*`, NameDecorator, nil}, + {`\(`, Punctuation, Push("tyvarseq")}, + {"=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Punctuation, Push("#pop", "typbind")}, + {`([a-zA-Z][\w']*)`, KeywordType, nil}, + {"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", KeywordType, nil}, + {`\S+`, Error, Pop(1)}, + }, + "typbind": { + Include("whitespace"), + {`\b(and)\b(?!\')`, KeywordReserved, Push("#pop", "tname")}, + Include("breakout"), + Include("core"), + {`\S+`, Error, Pop(1)}, + }, + "dname": { + Include("whitespace"), + Include("breakout"), + {`\'[\w\']*`, NameDecorator, nil}, + {`\(`, Punctuation, Push("tyvarseq")}, + {`(=)(\s*)(datatype)`, ByGroups(Punctuation, Text, KeywordReserved), Pop(1)}, + {"=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Punctuation, Push("#pop", "datbind", "datcon")}, + {`([a-zA-Z][\w']*)`, KeywordType, nil}, + {"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", KeywordType, nil}, + {`\S+`, Error, Pop(1)}, + }, + "datbind": { + Include("whitespace"), + {`\b(and)\b(?!\')`, KeywordReserved, Push("#pop", "dname")}, + {`\b(withtype)\b(?!\')`, KeywordReserved, Push("#pop", "tname")}, + {`\b(of)\b(?!\')`, KeywordReserved, nil}, + {`(\|)(\s*)([a-zA-Z][\w']*)`, ByGroups(Punctuation, Text, NameClass), nil}, + {"(\\|)(\\s+)([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", ByGroups(Punctuation, Text, NameClass), nil}, + Include("breakout"), + Include("core"), + {`\S+`, Error, nil}, + }, + "ename": { + Include("whitespace"), + {`(exception|and)\b(\s+)([a-zA-Z][\w']*)`, ByGroups(KeywordReserved, Text, NameClass), nil}, + {"(exception|and)\\b(\\s*)([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", ByGroups(KeywordReserved, Text, NameClass), nil}, + {`\b(of)\b(?!\')`, KeywordReserved, nil}, + Include("breakout"), + Include("core"), + {`\S+`, Error, nil}, + }, + "datcon": { + Include("whitespace"), + {`([a-zA-Z][\w']*)`, NameClass, Pop(1)}, + {"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameClass, Pop(1)}, + {`\S+`, Error, Pop(1)}, + }, + "tyvarseq": { + {`\s`, Text, nil}, + {`\(\*`, CommentMultiline, Push("comment")}, + {`\'[\w\']*`, NameDecorator, nil}, + {`[a-zA-Z][\w']*`, Name, nil}, + {`,`, Punctuation, nil}, + {`\)`, Punctuation, Pop(1)}, + {"[!%&$#+\\-/:<=>?@\\\\~`^|*]+", Name, nil}, + }, + "comment": { + {`[^(*)]`, CommentMultiline, nil}, + {`\(\*`, CommentMultiline, Push()}, + {`\*\)`, CommentMultiline, Pop(1)}, + {`[(*)]`, CommentMultiline, nil}, + }, + }, +)) diff --git a/lexers/testdata/sml.actual b/lexers/testdata/sml.actual new file mode 100644 index 0000000..d219e6f --- /dev/null +++ b/lexers/testdata/sml.actual @@ -0,0 +1,44 @@ +signature S = sig + datatype t = Hoge | Fuga +end + +structur A = struct + structure B = struct + structure C = struct + type t = int * real * string * bool ref + end + end +end + +functor F(X:sig type t; val compare: t * t -> order): S = struct + datatype t = Hoge | Fuga +end + +structure Main = struct + local + structure M = F(Int) + open M + in + fun id x = x + val bool = if true then false orelse false else true andalso true + val int = ~1 + 1 + val real = 0.7 - 0.32E5 * E3~7 + val string = "a\a\b\t\n\v\f\r\^M\097\u00a1\"\\\ + \" + (* (* comments *) *) + val ## = 1 + val |=| = 2 + infix ## + infixr ## + val op## = case Hoge of + Hoge => Fuga + | Fuga => Hoge + type s = {1: t, label: unit} + type u = A.B.C.t + val s = {1 = Hoge, label = ()} + fun id x = x + val rec id = fn x => x + exception X and Y + raise X handle X => (nil, [1], [1, 2]) + end +end diff --git a/lexers/testdata/sml.expected b/lexers/testdata/sml.expected new file mode 100644 index 0000000..05cc29f --- /dev/null +++ b/lexers/testdata/sml.expected @@ -0,0 +1,391 @@ +[ + {"type":"KeywordReserved","value":"signature"}, + {"type":"Text","value":" "}, + {"type":"NameNamespace","value":"S"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"sig"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"datatype"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"t"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Hoge"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"|"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Fuga"}, + {"type":"Text","value":"\n"}, + {"type":"KeywordReserved","value":"end"}, + {"type":"Text","value":"\n\n"}, + {"type":"Name","value":"structur"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"A"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"struct"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"structure"}, + {"type":"Text","value":" "}, + {"type":"NameNamespace","value":"B"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"struct"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"structure"}, + {"type":"Text","value":" "}, + {"type":"NameNamespace","value":"C"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"struct"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"type"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"t"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"int"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"*"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"real"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"*"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"string"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"*"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"bool"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"ref"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"end"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"end"}, + {"type":"Text","value":"\n"}, + {"type":"KeywordReserved","value":"end"}, + {"type":"Text","value":"\n\n"}, + {"type":"KeywordReserved","value":"functor"}, + {"type":"Text","value":" "}, + {"type":"NameNamespace","value":"F"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"X"}, + {"type":"KeywordReserved","value":":sig"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"type"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"t"}, + {"type":"Error","value":";"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"compare"}, + {"type":"Name","value":":"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"t"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"*"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"t"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"order"}, + {"type":"Punctuation","value":")"}, + {"type":"Name","value":":"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"S"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"struct"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"datatype"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"t"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Hoge"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"|"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Fuga"}, + {"type":"Text","value":"\n"}, + {"type":"KeywordReserved","value":"end"}, + {"type":"Text","value":"\n\n"}, + {"type":"KeywordReserved","value":"structure"}, + {"type":"Text","value":" "}, + {"type":"NameNamespace","value":"Main"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"struct"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"local"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"structure"}, + {"type":"Text","value":" "}, + {"type":"NameNamespace","value":"M"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"F"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"Int"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"open"}, + {"type":"Text","value":" "}, + {"type":"NameNamespace","value":"M"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"in"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"fun"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"id"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"x"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"x"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"bool"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"if"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"true"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"then"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"false"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"orelse"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"false"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"else"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"true"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"andalso"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"true"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"int"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberInteger","value":"~1"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"+"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"real"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberFloat","value":"0.7"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"-"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberFloat","value":"0.32E5"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"*"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"E3"}, + {"type":"LiteralNumberInteger","value":"~7"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"string"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralStringDouble","value":"\"a"}, + {"type":"LiteralStringEscape","value":"\\a\\b\\t\\n\\v\\f\\r\\^M\\097\\u00a1\\\"\\\\"}, + {"type":"LiteralStringInterpol","value":"\\\n \\"}, + {"type":"LiteralStringDouble","value":"\""}, + {"type":"Text","value":"\n "}, + {"type":"CommentMultiline","value":"(* (* comments *) *)"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"##"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"|=|"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberInteger","value":"2"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"infix"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"##"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"infixr"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"##"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"op"}, + {"type":"Name","value":"##"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"case"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"Hoge"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"of"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"Hoge"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"=\u003e"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"Fuga"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"|"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"Fuga"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"=\u003e"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"Hoge"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"type"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"s"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Name","value":":"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"t"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"label:"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"unit"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"type"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"u"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"NameNamespace","value":"A.B.C."}, + {"type":"Name","value":"t"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"s"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"Hoge"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"label"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()}"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"fun"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"id"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"x"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"x"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"val"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"rec"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"id"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"fn"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"x"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"=\u003e"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"x"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"exception"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"X"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"and"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Y"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"raise"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"X"}, + {"type":"Text","value":" "}, + {"type":"KeywordReserved","value":"handle"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"X"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"=\u003e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"nil"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"["}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Punctuation","value":"],"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"["}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberInteger","value":"2"}, + {"type":"Punctuation","value":"])"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordReserved","value":"end"}, + {"type":"Text","value":"\n"}, + {"type":"KeywordReserved","value":"end"}, + {"type":"Text","value":"\n"} +]