diff --git a/lexers/testdata/v/v.actual b/lexers/testdata/v/v.actual new file mode 100644 index 000000000..bd477b016 --- /dev/null +++ b/lexers/testdata/v/v.actual @@ -0,0 +1,1733 @@ +module main + +// main module + +import os { input, user_os } +import time +import math + +type MyTime = time.Time + +fn main() { + println('hello world') + + println(sub(100, 50)) + + n := write_log(.return_error) or { + println('Error: $err') + 0 + } + println('$n bytes written') + + // Functions can be passed to other functions + println(run(5, sqr)) // "25" + // Anonymous functions can be declared inside other functions: + double_fn := fn (n int) int { + return n + n + } + println(run(5, double_fn)) // "10" + // Functions can be passed around without assigning them to variables: + res := run(5, fn (n int) int { + return n + n + }) + println(res) // "10" + // You can even have an array/map of functions: + fns := [sqr, cube] + println(fns[0](10)) // "100" + fns_map := { + 'sqr': sqr + 'cube': cube + } + println(fns_map['cube'](2)) // "8" +} + +fn add(x int, y int) int { + return x + y +} + +fn sub(x int, y int) int { + return x - y +} + +// This is a single line comment. +/* +This is a multiline comment. + /* It can be nested. */ +*/ + +fn foo() (int, int) { + return 2, 3 +} + +a, b := foo() +println(a) // 2 +println(b) // 3 +c, _ := foo() // ignore values using `_` + +name := 'Bob' +assert name.len == 3 + +s := r'hello\nworld' + +// all int literals are supported +assert '0xc3'.int() == 195 +assert '0o10'.int() == 8 +assert '0b1111_0000_1010'.int() == 3850 +assert '-0b1111_0000_1010'.int() == -3850 + +name := 'Bob' +println('Hello, $name!') // Hello, Bob! + +x := 123.4567 +println('[${x:.2}]') +println('[${x:10}]') +println('[${int(x):-10}]') +println('[${int(x):010}]') +println('[${int(x):b}]') +println('[${int(x):o}]') +println('[${int(x):X}]') + +println('[${10.0000:.2}]') +println('[${10.0000:.2f}]') + +rocket := `πŸš€` +assert rocket.bytes() == [u8(0xf0), 0x9f, 0x9a, 0x80] + +assert `\x61` == `a` +assert `\141` == `a` +assert `\u0061` == `a` + +// multibyte literals work too +assert `\u2605` == `β˜…` +assert `\u2605`.bytes() == [u8(0xe2), 0x98, 0x85] +assert `\xe2\x98\x85`.bytes() == [u8(0xe2), 0x98, 0x85] +assert `\342\230\205`.bytes() == [u8(0xe2), 0x98, 0x85] + +a := 0x7B +b := 0b01111011 +c := 0o173 + +num := 1_000_000 +three := 0b0_11 +float_num := 3_122.55 +hexa := 0xF_F +oct := 0o17_3 + +a := i64(123) +b := u8(42) +c := i16(12345) + +f := 1.0 +f1 := f64(3.14) +f2 := f32(3.14) + +f0 := 42e1 // 420 +f1 := 123e-2 // 1.23 +f2 := 456e+2 // 45600 + +mut nums := [1, 2, 3] +nums << 4 +println(nums) +nums << [5, 6, 7] + +mut names := ['John'] +names << 'Peter' +names << 'Sam' + +names := ['John', 'Peter', 'Sam'] +println('Alex' in names) // "false" + +mut nums := [1, 2, 3] +println(nums.len) // "3" +println(nums.cap) // "3" or greater +nums = [] // The array is now empty +println(nums.len) // "0" + +mut a := []int{len: 10000, cap: 30000, init: 3} + +users := []int{} + +mut numbers := []int{cap: 1000} +println(numbers.len) // 0 +// Now appending elements won't reallocate +for i in 0 .. 1000 { + numbers << i +} + +mut square := []int{len: 6, init: it * it} +// square == [0, 1, 4, 9, 16, 25] + +struct Point { + x int + y int +} + +struct Line { + p1 Point + p2 Point +} + +type ObjectSumType = Line | Point + +mut object_list := []ObjectSumType{} +object_list << Point{1, 1} +object_list << Line{ + p1: Point{3, 3} + p2: Point{4, 4} +} +dump(object_list) +/* +object_list: [ObjectSumType(Point{ + x: 1 + y: 1 +}), ObjectSumType(Line{ + p1: Point{ + x: 3 + y: 3 + } + p2: Point{ + x: 4 + y: 4 + } +})] +*/ + +mut a := [][]int{len: 2, init: []int{len: 3}} +a[0][1] = 2 + +nums := [1, 2, 3, 4, 5, 6] +even := nums.filter(it % 2 == 0) +println(even) // [2, 4, 6] +// filter can accept anonymous functions +even_fn := nums.filter(fn (x int) bool { + return x % 2 == 0 +}) +println(even_fn) + +nums := [1, 2, 3] +println(nums.any(it == 2)) // true +println(nums.all(it >= 2)) // false + +mut numbers := [1, 3, 2] +numbers.sort() // 1, 2, 3 +numbers.sort(a > b) // 3, 2, 1 + +struct User { + age int + name string +} + +mut users := [User{21, 'Bob'}, User{20, 'Zarkon'}, User{25, 'Alice'}] +users.sort(a.age < b.age) // sort by User.age int field +users.sort(a.name > b.name) // reverse sort by User.name string field + +custom_sort_fn := fn (a &User, b &User) int { + // return -1 when a comes before b + // return 0, when both are in same order + // return 1 when b comes before a + if a.name == b.name { + if a.age < b.age { + return 1 + } + if a.age > b.age { + return -1 + } + return 0 + } + if a.name < b.name { + return -1 + } else if a.name > b.name { + return 1 + } + return 0 +} +users.sort_with_compare(custom_sort_fn) + +nums := [0, 10, 20, 30, 40] +println(nums[1..4]) // [10, 20, 30] +println(nums[..4]) // [0, 10, 20, 30] +println(nums[1..]) // [10, 20, 30, 40] + +mut a := [0, 1, 2, 3, 4, 5] +mut b := a[2..4].clone() + +a := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +println(a#[-3..]) // [7, 8, 9] +println(a#[-20..]) // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +println(a#[-20..-8]) // [0, 1] +println(a#[..-3]) // [0, 1, 2, 3, 4, 5, 6] + +// empty arrays +println(a#[-20..-10]) // [] +println(a#[20..10]) // [] +println(a#[20..30]) // [] + +files := ['pippo.jpg', '01.bmp', '_v.txt', 'img_02.jpg', 'img_01.JPG'] +filtered := files.filter(it#[-4..].to_lower() == '.jpg').map(it.to_upper()) + +mut fnums := [3]int{} // fnums is a fixed size array with 3 elements. +fnums[0] = 1 +fnums[1] = 10 +fnums[2] = 100 +println(fnums) // => [1, 10, 100] +println(typeof(fnums).name) // => [3]int + +anums := fnums[..] + +mut m := map[string]int{} // a map with `string` keys and `int` values +m['one'] = 1 +m['two'] = 2 +println(m['one']) // "1" +println(m['bad_key']) // "0" +println('bad_key' in m) // Use `in` to detect whether such key exists +println(m.keys()) // ['one', 'two'] +m.delete('two') + +numbers := { + 'one': 1 + 'two': 2 +} +println(numbers) + +arr := [1, 2, 3] +large_index := 999 +val := arr[large_index] or { panic('out of bounds') } +println(val) +// you can also do this, if you want to *propagate* the access error: +val2 := arr[333]? +println(val2) + +name := os.input('Enter your name: ') +println('Hello, $name!') + +fn (mut t MyTime) century() int { + return int(1.0 + math.trunc(f64(t.year) * 0.009999794661191)) +} + +fn main() { + mut my_time := MyTime{ + year: 2020 + month: 12 + day: 25 + } + println(time.new_time(my_time).utc_string()) + println('Century: $my_time.century()') +} + +a := 10 +b := 20 +if a < b { + println('$a < $b') +} else if a > b { + println('$a > $b') +} else { + println('$a == $b') +} + +num := 777 +s := if num % 2 == 0 { 'even' } else { 'odd' } +println(s) +// "odd" + +struct Abc { + val string +} + +struct Xyz { + foo string +} + +type Alphabet = Abc | Xyz + +x := Alphabet(Abc{'test'}) // sum type +if x is Abc { + // x is automatically casted to Abc and can be used here + println(x) +} +if x !is Abc { + println('Not Abc') +} + +match x { + Abc { + // x is automatically casted to Abc and can be used here + println(x) + } + Xyz { + // x is automatically casted to Xyz and can be used here + println(x) + } +} + +nums := [1, 2, 3] +println(1 in nums) // true +println(4 !in nums) // true +m := { + 'one': 1 + 'two': 2 +} +println('one' in m) // true +println('three' !in m) // true + +enum Token { + plus + minus + div + mult +} + +struct Parser { + token Token +} + +parser := Parser{} +if parser.token == .plus || parser.token == .minus || parser.token == .div || parser.token == .mult { + // ... +} +if parser.token in [.plus, .minus, .div, .mult] { + // ... +} + +mut numbers := [0, 1, 2] +for mut num in numbers { + num++ +} + +struct SquareIterator { + arr []int +mut: + idx int +} + +fn (mut iter SquareIterator) next() ?int { + if iter.idx >= iter.arr.len { + return error('') + } + defer { + iter.idx++ + } + return iter.arr[iter.idx] * iter.arr[iter.idx] +} + +nums := [1, 2, 3, 4, 5] +iter := SquareIterator{ + arr: nums +} +for squared in iter { + println(squared) +} + +m := { + 'one': 1 + 'two': 2 +} +for key, value in m { + println('$key -> $value') + // Output: one -> 1 + // two -> 2 +} + +mut sum := 0 +mut i := 0 +for i <= 100 { + sum += i + i++ +} + +mut num := 0 +for { + num += 2 + if num >= 10 { + break + } +} + +for i := 0; i < 10; i += 2 { + // Don't print 6 + if i == 6 { + continue + } + println(i) +} + +outer: for i := 4; true; i++ { + println(i) + for { + if i < 7 { + continue outer + } else { + break outer + } + } +} + +match os { + 'darwin' { println('macOS.') } + 'linux' { println('Linux.') } + else { println(os) } +} + +s := match number { + 1 { 'one' } + 2 { 'two' } + else { 'many' } +} + +match true { + 2 > 4 { println('if') } + 3 == 4 { println('else if') } + 2 == 2 { println('else if2') } + else { println('else') } +} + +enum Color { + red + blue + green +} + +fn is_red_or_blue(c Color) bool { + return match c { + .red, .blue { true } // comma can be used to test multiple values + .green { false } + } +} + +c := `v` +typ := match c { + `0`...`9` { 'digit' } + `A`...`Z` { 'uppercase' } + `a`...`z` { 'lowercase' } + else { 'other' } +} + +enum State { + normal + write_log + return_error +} + +// write log file and return number of bytes written +fn write_log(s State) ?int { + mut f := os.create('log.txt')? + defer { + f.close() + } + if s == .write_log { + // `f.close()` will be called after `f.write()` has been + // executed, but before `write_log()` finally returns the + // number of bytes written to `main()` + return f.writeln('This is a log file') + } else if s == .return_error { + // the file will be closed after the `error()` function + // has returned - so the error message will still report + // it as open + return error('nothing written; file open: $f.is_opened') + } + // the file will be closed here, too + return 0 +} + +[params] +struct ButtonConfig { + text string + is_disabled bool + width int = 70 + height int = 20 +} + +struct Button { + text string + width int + height int +} + +fn new_button(c ButtonConfig) &Button { + return &Button{ + width: c.width + height: c.height + text: c.text + } +} + +button := new_button(text: 'Click me', width: 100) +// the height is unset, so it's the default value +assert button.height == 20 +new_button(ButtonConfig{text:'Click me', width:100}) + +struct Foo { + a int // private immutable (default) +mut: + b int // private mutable + c int // (you can list multiple fields with the same access modifier) +pub: + d int // public immutable (readonly) +pub mut: + e int // public, but mutable only in parent module +__global: + // (not recommended to use, that's why the 'global' keyword starts with __) + f int // public and mutable both inside and outside parent module +} + +struct User { + age int +} + +fn (u User) can_register() bool { + return u.age > 16 +} + +user := User{ + age: 10 +} +println(user.can_register()) // "false" +user2 := User{ + age: 20 +} +println(user2.can_register()) // "true" + +struct Size { +mut: + width int + height int +} + +fn (s &Size) area() int { + return s.width * s.height +} + +struct Button { + Size + title string +} + +mut button := Button{ + title: 'Click me' + height: 2 +} + +button.width = 3 +assert button.area() == 6 +assert button.Size.area() == 6 + +mut button := Button{ + Size: Size{ + width: 3 + height: 2 + } +} + +struct Rgba32_Component { + r byte + g byte + b byte + a byte +} + +union Rgba32 { + Rgba32_Component + value u32 +} + +clr1 := Rgba32{ + value: 0x008811FF +} + +clr2 := Rgba32{ + Rgba32_Component: Rgba32_Component{ + a: 128 + } +} + +sz := sizeof(Rgba32) +unsafe { + println('Size: ${sz}B,clr1.b: $clr1.b,clr2.b: $clr2.b') +} + +fn multiply_by_2(mut arr []int) { + for i in 0 .. arr.len { + arr[i] *= 2 + } +} + +mut nums := [1, 2, 3] +multiply_by_2(mut nums) +println(nums) +// "[2, 4, 6]" + +struct User { + name string + age int + is_registered bool +} + +fn register(u User) User { + return User{ + ...u + is_registered: true + } +} + +mut user := User{ + name: 'abc' + age: 23 +} +user = register(user) +println(user) + +fn sum(a ...int) int { + mut total := 0 + for x in a { + total += x + } + return total +} + +println(sum()) // 0 +println(sum(1)) // 1 +println(sum(2, 3)) // 5 +// using array decomposition +a := [2, 3, 4] +println(sum(...a)) // <-- using prefix ... here. output: 9 +b := [5, 6, 7] +println(sum(...b)) // output: 18 + +fn sqr(n int) int { + return n * n +} + +fn cube(n int) int { + return n * n * n +} + +fn run(value int, op fn (int) int) int { + return op(value) +} + +my_int := 1 +my_closure := fn [my_int] () { + println(my_int) +} +my_closure() // prints 1 + +fn new_counter() fn () int { + mut i := 0 + return fn [mut i] () int { + i++ + return i + } +} + +c := new_counter() +println(c()) // 1 +println(c()) // 2 +println(c()) // 3 + +mut i := 0 +mut ref := &i +print_counter := fn [ref] () { + println(*ref) +} + +print_counter() // 0 +i = 10 +print_counter() // 10 + +struct Foo { + abc int +} + +fn (foo &Foo) bar() { + println(foo.abc) +} + +struct Node { + val T + left &Node + right &Node +} + +const ( + pi = 3.14 + world = 'δΈ–η•Œ' +) + +const e = 2.71828 + +struct Color { + r int + g int + b int +} + +fn rgb(r int, g int, b int) Color { + return Color{ + r: r + g: g + b: b + } +} + +const ( + numbers = [1, 2, 3] + red = Color{ + r: 255 + g: 0 + b: 0 + } + // evaluate function call at compile-time* + blue = rgb(0, 0, 255) +) + +module mymodule + +pub const golden_ratio = 1.61803 + +fn calc() { + println(mymodule.golden_ratio) +} + +pub fn say_hi() { + println('hello from mymodule!') +} + +fn factorial(n u32) u32 { + if dump(n <= 1) { + return dump(1) + } + return dump(n * factorial(n - 1)) +} + +fn init() { + // your setup code here ... +} + +struct Dog { + breed string +} + +fn (d Dog) speak() string { + return 'woof' +} + +struct Cat { + breed string +} + +fn (c Cat) speak() string { + return 'meow' +} + +// unlike Go and like TypeScript, V's interfaces can define fields, not just methods. +interface Speaker { + breed string + speak() string +} + +fn main() { + dog := Dog{'Leonberger'} + cat := Cat{'Siamese'} + + mut arr := []Speaker{} + arr << dog + arr << cat + for item in arr { + println('a $item.breed says: $item.speak()') + } +} + +pub interface Reader { +mut: + read(mut buf []byte) ?int +} + +pub interface Writer { +mut: + write(buf []byte) ?int +} + +// ReaderWriter embeds both Reader and Writer. +// The effect is the same as copy/pasting all of the +// Reader and all of the Writer methods/fields into +// ReaderWriter. +pub interface ReaderWriter { + Reader + Writer +} + +type Filter = fn (string) string + +fn filter(s string, f Filter) string { + return f(s) +} + +my_filter := Filter(uppercase) +my_filter := uppercase + +enum Color { + @none + red + green + blue +} + +color := Color.@none + +enum Cycle { + one + two + three +} + +fn (c Cycle) next() Cycle { + match c { + .one { + return .two + } + .two { + return .three + } + .three { + return .one + } + } +} + +mut c := Cycle.one +for _ in 0 .. 10 { + println(c) + c = c.next() +} + +struct Empty {} + +struct Node { + value f64 + left Tree + right Tree +} + +type Tree = Empty | Node + +// sum up all node values +fn sum(tree Tree) f64 { + return match tree { + Empty { 0 } + Node { tree.value + sum(tree.left) + sum(tree.right) } + } +} + +fn main() { + left := Node{0.2, Empty{}, Empty{}} + right := Node{0.3, Empty{}, Node{0.4, Empty{}, Empty{}}} + tree := Node{0.5, left, right} + println(sum(tree)) // 0.2 + 0.3 + 0.4 + 0.5 = 1.4 +} + +struct Moon {} + +struct Mars {} + +struct Venus {} + +type World = Mars | Moon | Venus + +fn (m Mars) dust_storm() bool { + return true +} + +fn main() { + mut w := World(Moon{}) + assert w is Moon + w = Mars{} + // use `as` to access the Mars instance + mars := w as Mars + if mars.dust_storm() { + println('bad weather!') + } +} + +if mut w is Mars { + assert typeof(w).name == 'Mars' + if w.dust_storm() { + println('bad weather!') + } +} + +fn (m Moon) moon_walk() {} +fn (m Mars) shiver() {} +fn (v Venus) sweat() {} + +fn pass_time(w World) { + match w { + // using the shadowed match variable, in this case `w` (smart cast) + Moon { w.moon_walk() } + Mars { w.shiver() } + else {} + } +} + +struct User { + id int + name string +} + +struct Repo { + users []User +} + +fn (r Repo) find_user_by_id(id int) ! User { + for user in r.users { + if user.id == id { + // V automatically wraps this into an option type + return user + } + } + return error('User $id not found') +} + +fn main() { + repo := Repo{ + users: [User{1, 'Andrew'}, User{2, 'Bob'}, User{10, 'Charles'}] + } + user := repo.find_user_by_id(10) or { + println(err) // "User 10 not found" + return + } + println(user.id) // "10" + println(user.name) // "Charles" +} + +import net.http + +fn f(url string) ?string { + resp := http.get(url)? + return resp.text +} + +resp := http.get(url) or { return err } + +if resp := http.get('https://google.com') { + println(resp.text) // resp is a http.Response, not an optional +} else { + println(err) +} + +fn do_something(s string) !string { + if s == 'foo' { + return 'foo' + } + return error('invalid string') // Could be `return none` as well +} + +a := do_something('foo') or { 'default' } // a will be 'foo' +b := do_something('bar') or { 'default' } // b will be 'default' +println(a) +println(b) + +struct Repo { + db DB +} + +struct User { + id int + name string +} + +struct Post { + id int + user_id int + title string + body string +} + +fn new_repo(db DB) Repo { + return Repo{db: db} +} + +// This is a generic function. V will generate it for every type it's used with. +fn (r Repo) find_by_id(id int) ?T { + table_name := T.name // in this example getting the name of the type gives us the table name + return r.db.query_one('select * from $table_name where id = ?', id) +} + +db := new_db() +users_repo := new_repo(db) // returns Repo +posts_repo := new_repo(db) // returns Repo +user := users_repo.find_by_id(1)? // find_by_id +post := posts_repo.find_by_id(1)? // find_by_id + +fn compare(a T, b T) int { + if a < b { + return -1 + } + if a > b { + return 1 + } + return 0 +} + +fn p(a f64, b f64) { // ordinary function without return value + c := math.sqrt(a * a + b * b) + println(c) +} + +fn main() { + go p(3, 4) + // p will be run in parallel thread +} + +fn get_hypot(a f64, b f64) f64 { + c := sqrt(a * a + b * b) + return c +} + +fn main() { + g := go get_hypot(54.06, 2.08) // spawn thread and get handle to it + h1 := get_hypot(2.32, 16.74) // do some other calculation here + h2 := g.wait() // get result from spawned thread + println('Results: $h1, $h2') // prints `Results: 16.9, 54.1` +} + +fn task(id int, duration int) { + println('task $id begin') + time.sleep(duration * time.millisecond) + println('task $id end') +} + +fn main() { + mut threads := []thread{} + threads << go task(1, 500) + threads << go task(2, 900) + threads << go task(3, 100) + threads.wait() + println('done') +} + +fn expensive_computing(i int) int { + return i * i +} + +fn main() { + mut threads := []thread int{} + for i in 1 .. 10 { + threads << go expensive_computing(i) + } + // Join all tasks + r := threads.wait() + println('All jobs finished: $r') +} + +ch := chan int{} // unbuffered - "synchronous" +ch2 := chan f64{cap: 100} // buffer length 100 + +ch := chan int{} +ch2 := chan f64{} +// ... +ch.close() +// ... +m := <-ch or { + println('channel has been closed') +} + +// propagate error +y := <-ch2 ? + +fn main() { + ch := chan f64{} + ch2 := chan f64{} + ch3 := chan f64{} + mut b := 0.0 + c := 1.0 + // ... setup go threads that will send on ch/ch2 + go fn (the_channel chan f64) { + time.sleep(5 * time.millisecond) + the_channel <- 1.0 + }(ch) + go fn (the_channel chan f64) { + time.sleep(1 * time.millisecond) + the_channel <- 1.0 + }(ch2) + go fn (the_channel chan f64) { + _ := <-the_channel + }(ch3) + + select { + a := <-ch { + // do something with `a` + eprintln('> a: $a') + } + b = <-ch2 { + // do something with predeclared variable `b` + eprintln('> b: $b') + } + ch3 <- c { + // do something if `c` was sent + time.sleep(5 * time.millisecond) + eprintln('> c: $c was send on channel ch3') + } + 500 * time.millisecond { + // do something if no channel has become ready within 0.5s + eprintln('> more than 0.5s passed without a channel being ready') + } + } + eprintln('> done') +} + +struct Abc { + x int +} + +a := 2.13 +ch := chan f64{} +res := ch.try_push(a) // try to perform `ch <- a` +println(res) +l := ch.len // number of elements in queue +c := ch.cap // maximum queue length +is_closed := ch.closed // bool flag - has `ch` been closed +println(l) +println(c) +mut b := Abc{} +ch2 := chan Abc{} +res2 := ch2.try_pop(mut b) // try to perform `b = <-ch2` + +struct St { +mut: + x int // data to be shared +} + +fn (shared b St) g() { + lock b { + // read/modify/write b.x + } +} + +fn main() { + shared a := St{ + x: 10 + } + go a.g() + // ... + rlock a { + // read a.x + } +} + +import json + +struct Foo { + x int +} + +struct User { + name string [required] + age int + // Use the `skip` attribute to skip certain fields + foo Foo [skip] + // If the field name is different in JSON, it can be specified + last_name string [json: lastName] +} + +data := '{ "name": "Frodo", "lastName": "Baggins", "age": 25 }' +user := json.decode(User, data) or { + eprintln('Failed to decode json, error: $err') + return +} +println(user.name) +println(user.last_name) +println(user.age) +// You can also decode JSON arrays: +sfoos := '[{"x":123},{"x":456}]' +foos := json.decode([]Foo, sfoos)? +println(foos[0].x) +println(foos[1].x) + + +struct User { + name string + score i64 +} + +mut data := map[string]int{} +user := &User{ + name: 'Pierre' + score: 1024 +} + +data['x'] = 42 +data['y'] = 360 + +println(json.encode(data)) // {"x":42,"y":360} +println(json.encode(user)) // {"name":"Pierre","score":1024} + +fn test_hello() { + assert hello() == 'Hello world' +} + +import strconv + +fn test_atoi() ? { + assert strconv.atoi('1')? == 1 + assert strconv.atoi('one')? == 1 // test will fail +} + +fn test_subtest() { + res := os.execute('${os.quoted_path(@VEXE)} other_test.v') + assert res.exit_code == 1 + assert res.output.contains('other_test.v does not exist') +} + +os.execute('${os.quoted_path("{test}. \${another test}. \{and another\}")} other_test.v') + +struct RefStruct { +mut: + r &MyStruct +} + +[heap] +struct MyStruct { + n int +} + +fn main() { + m := MyStruct{} + mut r := RefStruct{ + r: &m + } + r.g() + println('r: $r') +} + +fn (mut r RefStruct) g() { + s := MyStruct{ + n: 7 + } + r.f(&s) // reference to `s` inside `r` is passed back to `main() ` +} + +fn (mut r RefStruct) f(s &MyStruct) { + r.r = s // would trigger error without `[heap]` +} + +import sqlite + +// sets a custom table name. Default is struct name (case-sensitive) +[table: 'customers'] +struct Customer { + id int [primary; sql: serial] // a field named `id` of integer type must be the first field + name string [nonull] + nr_orders int + country string [nonull] +} + +db := sqlite.connect('customers.db')? + +sql db { + create table Customer +} + +// select count(*) from customers +nr_customers := sql db { + select count from Customer +} +println('number of all customers: $nr_customers') +// V syntax can be used to build queries +uk_customers := sql db { + select from Customer where country == 'uk' && nr_orders > 0 +} +println(uk_customers.len) +for customer in uk_customers { + println('$customer.id - $customer.name') +} +// by adding `limit 1` we tell V that there will be only one object +customer := sql db { + select from Customer where id == 1 limit 1 +} +println('$customer.id - $customer.name') +// insert a new customer +new_customer := Customer{ + name: 'Bob' + nr_orders: 10 +} +sql db { + insert new_customer into Customer +} + +// clearall clears all bits in the array +fn clearall() { +} + +// copy_all recursively copies all elements of the array by their value, +// # Some Heading +// if `dupes` is false all duplicate values are eliminated in the process. +// ---------------------------------------- +fn copy_all(dupes bool) { + // ... +} + +fn main() { + sw := time.new_stopwatch() + println('Hello world') + println('Greeting the world took: ${sw.elapsed().nanoseconds()}ns') +} + +// allocate 2 uninitialized bytes & return a reference to them +mut p := unsafe { malloc(2) } +p[0] = `h` // Error: pointer indexing is only allowed in `unsafe` blocks +unsafe { + p[0] = `h` // OK + p[1] = `i` +} +p++ // Error: pointer arithmetic is only allowed in `unsafe` blocks +unsafe { + p++ // OK +} +assert *p == `i` + +struct Foo { + a int + b int +} + +assert sizeof(Foo) == 8 +assert __offsetof(Foo, a) == 0 +assert __offsetof(Foo, b) == 4 + +#flag -lsqlite3 +#include "sqlite3.h" +// See also the example from https://www.sqlite.org/quickstart.html +struct C.sqlite3 { +} + +struct C.sqlite3_stmt { +} + +type FnSqlite3Callback = fn (voidptr, int, &&char, &&char) int + +fn C.sqlite3_open(&char, &&C.sqlite3) int + +fn C.sqlite3_close(&C.sqlite3) int + +fn C.sqlite3_column_int(stmt &C.sqlite3_stmt, n int) int + +// ... you can also just define the type of parameter and leave out the C. prefix +fn C.sqlite3_prepare_v2(&C.sqlite3, &char, int, &&C.sqlite3_stmt, &&char) int + +fn C.sqlite3_step(&C.sqlite3_stmt) + +fn C.sqlite3_finalize(&C.sqlite3_stmt) + +fn C.sqlite3_exec(db &C.sqlite3, sql &char, cb FnSqlite3Callback, cb_arg voidptr, emsg &&char) int + +fn C.sqlite3_free(voidptr) + +fn my_callback(arg voidptr, howmany int, cvalues &&char, cnames &&char) int { + unsafe { + for i in 0 .. howmany { + print('| ${cstring_to_vstring(cnames[i])}: ${cstring_to_vstring(cvalues[i]):20} ') + } + } + println('|') + return 0 +} + +fn main() { + db := &C.sqlite3(0) // this means `sqlite3* db = 0` + // passing a string literal to a C function call results in a C string, not a V string + C.sqlite3_open(c'users.db', &db) + // C.sqlite3_open(db_path.str, &db) + query := 'select count(*) from users' + stmt := &C.sqlite3_stmt(0) + // NB: you can also use the `.str` field of a V string, + // to get its C style zero terminated representation + C.sqlite3_prepare_v2(db, &char(query.str), -1, &stmt, 0) + C.sqlite3_step(stmt) + nr_users := C.sqlite3_column_int(stmt, 0) + C.sqlite3_finalize(stmt) + println('There are $nr_users users in the database.') + // + error_msg := &char(0) + query_all_users := 'select * from users' + rc := C.sqlite3_exec(db, &char(query_all_users.str), my_callback, voidptr(7), &error_msg) + if rc != C.SQLITE_OK { + eprintln(unsafe { cstring_to_vstring(error_msg) }) + C.sqlite3_free(error_msg) + } + C.sqlite3_close(db) +} + +[export: 'my_custom_c_name'] +fn foo() { +} + +$if windows { + #include "@VEXEROOT/thirdparty/stdatomic/win/atomic.h" +} $else { + #include "@VEXEROOT/thirdparty/stdatomic/nix/atomic.h" +} + +// declare functions we want to use - V does not parse the C header +fn C.atomic_store_u32(&u32, u32) +fn C.atomic_load_u32(&u32) u32 +fn C.atomic_compare_exchange_weak_u32(&u32, &u32, u32) bool +fn C.atomic_compare_exchange_strong_u32(&u32, &u32, u32) bool + +const num_iterations = 10000000 + +// see section "Global Variables" below +__global ( + atom u32 // ordinary variable but used as atomic +) + +fn change() int { + mut races_won_by_change := 0 + for { + mut cmp := u32(17) // addressable value to compare with and to store the found value + // atomic version of `if atom == 17 { atom = 23 races_won_by_change++ } else { cmp = atom }` + if C.atomic_compare_exchange_strong_u32(&atom, &cmp, 23) { + races_won_by_change++ + } else { + if cmp == 31 { + break + } + cmp = 17 // re-assign because overwritten with value of atom + } + } + return races_won_by_change +} + +fn main() { + C.atomic_store_u32(&atom, 17) + t := go change() + mut races_won_by_main := 0 + mut cmp17 := u32(17) + mut cmp23 := u32(23) + for i in 0 .. num_iterations { + // atomic version of `if atom == 17 { atom = 23 races_won_by_main++ }` + if C.atomic_compare_exchange_strong_u32(&atom, &cmp17, 23) { + races_won_by_main++ + } else { + cmp17 = 17 + } + desir := if i == num_iterations - 1 { u32(31) } else { u32(17) } + // atomic version of `for atom != 23 {} atom = desir` + for !C.atomic_compare_exchange_weak_u32(&atom, &cmp23, desir) { + cmp23 = 23 + } + } + races_won_by_change := t.wait() + atom_new := C.atomic_load_u32(&atom) + println('atom: $atom_new, #exchanges: ${races_won_by_main + races_won_by_change}') + // prints `atom: 31, #exchanges: 10000000`) + println('races won by\n- `main()`: $races_won_by_main\n- `change()`: $races_won_by_change') +} + +import sync + +__global ( + sem sync.Semaphore // needs initialization in `init()` + mtx sync.RwMutex // needs initialization in `init()` + f1 = f64(34.0625) // explicily initialized + shmap shared map[string]f64 // initialized as empty `shared` map + f2 f64 // initialized to `0.0` +) + +fn init() { + sem.init(0) + mtx.init() +} + +#flag linux -lsdl2 +#flag linux -Ivig +#flag linux -DCIMGUI_DEFINE_ENUMS_AND_STRUCTS=1 +#flag linux -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1 +#flag linux -DIMGUI_IMPL_API= + +#pkgconfig r_core +#pkgconfig --cflags --libs r_core + +$if $pkgconfig('mysqlclient') { + #pkgconfig mysqlclient +} $else $if $pkgconfig('mariadb') { + #pkgconfig mariadb +} + +#flag -I @VMODROOT/c +#flag @VMODROOT/c/implementation.o +#include "header.h" + +fn main() { + // Support for multiple conditions in one branch + $if ios || android { + println('Running on a mobile device!') + } + $if linux && x64 { + println('64-bit Linux.') + } + // Usage as expression + os := $if windows { 'Windows' } $else { 'UNIX' } + println('Using $os') + // $else-$if branches + $if tinyc { + println('tinyc') + } $else $if clang { + println('clang') + } $else $if gcc { + println('gcc') + } $else { + println('different compiler') + } + $if test { + println('testing') + } + // v -cg ... + $if debug { + println('debugging') + } + // v -prod ... + $if prod { + println('production build') + } + // v -d option ... + $if option ? { + println('custom option') + } +} + +fn main() { + embedded_file := $embed_file('v.png', .zlib) // compressed using zlib + os.write_file('exported.png', embedded_file.to_string())? + + compile_time_env := $env('ENV_VAR') + println(compile_time_env) +} + +fn build() string { + name := 'Peter' + age := 25 + numbers := [1, 2, 3] + return $tmpl('1.txt') +} + +$if linux { + $compile_error('Linux is not supported') +} + +eprintln('file: ' + @FILE + ' | line: ' + @LINE + ' | fn: ' + @MOD + '.' + @FN) + +import v.vmod +vm := vmod.decode( @VMOD_FILE ) or { panic(err) } +eprintln('$vm.name $vm.version\n $vm.description') + +fn main() { + $for field in User.fields { + $if field.typ is string { + println('$field.name is of type string') + } + } +} + +struct Vec { + x int + y int +} + +fn (a Vec) str() string { + return '{$a.x, $a.y}' +} + +fn (a Vec) + (b Vec) Vec { + return Vec{a.x + b.x, a.y + b.y} +} + +fn (a Vec) - (b Vec) Vec { + return Vec{a.x - b.x, a.y - b.y} +} + +fn main() { + a := Vec{2, 3} + b := Vec{4, 5} + mut c := Vec{1, 2} + println(a + b) // "{6, 8}" + println(a - b) // "{-2, -2}" + c += a + println(c) // "{3, 5}" +} + +a := 100 +b := 20 +mut c := 0 +asm amd64 { + mov eax, a + add eax, b + mov c, eax + ; =r (c) as c // output + ; r (a) as a // input + r (b) as b +} +println('a: $a') // 100 +println('b: $b') // 20 +println('c: $c') // 120 + +// [flag] enables Enum types to be used as bitfields + +[flag] +enum BitField { + read + write + other +} + +fn main() { + assert 1 == int(BitField.read) + assert 2 == int(BitField.write) + mut bf := BitField.read + assert bf.has(.read | .other) // test if *at least one* of the flags is set + assert !bf.all(.read | .other) // test if *all* of the flags is set + bf.set(.write | .other) + assert bf.has(.read | .write | .other) + assert bf.all(.read | .write | .other) + bf.toggle(.other) + assert bf == BitField.read | .write + assert bf.all(.read | .write) + assert !bf.has(.other) +} + +// Calling this function will result in a deprecation warning +[deprecated] +fn old_function() { +} + +// It can also display a custom deprecation message +[deprecated: 'use new_function() instead'] +[deprecated_after: '2021-05-27'] +fn legacy_function() {} + +// This function's calls will be inlined. +[inline] +fn inlined_function() { +} + +// This function's calls will NOT be inlined. +[noinline] +fn function() { +} + +[if debug] +fn foo() { +} + +fn bar() { + foo() // will not be called if `-d debug` is not passed +} + +if x { + // ... + if y { + unsafe { + goto my_label + } + } + // ... +} +my_label: \ No newline at end of file diff --git a/lexers/testdata/v/v.expected b/lexers/testdata/v/v.expected new file mode 100644 index 000000000..b33b362da --- /dev/null +++ b/lexers/testdata/v/v.expected @@ -0,0 +1,10363 @@ +[ + {"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":":"} +] diff --git a/lexers/testdata/v/v.mode.actual b/lexers/testdata/v/v.mode.actual new file mode 100644 index 000000000..92d495943 --- /dev/null +++ b/lexers/testdata/v/v.mode.actual @@ -0,0 +1,6 @@ +Module { + name: 'mymodule', + description: 'My nice module wraps a simple C library.', + version: '0.0.1' + dependencies: [] +} \ No newline at end of file diff --git a/lexers/testdata/v/v.mode.expected b/lexers/testdata/v/v.mode.expected new file mode 100644 index 000000000..ec56ffdc2 --- /dev/null +++ b/lexers/testdata/v/v.mode.expected @@ -0,0 +1,29 @@ +[ + {"type":"NameClass","value":"Module"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n\t"}, + {"type":"NameVariable","value":"name"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"LiteralStringSingle","value":"'mymodule'"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n\t"}, + {"type":"NameVariable","value":"description"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"LiteralStringSingle","value":"'My nice module wraps a simple C library.'"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n\t"}, + {"type":"NameVariable","value":"version"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"LiteralStringSingle","value":"'0.0.1'"}, + {"type":"Text","value":"\n\t"}, + {"type":"NameVariable","value":"dependencies"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"[]"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"} +] diff --git a/lexers/testdata/vshell.actual b/lexers/testdata/vshell.actual new file mode 100644 index 000000000..5600127a7 --- /dev/null +++ b/lexers/testdata/vshell.actual @@ -0,0 +1,24 @@ +#!/usr/bin/env -S v run +// The shebang above associates the file to V on Unix-like systems, +// so it can be run just by specifying the path to the file +// once it's made executable using `chmod +x`. + +// print command then execute it +fn sh(cmd string){ + println("❯ $cmd") + print(execute_or_exit(cmd).output) +} + +// Remove if build/ exits, ignore any errors if it doesn't +rmdir_all('build') or { } + +// Create build/, never fails as build/ does not exist +mkdir('build')? + +// Move *.v files to build/ +result := execute('mv *.v build/') +if result.exit_code != 0 { + println(result.output) +} + +sh('ls') \ No newline at end of file diff --git a/lexers/testdata/vshell.expected b/lexers/testdata/vshell.expected new file mode 100644 index 000000000..971e7f47c --- /dev/null +++ b/lexers/testdata/vshell.expected @@ -0,0 +1,88 @@ +[ + {"type":"CommentHashbang","value":"#!/usr/bin/env -S v run\n"}, + {"type":"CommentSingle","value":"// The shebang above associates the file to V on Unix-like systems,\n// so it can be run just by specifying the path to the file\n// once it's made executable using `chmod +x`.\n"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSingle","value":"// print command then execute it\n"}, + {"type":"KeywordDeclaration","value":"fn"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"sh"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"cmd"}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"string"}, + {"type":"Punctuation","value":"){"}, + {"type":"Text","value":"\n "}, + {"type":"NameBuiltin","value":"println"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringDouble","value":"\"❯ "}, + {"type":"Operator","value":"$"}, + {"type":"NameVariable","value":"cmd"}, + {"type":"LiteralStringDouble","value":"\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"NameBuiltin","value":"print"}, + {"type":"Punctuation","value":"("}, + {"type":"NameBuiltin","value":"execute_or_exit"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"cmd"}, + {"type":"Punctuation","value":")."}, + {"type":"NameVariable","value":"output"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"CommentSingle","value":"// Remove if build/ exits, ignore any errors if it doesn't\n"}, + {"type":"NameBuiltin","value":"rmdir_all"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringSingle","value":"'build'"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"or"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"CommentSingle","value":"// Create build/, never fails as build/ does not exist\n"}, + {"type":"NameBuiltin","value":"mkdir"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringSingle","value":"'build'"}, + {"type":"Punctuation","value":")"}, + {"type":"KeywordDeclaration","value":"?"}, + {"type":"Text","value":"\n\n"}, + {"type":"CommentSingle","value":"// Move *.v files to build/\n"}, + {"type":"NameVariable","value":"result"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":":="}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"execute"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringSingle","value":"'mv *.v build/'"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"if"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"result"}, + {"type":"Punctuation","value":"."}, + {"type":"NameVariable","value":"exit_code"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"!="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberInteger","value":"0"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n\t"}, + {"type":"NameBuiltin","value":"println"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"result"}, + {"type":"Punctuation","value":"."}, + {"type":"NameVariable","value":"output"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"NameFunction","value":"sh"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralStringSingle","value":"'ls'"}, + {"type":"Punctuation","value":")"} +] diff --git a/lexers/v.go b/lexers/v.go new file mode 100644 index 000000000..11561b3af --- /dev/null +++ b/lexers/v.go @@ -0,0 +1,173 @@ +package lexers + +import ( + "strings" + + . "github.com/alecthomas/chroma/v2" // nolint +) + +// V lexer. +var V = Register(MustNewLexer( + &Config{ + Name: "V", + Aliases: []string{"v", "vlang"}, + Filenames: []string{"*.v", "*.vv", "v.mod"}, + MimeTypes: []string{"text/x-v"}, + EnsureNL: true, + }, + vRules, +).SetAnalyser(func(text string) float32 { + if strings.Contains(text, "import ") && strings.Contains(text, "module ") { + return 0.2 + } + if strings.Contains(text, "module ") { + return 0.1 + } + return 0.0 +})) + +const ( + namePattern = `[^\W\d]\w*` + typeNamePattern = `[A-Z]\w*` + multiLineCommentPattern = `/\*(?:.|\n)*?\*/` +) + +func vRules() Rules { + return Rules{ + "root": { + {`\n`, Text, nil}, + {`\s+`, Text, nil}, + {`\\\n`, Text, nil}, + {`(?<=module\s+\w[^\n]*\s+)(//[^\n]+\n)+(?=\n)`, StringDoc, nil}, + {`(// *)(\w+)([^\n]+\n)(?=(?://[^\n]*\n)* *(?:pub +)?(?:fn|struct|union|type|interface|enum|const) +\2\b)`, ByGroups(StringDoc, GenericEmph, StringDoc), Push(`string-doc`)}, + {`//[^\n]*\n`, CommentSingle, nil}, + {`/\*(?:(?:` + multiLineCommentPattern + `)*|.|\n)*\*/`, CommentMultiline, nil}, + {`\b(import|module)\b`, KeywordNamespace, nil}, + {`\b(fn|struct|union|map|chan|type|interface|enum|const|mut|shared|pub|__global)\b`, KeywordDeclaration, nil}, + {`\?`, KeywordDeclaration, nil}, + {`(?<=\)\s*)!`, KeywordDeclaration, nil}, + {`[ \t]*#include[^\n]+`, Using(`c`), nil}, + {`[ \t]*#\w[^\n]*`, CommentPreproc, nil}, + {`(sql)(\s+)(\w+)(\s+)({)([^}]*?)(})`, ByGroups(Keyword, Text, Name, Text, Punctuation, Using(`sql`), Punctuation), nil}, + {`\$(?=\w)`, Operator, nil}, + {`(?<=\$)(?:embed_file|pkgconfig|tmpl|env|compile_error|compile_warn)`, NameBuiltin, nil}, + {`(asm)(\s+)(\w+)(\s*)({)([^}]*?)(})`, ByGroups(Keyword, Text, KeywordType, Text, Punctuation, Using(`nasm`), Punctuation), nil}, + {`\b_(?:un)?likely_(?=\()`, NameFunctionMagic, nil}, + {`(?<=\$if.+?(?:&&|\|\|)?)(` + Words(``, ``, `windows`, `linux`, `macos`, `mac`, `darwin`, `ios`, `android`, `mach`, `dragonfly`, `gnu`, `hpux`, `haiku`, `qnx`, `solaris`, `gcc`, `tinyc`, `clang`, `mingw`, `msvc`, `cplusplus`, `amd64`, `arm64`, `x64`, `x32`, `little_endian`, `big_endian`, `debug`, `prod`, `test`, `js`, `glibc`, `prealloc`, `no_bounds_checking`, `freestanding`, `no_segfault_handler`, `no_backtrace`, `no_main`) + `)+`, NameBuiltin, nil}, + {`@` + Words(``, `\b`, `FN`, `METHOD`, `MOD`, `STRUCT`, `FILE`, `LINE`, `COLUMN`, `VEXE`, `VEXEROOT`, `VHASH`, `VMOD_FILE`, `VMODROOT`), NameVariableMagic, nil}, + {Words(`\b(?>=|>>>=|>>>|<<|>>|<=|>=|\^=|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\||<-|\+\+|--|==|!=|:=|\.\.\.|\.\.|[+\-*/%&|^~=#@!])`, Operator, nil}, + {`[\d_]+(\.\d+e[+\-]?\d+|\.\d+|e[+\-]?\d+)`, LiteralNumberFloat, nil}, + {`\.\d+(e[+\-]?\d+)?`, LiteralNumberFloat, nil}, + {`0o[0-7_]+`, LiteralNumberOct, nil}, + {`0x[0-9a-fA-F_]+`, LiteralNumberHex, nil}, + {`0b[01_]+`, LiteralNumberBin, nil}, + {`(0|[1-9][0-9_]*)`, LiteralNumberInteger, nil}, + {"`", StringChar, Push(`char`)}, + Include(`strings`), + {`@?` + typeNamePattern, NameClass, nil}, + {`(?<=` + namePattern + `)(<)(` + typeNamePattern + `)(>)`, ByGroups(Punctuation, NameClass, Punctuation), nil}, + {`@?` + namePattern + `(?=\()`, NameFunction, nil}, + {`(?<=fn\s+)@?` + namePattern + `(?=\s*\()`, NameFunction, nil}, + {`(?<=(?:continue|break|goto)\s+)\w+`, NameLabel, nil}, + {`\b` + namePattern + `(?=:(?:$|\s+for))`, NameLabel, nil}, + {`[<>()\[\]{}.,;:]`, Punctuation, nil}, + {`@?` + namePattern, NameVariable, nil}, + }, + "strings": { + {`(c)?(")`, ByGroups(StringAffix, StringDouble), Push(`string-double`)}, + {`(c)?(')`, ByGroups(StringAffix, StringSingle), Push(`string-single`)}, + {`(r)("[^"]+")`, ByGroups(StringAffix, String), nil}, + {`(r)('[^']+')`, ByGroups(StringAffix, String), nil}, + }, + "string-double": { + {`"`, StringDouble, Pop(1)}, + Include(`char-escape`), + {`(\$)((?!\\){)`, ByGroups(Operator, Punctuation), Push(`string-curly-interpolation`)}, + {`\$`, Operator, Push(`string-interpolation`)}, + {`[^"]+?`, StringDouble, nil}, + }, + "string-single": { + {`'`, StringSingle, Pop(1)}, + Include(`char-escape`), + {`(\$)((?!\\){)`, ByGroups(Operator, Punctuation), Push(`string-curly-interpolation`)}, + {`\$`, Operator, Push(`string-interpolation`)}, + {`[^']+?`, StringSingle, nil}, + }, + "char": { + {"`", StringChar, Pop(1)}, + Include(`char-escape`), + {`[^\\]`, StringChar, nil}, + }, + "char-escape": { + {"\\\\[`'\"\\\\abfnrtv$]|\\\\x[0-9a-fA-F]{2}|\\\\[0-7]{1,3}|\\\\u[0-9a-fA-F]{4}|\\\\U[0-9a-fA-F]{8}", StringEscape, nil}, + }, + "string-doc": { + {`(// *)(#+ [^\n]+)(\n)`, ByGroups(StringDoc, GenericHeading, Text), nil}, + {`// *([=_*~-])\1{2,}\n`, StringDelimiter, nil}, + {`//[^\n]*\n`, StringDoc, nil}, + Default(Pop(1)), + }, + "string-interpolation": { + {`(\.)?(@)?(?:(` + namePattern + `)(\()([^)]*)(\))|(` + namePattern + `))`, ByGroups(Punctuation, Operator, NameFunction, Punctuation, UsingSelf(`root`), Punctuation, NameVariable), nil}, + Default(Pop(1)), + }, + "string-curly-interpolation": { + {`}`, Punctuation, Pop(1)}, + Include(`strings`), + {`(:)( *?)([ 0'#+-])?(?:(\.)?([0-9]+))?([fFgeEGxXobsd])?`, ByGroups(Punctuation, Text, Operator, Punctuation, Number, StringAffix), nil}, + {`[^}"':]+`, UsingSelf(`root`), nil}, + }, + "attribute": { + {`\]`, Punctuation, Pop(1)}, + {`'`, Punctuation, Push(`string-single`)}, + {`"`, Punctuation, Push(`string-double`)}, + {`[;:]`, Punctuation, nil}, + {`(?<=\[)if\b`, Keyword, nil}, + {`\s+`, Text, nil}, + {`(?<=: *)\w+`, String, nil}, + {namePattern, NameAttribute, nil}, + }, + } +} + +// V shell lexer. +var VSH = Register(MustNewLexer( + &Config{ + Name: "V shell", + Aliases: []string{"vsh", "vshell"}, + Filenames: []string{"*.vsh"}, + MimeTypes: []string{"text/x-vsh"}, + EnsureNL: true, + }, + vshRules, +).SetAnalyser(func(text string) float32 { + firstLine := strings.Split(text, "\n")[0] + if strings.Contains(firstLine, "#!/usr/bin/env") && strings.Contains(firstLine, "v run") { + return 1.0 + } + if strings.Contains(firstLine, "#!/") && strings.Contains(firstLine, "/v run") { + return 1.0 + } + return 0.0 +})) + +func vshRules() Rules { + vshRules := vRules() + vshRoot := []Rule{ + {`^#![^\n]*\n`, CommentHashbang, nil}, + {Words(`\b`, `\b`, `args`, `max_path_len`, `wd_at_startup`, `sys_write`, `sys_open`, `sys_close`, `sys_mkdir`, `sys_creat`, `path_separator`, `path_delimiter`, `s_ifmt`, `s_ifdir`, `s_iflnk`, `s_isuid`, `s_isgid`, `s_isvtx`, `s_irusr`, `s_iwusr`, `s_ixusr`, `s_irgrp`, `s_iwgrp`, `s_ixgrp`, `s_iroth`, `s_iwoth`, `s_ixoth`), NameConstant, nil}, + {Words(`\b`, `\b`, `ProcessState`, `SeekMode`, `Signal`, `Command`, `ExecutableNotFoundError`, `File`, `FileNotOpenedError`, `Process`, `Result`, `SizeOfTypeIs0Error`, `Uname`), NameBuiltin, nil}, + {Words(`\b`, `(?=\()`, `abs_path`, `args_after`, `args_before`, `base`, `cache_dir`, `chdir`, `chmod`, `chown`, `config_dir`, `cp`, `cp_all`, `create`, `debugger_present`, `dir`, `environ`, `executable`, `execute`, `execute_or_exit`, `execute_or_panic`, `execve`, `execvp`, `existing_path`, `exists`, `exists_in_system_path`, `expand_tilde_to_home`, `fd_close`, `fd_read`, `fd_slurp`, `fd_write`, `file_ext`, `file_last_mod_unix`, `file_name`, `file_size`, `fileno`, `find_abs_path_of_executable`, `flush`, `fork`, `get_error_msg`, `get_line`, `get_lines`, `get_lines_joined`, `get_raw_line`, `get_raw_lines_joined`, `get_raw_stdin`, `getegid`, `getenv`, `getenv_opt`, `geteuid`, `getgid`, `getpid`, `getppid`, `getuid`, `getwd`, `glob`, `home_dir`, `hostname`, `inode`, `input`, `input_opt`, `is_abs_path`, `is_atty`, `is_dir`, `is_dir_empty`, `is_executable`, `is_file`, `is_link`, `is_readable`, `is_writable`, `is_writable_folder`, `join_path`, `join_path_single`, `last_error`, `link`, `log`, `loginname`, `ls`, `mkdir`, `mkdir_all`, `mv`, `mv_by_cp`, `new_process`, `norm_path`, `open`, `open_append`, `open_file`, `open_uri`, `posix_get_error_msg`, `posix_set_permission_bit`, `quoted_path`, `read_bytes`, `read_file`, `read_file_array`, `read_lines`, `real_path`, `resource_abs_path`, `rm`, `rmdir`, `rmdir_all`, `setenv`, `sigint_to_signal_name`, `signal_opt`, `stderr`, `stdin`, `stdout`, `symlink`, `system`, `temp_dir`, `truncate`, `uname`, `unsetenv`, `user_os`, `utime`, `vfopen`, `vmodules_dir`, `vmodules_paths`, `wait`, `walk`, `walk_ext`, `walk_with_context`, `write_file`, `write_file_array`, `bitmask`, `close`, `read_line`, `start`, `msg`, `read`, `read_bytes_at`, `read_bytes_into`, `read_bytes_into_newline`, `read_from`, `read_into_ptr`, `read_raw`, `read_raw_at`, `read_struct`, `read_struct_at`, `seek`, `tell`, `write`, `write_raw`, `write_raw_at`, `write_string`, `write_struct`, `write_struct_at`, `write_to`, `writeln`, `is_alive`, `run`, `set_args`, `set_environment`, `set_redirect_stdio`, `signal_continue`, `signal_kill`, `signal_pgkill`, `signal_stop`, `stderr_read`, `stderr_slurp`, `stdin_write`, `stdout_read`, `stdout_slurp`), NameBuiltin, nil}, + } + + vshRules[`root`] = append(vshRoot, vshRules[`root`]...) + + return vshRules +}