From f1046d70de05c71c0f0cc809bb86707fb10cad0c Mon Sep 17 00:00:00 2001 From: ttay Date: Thu, 11 Jun 2020 23:20:01 +0800 Subject: [PATCH 1/2] Added pony lexer --- lexers/p/pony.go | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lexers/p/pony.go diff --git a/lexers/p/pony.go b/lexers/p/pony.go new file mode 100644 index 000000000..9696b2079 --- /dev/null +++ b/lexers/p/pony.go @@ -0,0 +1,59 @@ +package p + +import ( + . "github.com/alecthomas/chroma" // nolint + "github.com/alecthomas/chroma/lexers/internal" +) + +// Pony lexer. +var Pony = internal.Register(MustNewLexer( + &Config{ + Name: "Pony", + Aliases: []string{"pony"}, + Filenames: []string{"*.pony"}, + MimeTypes: []string{}, + }, + Rules{ + "root": { + {`\n`, Text, nil}, + {`[^\S\n]+`, Text, nil}, + {`//.*\n`, CommentSingle, nil}, + {`/\*`, CommentMultiline, Push("nested_comment")}, + {`"""(?:.|\n)*?"""`, LiteralStringDoc, nil}, + {`"`, LiteralString, Push("string")}, + {`\'.*\'`, LiteralStringChar, nil}, + {`=>|[]{}:().~;,|&!^?[]`, Punctuation, nil}, + {Words(``, `\b`, `addressof`, `and`, `as`, `consume`, `digestof`, `is`, `isnt`, `not`, `or`), OperatorWord, nil}, + {`!=|==|<<|>>|[-+/*%=<>]`, Operator, nil}, + {Words(``, `\b`, `box`, `break`, `compile_error`, `compile_intrinsic`, `continue`, `do`, `else`, `elseif`, `embed`, `end`, `error`, `for`, `if`, `ifdef`, `in`, `iso`, `lambda`, `let`, `match`, `object`, `recover`, `ref`, `repeat`, `return`, `tag`, `then`, `this`, `trn`, `try`, `until`, `use`, `var`, `val`, `where`, `while`, `with`, `#any`, `#read`, `#send`, `#share`), Keyword, nil}, + {`(actor|class|struct|primitive|interface|trait|type)((?:\s)+)`, ByGroups(Keyword, Text), Push("typename")}, + {`(new|fun|be)((?:\s)+)`, ByGroups(Keyword, Text), Push("methodname")}, + {Words(``, `\b`, `U8`, `U16`, `U32`, `U64`, `ULong`, `USize`, `U128`, `Unsigned`, `Stringable`, `String`, `StringBytes`, `StringRunes`, `InputNotify`, `InputStream`, `Stdin`, `ByteSeq`, `ByteSeqIter`, `OutStream`, `StdStream`, `SourceLoc`, `I8`, `I16`, `I32`, `I64`, `ILong`, `ISize`, `I128`, `Signed`, `Seq`, `RuntimeOptions`, `Real`, `Integer`, `SignedInteger`, `UnsignedInteger`, `FloatingPoint`, `Number`, `Int`, `ReadSeq`, `ReadElement`, `Pointer`, `Platform`, `NullablePointer`, `None`, `Iterator`, `F32`, `F64`, `Float`, `Env`, `DoNotOptimise`, `DisposableActor`, `Less`, `Equal`, `Greater`, `Compare`, `HasEq`, `Equatable`, `Comparable`, `Bool`, `AsioEventID`, `AsioEventNotify`, `AsioEvent`, `Array`, `ArrayKeys`, `ArrayValues`, `ArrayPairs`, `Any`, `AmbientAuth`), KeywordType, nil}, + {`_?[A-Z]\w*`, NameClass, nil}, + {`string\(\)`, NameOther, nil}, + {`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+`, LiteralNumberFloat, nil}, + {`0x[0-9a-fA-F]+`, LiteralNumberHex, nil}, + {`\d+`, LiteralNumberInteger, nil}, + {`(true|false)\b`, Keyword, nil}, + {`_\d*`, Name, nil}, + {`_?[a-z][\w\'_]*`, Name, nil}, + }, + "typename": { + {`(iso|trn|ref|val|box|tag)?((?:\s)*)(_?[A-Z]\w*)`, ByGroups(Keyword, Text, NameClass), Pop(1)}, + }, + "methodname": { + {`(iso|trn|ref|val|box|tag)?((?:\s)*)(_?[a-z]\w*)`, ByGroups(Keyword, Text, NameFunction), Pop(1)}, + }, + "nested_comment": { + {`[^*/]+`, CommentMultiline, nil}, + {`/\*`, CommentMultiline, Push()}, + {`\*/`, CommentMultiline, Pop(1)}, + {`[*/]`, CommentMultiline, nil}, + }, + "string": { + {`"`, LiteralString, Pop(1)}, + {`\\"`, LiteralString, nil}, + {`[^\\"]+`, LiteralString, nil}, + }, + }, +)) From aa531d7ee0656c99b698555abd753612d8c5f653 Mon Sep 17 00:00:00 2001 From: ttay Date: Fri, 12 Jun 2020 11:05:06 +0800 Subject: [PATCH 2/2] added tests --- lexers/testdata/pony.actual | 82 ++++++ lexers/testdata/pony.expected | 541 ++++++++++++++++++++++++++++++++++ 2 files changed, 623 insertions(+) create mode 100644 lexers/testdata/pony.actual create mode 100644 lexers/testdata/pony.expected diff --git a/lexers/testdata/pony.actual b/lexers/testdata/pony.actual new file mode 100644 index 000000000..b4f272da3 --- /dev/null +++ b/lexers/testdata/pony.actual @@ -0,0 +1,82 @@ +use "net" +use "files" + +class ClientSide is TCPConnectionNotify + let _env: Env + + new iso create(env: Env) => + _env = env + + fun ref connecting(conn: TCPConnection ref, count: U32) => + _env.out.print("connecting: " + count.string()) + + fun ref connected(conn: TCPConnection ref) => + try + (let host, let service) = conn.remote_address().name()? + _env.out.print("connected to " + host + ":" + service) + conn.set_nodelay(true) + conn.set_keepalive(10) + conn.write("client says hi") + end + +class Listener is TCPListenNotify + let _env: Env + let _limit: USize + var _host: String = "" + var _count: USize = 0 + + new create(env: Env, limit: USize) => + _env = env + _limit = limit + + fun ref connected(listen: TCPListener ref): TCPConnectionNotify iso^ => + let env = _env + + _env.out.print("Server starting") + + let server = ServerSide(env) + + _spawn(listen) + server + + fun ref _spawn(listen: TCPListener ref) => + if (_limit > 0) and (_count >= _limit) then + listen.dispose() + return + end + + _count = _count + 1 + _env.out.print("spawn " + _count.string()) + + try + let env = _env + + _env.out.print("Client starting") + TCPConnection( + _env.root as AmbientAuth, + ClientSide(env), + _host, + _service) + else + _env.out.print("couldn't create client side") + listen.close() + end + +actor Main + new create(env: Env) => + let limit = try + env.args(1)?.usize()? + else + 1 + end + + try + let auth = env.root as AmbientAuth + TCPListener(auth, recover Listener(env, limit) end) + UDPSocket(auth, recover Pong(env) end) + else + env.out.print("unable to use the network") + end + be test() => + nonsensical.stuff.here() + diff --git a/lexers/testdata/pony.expected b/lexers/testdata/pony.expected new file mode 100644 index 000000000..be46eb55a --- /dev/null +++ b/lexers/testdata/pony.expected @@ -0,0 +1,541 @@ +[ + {"type":"Keyword","value":"use"}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"net\""}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"use"}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"files\""}, + {"type":"Text","value":"\n\n"}, + {"type":"Keyword","value":"class"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"ClientSide"}, + {"type":"Text","value":" "}, + {"type":"OperatorWord","value":"is"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"TCPConnectionNotify"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_env"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"Env"}, + {"type":"Text","value":"\n\n "}, + {"type":"Keyword","value":"new"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"iso"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"create"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"Env"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"=\u003e"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_env"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"env"}, + {"type":"Text","value":"\n\n "}, + {"type":"Keyword","value":"fun"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"ref"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"connecting"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"conn"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"TCPConnection"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"ref"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"count"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"U32"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"=\u003e"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"out"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"connecting: \""}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"+"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"count"}, + {"type":"Punctuation","value":"."}, + {"type":"NameOther","value":"string()"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n\n "}, + {"type":"Keyword","value":"fun"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"ref"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"connected"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"conn"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"TCPConnection"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"ref"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"=\u003e"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"try"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"host"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"service"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"conn"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"remote_address"}, + {"type":"Punctuation","value":"()."}, + {"type":"Name","value":"name"}, + {"type":"Punctuation","value":"()?"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"out"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"connected to \""}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"+"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"host"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"+"}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\":\""}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"+"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"service"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"conn"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"set_nodelay"}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"true"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"conn"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"set_keepalive"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralNumberInteger","value":"10"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"conn"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"write"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"client says hi\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"end"}, + {"type":"Text","value":"\n\n"}, + {"type":"Keyword","value":"class"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Listener"}, + {"type":"Text","value":" "}, + {"type":"OperatorWord","value":"is"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"TCPListenNotify"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_env"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"Env"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_limit"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"USize"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"var"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_host"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"String"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"\""}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"var"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_count"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"USize"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberInteger","value":"0"}, + {"type":"Text","value":"\n\n "}, + {"type":"Keyword","value":"new"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"create"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"Env"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"limit"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"USize"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"=\u003e"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_env"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"env"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_limit"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"limit"}, + {"type":"Text","value":"\n\n "}, + {"type":"Keyword","value":"fun"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"ref"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"connected"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"listen"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"TCPListener"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"ref"}, + {"type":"Punctuation","value":"):"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"TCPConnectionNotify"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"iso"}, + {"type":"Punctuation","value":"^"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"=\u003e"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"env"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_env"}, + {"type":"Text","value":"\n\n "}, + {"type":"Name","value":"_env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"out"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"Server starting\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n\n "}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"server"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"ServerSide"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n\n "}, + {"type":"Name","value":"_spawn"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"listen"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"server"}, + {"type":"Text","value":"\n\n "}, + {"type":"Keyword","value":"fun"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"ref"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"_spawn"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"listen"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"TCPListener"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"ref"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"=\u003e"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"if"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"_limit"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"\u003e"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberInteger","value":"0"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"OperatorWord","value":"and"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"_count"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"\u003e="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_limit"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"then"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"listen"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"dispose"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"return"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"end"}, + {"type":"Text","value":"\n\n "}, + {"type":"Name","value":"_count"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_count"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"+"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"out"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"spawn \""}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"+"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_count"}, + {"type":"Punctuation","value":"."}, + {"type":"NameOther","value":"string()"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n\n "}, + {"type":"Keyword","value":"try"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"env"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"_env"}, + {"type":"Text","value":"\n\n "}, + {"type":"Name","value":"_env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"out"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"Client starting\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"NameClass","value":"TCPConnection"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"root"}, + {"type":"Text","value":" "}, + {"type":"OperatorWord","value":"as"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"AmbientAuth"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n "}, + {"type":"NameClass","value":"ClientSide"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":"),"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_host"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_service"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"else"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"_env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"out"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"couldn't create client side\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"listen"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"close"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"end"}, + {"type":"Text","value":"\n\n"}, + {"type":"Keyword","value":"actor"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Main"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"new"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"create"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"Env"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"=\u003e"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"limit"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"try"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"args"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Punctuation","value":")?."}, + {"type":"Name","value":"usize"}, + {"type":"Punctuation","value":"()?"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"else"}, + {"type":"Text","value":"\n "}, + {"type":"LiteralNumberInteger","value":"1"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"end"}, + {"type":"Text","value":"\n\n "}, + {"type":"Keyword","value":"try"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"let"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"auth"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"root"}, + {"type":"Text","value":" "}, + {"type":"OperatorWord","value":"as"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"AmbientAuth"}, + {"type":"Text","value":"\n "}, + {"type":"NameClass","value":"TCPListener"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"auth"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"recover"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Listener"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"limit"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"end"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"NameClass","value":"UDPSocket"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"auth"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"recover"}, + {"type":"Text","value":" "}, + {"type":"NameClass","value":"Pong"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"end"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"else"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"env"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"out"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"unable to use the network\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"end"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"be"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"test"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"=\u003e"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"nonsensical"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"stuff"}, + {"type":"Punctuation","value":"."}, + {"type":"Name","value":"here"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":"\n\n"} +]