10363 lines
389 KiB
Text
10363 lines
389 KiB
Text
[
|
|
{"type":"KeywordNamespace","value":"module"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"main"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"LiteralStringDoc","value":"// main module\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordNamespace","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"input"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"user_os"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordNamespace","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordNamespace","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"math"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"type"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"MyTime"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameClass","value":"Time"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'hello world'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"sub"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"100"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"50"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":"\n\n\t"},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"write_log"},
|
|
{"type":"Punctuation","value":"(."},
|
|
{"type":"NameVariable","value":"return_error"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"or"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Error: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"err"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"LiteralStringSingle","value":" bytes written'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n\t"},
|
|
{"type":"CommentSingle","value":"// Functions can be passed to other functions\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"run"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"sqr"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"25\"\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"CommentSingle","value":"// Anonymous functions can be declared inside other functions:\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"double_fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"run"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"double_fn"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"10\"\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"CommentSingle","value":"// Functions can be passed around without assigning them to variables:\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"res"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"run"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"})"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"res"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"10\"\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"CommentSingle","value":"// You can even have an array/map of functions:\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"fns"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameVariable","value":"sqr"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cube"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"fns"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":"]("},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"100\"\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"fns_map"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"LiteralStringSingle","value":"'sqr'"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"sqr"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"LiteralStringSingle","value":"'cube'"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cube"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"fns_map"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'cube'"},
|
|
{"type":"Punctuation","value":"]("},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"8\"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"add"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"sub"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// This is a single line comment.\n"},
|
|
{"type":"CommentMultiline","value":"/*\nThis is a multiline comment.\n /* It can be nested. */\n*/"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"foo"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"foo"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 2\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 3\n"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"_"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"foo"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// ignore values using `_`\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Bob'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringAffix","value":"r"},
|
|
{"type":"LiteralString","value":"'hello\\nworld'"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// all int literals are supported\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'0xc3'"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"195"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'0o10'"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"8"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'0b1111_0000_1010'"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3850"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'-0b1111_0000_1010'"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"3850"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Bob'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Hello, "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"LiteralStringSingle","value":"!'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// Hello, Bob!\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"123.4567"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'["},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":":."},
|
|
{"type":"LiteralNumber","value":"2"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"]'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'["},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"LiteralNumber","value":"10"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"]'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'["},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":"):"},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumber","value":"10"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"]'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'["},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":"):"},
|
|
{"type":"Operator","value":"0"},
|
|
{"type":"LiteralNumber","value":"10"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"]'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'["},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":"):"},
|
|
{"type":"LiteralStringAffix","value":"b"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"]'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'["},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":"):"},
|
|
{"type":"LiteralStringAffix","value":"o"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"]'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'["},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":"):"},
|
|
{"type":"LiteralStringAffix","value":"X"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"]'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'["},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberFloat","value":"10.0000"},
|
|
{"type":"Punctuation","value":":."},
|
|
{"type":"LiteralNumber","value":"2"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"]'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'["},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberFloat","value":"10.0000"},
|
|
{"type":"Punctuation","value":":."},
|
|
{"type":"LiteralNumber","value":"2"},
|
|
{"type":"LiteralStringAffix","value":"f"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"]'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"rocket"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`🚀`"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"rocket"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"bytes"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameBuiltin","value":"u8"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberHex","value":"0xf0"},
|
|
{"type":"Punctuation","value":"),"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x9f"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x9a"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x80"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"LiteralStringEscape","value":"\\x61"},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`a`"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"LiteralStringEscape","value":"\\141"},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`a`"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"LiteralStringEscape","value":"\\u0061"},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`a`"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// multibyte literals work too\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"LiteralStringEscape","value":"\\u2605"},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`★`"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"LiteralStringEscape","value":"\\u2605"},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"bytes"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameBuiltin","value":"u8"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberHex","value":"0xe2"},
|
|
{"type":"Punctuation","value":"),"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x98"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x85"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"LiteralStringEscape","value":"\\xe2\\x98\\x85"},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"bytes"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameBuiltin","value":"u8"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberHex","value":"0xe2"},
|
|
{"type":"Punctuation","value":"),"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x98"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x85"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"LiteralStringEscape","value":"\\342\\230\\205"},
|
|
{"type":"LiteralStringChar","value":"`"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"bytes"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameBuiltin","value":"u8"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberHex","value":"0xe2"},
|
|
{"type":"Punctuation","value":"),"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x98"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x85"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x7B"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberBin","value":"0b01111011"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberOct","value":"0o173"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"num"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1_000_000"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"three"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberBin","value":"0b0_11"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"float_num"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"3_122.55"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"hexa"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0xF_F"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"oct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberOct","value":"0o17_3"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"i64"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"123"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"u8"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"42"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"i16"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"12345"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"f"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"1.0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"f1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"f64"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberFloat","value":"3.14"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"f2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"f32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberFloat","value":"3.14"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"f0"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"42e1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 420\n"},
|
|
{"type":"NameVariable","value":"f1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"123e-2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 1.23\n"},
|
|
{"type":"NameVariable","value":"f2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"456e+2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 45600\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"6"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"7"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"names"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'John'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"names"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Peter'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"names"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Sam'"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"names"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'John'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Peter'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Sam'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Alex'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"names"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"false\"\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"3\"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"cap"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"3\" or greater\n"},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// The array is now empty\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"0\"\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10000"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cap"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"30000"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"init"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"users"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"cap"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1000"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 0\n// Now appending elements won't reallocate\n"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1000"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"square"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"6"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"init"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariableMagic","value":"it"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariableMagic","value":"it"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// square == [0, 1, 4, 9, 16, 25]\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Point"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Line"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"p1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Point"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"p2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Point"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"type"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"ObjectSumType"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Line"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Point"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"object_list"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"NameClass","value":"ObjectSumType"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"object_list"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Point"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"object_list"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Line"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"p1"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Point"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"p2"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Point"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"dump"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"object_list"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentMultiline","value":"/*\nobject_list: [ObjectSumType(Point{\n\tx: 1\n\ty: 1\n}), ObjectSumType(Line{\n\tp1: Point{\n\t\tx: 3\n\t\ty: 3\n\t}\n\tp2: Point{\n\t\tx: 4\n\t\ty: 4\n\t}\n})]\n*/"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[][]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"init"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"}}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":"]["},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"6"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"even"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"filter"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariableMagic","value":"it"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"%"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"even"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// [2, 4, 6]\n// filter can accept anonymous functions\n"},
|
|
{"type":"NameVariable","value":"even_fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"filter"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"%"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"})"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"even_fn"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"any"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariableMagic","value":"it"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// true\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"all"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariableMagic","value":"it"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003e="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// false\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"sort"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 1, 2, 3\n"},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"sort"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 3, 2, 1\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"users"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"21"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Bob'"},
|
|
{"type":"Punctuation","value":"},"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Zarkon'"},
|
|
{"type":"Punctuation","value":"},"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"25"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Alice'"},
|
|
{"type":"Punctuation","value":"}]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"users"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"sort"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// sort by User.age int field\n"},
|
|
{"type":"NameVariable","value":"users"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"sort"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// reverse sort by User.name string field\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"custom_sort_fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// return -1 when a comes before b\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"CommentSingle","value":"// return 0, when both are in same order\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"CommentSingle","value":"// return 1 when b comes before a\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"users"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"sort_with_compare"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"custom_sort_fn"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"30"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"40"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// [10, 20, 30]\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// [0, 10, 20, 30]\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// [10, 20, 30, 40]\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":"]."},
|
|
{"type":"NameBuiltin","value":"clone"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"6"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"7"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"8"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"9"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Operator","value":"#"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// [7, 8, 9]\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Operator","value":"#"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Operator","value":"#"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Operator","value":"..-"},
|
|
{"type":"LiteralNumberInteger","value":"8"},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// [0, 1]\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Operator","value":"#"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"Operator","value":"..-"},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// [0, 1, 2, 3, 4, 5, 6]\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// empty arrays\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Operator","value":"#"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Operator","value":"..-"},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// []\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Operator","value":"#"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// []\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Operator","value":"#"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"LiteralNumberInteger","value":"30"},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// []\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"files"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'pippo.jpg'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'01.bmp'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'_v.txt'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'img_02.jpg'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'img_01.JPG'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"filtered"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"files"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"filter"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariableMagic","value":"it"},
|
|
{"type":"Operator","value":"#"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Punctuation","value":"]."},
|
|
{"type":"NameBuiltin","value":"to_lower"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'.jpg'"},
|
|
{"type":"Punctuation","value":")."},
|
|
{"type":"KeywordDeclaration","value":"map"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariableMagic","value":"it"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"to_upper"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"fnums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// fnums is a fixed size array with 3 elements.\n"},
|
|
{"type":"NameVariable","value":"fnums"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"fnums"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"fnums"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"100"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"fnums"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// =\u003e [1, 10, 100]\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Keyword","value":"typeof"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"fnums"},
|
|
{"type":"Punctuation","value":")."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// =\u003e [3]int\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"anums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"fnums"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"map"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// a map with `string` keys and `int` values\n"},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'one'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'two'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'one'"},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"1\"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'bad_key'"},
|
|
{"type":"Punctuation","value":"])"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"0\"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'bad_key'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// Use `in` to detect whether such key exists\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"keys"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// ['one', 'two']\n"},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"delete"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'two'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringSingle","value":"'one'"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringSingle","value":"'two'"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"large_index"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"999"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"val"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameVariable","value":"large_index"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"or"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"panic"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'out of bounds'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"val"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// you can also do this, if you want to *propagate* the access error:\n"},
|
|
{"type":"NameVariable","value":"val2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"333"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"val2"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"input"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Enter your name: '"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Hello, "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"LiteralStringSingle","value":"!'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"t"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"MyTime"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"century"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberFloat","value":"1.0"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"math"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"trunc"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameBuiltin","value":"f64"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"t"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"year"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"0.009999794661191"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"my_time"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"MyTime"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"year"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2020"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"month"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"12"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"day"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"25"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"new_time"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"my_time"},
|
|
{"type":"Punctuation","value":")."},
|
|
{"type":"NameFunction","value":"utc_string"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Century: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"my_time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"century"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"LiteralStringSingle","value":" \u003c "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"LiteralStringSingle","value":" \u003e "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"LiteralStringSingle","value":" == "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"num"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"777"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"num"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"%"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'even'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'odd'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// \"odd\"\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Abc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"val"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Xyz"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"foo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"type"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Alphabet"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Abc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Xyz"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Alphabet"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"Abc"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralStringSingle","value":"'test'"},
|
|
{"type":"Punctuation","value":"})"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// sum type\n"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"is"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Abc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// x is automatically casted to Abc and can be used here\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"!"},
|
|
{"type":"Keyword","value":"is"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Abc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Not Abc'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"Abc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"CommentSingle","value":"// x is automatically casted to Abc and can be used here\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"Xyz"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"CommentSingle","value":"// x is automatically casted to Xyz and can be used here\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// true\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"!"},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// true\n"},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringSingle","value":"'one'"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringSingle","value":"'two'"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'one'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// true\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'three'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"!"},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// true\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"enum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Token"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"plus"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"minus"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"div"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"mult"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Parser"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"token"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Token"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"parser"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Parser"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"parser"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"token"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"plus"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"||"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"parser"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"token"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"minus"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"||"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"parser"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"token"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"div"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"||"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"parser"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"token"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"mult"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// ...\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"parser"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"token"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[."},
|
|
{"type":"NameVariable","value":"plus"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"minus"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"div"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"mult"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// ...\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"num"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"num"},
|
|
{"type":"Operator","value":"++"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"SquareIterator"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"idx"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"SquareIterator"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"next"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"idx"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003e="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"error"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"''"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"defer"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"idx"},
|
|
{"type":"Operator","value":"++"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"idx"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"idx"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"SquareIterator"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"squared"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"iter"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"squared"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringSingle","value":"'one'"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringSingle","value":"'two'"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"key"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"value"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"key"},
|
|
{"type":"LiteralStringSingle","value":" -\u003e "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"value"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// Output: one -\u003e 1\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"CommentSingle","value":"//\t\t two -\u003e 2\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"sum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"100"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"sum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Operator","value":"++"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"num"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"num"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"num"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003e="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"break"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":";"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Punctuation","value":";"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// Don't print 6\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"6"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"continue"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameLabel","value":"outer"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":";"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordConstant","value":"true"},
|
|
{"type":"Punctuation","value":";"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Operator","value":"++"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"7"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Keyword","value":"continue"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameLabel","value":"outer"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Keyword","value":"break"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameLabel","value":"outer"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringSingle","value":"'darwin'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'macOS.'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringSingle","value":"'linux'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Linux.'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"number"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'one'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'two'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'many'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordConstant","value":"true"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'if'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'else if'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'else if2'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'else'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"enum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Color"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"red"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"blue"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"green"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"is_red_or_blue"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Color"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"red"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"blue"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordConstant","value":"true"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// comma can be used to test multiple values\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"green"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordConstant","value":"false"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`v`"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"typ"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringChar","value":"`0`"},
|
|
{"type":"Operator","value":"..."},
|
|
{"type":"LiteralStringChar","value":"`9`"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'digit'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringChar","value":"`A`"},
|
|
{"type":"Operator","value":"..."},
|
|
{"type":"LiteralStringChar","value":"`Z`"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'uppercase'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"LiteralStringChar","value":"`a`"},
|
|
{"type":"Operator","value":"..."},
|
|
{"type":"LiteralStringChar","value":"`z`"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'lowercase'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'other'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"enum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"State"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"normal"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"write_log"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"return_error"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// write log file and return number of bytes written\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"write_log"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"State"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"f"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"create"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'log.txt'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"defer"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"f"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"close"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"write_log"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"CommentSingle","value":"// `f.close()` will be called after `f.write()` has been\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"CommentSingle","value":"// executed, but before `write_log()` finally returns the\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"CommentSingle","value":"// number of bytes written to `main()`\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"f"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"writeln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'This is a log file'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"return_error"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"CommentSingle","value":"// the file will be closed after the `error()` function\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"CommentSingle","value":"// has returned - so the error message will still report\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"CommentSingle","value":"// it as open\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"error"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'nothing written; file open: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"f"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"is_opened"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// the file will be closed here, too\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"params"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"ButtonConfig"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"text"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"is_disabled"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"70"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"height"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Button"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"text"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"height"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"new_button"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"ButtonConfig"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"Button"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"Button"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"height"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"height"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"text"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"text"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"button"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"new_button"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"text"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Click me'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"100"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// the height is unset, so it's the default value\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"button"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"height"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameFunction","value":"new_button"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"ButtonConfig"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"text"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"LiteralStringSingle","value":"'Click me'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"LiteralNumberInteger","value":"100"},
|
|
{"type":"Punctuation","value":"})"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// private immutable (default)\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// private mutable\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// (you can list multiple fields with the same access modifier)\n"},
|
|
{"type":"KeywordDeclaration","value":"pub"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"d"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// public immutable (readonly)\n"},
|
|
{"type":"KeywordDeclaration","value":"pub"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// public, but mutable only in parent module\n"},
|
|
{"type":"KeywordDeclaration","value":"__global"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// (not recommended to use, that's why the 'global' keyword starts with __)\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"f"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// public and mutable both inside and outside parent module\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"u"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"can_register"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"u"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"16"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"can_register"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"false\"\n"},
|
|
{"type":"NameVariable","value":"user2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user2"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"can_register"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"true\"\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Size"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"height"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"Size"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"area"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"height"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Button"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"Size"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"title"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"button"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Button"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"title"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Click me'"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"height"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"button"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"button"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"area"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"6"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"button"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameClass","value":"Size"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"area"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"6"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"button"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Button"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"Size"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Size"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"width"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"height"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Rgba32_Component"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"byte"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"g"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"byte"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"byte"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"byte"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"union"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Rgba32"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"Rgba32_Component"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"value"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"clr1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Rgba32"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"value"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberHex","value":"0x008811FF"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"clr2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Rgba32"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"Rgba32_Component"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Rgba32_Component"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"128"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"sz"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"sizeof"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"Rgba32"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"unsafe"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Size: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"sz"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"B,clr1.b: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"clr1"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"LiteralStringSingle","value":",clr2.b: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"clr2"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"multiply_by_2"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameFunction","value":"multiply_by_2"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"nums"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// \"[2, 4, 6]\"\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":"\t\t "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":"\t\t\t "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"is_registered"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"register"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"u"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Operator","value":"..."},
|
|
{"type":"NameVariable","value":"u"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"is_registered"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordConstant","value":"true"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'abc'"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"23"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"register"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"..."},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"total"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"total"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"total"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 0\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 1\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 5\n// using array decomposition\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"..."},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \u003c-- using prefix ... here. output: 9\n"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"6"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"7"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"..."},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// output: 18\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"sqr"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"cube"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"run"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"value"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"op"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"op"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"value"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"my_int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"my_closure"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameVariable","value":"my_int"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"my_int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameFunction","value":"my_closure"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// prints 1\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"new_counter"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Operator","value":"++"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"new_counter"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"c"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 1\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"c"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 2\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"c"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 3\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"ref"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"print_counter"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameVariable","value":"ref"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"NameVariable","value":"ref"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameFunction","value":"print_counter"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 0\n"},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameFunction","value":"print_counter"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 10\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"abc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"foo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"bar"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"foo"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"abc"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"val"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"left"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"right"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"const"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"pi"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"3.14"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"world"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'世界'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"const"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"2.71828"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Color"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"g"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"rgb"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"g"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Color"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Color"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"g"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"g"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"const"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"red"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Color"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"255"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"g"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// evaluate function call at compile-time*\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"blue"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"rgb"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"255"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordNamespace","value":"module"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"mymodule"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"pub"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"const"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"golden_ratio"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"1.61803"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"calc"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"mymodule"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"golden_ratio"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"pub"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"say_hi"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'hello from mymodule!'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"factorial"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"dump"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"dump"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"dump"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"factorial"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"init"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// your setup code here ...\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Dog"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"breed"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"d"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Dog"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"speak"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'woof'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Cat"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"breed"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Cat"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"speak"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'meow'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// unlike Go and like TypeScript, V's interfaces can define fields, not just methods.\n"},
|
|
{"type":"KeywordDeclaration","value":"interface"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Speaker"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"breed"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameFunction","value":"speak"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"dog"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Dog"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralStringSingle","value":"'Leonberger'"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"cat"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Cat"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralStringSingle","value":"'Siamese'"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"NameClass","value":"Speaker"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"dog"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cat"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"item"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"arr"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'a "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"item"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"breed"},
|
|
{"type":"LiteralStringSingle","value":" says: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"item"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"speak"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"pub"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"interface"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Reader"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameFunction","value":"read"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"buf"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"NameVariable","value":"byte"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"pub"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"interface"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Writer"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameFunction","value":"write"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"buf"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"NameVariable","value":"byte"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"LiteralStringDoc","value":"// "},
|
|
{"type":"GenericEmph","value":"ReaderWriter"},
|
|
{"type":"LiteralStringDoc","value":" embeds both Reader and Writer.\n// The effect is the same as copy/pasting all of the\n// Reader and all of the Writer methods/fields into\n// ReaderWriter.\n"},
|
|
{"type":"KeywordDeclaration","value":"pub"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"interface"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"ReaderWriter"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"Reader"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"Writer"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"type"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Filter"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"filter"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"f"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Filter"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"f"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"my_filter"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Filter"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"uppercase"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"my_filter"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"uppercase"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"enum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Color"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Operator","value":"@"},
|
|
{"type":"NameVariable","value":"none"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"red"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"green"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"blue"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"color"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Color"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"Operator","value":"@"},
|
|
{"type":"NameVariable","value":"none"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"enum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Cycle"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"one"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"two"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"three"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Cycle"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"next"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Cycle"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"one"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"two"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"two"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"three"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"three"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"one"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Cycle"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"one"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"_"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"next"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Empty"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"value"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"left"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Tree"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"right"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Tree"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"type"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Tree"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Empty"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"LiteralStringDoc","value":"// "},
|
|
{"type":"GenericEmph","value":"sum"},
|
|
{"type":"LiteralStringDoc","value":" up all node values\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"tree"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Tree"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"tree"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameClass","value":"Empty"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"tree"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"value"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"tree"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"left"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"tree"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"right"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"left"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberFloat","value":"0.2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Empty"},
|
|
{"type":"Punctuation","value":"{},"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Empty"},
|
|
{"type":"Punctuation","value":"{}}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"right"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberFloat","value":"0.3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Empty"},
|
|
{"type":"Punctuation","value":"{},"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberFloat","value":"0.4"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Empty"},
|
|
{"type":"Punctuation","value":"{},"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Empty"},
|
|
{"type":"Punctuation","value":"{}}}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"tree"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Node"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberFloat","value":"0.5"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"left"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"right"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameFunction","value":"sum"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"tree"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 0.2 + 0.3 + 0.4 + 0.5 = 1.4\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Moon"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Mars"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Venus"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"type"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"World"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Mars"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Moon"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Venus"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Mars"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"dust_storm"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordConstant","value":"true"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"World"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"Moon"},
|
|
{"type":"Punctuation","value":"{})"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"is"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Moon"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Mars"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// use `as` to access the Mars instance\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"mars"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"as"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Mars"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"mars"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"dust_storm"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'bad weather!'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"is"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Mars"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"typeof"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Punctuation","value":")."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Mars'"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"dust_storm"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'bad weather!'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Moon"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"moon_walk"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Mars"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"shiver"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"v"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Venus"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"sweat"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"pass_time"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"World"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"CommentSingle","value":"// using the shadowed match variable, in this case `w` (smart cast)\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"NameClass","value":"Moon"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"moon_walk"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameClass","value":"Mars"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"w"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"shiver"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Repo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"users"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Repo"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"find_user_by_id"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"!"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"users"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"CommentSingle","value":"// V automatically wraps this into an option type\n"},
|
|
{"type":"Text","value":"\t\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"error"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'User "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"LiteralStringSingle","value":" not found'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"repo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Repo"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"users"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Andrew'"},
|
|
{"type":"Punctuation","value":"},"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Bob'"},
|
|
{"type":"Punctuation","value":"},"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Charles'"},
|
|
{"type":"Punctuation","value":"}]"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"repo"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"find_user_by_id"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"or"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t "},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"err"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"User 10 not found\"\n"},
|
|
{"type":"Text","value":"\t\t "},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"10\"\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"Charles\"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordNamespace","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"net"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"http"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"f"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"url"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"resp"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"http"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"get"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"url"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"resp"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"text"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"resp"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"http"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"get"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"url"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"or"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"err"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"resp"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"http"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"get"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'https://google.com'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"resp"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"text"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// resp is a http.Response, not an optional\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"err"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"do_something"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"!"},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'foo'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'foo'"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"error"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'invalid string'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// Could be `return none` as well\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"do_something"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'foo'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"or"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'default'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// a will be 'foo'\n"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"do_something"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'bar'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"or"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'default'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// b will be 'default'\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Repo"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"DB"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Post"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"user_id"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"title"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"body"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"new_repo"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e("},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"DB"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Repo"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Repo"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e{"},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// This is a generic function. V will generate it for every type it's used with.\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Repo"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e)"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"find_by_id"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"table_name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// in this example getting the name of the type gives us the table name\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"query_one"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e("},
|
|
{"type":"LiteralStringSingle","value":"'select * from "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"table_name"},
|
|
{"type":"LiteralStringSingle","value":" where id = ?'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"new_db"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"users_repo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"new_repo"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"\u003e("},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// returns Repo\u003cUser\u003e\n"},
|
|
{"type":"NameVariable","value":"posts_repo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"new_repo"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"Post"},
|
|
{"type":"Punctuation","value":"\u003e("},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// returns Repo\u003cPost\u003e\n"},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"users_repo"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"find_by_id"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// find_by_id\u003cUser\u003e\n"},
|
|
{"type":"NameVariable","value":"post"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"posts_repo"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"find_by_id"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// find_by_id\u003cPost\u003e\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"compare"},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":"\u003e("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"T"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"p"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// ordinary function without return value\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"math"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqrt"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"p"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// p will be run in parallel thread\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"get_hypot"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"sqrt"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"g"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"get_hypot"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberFloat","value":"54.06"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"2.08"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// spawn thread and get handle to it\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"h1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"get_hypot"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberFloat","value":"2.32"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"16.74"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// do some other calculation here\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"h2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"g"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"wait"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\t\t\t\t "},
|
|
{"type":"CommentSingle","value":"// get result from spawned thread\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Results: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"h1"},
|
|
{"type":"LiteralStringSingle","value":", "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"h2"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// prints `Results: 16.9, 54.1`\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"task"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"duration"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'task "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"LiteralStringSingle","value":" begin'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sleep"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"duration"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"millisecond"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'task "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"LiteralStringSingle","value":" end'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"threads"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"NameVariable","value":"thread"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"threads"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"task"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"500"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"threads"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"task"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"900"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"threads"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"task"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"100"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"threads"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"wait"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'done'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"expensive_computing"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"threads"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"[]"},
|
|
{"type":"NameVariable","value":"thread"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"threads"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"expensive_computing"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// Join all tasks\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"threads"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"wait"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'All jobs finished: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// unbuffered - \"synchronous\"\n"},
|
|
{"type":"NameVariable","value":"ch2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"cap"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"100"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// buffer length 100\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"ch2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// ...\n"},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"close"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// ...\n"},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c-"},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"or"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'channel has been closed'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// propagate error\n"},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c-"},
|
|
{"type":"NameVariable","value":"ch2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"ch2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"ch3"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"0.0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"1.0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// ... setup go threads that will send on ch/ch2\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"the_channel"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sleep"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"millisecond"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"the_channel"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"1.0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}("},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"the_channel"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sleep"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"millisecond"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"the_channel"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"1.0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}("},
|
|
{"type":"NameVariable","value":"ch2"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"the_channel"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"_"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c-"},
|
|
{"type":"NameVariable","value":"the_channel"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}("},
|
|
{"type":"NameVariable","value":"ch3"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n\t"},
|
|
{"type":"Keyword","value":"select"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c-"},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"CommentSingle","value":"// do something with `a`\n"},
|
|
{"type":"Text","value":"\t\t\t"},
|
|
{"type":"NameBuiltin","value":"eprintln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'\u003e a: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c-"},
|
|
{"type":"NameVariable","value":"ch2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"CommentSingle","value":"// do something with predeclared variable `b`\n"},
|
|
{"type":"Text","value":"\t\t\t"},
|
|
{"type":"NameBuiltin","value":"eprintln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'\u003e b: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"ch3"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"CommentSingle","value":"// do something if `c` was sent\n"},
|
|
{"type":"Text","value":"\t\t\t"},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sleep"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"millisecond"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"NameBuiltin","value":"eprintln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'\u003e c: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"LiteralStringSingle","value":" was send on channel ch3'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"LiteralNumberInteger","value":"500"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"millisecond"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"CommentSingle","value":"// do something if no channel has become ready within 0.5s\n"},
|
|
{"type":"Text","value":"\t\t\t"},
|
|
{"type":"NameBuiltin","value":"eprintln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'\u003e more than 0.5s passed without a channel being ready'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"eprintln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'\u003e done'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Abc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberFloat","value":"2.13"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"res"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"try_push"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// try to perform `ch \u003c- a`\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"res"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"l"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// number of elements in queue\n"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"cap"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// maximum queue length\n"},
|
|
{"type":"NameVariable","value":"is_closed"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"ch"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"closed"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// bool flag - has `ch` been closed\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"l"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Abc"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"ch2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"chan"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Abc"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"res2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"ch2"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"try_pop"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// try to perform `b = \u003c-ch2`\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"St"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// data to be shared\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"shared"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"St"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"g"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"lock"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"CommentSingle","value":"// read/modify/write b.x\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"shared"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"St"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"g"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// ...\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Keyword","value":"rlock"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"CommentSingle","value":"// read a.x\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordNamespace","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"json"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"required"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// Use the `skip` attribute to skip certain fields\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"foo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"skip"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// If the field name is different in JSON, it can be specified\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"last_name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"json"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralString","value":"lastName"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"data"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'{ \"name\": \"Frodo\", \"lastName\": \"Baggins\", \"age\": 25 }'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"json"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"decode"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"data"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"or"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"eprintln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Failed to decode json, error: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"err"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"last_name"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// You can also decode JSON arrays:\n"},
|
|
{"type":"NameVariable","value":"sfoos"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'[{\"x\":123},{\"x\":456}]'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"foos"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"json"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"decode"},
|
|
{"type":"Punctuation","value":"([]"},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"sfoos"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"foos"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":"]."},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"foos"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":"]."},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"score"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"i64"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"data"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"map"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Pierre'"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"score"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1024"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"data"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'x'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"42"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"data"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralStringSingle","value":"'y'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"360"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"json"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"encode"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"data"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// {\"x\":42,\"y\":360}\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"json"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"encode"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"user"},
|
|
{"type":"Punctuation","value":"))"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// {\"name\":\"Pierre\",\"score\":1024}\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"test_hello"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"hello"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Hello world'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordNamespace","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"strconv"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"test_atoi"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"strconv"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atoi"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'1'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"strconv"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atoi"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'one'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// test will fail\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"test_subtest"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"res"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"execute"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"quoted_path"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariableMagic","value":"@VEXE"},
|
|
{"type":"Punctuation","value":")}"},
|
|
{"type":"LiteralStringSingle","value":" other_test.v'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"res"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"exit_code"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"res"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"output"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"contains"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'other_test.v does not exist'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"execute"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"quoted_path"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringDouble","value":"\"{test}. "},
|
|
{"type":"LiteralStringEscape","value":"\\$"},
|
|
{"type":"LiteralStringDouble","value":"{another test}. \\{and another\\}\""},
|
|
{"type":"Punctuation","value":")}"},
|
|
{"type":"LiteralStringSingle","value":" other_test.v'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"RefStruct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"MyStruct"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"heap"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"MyStruct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"MyStruct"},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"RefStruct"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"m"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"g"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'r: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"RefStruct"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"g"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"MyStruct"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"7"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"f"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// reference to `s` inside `r` is passed back to `main() `\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"RefStruct"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"f"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"MyStruct"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// would trigger error without `[heap]`\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordNamespace","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"sqlite"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// sets a custom table name. Default is struct name (case-sensitive)\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"table"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"'"},
|
|
{"type":"LiteralStringSingle","value":"customers'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Customer"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"Text","value":"\t\t "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"primary"},
|
|
{"type":"Punctuation","value":";"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameAttribute","value":"sql"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralString","value":"serial"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// a field named `id` of integer type must be the first field\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"nonull"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"nr_orders"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"country"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"nonull"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"sqlite"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"connect"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'customers.db'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"sql"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"TextWhitespace","value":"\n\t"},
|
|
{"type":"Keyword","value":"create"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Keyword","value":"table"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Name","value":"Customer"},
|
|
{"type":"TextWhitespace","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// select count(*) from customers\n"},
|
|
{"type":"NameVariable","value":"nr_customers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"sql"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"TextWhitespace","value":"\n\t"},
|
|
{"type":"Keyword","value":"select"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Keyword","value":"count"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Keyword","value":"from"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Name","value":"Customer"},
|
|
{"type":"TextWhitespace","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'number of all customers: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"nr_customers"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// V syntax can be used to build queries\n"},
|
|
{"type":"NameVariable","value":"uk_customers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"sql"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"TextWhitespace","value":"\n\t"},
|
|
{"type":"Keyword","value":"select"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Keyword","value":"from"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Name","value":"Customer"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Keyword","value":"where"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Name","value":"country"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'uk'"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Name","value":"nr_orders"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Operator","value":"\u003e"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"TextWhitespace","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"uk_customers"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"len"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"customer"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"uk_customers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"customer"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"LiteralStringSingle","value":" - "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"customer"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// by adding `limit 1` we tell V that there will be only one object\n"},
|
|
{"type":"NameVariable","value":"customer"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"sql"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"TextWhitespace","value":"\n\t"},
|
|
{"type":"Keyword","value":"select"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Keyword","value":"from"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Name","value":"Customer"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Keyword","value":"where"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Name","value":"id"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Keyword","value":"limit"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"TextWhitespace","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"customer"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"id"},
|
|
{"type":"LiteralStringSingle","value":" - "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"customer"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// insert a new customer\n"},
|
|
{"type":"NameVariable","value":"new_customer"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Customer"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Bob'"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"nr_orders"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"sql"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"TextWhitespace","value":"\n\t"},
|
|
{"type":"Keyword","value":"insert"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Name","value":"new_customer"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Keyword","value":"into"},
|
|
{"type":"TextWhitespace","value":" "},
|
|
{"type":"Name","value":"Customer"},
|
|
{"type":"TextWhitespace","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"LiteralStringDoc","value":"// "},
|
|
{"type":"GenericEmph","value":"clearall"},
|
|
{"type":"LiteralStringDoc","value":" clears all bits in the array\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"clearall"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"LiteralStringDoc","value":"// "},
|
|
{"type":"GenericEmph","value":"copy_all"},
|
|
{"type":"LiteralStringDoc","value":" recursively copies all elements of the array by their value,\n// "},
|
|
{"type":"GenericHeading","value":"# Some Heading"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"LiteralStringDoc","value":"// if `dupes` is false all duplicate values are eliminated in the process.\n"},
|
|
{"type":"LiteralStringDelimiter","value":"// ----------------------------------------\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"copy_all"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"dupes"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// ...\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"sw"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"time"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"new_stopwatch"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Hello world'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Greeting the world took: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"sw"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"elapsed"},
|
|
{"type":"Punctuation","value":"()."},
|
|
{"type":"NameFunction","value":"nanoseconds"},
|
|
{"type":"Punctuation","value":"()}"},
|
|
{"type":"LiteralStringSingle","value":"ns'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// allocate 2 uninitialized bytes \u0026 return a reference to them\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"p"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"unsafe"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"malloc"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"p"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`h`"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// Error: pointer indexing is only allowed in `unsafe` blocks\n"},
|
|
{"type":"Keyword","value":"unsafe"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"p"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`h`"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// OK\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"p"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`i`"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"p"},
|
|
{"type":"Operator","value":"++"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// Error: pointer arithmetic is only allowed in `unsafe` blocks\n"},
|
|
{"type":"Keyword","value":"unsafe"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"p"},
|
|
{"type":"Operator","value":"++"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// OK\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"*"},
|
|
{"type":"NameVariable","value":"p"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringChar","value":"`i`"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"sizeof"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"8"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"__offsetof"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"__offsetof"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"Foo"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentPreproc","value":"#flag -lsqlite3"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentPreproc","value":"#include"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentPreprocFile","value":"\"sqlite3.h\""},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// See also the example from https://www.sqlite.org/quickstart.html\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3_stmt"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"type"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"FnSqlite3Callback"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordType","value":"voidptr"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"NameVariable","value":"char"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"NameVariable","value":"char"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_open"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"char"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_close"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_column_int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"stmt"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3_stmt"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"n"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// ... you can also just define the type of parameter and leave out the C. prefix\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_prepare_v2"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"char"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3_stmt"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"NameVariable","value":"char"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_step"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3_stmt"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_finalize"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3_stmt"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_exec"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"sqlite3"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"sql"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"char"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cb"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"FnSqlite3Callback"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cb_arg"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"voidptr"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"emsg"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"NameVariable","value":"char"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_free"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"KeywordType","value":"voidptr"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"my_callback"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"arg"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"voidptr"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"howmany"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cvalues"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"NameVariable","value":"char"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cnames"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"NameVariable","value":"char"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"unsafe"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"howmany"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"NameBuiltin","value":"print"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'| "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameBuiltin","value":"cstring_to_vstring"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"cnames"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Punctuation","value":"])}"},
|
|
{"type":"LiteralStringSingle","value":": "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameBuiltin","value":"cstring_to_vstring"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"cvalues"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Punctuation","value":"]):"},
|
|
{"type":"LiteralNumber","value":"20"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":" '"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'|'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// this means `sqlite3* db = 0`\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"CommentSingle","value":"// passing a string literal to a C function call results in a C string, not a V string\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_open"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringAffix","value":"c"},
|
|
{"type":"LiteralStringSingle","value":"'users.db'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// C.sqlite3_open(db_path.str, \u0026db)\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"query"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'select count(*) from users'"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"stmt"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_stmt"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// NB: you can also use the `.str` field of a V string,\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"CommentSingle","value":"// to get its C style zero terminated representation\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_prepare_v2"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameFunction","value":"char"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"query"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"str"},
|
|
{"type":"Punctuation","value":"),"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"stmt"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_step"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"stmt"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"nr_users"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_column_int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"stmt"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_finalize"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"stmt"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'There are "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"nr_users"},
|
|
{"type":"LiteralStringSingle","value":" users in the database.'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"//\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"error_msg"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameFunction","value":"char"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"query_all_users"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'select * from users'"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"rc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_exec"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameFunction","value":"char"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"query_all_users"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"str"},
|
|
{"type":"Punctuation","value":"),"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"my_callback"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"voidptr"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"7"},
|
|
{"type":"Punctuation","value":"),"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"error_msg"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"rc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"!="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameClass","value":"SQLITE_OK"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"eprintln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Keyword","value":"unsafe"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"cstring_to_vstring"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"error_msg"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"})"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_free"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"error_msg"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"sqlite3_close"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"db"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"export"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"'"},
|
|
{"type":"LiteralStringSingle","value":"my_custom_c_name'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"foo"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"windows"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentPreproc","value":"#include"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentPreprocFile","value":"\"@VEXEROOT/thirdparty/stdatomic/win/atomic.h\""},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentPreproc","value":"#include"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentPreprocFile","value":"\"@VEXEROOT/thirdparty/stdatomic/nix/atomic.h\""},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// declare functions we want to use - V does not parse the C header\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atomic_store_u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atomic_load_u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atomic_compare_exchange_weak_u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atomic_compare_exchange_strong_u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"bool"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"const"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"num_iterations"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10000000"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// see section \"Global Variables\" below\n"},
|
|
{"type":"KeywordDeclaration","value":"__global"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"atom"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"u32"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// ordinary variable but used as atomic\n"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"change"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"races_won_by_change"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cmp"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"17"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// addressable value to compare with and to store the found value\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"CommentSingle","value":"// atomic version of `if atom == 17 { atom = 23 races_won_by_change++ } else { cmp = atom }`\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atomic_compare_exchange_strong_u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"atom"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"cmp"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"23"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"NameVariable","value":"races_won_by_change"},
|
|
{"type":"Operator","value":"++"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cmp"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"31"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t\t"},
|
|
{"type":"Keyword","value":"break"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"NameVariable","value":"cmp"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"17"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// re-assign because overwritten with value of atom\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"races_won_by_change"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atomic_store_u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"atom"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"17"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"t"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"go"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"change"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"races_won_by_main"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cmp17"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"17"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"cmp23"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"23"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":".."},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"num_iterations"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"CommentSingle","value":"// atomic version of `if atom == 17 { atom = 23 races_won_by_main++ }`\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atomic_compare_exchange_strong_u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"atom"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"cmp17"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"23"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"NameVariable","value":"races_won_by_main"},
|
|
{"type":"Operator","value":"++"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"NameVariable","value":"cmp17"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"17"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameVariable","value":"desir"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"num_iterations"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"31"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"17"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"CommentSingle","value":"// atomic version of `for atom != 23 {} atom = desir`\n"},
|
|
{"type":"Text","value":"\t\t"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"!"},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atomic_compare_exchange_weak_u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"atom"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"cmp23"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"desir"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"NameVariable","value":"cmp23"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"23"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"races_won_by_change"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"t"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"wait"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"atom_new"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"C"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"atomic_load_u32"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Operator","value":"\u0026"},
|
|
{"type":"NameVariable","value":"atom"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'atom: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"atom_new"},
|
|
{"type":"LiteralStringSingle","value":", #exchanges: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"races_won_by_main"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"races_won_by_change"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// prints `atom: 31, #exchanges: 10000000`)\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'races won by"},
|
|
{"type":"LiteralStringEscape","value":"\\n"},
|
|
{"type":"LiteralStringSingle","value":"- `main()`: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"races_won_by_main"},
|
|
{"type":"LiteralStringEscape","value":"\\n"},
|
|
{"type":"LiteralStringSingle","value":"- `change()`: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"races_won_by_change"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordNamespace","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"sync"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"__global"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"sem"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"NameVariable","value":"sync"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameClass","value":"Semaphore"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// needs initialization in `init()`\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"mtx"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"NameVariable","value":"sync"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameClass","value":"RwMutex"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// needs initialization in `init()`\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"f1"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"f64"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberFloat","value":"34.0625"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// explicily initialized\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"shmap"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"shared"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"map"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// initialized as empty `shared` map\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"f2"},
|
|
{"type":"Text","value":"\t "},
|
|
{"type":"KeywordType","value":"f64"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// initialized to `0.0`\n"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"init"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"sem"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"init"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"mtx"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"init"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentPreproc","value":"#flag linux -lsdl2"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentPreproc","value":"#flag linux -Ivig"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentPreproc","value":"#flag linux -DCIMGUI_DEFINE_ENUMS_AND_STRUCTS=1"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentPreproc","value":"#flag linux -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentPreproc","value":"#flag linux -DIMGUI_IMPL_API="},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentPreproc","value":"#pkgconfig r_core"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentPreproc","value":"#pkgconfig --cflags --libs r_core"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameBuiltin","value":"pkgconfig"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'mysqlclient'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentPreproc","value":"#pkgconfig mysqlclient"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameBuiltin","value":"pkgconfig"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'mariadb'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentPreproc","value":"#pkgconfig mariadb"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentPreproc","value":"#flag -I @VMODROOT/c"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentPreproc","value":"#flag @VMODROOT/c/implementation.o"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentPreproc","value":"#include"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentPreprocFile","value":"\"header.h\""},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// Support for multiple conditions in one branch\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"ios"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"||"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"android"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Running on a mobile device!'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"linux"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u0026\u0026"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"x64"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'64-bit Linux.'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// Usage as expression\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"windows"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Windows'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'UNIX'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Using "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// $else-$if branches\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"tinyc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'tinyc'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"clang"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'clang'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"gcc"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'gcc'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'different compiler'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"test"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'testing'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// v -cg ...\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"debug"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'debugging'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// v -prod ...\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"prod"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'production build'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// v -d option ...\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"option"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'custom option'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"embedded_file"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameBuiltin","value":"embed_file"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'v.png'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"zlib"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// compressed using zlib\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"os"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"write_file"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'exported.png'"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"embedded_file"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"to_string"},
|
|
{"type":"Punctuation","value":"())"},
|
|
{"type":"KeywordDeclaration","value":"?"},
|
|
{"type":"Text","value":"\n\n\t"},
|
|
{"type":"NameVariable","value":"compile_time_env"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameBuiltin","value":"env"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'ENV_VAR'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"compile_time_env"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"build"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'Peter'"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"age"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"25"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"numbers"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","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":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameBuiltin","value":"tmpl"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'1.txt'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"linux"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameBuiltin","value":"compile_error"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'Linux is not supported'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameBuiltin","value":"eprintln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'file: '"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariableMagic","value":"@FILE"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"' | line: '"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariableMagic","value":"@LINE"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"' | fn: '"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariableMagic","value":"@MOD"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'.'"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariableMagic","value":"@FN"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordNamespace","value":"import"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"v"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"vmod"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"vm"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"vmod"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"decode"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariableMagic","value":"@VMOD_FILE"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"or"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"panic"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"err"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"eprintln"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"vm"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"LiteralStringSingle","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"vm"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"version"},
|
|
{"type":"LiteralStringEscape","value":"\\n"},
|
|
{"type":"LiteralStringSingle","value":" "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"vm"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"description"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"field"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"User"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"fields"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"field"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"typ"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Keyword","value":"is"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"field"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"name"},
|
|
{"type":"LiteralStringSingle","value":" is of type string'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"struct"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"str"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"string"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringSingle","value":"'{"},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"LiteralStringSingle","value":", "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"LiteralStringSingle","value":"}'"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"4"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vec"},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"{6, 8}\"\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"{-2, -2}\"\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// \"{3, 5}\"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"100"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Keyword","value":"asm"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"amd64"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameFunction","value":"mov"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"eax"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameFunction","value":"add"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"eax"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameFunction","value":"mov"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"eax"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"; =r (c) as c // output"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"; r (a) as a // input"},
|
|
{"type":"Text","value":"\n\t "},
|
|
{"type":"NameFunction","value":"r"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"as"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'a: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"a"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 100\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'b: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"b"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 20\n"},
|
|
{"type":"NameBuiltin","value":"println"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringSingle","value":"'c: "},
|
|
{"type":"Operator","value":"$"},
|
|
{"type":"NameVariable","value":"c"},
|
|
{"type":"LiteralStringSingle","value":"'"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// 120\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"// [flag] enables Enum types to be used as bitfields\n"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"flag"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"enum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"BitField"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"read"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"write"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"other"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"main"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"BitField"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"read"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"int"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"NameClass","value":"BitField"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"write"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"KeywordDeclaration","value":"mut"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"BitField"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"read"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"has"},
|
|
{"type":"Punctuation","value":"(."},
|
|
{"type":"NameVariable","value":"read"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"other"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// test if *at least one* of the flags is set\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"!"},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"all"},
|
|
{"type":"Punctuation","value":"(."},
|
|
{"type":"NameVariable","value":"read"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"other"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// test if *all* of the flags is set\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"set"},
|
|
{"type":"Punctuation","value":"(."},
|
|
{"type":"NameVariable","value":"write"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"other"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"has"},
|
|
{"type":"Punctuation","value":"(."},
|
|
{"type":"NameVariable","value":"read"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"write"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"other"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"all"},
|
|
{"type":"Punctuation","value":"(."},
|
|
{"type":"NameVariable","value":"read"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"write"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"other"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"toggle"},
|
|
{"type":"Punctuation","value":"(."},
|
|
{"type":"NameVariable","value":"other"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"=="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"BitField"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"read"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"write"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameBuiltin","value":"all"},
|
|
{"type":"Punctuation","value":"(."},
|
|
{"type":"NameVariable","value":"read"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"|"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameVariable","value":"write"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Keyword","value":"assert"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"!"},
|
|
{"type":"NameVariable","value":"bf"},
|
|
{"type":"Punctuation","value":"."},
|
|
{"type":"NameFunction","value":"has"},
|
|
{"type":"Punctuation","value":"(."},
|
|
{"type":"NameVariable","value":"other"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// Calling this function will result in a deprecation warning\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"deprecated"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"old_function"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// It can also display a custom deprecation message\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"deprecated"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"'"},
|
|
{"type":"LiteralStringSingle","value":"use new_function() instead'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"deprecated_after"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"'"},
|
|
{"type":"LiteralStringSingle","value":"2021-05-27'"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"legacy_function"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// This function's calls will be inlined.\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"inline"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"inlined_function"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"// This function's calls will NOT be inlined.\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"NameAttribute","value":"noinline"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"function"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameAttribute","value":"debug"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"foo"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"KeywordDeclaration","value":"fn"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"bar"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"NameFunction","value":"foo"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"CommentSingle","value":"// will not be called if `-d debug` is not passed\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"x"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// ...\n"},
|
|
{"type":"Text","value":"\t"},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameVariable","value":"y"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Keyword","value":"unsafe"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Text","value":"\n\t\t\t"},
|
|
{"type":"Keyword","value":"goto"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameLabel","value":"my_label"},
|
|
{"type":"Text","value":"\n\t\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\t"},
|
|
{"type":"CommentSingle","value":"// ...\n"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameLabel","value":"my_label"},
|
|
{"type":"Punctuation","value":":"}
|
|
]
|