diff options
| author | Georg Brandl <georg@python.org> | 2021-01-18 21:24:00 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2021-01-18 22:08:36 +0100 |
| commit | 2a3d3a7d5b9c60dedf6638d876161d9563faebcf (patch) | |
| tree | 809c0b4a686db98f5954afa1944404cd9652c6b2 /tests/lexers/cr/example.txt | |
| parent | f0445be718da83541ea3401aad882f3937147263 (diff) | |
| download | pygments-git-examplefiles.tar.gz | |
Move test_examplefiles to new tests/lexers scheme.examplefiles
Diffstat (limited to 'tests/lexers/cr/example.txt')
| -rw-r--r-- | tests/lexers/cr/example.txt | 15144 |
1 files changed, 15144 insertions, 0 deletions
diff --git a/tests/lexers/cr/example.txt b/tests/lexers/cr/example.txt new file mode 100644 index 00000000..c6cbda6c --- /dev/null +++ b/tests/lexers/cr/example.txt @@ -0,0 +1,15144 @@ +---input--- +# Examples taken from http://crystal-lang.org/docs/ +# Copyright 2012-2018 Manas Technology Solutions. +# Updated on May 17th, 2018 by @faustinoaq. + +require "http/server" + +server = HTTP::Server.new(8080) do |context| + context.response.content_type = "text/plain" + context.response.print "Hello world! The time is #{Time.now}" +end + +puts "Listening on http://0.0.0.0:8080" +server.listen + +module HTTP + class RequestHandler + end +end + +alias NumericValue = Float32 | Float64 | Int32 | Int64 + +enum Time::DayOfWeek +end + +class Greeting + class_property global_greeting = "Hello world" + + @@default_greeting = "Hello world" + + def initialize(@custom_greeting = nil) + end + + def print_greeting + greeting = @custom_greeting || @@default_greeting + puts greeting + end +end + +LUCKY_NUMBERS = [3, 7, 11] +DOCUMENTATION_URL = "http://crystal-lang.org/docs" + +module Scorecard + class Parser + def parse(score_text) + begin + score_text.scan(SCORE_PATTERN) do |match| + handle_match(match) + end + rescue err : ParseError + # handle error ... + end + end + end +end + +module Money + CURRENCIES = { + "EUR" => 1.0, + "ARS" => 10.55, + "USD" => 1.12, + "JPY" => 134.15, + } + + class Amount + getter :currency, :value + + def initialize(@currency, @value) + end + end + + class CurrencyConversion + def initialize(@amount, @target_currency) + end + + def amount + # implement conversion ... + end + end +end + +i = 0 +while i < 10 + proc = ->(x : Int32) do + spawn do + puts(x) + end + end + proc.call(i) + i += 1 +end + +Fiber.yield + +# A buffered channel of capacity 2 +channel = Channel(Int32).new(2) + +spawn do + channel.send(1) + channel.send(2) + channel.send(3) +end + +3.times do |i| + puts channel.receive +end + +class MyDictionary(K, V) +end + +MyBox.new(1) # :: MyBox(Int32) +MyBox.new("hello") # :: MyBox(String) + +module Moo(T) + def t + T + end +end + +class Foo(U) + include Moo(U) + + def initialize(@value : U) + end +end + +foo = Foo.new(1) +foo.t # Int32 + +class Parent(T) +end + +class Int32Child < Parent(Int32) +end + +class GenericChild(T) < Parent(T) +end + +class Person +end + +a = 1 +ptr = pointerof(a) +ptr[100_000] = 2 # undefined behaviour, probably a segmentation fault + +alias Int32OrString = Int32 | String + +alias Int32OrNil = Int32? + +alias Int32OrNil_ = Int32 | ::Nil + +alias Int32Ptr = Int32* + +alias Int32Ptr_ = Pointer(Int32) + +alias Int32_8 = Int32[8] + +alias Int32_8_ = StaticArray(Int32, 8) + +alias Int32StringTuple = {Int32, String} + +alias Int32StringTuple_ = Tuple(Int32, String) + +alias Int32ToString = Int32 -> String + +alias Int32ToString_ = Proc(Int32, String) + +alias ProcThatReturnsInt32 = -> Int32 + +alias Int32AndCharToString = Int32, Char -> String + +alias ComplexProc = (Int32 -> Int32) -> String + +def foo(x : Int32) + "instance" +end + +def foo(x : Int32.class) + "class" +end + +foo 1 # "instance" +foo Int32 # "class" + +class Parent +end + +class Child1 < Parent +end + +class Child2 < Parent +end + +ary = [] of Parent.class +ary << Child1 +ary << Child2 + +# Same as not specifying a restriction, not very useful +def foo(x : _) +end + +# A bit more useful: any two arguments Proc that returns an Int32: +def foo(x : _, _ -> Int32) +end + +# alias SameAsInt32 = typeof(2) +# alias Int32OrString_ = typeof(1, "a") + +class Person + def initialize(name) + @name = name + @age = 0 + end + + def name + @name + end + + def age + @age + end +end + +john = Person.new "John" +peter = Person.new "Peter" + +john.name # => "John" +john.age # => 0 + +peter.name # => "Peter" + +class Person + def self.new(name) + instance = Person.allocate + instance.initialize(name) + instance + end +end + +if a.is_a?(String) + # here a is a String +end + +if b.is_a?(Number) + # here b is a Number +end + +a = some_condition ? 1 : "hello" +# a : Int32 | String + +if a.is_a?(Number) + # a : Int32 +else + # a : String +end + +if a.is_a?(String) && b.is_a?(Number) + # here a is a String and b is a Number +end + +a.+(b) + +struct Vector2 + getter x, y + + def initialize(@x, @y) + end + + def +(other) + Vector2.new(x + other.x, y + other.y) + end +end + +v1 = Vector2.new(1, 2) +v2 = Vector2.new(3, 4) +v1 + v2 # => Vector2(@x=4, @y=6) + +struct Vector2 + def - + Vector2.new(-x, -y) + end +end + +v1 = Vector2.new(1, 2) +-v1 # => Vector2(@x=-1, @y=-2) + +class MyArray + def [](index) + # ... + end + + def [](index1, index2, index3) + # ... + end + + def []=(index, value) + # ... + end +end + +array = MyArray.new + +array[1] # invokes the first method +array[1, 2, 3] # invokes the second method +array[1] = 2 # invokes the third method + +array.[](1) # invokes the first method +array.[](1, 2, 3) # invokes the second method +array.[]=(1, 2) # invokes the third method + +raise "OH NO!" +raise Exception.new("Some error") + +class MyException < Exception +end + +begin + raise MyException.new("OH NO!") +rescue ex : MyException + puts "Rescued MyException: #{ex.message}" +end + +begin + # ... +rescue ex : MyException | MyOtherException + # only MyException or MyOtherException +rescue + # any other kind of exception +ensure + puts "Cleanup..." +end + +def some_method + something_dangerous +rescue + # execute if an exception is raised +end + +array = [1, 2, 3] +array[4] # raises because of IndexError +array[4]? # returns nil because of index out of bounds + +def some_proc(&block : Int32 -> Int32) + block +end + +x = 0 +proc = ->(i : Int32) { x += i } +proc = some_proc(&proc) +proc.call(1) # => 1 +proc.call(10) # => 11 +x # => 11 + +def add(x, y) + x + y +end + +adder = ->add(Int32, Int32) +adder.call(1, 2) # => 3 + +module Curses + class Window + end +end + +Curses::Window.new + +module ItemsSize + def size + items.size + end +end + +class Items + include ItemsSize + + def items + [1, 2, 3] + end +end + +items = Items.new +items.size # => 3 + +module Base64 + extend self + + def encode64(string) + # ... + end + + def decode64(string) + # ... + end +end + +Base64.encode64 "hello" # => "aGVsbG8=" + +if some_condition + a = 1 +else + a = "hello" +end + +a_as_int = a.as(Int32) +a_as_int.abs # works, compiler knows that a_as_int is Int32 + +ptr = Pointer(Int32).malloc(1) +ptr.as(Int8*) # :: Pointer(Int8) + +array = [1, 2, 3] + +# object_id returns the address of an object in memory, +# so we create a pointer with that address +ptr = Pointer(Void).new(array.object_id) + +# Now we cast that pointer to the same type, and +# we should get the same value +array2 = ptr.as(Array(Int32)) +array2.same?(array) # => true + +a = 1 +b = a.as(Int32 | Float64) +b # :: Int32 | Float64 + +ary = [1, 2, 3] + +# We want to create an array 1, 2, 3 of Int32 | Float64 +ary2 = ary.map { |x| x.as(Int32 | Float64) } + +ary2 # :: Array(Int32 | Float64) +ary2 << 1.5 # OK + +class Person + def initialize(@name) + end + + def name + @name + end +end + +a = [] of Person +x = a.map { |f| f.name } # Error: can't infer block return type + +a = [] of Person +x = a.map { |f| f.name.as(String) } # OK + +Person.new "John" + +a = [] of Person +x = a.map { |f| f.name } # OK + +loop do + do_something + break if some_condition +end + +class Point + def initialize(@x, @y) + end +end + +Point.new 1, 2 + +# 2 x Int32 = 2 x 4 = 8 +instance_sizeof(Point) # => 12 + +a = 1 +while a < 5 + a += 1 + if a == 3 + next + end + puts a +end + +# The above prints the numbers 2, 4 and 5 + +lib C + # In C: double cos(double x) + fun cos(value : Float64) : Float64 + + fun getch : Int32 + + fun srand(seed : UInt32) + + fun exit(status : Int32) : NoReturn + + fun printf(format : UInt8*, ...) : Int32 +end + +C.cos(1.5) # => 0.0707372 +C.srand(1_u32) + +a = 1 +b = 2 +C.printf "%d + %d = %d\n", a, b, a + b + +lib LibSDL + fun init = SDL_Init(flags : UInt32) : Int32 +end + +lib LLVMIntrinsics + fun ceil_f32 = "llvm.ceil.f32"(value : Float32) : Float32 +end + +lib MyLib + fun my_fun(some_size : LibC::SizeT) +end + +@[Link("pcre")] +lib LibPCRE +end + +lib C + {% if flag?(:x86_64) %} + alias SizeT = UInt64 + {% else %} + alias SizeT = UInt32 + {% end %} + + fun memcmp(p1 : Void*, p2 : Void*, size : C::SizeT) : Int32 +end + +lib X + enum SomeEnum + Ten = 10 + Twenty = 10 * 2 + ThirtyTwo = 1 << 5 + end +end + +lib X + enum SomeEnum + A = 1_u32 + end +end + +X::SomeEnum::Zero # => 0_i8 +X::SomeEnum::Two # => 2_i8 + +lib X + fun callback(f : Int32 -> Int32) +end + +f = ->(x : Int32) { x + 1 } +X.callback(f) + +X.callback ->(x) { x + 1 } + +X.callback nil + +lib LibFoo + fun store_callback(callback : ->) + fun execute_callback +end + +LibFoo.store_callback ->{ raise "OH NO!" } +LibFoo.execute_callback + +lib LibFoo + fun store_callback(callback : ->) + + @[Raises] + fun execute_callback +end + +@[Link("pcre")] +lib PCRE + INFO_CAPTURECOUNT = 2 +end + +PCRE::INFO_CAPTURECOUNT # => 2 + +lib U + # In C: + # + # union IntOrFloat { + # int some_int; + # double some_float; + # }; + union IntOrFloat + some_int : Int32 + some_float : Float64 + end +end + +value = U::IntOrFloat.new + +value = uninitialized U::IntOrFlaot +value.some_int # => some garbage value + +value = U::IntOrFloat.new +value.some_int = 1 +value.some_int # => 1 +value.some_float # => 4.94066e-324 + +def change_it(value) + value.some_int = 1 +end + +value = U::IntOrFloat.new +change_it value +value.some_int # => 0 + +lib C + # In C: + # + # struct TimeZone { + # int minutes_west; + # int dst_time; + # }; + struct TimeZone + minutes_west : Int32 + dst_time : Int32 + end +end + +lib C + # This is a forward declaration + struct Node + end + + struct Node + node : Node* + end +end + +tz = C::TimeZone.new + +tz = uninitialized C::TimeZone +tz.minutes_west # => some garbage value + +tz = C::TimeZone.new +tz.minutes_west = 1 +tz.minutes_west # => 1 + +tz = C::TimeZone.new minutes_west: 1, dst_time: 2 +tz.minutes_west # => 1 +tz.dst_time # => 2 + +def change_it(tz) + tz.minutes_west = 1 +end + +tz = C::TimeZone.new +change_it tz +tz.minutes_west # => 0 + +lib C + $errno : Int32 +end + +C.errno # => some value +C.errno = 0 +C.errno # => 0 + +lib C + @[ThreadLocal] + $errno : Int32 +end + +lib C + fun waitpid(pid : Int32, status_ptr : Int32*, options : Int32) : Int32 +end + +status_ptr = uninitialized Int32 + +C.waitpid(pid, pointerof(status_ptr), options) + +C.waitpid(pid, out status_ptr, options) + +lib X + type CInt = Int32 +end + +{% if flag?(:x86_64) %} + # some specific code for 64 bits platforms +{% else %} + # some specific code for non-64 bits platforms +{% end %} + +{% if flag?(:linux) && flag?(:x86_64) %} + # some specific code for linux 64 bits +{% end %} + +lib C + {% if flag?(:linux) && flag?(:x86_64) %} + struct SomeStruct + some_field : Int32 + end + {% else %} + struct SomeStruct + some_field : Int64 + end + {% end %} +end + +# Assigns to a local variable +local = 1 + +# Assigns to a global property +class Global + class_property global1 = 1 + class_getter global2 = 2 + class_setter global3 = 3 + + # Fails on nil + class_property! global4 = 4 + class_getter! global5 = 5 + class_setter! global6 = 6 +end + +class Testing + # Assigns to an instance variable + @instance = 2 + + # Assigns to a class variable + @@class = 3 +end + +local += 1 # same as: local = local + 1 + +# The above is valid with these operators: +# +, -, *, /, %, |, &, ^, **, <<, >> + +local ||= 1 # same as: local || (local = 1) +local &&= 1 # same as: local && (local = 1) + +# A setter +person.name=("John") + +# The above can be written as: +person.name = "John" + +# An indexed assignment +objects.[]=(2, 3) + +# The above can be written as: +objects[2] = 3 + +# Not assignment-related, but also syntax sugar: +objects.[](2, 3) + +# The above can be written as: +objects[2, 3] + +person.age += 1 # same as: person.age = person.age + 1 + +person.name ||= "John" # same as: person.name || (person.name = "John") +person.name &&= "John" # same as: person.name && (person.name = "John") + +objects[1] += 2 # same as: objects[1] = objects[1] + 2 + +objects[1] ||= 2 # same as: objects[1]? || (objects[1] = 2) +objects[1] &&= 2 # same as: objects[1]? && (objects[1] = 2) + +alias PInt32 = Pointer(Int32) + +ptr = PInt32.malloc(1) # : Pointer(Int32) + +alias RecArray = Array(Int32) | Array(RecArray) + +ary = [] of RecArray +ary.push [1, 2, 3] +ary.push ary +ary # => [[1, 2, 3], [...]] + +module Json + alias Type = Nil | + Bool | + Int64 | + Float64 | + String | + Array(Type) | + Hash(String, Type) +end + +a = 1 +if a > 0 + a = 10 +end +a # => 10 + +b = 1 +if b > 2 + b = 10 +else + b = 20 +end +b # => 20 + +if some_condition + do_something +elsif some_other_condition + do_something_else +else + do_that +end + +a = 1 +if some_condition + a = "hello" +else + a = true +end +# a : String | Bool + +b = 1 +if some_condition + b = "hello" +end +# b : Int32 | String + +if some_condition + c = 1 +else + c = "hello" +end +# c : Int32 | String + +if some_condition + d = 1 +end +# d : Int32 | Nil + +a = 1 +if some_condition + a = "hello" + # a : String + a.size +end +# a : String | Int32 + +if some_condition + e = 1 +else + e = "hello" + # e : String + return +end +# e : Int32 + +enum Color : UInt8 + Red # 0 + Green # 1 + Blue = 5 # overwritten to 5 + Yellow # 6 (5 + 1) + + def red? + self == Color::Red + end +end + +Color::Red.value # :: UInt8 + +@[Flags] +enum IOMode + Read # 1 + Write # 2 + Async # 4 +end + +IOMode::None.value # => 0 +IOMode::All.value # => 7 + +puts(Color::Red) # prints "Red" +puts(IOMode::Write | IOMode::Async) # prints "Write, Async" + +puts Color.new(1) # => prints "Green" + +puts Color.new(10) # => prints "10" + +Color::Red.red? # => true +Color::Blue.red? # => false + +def paint(color : Color) + case color + when Color::Red + # ... + else + # Unusual, but still can happen + raise "unknown color: #{color}" + end +end + +paint Color::Red + +def paint(color : Symbol) + case color + when :red + # ... + else + raise "unknown color: #{color}" + end +end + +paint :red + +name = "Crystal" +age = 1 + +flower = "Tulip" +# At this point 'flower' is a String + +flower = 1 + +# At this point 'flower' is an Int32 + +class Foo + def finalize + # Invoked when Foo is garbage-collected + puts "Bye bye from #{self}!" + end +end + +# Prints "Bye bye ...!" for ever +loop do + Foo.new +end + +# Defines a method in the program +def add(x, y) + x + y +end + +# Invokes the add method in the program +add(1, 2) # => 3 + +def even?(num) + if num % 2 == 0 + return true + end + + return false +end + +def add(x, y) + x + y +end + +class Foo + def bar + # invokes the program's add method + add(1, 2) + + # invokes Foo's baz method + baz(1, 2) + end + + def baz(x, y) + x * y + end +end + +def baz(x, y) + x + y +end + +class Foo + def bar + baz(4, 2) # => 2 + ::baz(4, 2) # => 6 + end + + def baz(x, y) + x - y + end +end + +x = 1 + +def add(y) + x + y # error: undefined local variable or method 'x' +end + +add(2) + +add 1, 2 # same as add(1, 2) + +class Counter + @@instances = 0 + + def initialize + @@instances += 1 + end + + def self.instances + @@instances + end +end + +Counter.instances # => 0 +Counter.new +Counter.new +Counter.new +Counter.instances # => 3 + +class Counter + def self.increment + @@instances += 1 + end +end + +Counter.increment # Error: undefined method '+' for Nil + +class Parent + @@counter = 0 +end + +class Child < Parent + def self.counter + @@counter + end +end + +Child.counter # => nil + +unless some_condition + then_expression +else + else_expression +end + +# Can also be written as a suffix +close_door unless door_closed? + +a = 1 +b = typeof(a) # => Int32 + +typeof(1, "a", 'a') # => (Int32 | String | Char) + +hash = {} of Int32 => String +another_hash = typeof(hash).new # :: Hash(Int32, String) + +class Array + def self.elem_type(typ) + if typ.is_a?(Array) + elem_type(typ.first) + else + typ + end + end +end + +nest = [1, ["b", [:c, ['d']]]] +flat = Array(typeof(Array.elem_type(nest))).new +typeof(nest) # => Array(Int32 | Array(String | Array(Symbol | Array(Char)))) +typeof(flat) # => Array(String | Int32 | Symbol | Char) + +a = 2 if some_condition + +x = 0 +proc = ->{ x += 1; x } +proc.call # => 1 +proc.call # => 2 +x # => 2 + +def counter + x = 0 + ->{ x += 1; x } +end + +proc = counter +proc.call # => 1 +proc.call # => 2 + +def foo + yield +end + +x = 1 +foo do + x = "hello" +end +x # : Int32 | String + +x = 1 +foo do + x = "hello" +end +x # : Int32 | String + +x = 'a' +x # : Char + +def capture(&block) + block +end + +x = 1 +capture { x = "hello" } + +x = 'a' +x # : Int32 | String | Char + +def capture(&block) + block +end + +x = 1 +->{ x = "hello" } + +x = 'a' +x # : Int32 | String | Char + +abstract class Animal + # Makes this animal talk + abstract def talk +end + +class Dog < Animal + def talk + "Woof!" + end +end + +class Cat < Animal + def talk + "Miau" + end +end + +class Person + getter pet + + def initialize(@name, @pet) + end +end + +john = Person.new "John", Dog.new +peter = Person.new "Peter", Cat.new + +john.pet.talk # => "Woof!" + +a = 1 > 2 ? 3 : 4 + +# The above is the same as: +a = if 1 > 2 + 3 + else + 4 + end + +def some_method : String + "hello" +end + +PI = 3.14 + +module Earth + RADIUS = 6_371_000 +end + +PI # => 3.14 +Earth::RADIUS # => 6_371_000 + +TEN = begin + a = 0 + while a < 10 + a += 1 + end + a +end + +TEN # => 10 + +class Person + getter name + + def initialize(@name) + @age = 0 + end +end + +john = Person.new "John" +john.name # => "John" +john.name.size # => 4 + +one = Person.new 1 +one.name # => 1 +one.name + 2 # => 3 + +john = Person.new "John" +one = Person.new 1 + +john = Person.new "John" +one = Person.new 1 + +# Error: undefined method 'size' for Int32 +john.name.size + +# Error: no overload matches 'String#+' with types Int32 +john.name + 3 + +john = Person.new "John" +john.name.size +one = Person.new 1 + +class Person + getter name + + def initialize(@name) + @age = 0 + end + + def address + @address + end + + def address=(@address) + end +end + +john = Person.new "John" +john.address = "Argentina" + +# Error: undefined method 'size' for Nil +john.address.size + +class Person + @age = 0 + + def initialize(@name) + end +end + +class Person + @age : Int32 + + def initialize(@name) + @age = 0 + end +end + +a = if 2 > 1 + 3 + else + 4 + end +a # => 3 + +if 1 > 2 +else + 3 +end + +def twice(&block) + yield + yield +end + +twice() do + puts "Hello!" +end + +twice do + puts "Hello!" +end + +twice { puts "Hello!" } + +def twice + yield 1 + yield 2 +end + +twice do |i| + puts "Got #{i}" +end + +twice { |i| puts "Got #{i}" } + +def many + yield 1, 2, 3 +end + +many do |x, y, z| + puts x + y + z +end + +# Output: 6 + +def many + yield 1, 2, 3 +end + +many do |x, y| + puts x + y +end + +# Output: 3 + +def twice + yield + yield +end + +twice do |i| + puts i.inspect +end + +def some + yield 1, 'a' + yield true, "hello" + yield 2 +end + +some do |first, second| + # first is Int32 | Bool + # second is Char | String | Nil +end + +method do |argument| + argument.some_method +end + +method(&.some_method) + +method &.some_method(arg1, arg2) + +method &.+(2) +method &.[index] + +def twice + v1 = yield 1 + puts v1 + + v2 = yield 2 + puts v2 +end + +twice do |i| + i + 1 +end + +ary = [1, 2, 3] +ary.map { |x| x + 1 } # => [2, 3, 4] +ary.select { |x| x % 2 == 1 } # => [1, 3] + +def transform(value) + yield value +end + +transform(1) { |x| x + 1 } # => 2 + +def thrice + puts "Before 1" + yield 1 + puts "Before 2" + yield 2 + puts "Before 3" + yield 3 + puts "After 3" +end + +thrice do |i| + if i == 2 + break + end +end + +def twice + yield 1 + yield 2 +end + +twice { |i| i + 1 } # => 3 +twice { |i| break "hello" } # => "hello" + +value = twice do |i| + if i == 1 + break "hello" + end + i + 1 +end +value # :: Int32 | String + +values = twice { break 1, 2 } +values # => {1, 2} + +value = twice { break } +value # => nil + +def twice + yield 1 + yield 2 +end + +twice do |i| + if i == 1 + puts "Skipping 1" + next + end + + puts "Got #{i}" +end + +def twice + v1 = yield 1 + puts v1 + + v2 = yield 2 + puts v2 +end + +twice do |i| + if i == 1 + next 10 + end + + i + 1 +end + +# Output +# 10 +# 3 + +class Foo + def one + 1 + end + + def yield_with_self + with self yield + end + + def yield_normally + yield + end +end + +def one + "one" +end + +Foo.new.yield_with_self { one } # => 1 +Foo.new.yield_normally { one } # => "one" + +def twice + yield 1 + yield 2 +end + +twice do |i| + puts "Got: #{i}" +end + +i = 1 +puts "Got: #{i}" +i = 2 +puts "Got: #{i}" + +3.times do |i| + puts i +end + +struct Int + def times + i = 0 + while i < self + yield i + i += 1 + end + end +end + +i = 0 +while i < 3 + puts i + i += 1 +end + +class Person + def initialize(@name) + end + + def greet + puts "Hi, I'm #{@name}" + end +end + +class Employee < Person +end + +employee = Employee.new "John" +employee.greet # "Hi, I'm John" + +class Person + def initialize(@name) + end +end + +class Employee < Person + def initialize(@name, @company_name) + end +end + +Employee.new "John", "Acme" # OK +Employee.new "Peter" # Error: wrong number of arguments +# for 'Employee:Class#new' (1 for 2) + +class Person + def greet(msg) + puts "Hi, #{msg}" + end +end + +class Employee < Person + def greet(msg) + puts "Hello, #{msg}" + end +end + +p = Person.new +p.greet "everyone" # "Hi, everyone" + +e = Employee.new +e.greet "everyone" # "Hello, everyone" + +class Person + def greet(msg) + puts "Hi, #{msg}" + end +end + +class Employee < Person + def greet(msg : Int32) + puts "Hi, this is a number: #{msg}" + end +end + +e = Employee.new +e.greet "everyone" # "Hi, everyone" + +e.greet 1 # "Hi, this is a number: 1" + +class Person + def greet(msg) + puts "Hello, " # {msg}" + end +end + +class Employee < Person + def greet(msg) + super # Same as: super(msg) + super("another message") + end +end + +def int_to_int(&block : Int32 -> Int32) + block +end + +proc = int_to_int { |x| x + 1 } +proc.call(1) # => 2 + +class Model + def on_save(&block) + @on_save_callback = block + end + + def save + if callback = @on_save_callback + callback.call + end + end +end + +model = Model.new +model.on_save { puts "Saved!" } +model.save # prints "Saved!" + +def some_proc(&block : Int32 ->) + block +end + +proc = some_proc { |x| x + 1 } +proc.call(1) # void + +def some_proc(&block : Int32 -> _) + block +end + +proc = some_proc { |x| x + 1 } +proc.call(1) # 2 + +proc = some_proc { |x| x.to_s } +proc.call(1) # "1" + +macro update_x + x = 1 +end + +x = 0 +update_x +x # => 1 + +macro dont_update_x + %x = 1 + puts %x +end + +x = 0 +dont_update_x # outputs 1 +x # => 0 + +macro fresh_vars_sample(*names) + # First declare vars + {% for name, index in names %} + print "Declaring: ", "%name{index}", '\n' + %name{index} = {{index}} + {% end %} + + # Then print them + {% for name, index in names %} + print "%name{index}: ", %name{index}, '\n' + {% end %} +end + +fresh_vars_sample a, b, c + +# Sample output: +# Declaring: __temp_255 +# Declaring: __temp_256 +# Declaring: __temp_257 +# __temp_255: 0 +# __temp_256: 1 +# __temp_257: 2 + +class Object + macro instance_vars_names + def instance_vars_names : Array(String) + {{ @type.instance_vars.map &.name.stringify }} + end + end +end + +class Person + def initialize(@name, @age) + end +end + +person = Person.new "John", 30 +person.instance_vars_names # => ["name", "age"] + +class Object + macro has_instance_var?(name) + def has_instance_var?(name) : Bool + # We cannot access name inside the macro expansion here, + # instead we need to use the macro language to construct an array + # and do the inclusion check at runtime. + {{ @type.instance_vars.map &.name.stringify }}.includes? name + end + end +end + +person = Person.new "John", 30 +person.has_instance_var?("name") # => true +person.has_instance_var?("birthday") # => false + +class Parent + macro inherited + def {{@type.name.downcase.id}} + 1 + end + end +end + +class Child < Parent +end + +Child.new.child # => 1 + +macro method_missing(name, args, block) + print "Got ", {{name.id.stringify}}, " with ", {{args.size}}, " arguments", '\n' +end + +foo # Prints: Got foo with 0 arguments +bar 'a', 'b' # Prints: Got bar with 2 arguments + +sizeof(Int32) # => 4 +sizeof(Int64) # => 8 + +# On a 64 bits machine +sizeof(Pointer(Int32)) # => 8 +sizeof(String) # => 8 + +a = 1 +sizeof(typeof(a)) # => 4 + +class Foo + macro emphasize(value) + "***#{ {{value}} }***" + end + + def yield_with_self + with self yield + end +end + +Foo.new.yield_with_self { emphasize(10) } # => "***10***" + +# This generates: +# +# def :foo +# 1 +# end +define_method :foo, 1 + +macro define_method(name, content) + def {{name.id}} + {{content}} + end +end + +# This correctly generates: +# +# def foo +# 1 +# end +define_method :foo, 1 + +macro define_method(name, content) + def {{name}} + {% if content == 1 %} + "one" + {% else %} + {{content}} + {% end %} + end +end + +define_method foo, 1 +define_method bar, 2 + +foo # => one +bar # => 2 + +{% if env("TEST") %} + puts "We are in test mode" +{% end %} + +macro define_dummy_methods(names) + {% for name, index in names %} + def {{name.id}} + {{index}} + end + {% end %} +end + +define_dummy_methods [foo, bar, baz] + +foo # => 0 +bar # => 1 +baz # => 2 + +macro define_dummy_methods(hash) + {% for key, value in hash %} + def {{key.id}} + {{value}} + end + {% end %} +end + +define_dummy_methods({foo: 10, bar: 20}) +foo # => 10 +bar # => 20 + +{% for name, index in ["foo", "bar", "baz"] %} + def {{name.id}} + {{index}} + end +{% end %} + +foo # => 0 +bar # => 1 +baz # => 2 + +macro define_dummy_methods(*names) + {% for name, index in names %} + def {{name.id}} + {{index}} + end + {% end %} +end + +define_dummy_methods foo, bar, baz + +foo # => 0 +bar # => 1 +baz # => 2 + +macro println(*values) + print {{*values}}, '\n' +end + +println 1, 2, 3 # outputs 123\n + +VALUES = [1, 2, 3] + +{% for value in VALUES %} + puts {{value}} +{% end %} + +until some_condition + do_this +end + +# The above is the same as: +while !some_condition + do_this +end + +a = some_condition ? nil : 3 +# a is Int32 or Nil + +if a + # Since the only way to get here is if a is truthy, + # a can't be nil. So here a is Int32. + a.abs +end + +if a = some_expression + # here a is not nil +end + +if a && b + # here both a and b are guaranteed not to be Nil +end + +if @a + # here @a can be nil +end + +# First option: assign it to a variable +if a = @a + # here a can't be nil +end + +# Second option: use `Object#try` found in the standard library +@a.try do |a| + # here a can't be nil +end + +if method # first call to a method that can return Int32 or Nil + # here we know that the first call did not return Nil + method # second call can still return Int32 or Nil +end + +class Person + def become_older(by = 1) + @age += by + end +end + +john = Person.new "John" +john.age # => 0 + +john.become_older +john.age # => 1 + +john.become_older 2 +john.age # => 3 + +john.become_older by: 5 + +def some_method(x, y = 1, z = 2, w = 3) + # do something... +end + +some_method 10 # x = 10, y = 1, z = 2, w = 3 +some_method 10, z: 10 # x = 10, y = 1, z = 10, w = 3 +some_method 10, w: 1, y: 2, z: 3 # x = 10, y = 2, z = 3, w = 1 + +case exp +when value1, value2 + do_something +when value3 + do_something_else +else + do_another_thing +end + +case var +when String + # var : String + do_something +when Int32 + # var : Int32 + do_something_else +else + # here var is neither a String nor an Int32 + do_another_thing +end + +case num +when .even? + do_something +when .odd? + do_something_else +end + +case +when cond1, cond2 + do_something +when cond3 + do_something_else +end + +a = 1 +a.responds_to?(:abs) # => true +a.responds_to?(:size) # => false + +foo_or_bar = /foo|bar/ +heeello = /h(e+)llo/ +integer = /\d+/ + +r = /foo/imx + +slash = /\// + +r = %r(regex with slash: /) + +"hello world" + +"\"" # double quote +"\\" # backslash +"\e" # escape +"\f" # form feed +"\n" # newline +"\r" # carriage return +"\t" # tab +"\v" # vertical tab + +"\101" # == "A" +"\123" # == "S" +"\12" # == "\n" +"\1" # string with one character with code point 1 + +"\u0041" # == "A" + +"\u{41}" # == "A" +"\u{1F52E}" + +"hello + world" # same as "hello\n world" + +"hello " \ +"world, " \ +"no newlines" # same as "hello world, no newlines" + +"hello \ + world, \ + no newlines" # same as "hello world, no newlines" + +%(hello ("world")) # => "hello (\"world\")" +%[hello ["world"]] # => "hello [\"world\"]" +%{hello {"world"}} # => "hello {\"world\"}" +%<hello <"world">> # => "hello <\"world\">" +%|hello "world"| # => "hello \"world\"" + +<<-XML +<parent> + <child /> +</parent> +XML + +# Same as "Hello\n world" +<<-STRING + Hello + world + STRING + +# Same as " Hello\n world" +<<-STRING + Hello + world + STRING + +a = 1 +b = 2 +"sum = #{a + b}" # "sum = 3" + +1.0 # Float64 +1.0_f32 # Float32 +1_f32 # Float32 + +1e10 # Float64 +1.5e10 # Float64 +1.5e-7 # Float64 + ++1.3 # Float64 +-0.5 # Float64 + +1_000_000.111_111 # better than 1000000.111111 + +'a' +'z' +'0' +'_' +"ã‚" + +'\'' # single quote +'\\' # backslash +'\e' # escape +'\f' # form feed +'\n' # newline +'\r' # carriage return +'\t' # tab +'\v' # vertical tab + +"\101" # == 'A' +"\123" # == 'S' +"\12" # == '\n' +"\1" # code point 1 + +'\u0041' # == 'A' + +'\u{41}' # == 'A' +'\u{1F52E}' + +{1 => 2, 3 => 4} # Hash(Int32, Int32) +{1 => 2, 'a' => 3} # Hash(Int32 | Char, Int32) + +{} of Int32 => Int32 # same as Hash(Int32, Int32).new + +{key1: 'a', key2: 'b'} # Hash(Symbol, Char) + +{"key1": 'a', "key2": 'b'} # Hash(String, Char) + +MyType{"foo" => "bar"} + +tmp = MyType.new +tmp["foo"] = "bar" +tmp + +tmp = MyType(typeof("foo"), typeof("bar")).new +tmp["foo"] = "bar" +tmp + +MyType(String, String){"foo" => "bar"} + +:hello +:good_bye + +# With spaces and symbols +:"symbol with spaces" + +# Ending with question and exclamation marks +:question? +:exclamation! + +# For the operators +:+ +:- +:* +:/ +:== +:< +:<= +:> +:>= +:! +:!= +:=~ +:!~ +:& +:| +:^ +:~ +:** +:>> +:<< +:% +:[] +:[]? +:[]= +:<=> +:=== + +x..y # an inclusive range, in mathematics: [x, y] +x...y # an exclusive range, in mathematics: [x, y) + +# A proc without arguments +->{ 1 } # Proc(Int32) + +# A proc with one argument +->(x : Int32) { x.to_s } # Proc(Int32, String) + +# A proc with two arguments: +->(x : Int32, y : Int32) { x + y } # Proc(Int32, Int32, Int32) + +Proc(Int32, String).new { |x| x.to_s } # Proc(Int32, String) + +proc = ->(x : Int32, y : Int32) { x + y } +proc.call(1, 2) # => 3 + +def one + 1 +end + +proc = ->one +proc.call # => 1 + +def plus_one(x) + x + 1 +end + +proc = ->plus_one(Int32) +proc.call(41) # => 42 + +str = "hello" +proc = ->str.count(Char) +proc.call('e') # => 1 +proc.call('l') # => 2 + +tuple = {1, "hello", 'x'} # Tuple(Int32, String, Char) +tuple[0] # => 1 (Int32) +tuple[1] # => "hello" (String) +tuple[2] # => 'x' (Char) + +[1, 2, 3] # Array(Int32) +[1, "hello", 'x'] # Array(Int32 | String | Char) + +[] of Int32 # same as Array(Int32).new + +%w(one two three) # ["one", "two", "three"] + +%i(one two three) # [:one, :two, :three] + +MyType{1, 2, 3} + +tmp = MyType.new +tmp << 1 +tmp << 2 +tmp << 3 +tmp + +tmp = MyType(typeof(1, 2, 3)).new +tmp << 1 +tmp << 2 +tmp << 3 +tmp + +MyType(Int32 | String){1, 2, "foo"} + +nil + +1 # Int32 + +1_i8 # Int8 +1_i16 # Int16 +1_i32 # Int32 +1_i64 # Int64 + +1_u8 # UInt8 +1_u16 # UInt16 +1_u32 # UInt32 +1_u64 # UInt64 + ++10 # Int32 +-20 # Int32 + +2147483648 # Int64 +9223372036854775808 # UInt64 + +1_000_000 # better than 1000000 + +0b1101 # == 13 + +0o123 # == 83 + +0xFE012D # == 16646445 +0xfe012d # == 16646445 + +true # A Bool that is true +false # A Bool that is false + +a = 1 + +ptr = pointerof(a) +ptr.value = 2 + +a # => 2 + +class Point + def initialize(@x, @y) + end + + def x + @x + end + + def x_ptr + pointerof(@x) + end +end + +point = Point.new 1, 2 + +ptr = point.x_ptr +ptr.value = 10 + +point.x # => 10 + +def add(x : Number, y : Number) + x + y +end + +# Ok +add 1, 2 # Ok + +# Error: no overload matches 'add' with types Bool, Bool +add true, false + +def add(x, y) + x + y +end + +add true, false + +# A class that has a + method but isn't a Number +class Six + def +(other) + 6 + other + end +end + +# add method without type restrictions +def add(x, y) + x + y +end + +# OK +add Six.new, 10 + +# add method with type restrictions +def restricted_add(x : Number, y : Number) + x + y +end + +# Error: no overload matches 'restricted_add' with types Six, Int32 +restricted_add Six.new, 10 + +class Person + def ==(other : self) + other.name == name + end + + def ==(other) + false + end +end + +john = Person.new "John" +another_john = Person.new "John" +peter = Person.new "Peter" + +john == another_john # => true +john == peter # => false (names differ) +john == 1 # => false (because 1 is not a Person) + +class Person + def self.compare(p1 : self, p2 : self) + p1.name == p2.name + end +end + +john = Person.new "John" +peter = Person.new "Peter" + +Person.compare(john, peter) # OK + +def foo(x : Int32) +end + +foo 1 # OK +foo "hello" # Error + +def foo(x : Int32.class) +end + +foo Int32 # OK +foo String # Error + +def foo(x : Int32.class) + puts "Got Int32" +end + +def foo(x : String.class) + puts "Got String" +end + +foo Int32 # prints "Got Int32" +foo String # prints "Got String" + +def foo(*args : Int32) +end + +def foo(*args : String) +end + +foo 1, 2, 3 # OK, invokes first overload +foo "a", "b", "c" # OK, invokes second overload +foo 1, 2, "hello" # Error +foo() # Error + +def foo + # This is the empty-tuple case +end + +def foo(x : T) + T +end + +foo(1) # => Int32 +foo("hello") # => String + +def foo(x : Array(T)) + T +end + +foo([1, 2]) # => Int32 +foo([1, "a"]) # => (Int32 | String) + +def foo(x : T.class) + Array(T) +end + +foo(Int32) # => Array(Int32) +foo(String) # => Array(String) + +class Person + # Increases age by one + def become_older + @age += 1 + end + + # Increases age by the given number of years + def become_older(years : Int32) + @age += years + end + + # Increases age by the given number of years, as a String + def become_older(years : String) + @age += years.to_i + end + + # Yields the current age of this person and increases + # its age by the value returned by the block + def become_older + @age += yield @age + end +end + +person = Person.new "John" + +person.become_older +person.age # => 1 + +person.become_older 5 +person.age # => 6 + +person.become_older "12" +person.age # => 18 + +person.become_older do |current_age| + current_age < 20 ? 10 : 30 +end +person.age # => 28 + +a = 1 +a.is_a?(Int32) # => true +a.is_a?(String) # => false +a.is_a?(Number) # => true +a.is_a?(Int32 | String) # => true + +# One for each thread +@[ThreadLocal] +values = [] of Int32 + +@[AlwaysInline] +def foo + 1 +end + +@[NoInline] +def foo + 1 +end + +lib LibFoo + @[CallConvention("X86_StdCall")] + fun foo : Int32 +end + +def sum(*elements) + total = 0 + elements.each do |value| + total += value + end + total +end + +# elements is Tuple(Int32, Int32, Int32, Float64) +sum 1, 2, 3, 4.5 + +if a.responds_to?(:abs) + # here a's type will be reduced to those responding to the 'abs' method +end + +a = some_condition ? 1 : "hello" +# a : Int32 | String + +if a.responds_to?(:abs) + # here a will be Int32, since Int32#abs exists but String#abs doesn't +else + # here a will be String +end + +if (a = @a).responds_to?(:abs) + # here a is guaranteed to respond to `abs` +end + +def capture(&block) + block +end + +def invoke(&block) + block.call +end + +proc = capture { puts "Hello" } +invoke(&proc) # prints "Hello" + +def capture(&block) + block +end + +def twice + yield + yield +end + +proc = capture { puts "Hello" } +twice &proc + +twice &->{ puts "Hello" } + +def say_hello + puts "Hello" +end + +twice &->say_hello + +def foo + yield 1 +end + +def wrap_foo + puts "Before foo" + foo do |x| + yield x + end + puts "After foo" +end + +wrap_foo do |i| + puts i +end + +def foo + yield 1 +end + +def wrap_foo(&block : Int32 -> _) + puts "Before foo" + foo(&block) + puts "After foo" +end + +wrap_foo do |i| + puts i +end + +foo_forward do |i| + break # error +end + +a = 2 +while (a += 1) < 20 + if a == 10 + # goes to 'puts a' + break + end +end +puts a # => 10 + +class Person + private def say(message) + puts message + end + + def say_hello + say "hello" # OK, no receiver + self.say "hello" # Error, self is a receiver + + other = Person.new "Other" + other.say "hello" # Error, other is a receiver + end +end + +class Employee < Person + def say_bye + say "bye" # OK + end +end + +module Namespace + class Foo + protected def foo + puts "Hello" + end + end + + class Bar + def bar + # Works, because Foo and Bar are under Namespace + Foo.new.foo + end + end +end + +Namespace::Bar.new.bar + +class Person + protected def self.say(message) + puts message + end + + def say_hello + Person.say "hello" + end +end + +buffer = uninitialized UInt8[256] + +foo = rand(5) > 1 ? 1 : nil + +foo.not_nil!.to_i + +---tokens--- +'# Examples taken from http://crystal-lang.org/docs/' Comment.Single +'\n' Text + +'# Copyright 2012-2018 Manas Technology Solutions.' Comment.Single +'\n' Text + +'# Updated on May 17th, 2018 by @faustinoaq.' Comment.Single +'\n\n' Text + +'require' Keyword +' ' Text +'"' Literal.String.Double +'http/server' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'server' Name +' ' Text +'=' Operator +' ' Text +'HTTP' Name +'::' Operator +'Server' Name +'.' Operator +'new' Name +'(' Punctuation +'8080' Literal.Number.Integer +')' Punctuation +' ' Text +'do' Keyword +' ' Text +'|' Operator +'context' Name +'|' Operator +'\n ' Text +'context' Name +'.' Operator +'response' Name +'.' Operator +'content_type' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'text/plain' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'context' Name +'.' Operator +'response' Name +'.' Operator +'print' Name +' ' Text +'"' Literal.String.Double +'Hello world! The time is ' Literal.String.Double +'#{' Literal.String.Interpol +'Time' Name +'.' Operator +'now' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Listening on http://0.0.0.0:8080' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'server' Name +'.' Operator +'listen' Name +'\n\n' Text + +'module' Keyword +' ' Text +'HTTP' Name.Namespace +'\n ' Text +'class' Keyword +' ' Text +'RequestHandler' Name.Class +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'alias' Keyword +' ' Text +'NumericValue' Name.Class +' ' Text +'=' Operator +' ' Text +'Float32' Name +' ' Text +'|' Operator +' ' Text +'Float64' Name +' ' Text +'|' Operator +' ' Text +'Int32' Name +' ' Text +'|' Operator +' ' Text +'Int64' Name +'\n\n' Text + +'enum' Keyword +' ' Text +'Time::' Name.Namespace +'DayOfWeek' Name.Class +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Greeting' Name.Class +'\n ' Text +'class_property' Name.Builtin.Pseudo +' ' Text +'global_greeting' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Hello world' Literal.String.Double +'"' Literal.String.Double +'\n\n ' Text +'@@default_greeting' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Hello world' Literal.String.Double +'"' Literal.String.Double +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@custom_greeting' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Constant +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'print_greeting' Name.Function +'\n ' Text +'greeting' Name +' ' Text +'=' Operator +' ' Text +'@custom_greeting' Name.Variable.Instance +' ' Text +'||' Operator +' ' Text +'@@default_greeting' Name.Variable.Class +'\n ' Text +'puts' Name.Builtin +' ' Text +'greeting' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'LUCKY_NUMBERS' Name.Constant +' ' Text +'=' Operator +' ' Text +'[' Operator +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'7' Literal.Number.Integer +',' Punctuation +' ' Text +'11' Literal.Number.Integer +']' Operator +'\n' Text + +'DOCUMENTATION_URL' Name.Constant +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'http://crystal-lang.org/docs' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'module' Keyword +' ' Text +'Scorecard' Name.Namespace +'\n ' Text +'class' Keyword +' ' Text +'Parser' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'parse' Name.Function +'(' Punctuation +'score_text' Name +')' Punctuation +'\n ' Text +'begin' Keyword +'\n ' Text +'score_text' Name +'.' Operator +'scan' Name +'(' Punctuation +'SCORE_PATTERN' Name.Constant +')' Punctuation +' ' Text +'do' Keyword +' ' Text +'|' Operator +'match' Name +'|' Operator +'\n ' Text +'handle_match' Name +'(' Punctuation +'match' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'rescue' Keyword +' ' Text +'err' Name +' ' Text +':' Punctuation +' ' Text +'ParseError' Name +'\n ' Text +'# handle error ...' Comment.Single +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'module' Keyword +' ' Text +'Money' Name.Namespace +'\n ' Text +'CURRENCIES' Name.Constant +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'\n ' Text +'"' Literal.String.Double +'EUR' Literal.String.Double +'"' Literal.String.Double +' ' Text +'=' Operator +'>' Operator +' ' Text +'1.0' Literal.Number.Float +',' Punctuation +'\n ' Text +'"' Literal.String.Double +'ARS' Literal.String.Double +'"' Literal.String.Double +' ' Text +'=' Operator +'>' Operator +' ' Text +'10.55' Literal.Number.Float +',' Punctuation +'\n ' Text +'"' Literal.String.Double +'USD' Literal.String.Double +'"' Literal.String.Double +' ' Text +'=' Operator +'>' Operator +' ' Text +'1.12' Literal.Number.Float +',' Punctuation +'\n ' Text +'"' Literal.String.Double +'JPY' Literal.String.Double +'"' Literal.String.Double +' ' Text +'=' Operator +'>' Operator +' ' Text +'134.15' Literal.Number.Float +',' Punctuation +'\n ' Text +'}' Punctuation +'\n\n ' Text +'class' Keyword +' ' Text +'Amount' Name.Class +'\n ' Text +'getter' Name.Builtin.Pseudo +' ' Text +':currency' Literal.String.Symbol +',' Punctuation +' ' Text +':value' Literal.String.Symbol +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@currency' Name.Variable.Instance +',' Punctuation +' ' Text +'@value' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'class' Keyword +' ' Text +'CurrencyConversion' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@amount' Name.Variable.Instance +',' Punctuation +' ' Text +'@target_currency' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'amount' Name.Function +'\n ' Text +'# implement conversion ...' Comment.Single +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'i' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'while' Keyword +' ' Text +'i' Name +' ' Text +'<' Operator +' ' Text +'10' Literal.Number.Integer +'\n ' Text +'proc' Name +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +' ' Text +'do' Keyword +'\n ' Text +'spawn' Name.Builtin.Pseudo +' ' Text +'do' Keyword +'\n ' Text +'puts' Name.Builtin +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +'i' Name +')' Punctuation +'\n ' Text +'i' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'Fiber' Name +'.' Operator +'yield' Name +'\n\n' Text + +'# A buffered channel of capacity 2' Comment.Single +'\n' Text + +'channel' Name +' ' Text +'=' Operator +' ' Text +'Channel' Name +'(' Punctuation +'Int32' Name +')' Punctuation +'.' Operator +'new' Name +'(' Punctuation +'2' Literal.Number.Integer +')' Punctuation +'\n\n' Text + +'spawn' Name.Builtin.Pseudo +' ' Text +'do' Keyword +'\n ' Text +'channel' Name +'.' Operator +'send' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'channel' Name +'.' Operator +'send' Name +'(' Punctuation +'2' Literal.Number.Integer +')' Punctuation +'\n ' Text +'channel' Name +'.' Operator +'send' Name +'(' Punctuation +'3' Literal.Number.Integer +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'3' Literal.Number.Integer +'.' Operator +'times' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'puts' Name.Builtin +' ' Text +'channel' Name +'.' Operator +'receive' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'MyDictionary' Name.Class +'(' Punctuation +'K' Name +',' Punctuation +' ' Text +'V' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'MyBox' Name +'.' Operator +'new' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# :: MyBox(Int32)' Comment.Single +'\n' Text + +'MyBox' Name +'.' Operator +'new' Name +'(' Punctuation +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'# :: MyBox(String)' Comment.Single +'\n\n' Text + +'module' Keyword +' ' Text +'Moo' Name.Namespace +'(' Punctuation +'T' Name +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'t' Name.Function +'\n ' Text +'T' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Foo' Name.Class +'(' Punctuation +'U' Name.Class +')' Punctuation +'\n ' Text +'include' Keyword +' ' Text +'Moo' Name +'(' Punctuation +'U' Name +')' Punctuation +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@value' Name.Variable.Instance +' ' Text +':' Punctuation +' ' Text +'U' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +' ' Text +'=' Operator +' ' Text +'Foo' Name +'.' Operator +'new' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +'\n' Text + +'foo' Name +'.' Operator +'t' Name +' ' Text +'# Int32' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Parent' Name.Class +'(' Punctuation +'T' Name.Class +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Int32Child' Name.Class +' ' Text +'<' Operator +' ' Text +'Parent' Name +'(' Punctuation +'Int32' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'GenericChild' Name.Class +'(' Punctuation +'T' Name.Class +')' Punctuation +' ' Text +'<' Operator +' ' Text +'Parent' Name +'(' Punctuation +'T' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'ptr' Name +' ' Text +'=' Operator +' ' Text +'pointerof' Keyword.Pseudo +'(' Punctuation +'a' Name +')' Punctuation +'\n' Text + +'ptr' Name +'[' Operator +'100_000' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'# undefined behaviour, probably a segmentation fault' Comment.Single +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32OrString' Name.Class +' ' Text +'=' Operator +' ' Text +'Int32' Name +' ' Text +'|' Operator +' ' Text +'String' Name +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32OrNil' Name.Class +' ' Text +'=' Operator +' ' Text +'Int32?' Name +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32OrNil_' Name.Class +' ' Text +'=' Operator +' ' Text +'Int32' Name +' ' Text +'|' Operator +' ' Text +'::' Operator +'Nil' Name +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32Ptr' Name.Class +' ' Text +'=' Operator +' ' Text +'Int32' Name +'*' Operator +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32Ptr_' Name.Class +' ' Text +'=' Operator +' ' Text +'Pointer' Name +'(' Punctuation +'Int32' Name +')' Punctuation +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32_8' Name.Class +' ' Text +'=' Operator +' ' Text +'Int32' Name +'[' Operator +'8' Literal.Number.Integer +']' Operator +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32_8_' Name.Class +' ' Text +'=' Operator +' ' Text +'StaticArray' Name +'(' Punctuation +'Int32' Name +',' Punctuation +' ' Text +'8' Literal.Number.Integer +')' Punctuation +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32StringTuple' Name.Class +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'Int32' Name +',' Punctuation +' ' Text +'String' Name +'}' Punctuation +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32StringTuple_' Name.Class +' ' Text +'=' Operator +' ' Text +'Tuple' Name +'(' Punctuation +'Int32' Name +',' Punctuation +' ' Text +'String' Name +')' Punctuation +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32ToString' Name.Class +' ' Text +'=' Operator +' ' Text +'Int32' Name +' ' Text +'-' Operator +'>' Operator +' ' Text +'String' Name +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32ToString_' Name.Class +' ' Text +'=' Operator +' ' Text +'Proc' Name +'(' Punctuation +'Int32' Name +',' Punctuation +' ' Text +'String' Name +')' Punctuation +'\n\n' Text + +'alias' Keyword +' ' Text +'ProcThatReturnsInt32' Name.Class +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +' ' Text +'Int32' Name +'\n\n' Text + +'alias' Keyword +' ' Text +'Int32AndCharToString' Name.Class +' ' Text +'=' Operator +' ' Text +'Int32' Name +',' Punctuation +' ' Text +'Char' Name +' ' Text +'-' Operator +'>' Operator +' ' Text +'String' Name +'\n\n' Text + +'alias' Keyword +' ' Text +'ComplexProc' Name.Class +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'Int32' Name +' ' Text +'-' Operator +'>' Operator +' ' Text +'Int32' Name +')' Punctuation +' ' Text +'-' Operator +'>' Operator +' ' Text +'String' Name +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +'\n ' Text +'"' Literal.String.Double +'instance' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'.' Operator +'class' Name +')' Punctuation +'\n ' Text +'"' Literal.String.Double +'class' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +' ' Text +'1' Literal.Number.Integer +' ' Text +'# "instance"' Comment.Single +'\n' Text + +'foo' Name +' ' Text +'Int32' Name +' ' Text +'# "class"' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Parent' Name.Class +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Child1' Name.Class +' ' Text +'<' Operator +' ' Text +'Parent' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Child2' Name.Class +' ' Text +'<' Operator +' ' Text +'Parent' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'ary' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +' ' Text +'of' Keyword +' ' Text +'Parent' Name +'.' Operator +'class' Name +'\n' Text + +'ary' Name +' ' Text +'<<' Operator +' ' Text +'Child1' Name +'\n' Text + +'ary' Name +' ' Text +'<<' Operator +' ' Text +'Child2' Name +'\n\n' Text + +'# Same as not specifying a restriction, not very useful' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'_' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'# A bit more useful: any two arguments Proc that returns an Int32:' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'_' Name +',' Punctuation +' ' Text +'_' Name +' ' Text +'-' Operator +'>' Operator +' ' Text +'Int32' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'# alias SameAsInt32 = typeof(2)' Comment.Single +'\n' Text + +'# alias Int32OrString_ = typeof(1, "a")' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'name' Name +')' Punctuation +'\n ' Text +'@name' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'name' Name +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'name' Name.Function +'\n ' Text +'@name' Name.Variable.Instance +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'age' Name.Function +'\n ' Text +'@age' Name.Variable.Instance +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'peter' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'Peter' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'john' Name +'.' Operator +'name' Name +' ' Text +'# => "John"' Comment.Single +'\n' Text + +'john' Name +'.' Operator +'age' Name +' ' Text +'# => 0' Comment.Single +'\n\n' Text + +'peter' Name +'.' Operator +'name' Name +' ' Text +'# => "Peter"' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'new' Name.Function +'(' Punctuation +'name' Name +')' Punctuation +'\n ' Text +'instance' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'allocate' Name +'\n ' Text +'instance' Name +'.' Operator +'initialize' Name +'(' Punctuation +'name' Name +')' Punctuation +'\n ' Text +'instance' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'a' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'String' Name +')' Punctuation +'\n ' Text +'# here a is a String' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'b' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'Number' Name +')' Punctuation +'\n ' Text +'# here b is a Number' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'some_condition' Name +' ' Text +'?' Punctuation +' ' Text +'1' Literal.Number.Integer +' ' Text +':' Punctuation +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'# a : Int32 | String' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'a' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'Number' Name +')' Punctuation +'\n ' Text +'# a : Int32' Comment.Single +'\n' Text + +'else' Keyword +'\n ' Text +'# a : String' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'a' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'String' Name +')' Punctuation +' ' Text +'&&' Operator +' ' Text +'b' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'Number' Name +')' Punctuation +'\n ' Text +'# here a is a String and b is a Number' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +'.' Operator +'+' Name.Operator +'(' Punctuation +'b' Name +')' Punctuation +'\n\n' Text + +'struct' Keyword +' ' Text +'Vector2' Name.Class +'\n ' Text +'getter' Name.Builtin.Pseudo +' ' Text +'x' Name +',' Punctuation +' ' Text +'y' Name +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@x' Name.Variable.Instance +',' Punctuation +' ' Text +'@y' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'+' Name.Function +'(' Punctuation +'other' Name +')' Punctuation +'\n ' Text +'Vector2' Name +'.' Operator +'new' Name +'(' Punctuation +'x' Name +' ' Text +'+' Operator +' ' Text +'other' Name +'.' Operator +'x' Name +',' Punctuation +' ' Text +'y' Name +' ' Text +'+' Operator +' ' Text +'other' Name +'.' Operator +'y' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'v1' Name +' ' Text +'=' Operator +' ' Text +'Vector2' Name +'.' Operator +'new' Name +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'v2' Name +' ' Text +'=' Operator +' ' Text +'Vector2' Name +'.' Operator +'new' Name +'(' Punctuation +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'4' Literal.Number.Integer +')' Punctuation +'\n' Text + +'v1' Name +' ' Text +'+' Operator +' ' Text +'v2' Name +' ' Text +'# => Vector2(@x=4, @y=6)' Comment.Single +'\n\n' Text + +'struct' Keyword +' ' Text +'Vector2' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'-' Name.Function +'\n ' Text +'Vector2' Name +'.' Operator +'new' Name +'(' Punctuation +'-' Operator +'x' Name +',' Punctuation +' ' Text +'-' Operator +'y' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'v1' Name +' ' Text +'=' Operator +' ' Text +'Vector2' Name +'.' Operator +'new' Name +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'-' Operator +'v1' Name +' ' Text +'# => Vector2(@x=-1, @y=-2)' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'MyArray' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'[]' Name.Function +'(' Punctuation +'index' Name +')' Punctuation +'\n ' Text +'# ...' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'[]' Name.Function +'(' Punctuation +'index1' Name +',' Punctuation +' ' Text +'index2' Name +',' Punctuation +' ' Text +'index3' Name +')' Punctuation +'\n ' Text +'# ...' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'[]=' Name.Function +'(' Punctuation +'index' Name +',' Punctuation +' ' Text +'value' Name +')' Punctuation +'\n ' Text +'# ...' Comment.Single +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'array' Name +' ' Text +'=' Operator +' ' Text +'MyArray' Name +'.' Operator +'new' Name +'\n\n' Text + +'array' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'# invokes the first method' Comment.Single +'\n' Text + +'array' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +' ' Text +'# invokes the second method' Comment.Single +'\n' Text + +'array' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'# invokes the third method' Comment.Single +'\n\n' Text + +'array' Name +'.' Operator +'[]' Name.Operator +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# invokes the first method' Comment.Single +'\n' Text + +'array' Name +'.' Operator +'[]' Name.Operator +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +')' Punctuation +' ' Text +'# invokes the second method' Comment.Single +'\n' Text + +'array' Name +'.' Operator +'[]=' Name.Operator +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +' ' Text +'# invokes the third method' Comment.Single +'\n\n' Text + +'raise' Name.Builtin +' ' Text +'"' Literal.String.Double +'OH NO!' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'raise' Name.Builtin +' ' Text +'Exception' Name +'.' Operator +'new' Name +'(' Punctuation +'"' Literal.String.Double +'Some error' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'class' Keyword +' ' Text +'MyException' Name.Class +' ' Text +'<' Operator +' ' Text +'Exception' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'begin' Keyword +'\n ' Text +'raise' Name.Builtin +' ' Text +'MyException' Name +'.' Operator +'new' Name +'(' Punctuation +'"' Literal.String.Double +'OH NO!' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'rescue' Keyword +' ' Text +'ex' Name +' ' Text +':' Punctuation +' ' Text +'MyException' Name +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Rescued MyException: ' Literal.String.Double +'#{' Literal.String.Interpol +'ex' Name +'.' Operator +'message' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'begin' Keyword +'\n ' Text +'# ...' Comment.Single +'\n' Text + +'rescue' Keyword +' ' Text +'ex' Name +' ' Text +':' Punctuation +' ' Text +'MyException' Name +' ' Text +'|' Operator +' ' Text +'MyOtherException' Name +'\n ' Text +'# only MyException or MyOtherException' Comment.Single +'\n' Text + +'rescue' Keyword +'\n ' Text +'# any other kind of exception' Comment.Single +'\n' Text + +'ensure' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Cleanup...' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'some_method' Name.Function +'\n ' Text +'something_dangerous' Name +'\n' Text + +'rescue' Keyword +'\n ' Text +'# execute if an exception is raised' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'array' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +'\n' Text + +'array' Name +'[' Operator +'4' Literal.Number.Integer +']' Operator +' ' Text +'# raises because of IndexError' Comment.Single +'\n' Text + +'array' Name +'[' Operator +'4' Literal.Number.Integer +']?' Operator +' ' Text +'# returns nil because of index out of bounds' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'some_proc' Name.Function +'(' Punctuation +'&' Operator +'block' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +' ' Text +'-' Operator +'>' Operator +' ' Text +'Int32' Name +')' Punctuation +'\n ' Text +'block' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +'(' Punctuation +'i' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'x' Name +' ' Text +'+=' Operator +' ' Text +'i' Name +' ' Text +'}' Punctuation +'\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'some_proc' Name +'(' Punctuation +'&' Operator +'proc' Name +')' Punctuation +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# => 1' Comment.Single +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +'10' Literal.Number.Integer +')' Punctuation +' ' Text +'# => 11' Comment.Single +'\n' Text + +'x' Name +' ' Text +'# => 11' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'add' Name.Function +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'adder' Name +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +'add' Name +'(' Punctuation +'Int32' Name +',' Punctuation +' ' Text +'Int32' Name +')' Punctuation +'\n' Text + +'adder' Name +'.' Operator +'call' Name +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +' ' Text +'# => 3' Comment.Single +'\n\n' Text + +'module' Keyword +' ' Text +'Curses' Name.Namespace +'\n ' Text +'class' Keyword +' ' Text +'Window' Name.Class +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Curses' Name +'::' Operator +'Window' Name +'.' Operator +'new' Name +'\n\n' Text + +'module' Keyword +' ' Text +'ItemsSize' Name.Namespace +'\n ' Text +'def' Keyword +' ' Text +'size' Name.Function +'\n ' Text +'items' Name +'.' Operator +'size' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Items' Name.Class +'\n ' Text +'include' Keyword +' ' Text +'ItemsSize' Name +'\n\n ' Text +'def' Keyword +' ' Text +'items' Name.Function +'\n ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'items' Name +' ' Text +'=' Operator +' ' Text +'Items' Name +'.' Operator +'new' Name +'\n' Text + +'items' Name +'.' Operator +'size' Name +' ' Text +'# => 3' Comment.Single +'\n\n' Text + +'module' Keyword +' ' Text +'Base64' Name.Namespace +'\n ' Text +'extend' Keyword +' ' Text +'self' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'encode64' Name.Function +'(' Punctuation +'string' Name +')' Punctuation +'\n ' Text +'# ...' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'decode64' Name.Function +'(' Punctuation +'string' Name +')' Punctuation +'\n ' Text +'# ...' Comment.Single +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Base64' Name +'.' Operator +'encode64' Name +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# => "aGVsbG8="' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'else' Keyword +'\n ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'a_as_int' Name +' ' Text +'=' Operator +' ' Text +'a' Name +'.as' Keyword.Pseudo +'(' Punctuation +'Int32' Name +')' Punctuation +'\n' Text + +'a_as_int' Name +'.' Operator +'abs' Name +' ' Text +'# works, compiler knows that a_as_int is Int32' Comment.Single +'\n\n' Text + +'ptr' Name +' ' Text +'=' Operator +' ' Text +'Pointer' Name +'(' Punctuation +'Int32' Name +')' Punctuation +'.' Operator +'malloc' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +'\n' Text + +'ptr' Name +'.as' Keyword.Pseudo +'(' Punctuation +'Int8' Name +'*' Operator +')' Punctuation +' ' Text +'# :: Pointer(Int8)' Comment.Single +'\n\n' Text + +'array' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +'\n\n' Text + +'# object_id returns the address of an object in memory,' Comment.Single +'\n' Text + +'# so we create a pointer with that address' Comment.Single +'\n' Text + +'ptr' Name +' ' Text +'=' Operator +' ' Text +'Pointer' Name +'(' Punctuation +'Void' Name +')' Punctuation +'.' Operator +'new' Name +'(' Punctuation +'array' Name +'.' Operator +'object_id' Name +')' Punctuation +'\n\n' Text + +'# Now we cast that pointer to the same type, and' Comment.Single +'\n' Text + +'# we should get the same value' Comment.Single +'\n' Text + +'array2' Name +' ' Text +'=' Operator +' ' Text +'ptr' Name +'.as' Keyword.Pseudo +'(' Punctuation +'Array' Name +'(' Punctuation +'Int32' Name +')' Punctuation +')' Punctuation +'\n' Text + +'array2' Name +'.' Operator +'same?' Name +'(' Punctuation +'array' Name +')' Punctuation +' ' Text +'# => true' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'a' Name +'.as' Keyword.Pseudo +'(' Punctuation +'Int32' Name +' ' Text +'|' Operator +' ' Text +'Float64' Name +')' Punctuation +'\n' Text + +'b' Name +' ' Text +'# :: Int32 | Float64' Comment.Single +'\n\n' Text + +'ary' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +'\n\n' Text + +'# We want to create an array 1, 2, 3 of Int32 | Float64' Comment.Single +'\n' Text + +'ary2' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'map' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'x' Name +'|' Operator +' ' Text +'x' Name +'.as' Keyword.Pseudo +'(' Punctuation +'Int32' Name +' ' Text +'|' Operator +' ' Text +'Float64' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n\n' Text + +'ary2' Name +' ' Text +'# :: Array(Int32 | Float64)' Comment.Single +'\n' Text + +'ary2' Name +' ' Text +'<<' Operator +' ' Text +'1.5' Literal.Number.Float +' ' Text +'# OK' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'name' Name.Function +'\n ' Text +'@name' Name.Variable.Instance +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +' ' Text +'of' Keyword +' ' Text +'Person' Name +'\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'a' Name +'.' Operator +'map' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'f' Name +'|' Operator +' ' Text +'f' Name +'.' Operator +'name' Name +' ' Text +'}' Punctuation +' ' Text +"# Error: can't infer block return type" Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +' ' Text +'of' Keyword +' ' Text +'Person' Name +'\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'a' Name +'.' Operator +'map' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'f' Name +'|' Operator +' ' Text +'f' Name +'.' Operator +'name' Name +'.as' Keyword.Pseudo +'(' Punctuation +'String' Name +')' Punctuation +' ' Text +'}' Punctuation +' ' Text +'# OK' Comment.Single +'\n\n' Text + +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +' ' Text +'of' Keyword +' ' Text +'Person' Name +'\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'a' Name +'.' Operator +'map' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'f' Name +'|' Operator +' ' Text +'f' Name +'.' Operator +'name' Name +' ' Text +'}' Punctuation +' ' Text +'# OK' Comment.Single +'\n\n' Text + +'loop' Name.Builtin +' ' Text +'do' Keyword +'\n ' Text +'do_something' Name +'\n ' Text +'break' Keyword +' ' Text +'if' Keyword +' ' Text +'some_condition' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Point' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@x' Name.Variable.Instance +',' Punctuation +' ' Text +'@y' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Point' Name +'.' Operator +'new' Name +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +'\n\n' Text + +'# 2 x Int32 = 2 x 4 = 8' Comment.Single +'\n' Text + +'instance_sizeof' Keyword.Pseudo +'(' Punctuation +'Point' Name +')' Punctuation +' ' Text +'# => 12' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'while' Keyword +' ' Text +'a' Name +' ' Text +'<' Operator +' ' Text +'5' Literal.Number.Integer +'\n ' Text +'a' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'if' Keyword +' ' Text +'a' Name +' ' Text +'==' Operator +' ' Text +'3' Literal.Number.Integer +'\n ' Text +'next' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'a' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# The above prints the numbers 2, 4 and 5' Comment.Single +'\n\n' Text + +'lib' Keyword +' ' Text +'C' Name.Namespace +'\n ' Text +'# In C: double cos(double x)' Comment.Single +'\n ' Text +'fun' Keyword +' ' Text +'cos' Name.Function +'(' Punctuation +'value' Name +' ' Text +':' Punctuation +' ' Text +'Float64' Name +')' Punctuation +' ' Text +':' Punctuation +' ' Text +'Float64' Name +'\n\n ' Text +'fun' Keyword +' ' Text +'getch' Name.Function +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n\n ' Text +'fun' Keyword +' ' Text +'srand' Name.Function +'(' Punctuation +'seed' Name +' ' Text +':' Punctuation +' ' Text +'UInt32' Name +')' Punctuation +'\n\n ' Text +'fun' Keyword +' ' Text +'exit' Name.Function +'(' Punctuation +'status' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +' ' Text +':' Punctuation +' ' Text +'NoReturn' Name +'\n\n ' Text +'fun' Keyword +' ' Text +'printf' Name.Function +'(' Punctuation +'format' Name +' ' Text +':' Punctuation +' ' Text +'UInt8' Name +'*' Operator +',' Punctuation +' ' Text +'...' Operator +')' Punctuation +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'C' Name +'.' Operator +'cos' Name +'(' Punctuation +'1.5' Literal.Number.Float +')' Punctuation +' ' Text +'# => 0.0707372' Comment.Single +'\n' Text + +'C' Name +'.' Operator +'srand' Name +'(' Punctuation +'1_u32' Literal.Number.Integer +')' Punctuation +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'C' Name +'.' Operator +'printf' Name +' ' Text +'"' Literal.String.Double +'%d + %d = %d' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'a' Name +',' Punctuation +' ' Text +'b' Name +',' Punctuation +' ' Text +'a' Name +' ' Text +'+' Operator +' ' Text +'b' Name +'\n\n' Text + +'lib' Keyword +' ' Text +'LibSDL' Name.Namespace +'\n ' Text +'fun' Keyword +' ' Text +'init' Name.Function +' ' Text +'=' Operator +' ' Text +'SDL_Init' Name +'(' Punctuation +'flags' Name +' ' Text +':' Punctuation +' ' Text +'UInt32' Name +')' Punctuation +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'lib' Keyword +' ' Text +'LLVMIntrinsics' Name.Namespace +'\n ' Text +'fun' Keyword +' ' Text +'ceil_f32' Name.Function +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'llvm.ceil.f32' Literal.String.Double +'"' Literal.String.Double +'(' Punctuation +'value' Name +' ' Text +':' Punctuation +' ' Text +'Float32' Name +')' Punctuation +' ' Text +':' Punctuation +' ' Text +'Float32' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'lib' Keyword +' ' Text +'MyLib' Name.Namespace +'\n ' Text +'fun' Keyword +' ' Text +'my_fun' Name.Function +'(' Punctuation +'some_size' Name +' ' Text +':' Punctuation +' ' Text +'LibC' Name +'::' Operator +'SizeT' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'@[' Operator +'Link' Name.Decorator +'(' Punctuation +'"' Literal.String.Double +'pcre' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +']' Operator +'\n' Text + +'lib' Keyword +' ' Text +'LibPCRE' Name.Namespace +'\n' Text + +'end' Keyword +'\n\n' Text + +'lib' Keyword +' ' Text +'C' Name.Namespace +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'if' Keyword +' ' Text +'flag?' Name +'(' Punctuation +':x86_64' Literal.String.Symbol +')' Punctuation +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'alias' Keyword +' ' Text +'SizeT' Name.Class +' ' Text +'=' Operator +' ' Text +'UInt64' Name +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'else' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'alias' Keyword +' ' Text +'SizeT' Name.Class +' ' Text +'=' Operator +' ' Text +'UInt32' Name +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n\n ' Text +'fun' Keyword +' ' Text +'memcmp' Name.Function +'(' Punctuation +'p1' Name +' ' Text +':' Punctuation +' ' Text +'Void' Name +'*' Operator +',' Punctuation +' ' Text +'p2' Name +' ' Text +':' Punctuation +' ' Text +'Void' Name +'*' Operator +',' Punctuation +' ' Text +'size' Name +' ' Text +':' Punctuation +' ' Text +'C' Name +'::' Operator +'SizeT' Name +')' Punctuation +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'lib' Keyword +' ' Text +'X' Name.Namespace +'\n ' Text +'enum' Keyword +' ' Text +'SomeEnum' Name.Class +'\n ' Text +'Ten' Name +' ' Text +'=' Operator +' ' Text +'10' Literal.Number.Integer +'\n ' Text +'Twenty' Name +' ' Text +'=' Operator +' ' Text +'10' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'ThirtyTwo' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'<<' Operator +' ' Text +'5' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'lib' Keyword +' ' Text +'X' Name.Namespace +'\n ' Text +'enum' Keyword +' ' Text +'SomeEnum' Name.Class +'\n ' Text +'A' Name +' ' Text +'=' Operator +' ' Text +'1_u32' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'X' Name +'::' Operator +'SomeEnum' Name +'::' Operator +'Zero' Name +' ' Text +'# => 0_i8' Comment.Single +'\n' Text + +'X' Name +'::' Operator +'SomeEnum' Name +'::' Operator +'Two' Name +' ' Text +'# => 2_i8' Comment.Single +'\n\n' Text + +'lib' Keyword +' ' Text +'X' Name.Namespace +'\n ' Text +'fun' Keyword +' ' Text +'callback' Name.Function +'(' Punctuation +'f' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +' ' Text +'-' Operator +'>' Operator +' ' Text +'Int32' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'f' Name +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'X' Name +'.' Operator +'callback' Name +'(' Punctuation +'f' Name +')' Punctuation +'\n\n' Text + +'X' Name +'.' Operator +'callback' Name +' ' Text +'-' Operator +'>' Operator +'(' Punctuation +'x' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n\n' Text + +'X' Name +'.' Operator +'callback' Name +' ' Text +'nil' Keyword.Constant +'\n\n' Text + +'lib' Keyword +' ' Text +'LibFoo' Name.Namespace +'\n ' Text +'fun' Keyword +' ' Text +'store_callback' Name.Function +'(' Punctuation +'callback' Name +' ' Text +':' Punctuation +' ' Text +'-' Operator +'>' Operator +')' Punctuation +'\n ' Text +'fun' Keyword +' ' Text +'execute_callback' Name.Function +'\n' Text + +'end' Keyword +'\n\n' Text + +'LibFoo' Name +'.' Operator +'store_callback' Name +' ' Text +'-' Operator +'>' Operator +'{' Punctuation +' ' Text +'raise' Name.Builtin +' ' Text +'"' Literal.String.Double +'OH NO!' Literal.String.Double +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n' Text + +'LibFoo' Name +'.' Operator +'execute_callback' Name +'\n\n' Text + +'lib' Keyword +' ' Text +'LibFoo' Name.Namespace +'\n ' Text +'fun' Keyword +' ' Text +'store_callback' Name.Function +'(' Punctuation +'callback' Name +' ' Text +':' Punctuation +' ' Text +'-' Operator +'>' Operator +')' Punctuation +'\n\n ' Text +'@[' Operator +'Raises' Name.Decorator +']' Operator +'\n ' Text +'fun' Keyword +' ' Text +'execute_callback' Name.Function +'\n' Text + +'end' Keyword +'\n\n' Text + +'@[' Operator +'Link' Name.Decorator +'(' Punctuation +'"' Literal.String.Double +'pcre' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +']' Operator +'\n' Text + +'lib' Keyword +' ' Text +'PCRE' Name.Namespace +'\n ' Text +'INFO_CAPTURECOUNT' Name.Constant +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'PCRE' Name +'::' Operator +'INFO_CAPTURECOUNT' Name.Constant +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'lib' Keyword +' ' Text +'U' Name.Namespace +'\n ' Text +'# In C:' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +'# union IntOrFloat {' Comment.Single +'\n ' Text +'# int some_int;' Comment.Single +'\n ' Text +'# double some_float;' Comment.Single +'\n ' Text +'# };' Comment.Single +'\n ' Text +'union' Keyword +' ' Text +'IntOrFloat' Name.Class +'\n ' Text +'some_int' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n ' Text +'some_float' Name +' ' Text +':' Punctuation +' ' Text +'Float64' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'U' Name +'::' Operator +'IntOrFloat' Name +'.' Operator +'new' Name +'\n\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'uninitialized' Keyword.Pseudo +' ' Text +'U' Name +'::' Operator +'IntOrFlaot' Name +'\n' Text + +'value' Name +'.' Operator +'some_int' Name +' ' Text +'# => some garbage value' Comment.Single +'\n\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'U' Name +'::' Operator +'IntOrFloat' Name +'.' Operator +'new' Name +'\n' Text + +'value' Name +'.' Operator +'some_int' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'value' Name +'.' Operator +'some_int' Name +' ' Text +'# => 1' Comment.Single +'\n' Text + +'value' Name +'.' Operator +'some_float' Name +' ' Text +'# => 4.94066e-324' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'change_it' Name.Function +'(' Punctuation +'value' Name +')' Punctuation +'\n ' Text +'value' Name +'.' Operator +'some_int' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'U' Name +'::' Operator +'IntOrFloat' Name +'.' Operator +'new' Name +'\n' Text + +'change_it' Name +' ' Text +'value' Name +'\n' Text + +'value' Name +'.' Operator +'some_int' Name +' ' Text +'# => 0' Comment.Single +'\n\n' Text + +'lib' Keyword +' ' Text +'C' Name.Namespace +'\n ' Text +'# In C:' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +'# struct TimeZone {' Comment.Single +'\n ' Text +'# int minutes_west;' Comment.Single +'\n ' Text +'# int dst_time;' Comment.Single +'\n ' Text +'# };' Comment.Single +'\n ' Text +'struct' Keyword +' ' Text +'TimeZone' Name.Class +'\n ' Text +'minutes_west' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n ' Text +'dst_time' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'lib' Keyword +' ' Text +'C' Name.Namespace +'\n ' Text +'# This is a forward declaration' Comment.Single +'\n ' Text +'struct' Keyword +' ' Text +'Node' Name.Class +'\n ' Text +'end' Keyword +'\n\n ' Text +'struct' Keyword +' ' Text +'Node' Name.Class +'\n ' Text +'node' Name +' ' Text +':' Punctuation +' ' Text +'Node' Name +'*' Operator +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'tz' Name +' ' Text +'=' Operator +' ' Text +'C' Name +'::' Operator +'TimeZone' Name +'.' Operator +'new' Name +'\n\n' Text + +'tz' Name +' ' Text +'=' Operator +' ' Text +'uninitialized' Keyword.Pseudo +' ' Text +'C' Name +'::' Operator +'TimeZone' Name +'\n' Text + +'tz' Name +'.' Operator +'minutes_west' Name +' ' Text +'# => some garbage value' Comment.Single +'\n\n' Text + +'tz' Name +' ' Text +'=' Operator +' ' Text +'C' Name +'::' Operator +'TimeZone' Name +'.' Operator +'new' Name +'\n' Text + +'tz' Name +'.' Operator +'minutes_west' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'tz' Name +'.' Operator +'minutes_west' Name +' ' Text +'# => 1' Comment.Single +'\n\n' Text + +'tz' Name +' ' Text +'=' Operator +' ' Text +'C' Name +'::' Operator +'TimeZone' Name +'.' Operator +'new' Name +' ' Text +'minutes_west' Literal.String.Symbol +':' Punctuation +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'dst_time' Literal.String.Symbol +':' Punctuation +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'tz' Name +'.' Operator +'minutes_west' Name +' ' Text +'# => 1' Comment.Single +'\n' Text + +'tz' Name +'.' Operator +'dst_time' Name +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'change_it' Name.Function +'(' Punctuation +'tz' Name +')' Punctuation +'\n ' Text +'tz' Name +'.' Operator +'minutes_west' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'tz' Name +' ' Text +'=' Operator +' ' Text +'C' Name +'::' Operator +'TimeZone' Name +'.' Operator +'new' Name +'\n' Text + +'change_it' Name +' ' Text +'tz' Name +'\n' Text + +'tz' Name +'.' Operator +'minutes_west' Name +' ' Text +'# => 0' Comment.Single +'\n\n' Text + +'lib' Keyword +' ' Text +'C' Name.Namespace +'\n ' Text +'$errno' Name.Variable.Global +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'C' Name +'.' Operator +'errno' Name +' ' Text +'# => some value' Comment.Single +'\n' Text + +'C' Name +'.' Operator +'errno' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'C' Name +'.' Operator +'errno' Name +' ' Text +'# => 0' Comment.Single +'\n\n' Text + +'lib' Keyword +' ' Text +'C' Name.Namespace +'\n ' Text +'@[' Operator +'ThreadLocal' Name.Decorator +']' Operator +'\n ' Text +'$errno' Name.Variable.Global +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'lib' Keyword +' ' Text +'C' Name.Namespace +'\n ' Text +'fun' Keyword +' ' Text +'waitpid' Name.Function +'(' Punctuation +'pid' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +',' Punctuation +' ' Text +'status_ptr' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'*' Operator +',' Punctuation +' ' Text +'options' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'status_ptr' Name +' ' Text +'=' Operator +' ' Text +'uninitialized' Keyword.Pseudo +' ' Text +'Int32' Name +'\n\n' Text + +'C' Name +'.' Operator +'waitpid' Name +'(' Punctuation +'pid' Name +',' Punctuation +' ' Text +'pointerof' Keyword.Pseudo +'(' Punctuation +'status_ptr' Name +')' Punctuation +',' Punctuation +' ' Text +'options' Name +')' Punctuation +'\n\n' Text + +'C' Name +'.' Operator +'waitpid' Name +'(' Punctuation +'pid' Name +',' Punctuation +' ' Text +'out' Keyword.Pseudo +' ' Text +'status_ptr' Name +',' Punctuation +' ' Text +'options' Name +')' Punctuation +'\n\n' Text + +'lib' Keyword +' ' Text +'X' Name.Namespace +'\n ' Text +'type' Keyword +' ' Text +'CInt' Name.Class +' ' Text +'=' Operator +' ' Text +'Int32' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'{%' Literal.String.Interpol +' ' Text +'if' Keyword +' ' Text +'flag?' Name +'(' Punctuation +':x86_64' Literal.String.Symbol +')' Punctuation +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'# some specific code for 64 bits platforms' Comment.Single +'\n' Text + +'{%' Literal.String.Interpol +' ' Text +'else' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'# some specific code for non-64 bits platforms' Comment.Single +'\n' Text + +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n\n' Text + +'{%' Literal.String.Interpol +' ' Text +'if' Keyword +' ' Text +'flag?' Name +'(' Punctuation +':linux' Literal.String.Symbol +')' Punctuation +' ' Text +'&&' Operator +' ' Text +'flag?' Name +'(' Punctuation +':x86_64' Literal.String.Symbol +')' Punctuation +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'# some specific code for linux 64 bits' Comment.Single +'\n' Text + +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n\n' Text + +'lib' Keyword +' ' Text +'C' Name.Namespace +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'if' Keyword +' ' Text +'flag?' Name +'(' Punctuation +':linux' Literal.String.Symbol +')' Punctuation +' ' Text +'&&' Operator +' ' Text +'flag?' Name +'(' Punctuation +':x86_64' Literal.String.Symbol +')' Punctuation +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'struct' Keyword +' ' Text +'SomeStruct' Name.Class +'\n ' Text +'some_field' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n ' Text +'end' Keyword +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'else' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'struct' Keyword +' ' Text +'SomeStruct' Name.Class +'\n ' Text +'some_field' Name +' ' Text +':' Punctuation +' ' Text +'Int64' Name +'\n ' Text +'end' Keyword +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Assigns to a local variable' Comment.Single +'\n' Text + +'local' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'# Assigns to a global property' Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'Global' Name.Class +'\n ' Text +'class_property' Name.Builtin.Pseudo +' ' Text +'global1' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'class_getter' Name.Builtin.Pseudo +' ' Text +'global2' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'class_setter' Name.Builtin.Pseudo +' ' Text +'global3' Name +' ' Text +'=' Operator +' ' Text +'3' Literal.Number.Integer +'\n\n ' Text +'# Fails on nil' Comment.Single +'\n ' Text +'class_property!' Name.Builtin.Pseudo +' ' Text +'global4' Name +' ' Text +'=' Operator +' ' Text +'4' Literal.Number.Integer +'\n ' Text +'class_getter!' Name.Builtin.Pseudo +' ' Text +'global5' Name +' ' Text +'=' Operator +' ' Text +'5' Literal.Number.Integer +'\n ' Text +'class_setter' Name.Builtin.Pseudo +'!' Operator +' ' Text +'global6' Name +' ' Text +'=' Operator +' ' Text +'6' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Testing' Name.Class +'\n ' Text +'# Assigns to an instance variable' Comment.Single +'\n ' Text +'@instance' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n\n ' Text +'# Assigns to a class variable' Comment.Single +'\n ' Text +'@@class' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'3' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'local' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'# same as: local = local + 1' Comment.Single +'\n\n' Text + +'# The above is valid with these operators:' Comment.Single +'\n' Text + +'# +, -, *, /, %, |, &, ^, **, <<, >>' Comment.Single +'\n\n' Text + +'local' Name +' ' Text +'||' Operator +'=' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'# same as: local || (local = 1)' Comment.Single +'\n' Text + +'local' Name +' ' Text +'&&' Operator +'=' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'# same as: local && (local = 1)' Comment.Single +'\n\n' Text + +'# A setter' Comment.Single +'\n' Text + +'person' Name +'.' Operator +'name' Name +'=' Operator +'(' Punctuation +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'# The above can be written as:' Comment.Single +'\n' Text + +'person' Name +'.' Operator +'name' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'# An indexed assignment' Comment.Single +'\n' Text + +'objects' Name +'.' Operator +'[]=' Name.Operator +'(' Punctuation +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +')' Punctuation +'\n\n' Text + +'# The above can be written as:' Comment.Single +'\n' Text + +'objects' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'3' Literal.Number.Integer +'\n\n' Text + +'# Not assignment-related, but also syntax sugar:' Comment.Single +'\n' Text + +'objects' Name +'.' Operator +'[]' Name.Operator +'(' Punctuation +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +')' Punctuation +'\n\n' Text + +'# The above can be written as:' Comment.Single +'\n' Text + +'objects' Name +'[' Operator +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +'\n\n' Text + +'person' Name +'.' Operator +'age' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'# same as: person.age = person.age + 1' Comment.Single +'\n\n' Text + +'person' Name +'.' Operator +'name' Name +' ' Text +'||' Operator +'=' Operator +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# same as: person.name || (person.name = "John")' Comment.Single +'\n' Text + +'person' Name +'.' Operator +'name' Name +' ' Text +'&&' Operator +'=' Operator +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# same as: person.name && (person.name = "John")' Comment.Single +'\n\n' Text + +'objects' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'+=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'# same as: objects[1] = objects[1] + 2' Comment.Single +'\n\n' Text + +'objects' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'||' Operator +'=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'# same as: objects[1]? || (objects[1] = 2)' Comment.Single +'\n' Text + +'objects' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'&&' Operator +'=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'# same as: objects[1]? && (objects[1] = 2)' Comment.Single +'\n\n' Text + +'alias' Keyword +' ' Text +'PInt32' Name.Class +' ' Text +'=' Operator +' ' Text +'Pointer' Name +'(' Punctuation +'Int32' Name +')' Punctuation +'\n\n' Text + +'ptr' Name +' ' Text +'=' Operator +' ' Text +'PInt32' Name +'.' Operator +'malloc' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# : Pointer(Int32)' Comment.Single +'\n\n' Text + +'alias' Keyword +' ' Text +'RecArray' Name.Class +' ' Text +'=' Operator +' ' Text +'Array' Name +'(' Punctuation +'Int32' Name +')' Punctuation +' ' Text +'|' Operator +' ' Text +'Array' Name +'(' Punctuation +'RecArray' Name +')' Punctuation +'\n\n' Text + +'ary' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +' ' Text +'of' Keyword +' ' Text +'RecArray' Name +'\n' Text + +'ary' Name +'.' Operator +'push' Name +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +'\n' Text + +'ary' Name +'.' Operator +'push' Name +' ' Text +'ary' Name +'\n' Text + +'ary' Name +' ' Text +'# => [[1, 2, 3], [...]]' Comment.Single +'\n\n' Text + +'module' Keyword +' ' Text +'Json' Name.Namespace +'\n ' Text +'alias' Keyword +' ' Text +'Type' Name.Class +' ' Text +'=' Operator +' ' Text +'Nil' Name +' ' Text +'|' Operator +'\n ' Text +'Bool' Name +' ' Text +'|' Operator +'\n ' Text +'Int64' Name +' ' Text +'|' Operator +'\n ' Text +'Float64' Name +' ' Text +'|' Operator +'\n ' Text +'String' Name +' ' Text +'|' Operator +'\n ' Text +'Array' Name +'(' Punctuation +'Type' Name +')' Punctuation +' ' Text +'|' Operator +'\n ' Text +'Hash' Name +'(' Punctuation +'String' Name +',' Punctuation +' ' Text +'Type' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'if' Keyword +' ' Text +'a' Name +' ' Text +'>' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'10' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n' Text + +'a' Name +' ' Text +'# => 10' Comment.Single +'\n\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'if' Keyword +' ' Text +'b' Name +' ' Text +'>' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'b' Name +' ' Text +'=' Operator +' ' Text +'10' Literal.Number.Integer +'\n' Text + +'else' Keyword +'\n ' Text +'b' Name +' ' Text +'=' Operator +' ' Text +'20' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n' Text + +'b' Name +' ' Text +'# => 20' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'do_something' Name +'\n' Text + +'elsif' Keyword +' ' Text +'some_other_condition' Name +'\n ' Text +'do_something_else' Name +'\n' Text + +'else' Keyword +'\n ' Text +'do_that' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'if' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'else' Keyword +'\n ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'true' Keyword.Constant +'\n' Text + +'end' Keyword +'\n' Text + +'# a : String | Bool' Comment.Single +'\n\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'if' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'b' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n' Text + +'# b : Int32 | String' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'c' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'else' Keyword +'\n ' Text +'c' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n' Text + +'# c : Int32 | String' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'d' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n' Text + +'# d : Int32 | Nil' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'if' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'# a : String' Comment.Single +'\n ' Text +'a' Name +'.' Operator +'size' Name +'\n' Text + +'end' Keyword +'\n' Text + +'# a : String | Int32' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'e' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'else' Keyword +'\n ' Text +'e' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'# e : String' Comment.Single +'\n ' Text +'return' Keyword +'\n' Text + +'end' Keyword +'\n' Text + +'# e : Int32' Comment.Single +'\n\n' Text + +'enum' Keyword +' ' Text +'Color' Name.Class +' ' Text +':' Punctuation +' ' Text +'UInt8' Name +'\n ' Text +'Red' Name +' ' Text +'# 0' Comment.Single +'\n ' Text +'Green' Name +' ' Text +'# 1' Comment.Single +'\n ' Text +'Blue' Name +' ' Text +'=' Operator +' ' Text +'5' Literal.Number.Integer +' ' Text +'# overwritten to 5' Comment.Single +'\n ' Text +'Yellow' Name +' ' Text +'# 6 (5 + 1)' Comment.Single +'\n\n ' Text +'def' Keyword +' ' Text +'red?' Name.Function +'\n ' Text +'self' Keyword +' ' Text +'==' Operator +' ' Text +'Color' Name +'::' Operator +'Red' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Color' Name +'::' Operator +'Red' Name +'.' Operator +'value' Name +' ' Text +'# :: UInt8' Comment.Single +'\n\n' Text + +'@[' Operator +'Flags' Name.Decorator +']' Operator +'\n' Text + +'enum' Keyword +' ' Text +'IOMode' Name.Class +'\n ' Text +'Read' Name +' ' Text +'# 1' Comment.Single +'\n ' Text +'Write' Name +' ' Text +'# 2' Comment.Single +'\n ' Text +'Async' Name +' ' Text +'# 4' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'IOMode' Name +'::' Operator +'None' Name +'.' Operator +'value' Name +' ' Text +'# => 0' Comment.Single +'\n' Text + +'IOMode' Name +'::' Operator +'All' Name +'.' Operator +'value' Name +' ' Text +'# => 7' Comment.Single +'\n\n' Text + +'puts' Name.Builtin +'(' Punctuation +'Color' Name +'::' Operator +'Red' Name +')' Punctuation +' ' Text +'# prints "Red"' Comment.Single +'\n' Text + +'puts' Name.Builtin +'(' Punctuation +'IOMode' Name +'::' Operator +'Write' Name +' ' Text +'|' Operator +' ' Text +'IOMode' Name +'::' Operator +'Async' Name +')' Punctuation +' ' Text +'# prints "Write, Async"' Comment.Single +'\n\n' Text + +'puts' Name.Builtin +' ' Text +'Color' Name +'.' Operator +'new' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# => prints "Green"' Comment.Single +'\n\n' Text + +'puts' Name.Builtin +' ' Text +'Color' Name +'.' Operator +'new' Name +'(' Punctuation +'10' Literal.Number.Integer +')' Punctuation +' ' Text +'# => prints "10"' Comment.Single +'\n\n' Text + +'Color' Name +'::' Operator +'Red' Name +'.' Operator +'red?' Name +' ' Text +'# => true' Comment.Single +'\n' Text + +'Color' Name +'::' Operator +'Blue' Name +'.' Operator +'red?' Name +' ' Text +'# => false' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'paint' Name.Function +'(' Punctuation +'color' Name +' ' Text +':' Punctuation +' ' Text +'Color' Name +')' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'color' Name +'\n ' Text +'when' Keyword +' ' Text +'Color' Name +'::' Operator +'Red' Name +'\n ' Text +'# ...' Comment.Single +'\n ' Text +'else' Keyword +'\n ' Text +'# Unusual, but still can happen' Comment.Single +'\n ' Text +'raise' Name.Builtin +' ' Text +'"' Literal.String.Double +'unknown color: ' Literal.String.Double +'#{' Literal.String.Interpol +'color' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'paint' Name +' ' Text +'Color' Name +'::' Operator +'Red' Name +'\n\n' Text + +'def' Keyword +' ' Text +'paint' Name.Function +'(' Punctuation +'color' Name +' ' Text +':' Punctuation +' ' Text +'Symbol' Name +')' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'color' Name +'\n ' Text +'when' Keyword +' ' Text +':red' Literal.String.Symbol +'\n ' Text +'# ...' Comment.Single +'\n ' Text +'else' Keyword +'\n ' Text +'raise' Name.Builtin +' ' Text +'"' Literal.String.Double +'unknown color: ' Literal.String.Double +'#{' Literal.String.Interpol +'color' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'paint' Name +' ' Text +':red' Literal.String.Symbol +'\n\n' Text + +'name' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Crystal' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'age' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'flower' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Tulip' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +"# At this point 'flower' is a String" Comment.Single +'\n\n' Text + +'flower' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +"# At this point 'flower' is an Int32" Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Foo' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'finalize' Name.Function +'\n ' Text +'# Invoked when Foo is garbage-collected' Comment.Single +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Bye bye from ' Literal.String.Double +'#{' Literal.String.Interpol +'self' Keyword +'}' Literal.String.Interpol +'!' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Prints "Bye bye ...!" for ever' Comment.Single +'\n' Text + +'loop' Name.Builtin +' ' Text +'do' Keyword +'\n ' Text +'Foo' Name +'.' Operator +'new' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Defines a method in the program' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'add' Name.Function +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Invokes the add method in the program' Comment.Single +'\n' Text + +'add' Name +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +' ' Text +'# => 3' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'even?' Name.Function +'(' Punctuation +'num' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'num' Name +' ' Text +'%' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'return' Keyword +' ' Text +'true' Keyword.Constant +'\n ' Text +'end' Keyword +'\n\n ' Text +'return' Keyword +' ' Text +'false' Keyword.Constant +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'add' Name.Function +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Foo' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'bar' Name.Function +'\n ' Text +"# invokes the program's add method" Comment.Single +'\n ' Text +'add' Name +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n\n ' Text +"# invokes Foo's baz method" Comment.Single +'\n ' Text +'baz' Name +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'baz' Name.Function +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'*' Operator +' ' Text +'y' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'baz' Name.Function +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Foo' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'bar' Name.Function +'\n ' Text +'baz' Name +'(' Punctuation +'4' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +' ' Text +'# => 2' Comment.Single +'\n ' Text +'::' Operator +'baz' Name +'(' Punctuation +'4' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +' ' Text +'# => 6' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'baz' Name.Function +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'-' Operator +' ' Text +'y' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'def' Keyword +' ' Text +'add' Name.Function +'(' Punctuation +'y' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +' ' Text +"# error: undefined local variable or method 'x'" Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'add' Name +'(' Punctuation +'2' Literal.Number.Integer +')' Punctuation +'\n\n' Text + +'add' Name +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +' ' Text +'# same as add(1, 2)' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Counter' Name.Class +'\n ' Text +'@@instances' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'\n ' Text +'@@instances' Name.Variable.Class +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'instances' Name.Function +'\n ' Text +'@@instances' Name.Variable.Class +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Counter' Name +'.' Operator +'instances' Name +' ' Text +'# => 0' Comment.Single +'\n' Text + +'Counter' Name +'.' Operator +'new' Name +'\n' Text + +'Counter' Name +'.' Operator +'new' Name +'\n' Text + +'Counter' Name +'.' Operator +'new' Name +'\n' Text + +'Counter' Name +'.' Operator +'instances' Name +' ' Text +'# => 3' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Counter' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'increment' Name.Function +'\n ' Text +'@@instances' Name.Variable.Class +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Counter' Name +'.' Operator +'increment' Name +' ' Text +"# Error: undefined method '+' for Nil" Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Parent' Name.Class +'\n ' Text +'@@counter' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Child' Name.Class +' ' Text +'<' Operator +' ' Text +'Parent' Name +'\n ' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'counter' Name.Function +'\n ' Text +'@@counter' Name.Variable.Class +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Child' Name +'.' Operator +'counter' Name +' ' Text +'# => nil' Comment.Single +'\n\n' Text + +'unless' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'then_expression' Name +'\n' Text + +'else' Keyword +'\n ' Text +'else_expression' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Can also be written as a suffix' Comment.Single +'\n' Text + +'close_door' Name +' ' Text +'unless' Keyword +' ' Text +'door_closed?' Name +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'typeof' Keyword.Pseudo +'(' Punctuation +'a' Name +')' Punctuation +' ' Text +'# => Int32' Comment.Single +'\n\n' Text + +'typeof' Keyword.Pseudo +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +'a' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +"'a'" Literal.String.Char +')' Punctuation +' ' Text +'# => (Int32 | String | Char)' Comment.Single +'\n\n' Text + +'hash' Name +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +' ' Text +'of' Keyword +' ' Text +'Int32' Name +' ' Text +'=' Operator +'>' Operator +' ' Text +'String' Name +'\n' Text + +'another_hash' Name +' ' Text +'=' Operator +' ' Text +'typeof' Keyword.Pseudo +'(' Punctuation +'hash' Name +')' Punctuation +'.' Operator +'new' Name +' ' Text +'# :: Hash(Int32, String)' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Array' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'elem_type' Name.Function +'(' Punctuation +'typ' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'typ' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'Array' Name +')' Punctuation +'\n ' Text +'elem_type' Name +'(' Punctuation +'typ' Name +'.' Operator +'first' Name +')' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'typ' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'nest' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'[' Operator +'"' Literal.String.Double +'b' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'[' Operator +':c' Literal.String.Symbol +',' Punctuation +' ' Text +'[' Operator +"'d'" Literal.String.Char +']' Operator +']' Operator +']' Operator +']' Operator +'\n' Text + +'flat' Name +' ' Text +'=' Operator +' ' Text +'Array' Name +'(' Punctuation +'typeof' Keyword.Pseudo +'(' Punctuation +'Array' Name +'.' Operator +'elem_type' Name +'(' Punctuation +'nest' Name +')' Punctuation +')' Punctuation +')' Punctuation +'.' Operator +'new' Name +'\n' Text + +'typeof' Keyword.Pseudo +'(' Punctuation +'nest' Name +')' Punctuation +' ' Text +'# => Array(Int32 | Array(String | Array(Symbol | Array(Char))))' Comment.Single +'\n' Text + +'typeof' Keyword.Pseudo +'(' Punctuation +'flat' Name +')' Punctuation +' ' Text +'# => Array(String | Int32 | Symbol | Char)' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'if' Keyword +' ' Text +'some_condition' Name +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +'{' Punctuation +' ' Text +'x' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +';' Punctuation +' ' Text +'x' Name +' ' Text +'}' Punctuation +'\n' Text + +'proc' Name +'.' Operator +'call' Name +' ' Text +'# => 1' Comment.Single +'\n' Text + +'proc' Name +'.' Operator +'call' Name +' ' Text +'# => 2' Comment.Single +'\n' Text + +'x' Name +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'counter' Name.Function +'\n ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'-' Operator +'>' Operator +'{' Punctuation +' ' Text +'x' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +';' Punctuation +' ' Text +'x' Name +' ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'counter' Name +'\n' Text + +'proc' Name +'.' Operator +'call' Name +' ' Text +'# => 1' Comment.Single +'\n' Text + +'proc' Name +'.' Operator +'call' Name +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'\n ' Text +'yield' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'foo' Name +' ' Text +'do' Keyword +'\n ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n' Text + +'x' Name +' ' Text +'# : Int32 | String' Comment.Single +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'foo' Name +' ' Text +'do' Keyword +'\n ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n' Text + +'x' Name +' ' Text +'# : Int32 | String' Comment.Single +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +"'a'" Literal.String.Char +'\n' Text + +'x' Name +' ' Text +'# : Char' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'capture' Name.Function +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'block' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'capture' Name +' ' Text +'{' Punctuation +' ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +"'a'" Literal.String.Char +'\n' Text + +'x' Name +' ' Text +'# : Int32 | String | Char' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'capture' Name.Function +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'block' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'-' Operator +'>' Operator +'{' Punctuation +' ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +"'a'" Literal.String.Char +'\n' Text + +'x' Name +' ' Text +'# : Int32 | String | Char' Comment.Single +'\n\n' Text + +'abstract' Keyword +' ' Text +'class' Keyword +' ' Text +'Animal' Name.Class +'\n ' Text +'# Makes this animal talk' Comment.Single +'\n ' Text +'abstract' Keyword +' ' Text +'def' Keyword +' ' Text +'talk' Name.Function +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Dog' Name.Class +' ' Text +'<' Operator +' ' Text +'Animal' Name +'\n ' Text +'def' Keyword +' ' Text +'talk' Name.Function +'\n ' Text +'"' Literal.String.Double +'Woof!' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Cat' Name.Class +' ' Text +'<' Operator +' ' Text +'Animal' Name +'\n ' Text +'def' Keyword +' ' Text +'talk' Name.Function +'\n ' Text +'"' Literal.String.Double +'Miau' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'getter' Name.Builtin.Pseudo +' ' Text +'pet' Name +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +',' Punctuation +' ' Text +'@pet' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'Dog' Name +'.' Operator +'new' Name +'\n' Text + +'peter' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'Peter' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'Cat' Name +'.' Operator +'new' Name +'\n\n' Text + +'john' Name +'.' Operator +'pet' Name +'.' Operator +'talk' Name +' ' Text +'# => "Woof!"' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'>' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'?' Operator +' ' Text +'3' Literal.Number.Integer +' ' Text +':' Punctuation +' ' Text +'4' Literal.Number.Integer +'\n\n' Text + +'# The above is the same as:' Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'if' Keyword +' ' Text +'1' Literal.Number.Integer +' ' Text +'>' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'3' Literal.Number.Integer +'\n ' Text +'else' Keyword +'\n ' Text +'4' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'some_method' Name.Function +' ' Text +':' Punctuation +' ' Text +'String' Name +'\n ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'PI' Name.Constant +' ' Text +'=' Operator +' ' Text +'3.14' Literal.Number.Float +'\n\n' Text + +'module' Keyword +' ' Text +'Earth' Name.Namespace +'\n ' Text +'RADIUS' Name.Constant +' ' Text +'=' Operator +' ' Text +'6_371_000' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'PI' Name.Constant +' ' Text +'# => 3.14' Comment.Single +'\n' Text + +'Earth' Name +'::' Operator +'RADIUS' Name.Constant +' ' Text +'# => 6_371_000' Comment.Single +'\n\n' Text + +'TEN' Name.Constant +' ' Text +'=' Operator +' ' Text +'begin' Keyword +'\n ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'while' Keyword +' ' Text +'a' Name +' ' Text +'<' Operator +' ' Text +'10' Literal.Number.Integer +'\n ' Text +'a' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'a' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'TEN' Name.Constant +' ' Text +'# => 10' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'getter' Name.Builtin.Pseudo +' ' Text +'name' Name +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +')' Punctuation +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'john' Name +'.' Operator +'name' Name +' ' Text +'# => "John"' Comment.Single +'\n' Text + +'john' Name +'.' Operator +'name' Name +'.' Operator +'size' Name +' ' Text +'# => 4' Comment.Single +'\n\n' Text + +'one' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'one' Name +'.' Operator +'name' Name +' ' Text +'# => 1' Comment.Single +'\n' Text + +'one' Name +'.' Operator +'name' Name +' ' Text +'+' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'# => 3' Comment.Single +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'one' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'one' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +"# Error: undefined method 'size' for Int32" Comment.Single +'\n' Text + +'john' Name +'.' Operator +'name' Name +'.' Operator +'size' Name +'\n\n' Text + +"# Error: no overload matches 'String#+' with types Int32" Comment.Single +'\n' Text + +'john' Name +'.' Operator +'name' Name +' ' Text +'+' Operator +' ' Text +'3' Literal.Number.Integer +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'john' Name +'.' Operator +'name' Name +'.' Operator +'size' Name +'\n' Text + +'one' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'getter' Name.Builtin.Pseudo +' ' Text +'name' Name +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +')' Punctuation +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'address' Name.Function +'\n ' Text +'@address' Name.Variable.Instance +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'address' Name.Function +'=' Operator +'(' Punctuation +'@address' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'john' Name +'.' Operator +'address' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Argentina' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +"# Error: undefined method 'size' for Nil" Comment.Single +'\n' Text + +'john' Name +'.' Operator +'address' Name +'.' Operator +'size' Name +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +')' Punctuation +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'if' Keyword +' ' Text +'2' Literal.Number.Integer +' ' Text +'>' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'3' Literal.Number.Integer +'\n ' Text +'else' Keyword +'\n ' Text +'4' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n' Text + +'a' Name +' ' Text +'# => 3' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'1' Literal.Number.Integer +' ' Text +'>' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'else' Keyword +'\n ' Text +'3' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'twice' Name.Function +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'yield' Keyword +'\n ' Text +'yield' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +'(' Punctuation +')' Punctuation +' ' Text +'do' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello!' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'do' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello!' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'{' Punctuation +' ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello!' Literal.String.Double +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n\n' Text + +'def' Keyword +' ' Text +'twice' Name.Function +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'yield' Keyword +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Got ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Got ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n\n' Text + +'def' Keyword +' ' Text +'many' Name.Function +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'many' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'x' Name +',' Punctuation +' ' Text +'y' Name +',' Punctuation +' ' Text +'z' Name +'|' Operator +'\n ' Text +'puts' Name.Builtin +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +' ' Text +'+' Operator +' ' Text +'z' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Output: 6' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'many' Name.Function +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'many' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'x' Name +',' Punctuation +' ' Text +'y' Name +'|' Operator +'\n ' Text +'puts' Name.Builtin +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Output: 3' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'twice' Name.Function +'\n ' Text +'yield' Keyword +'\n ' Text +'yield' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'puts' Name.Builtin +' ' Text +'i' Name +'.' Operator +'inspect' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'some' Name.Function +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +"'a'" Literal.String.Char +'\n ' Text +'yield' Keyword +' ' Text +'true' Keyword.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'yield' Keyword +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'some' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'first' Name +',' Punctuation +' ' Text +'second' Name +'|' Operator +'\n ' Text +'# first is Int32 | Bool' Comment.Single +'\n ' Text +'# second is Char | String | Nil' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'method' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'argument' Name +'|' Operator +'\n ' Text +'argument' Name +'.' Operator +'some_method' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'method' Name +'(' Punctuation +'&' Operator +'.' Operator +'some_method' Name +')' Punctuation +'\n\n' Text + +'method' Name +' ' Text +'&' Operator +'.' Operator +'some_method' Name +'(' Punctuation +'arg1' Name +',' Punctuation +' ' Text +'arg2' Name +')' Punctuation +'\n\n' Text + +'method' Name +' ' Text +'&' Operator +'.' Operator +'+' Name.Operator +'(' Punctuation +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'method' Name +' ' Text +'&' Operator +'.' Operator +'[' Name +'index' Name +']' Operator +'\n\n' Text + +'def' Keyword +' ' Text +'twice' Name.Function +'\n ' Text +'v1' Name +' ' Text +'=' Operator +' ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'v1' Name +'\n\n ' Text +'v2' Name +' ' Text +'=' Operator +' ' Text +'yield' Keyword +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'v2' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'ary' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +'\n' Text + +'ary' Name +'.' Operator +'map' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'x' Name +'|' Operator +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +' ' Text +'# => [2, 3, 4]' Comment.Single +'\n' Text + +'ary' Name +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'x' Name +'|' Operator +' ' Text +'x' Name +' ' Text +'%' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'==' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +' ' Text +'# => [1, 3]' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'transform' Name.Function +'(' Punctuation +'value' Name +')' Punctuation +'\n ' Text +'yield' Keyword +' ' Text +'value' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'transform' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'x' Name +'|' Operator +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'thrice' Name.Function +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Before 1' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Before 2' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'yield' Keyword +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Before 3' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'yield' Keyword +' ' Text +'3' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'After 3' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'thrice' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'if' Keyword +' ' Text +'i' Name +' ' Text +'==' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'break' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'twice' Name.Function +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'yield' Keyword +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +' ' Text +'# => 3' Comment.Single +'\n' Text + +'twice' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'break' Keyword +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'}' Punctuation +' ' Text +'# => "hello"' Comment.Single +'\n\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'twice' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'if' Keyword +' ' Text +'i' Name +' ' Text +'==' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'break' Keyword +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n' Text + +'value' Name +' ' Text +'# :: Int32 | String' Comment.Single +'\n\n' Text + +'values' Name +' ' Text +'=' Operator +' ' Text +'twice' Name +' ' Text +'{' Punctuation +' ' Text +'break' Keyword +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'values' Name +' ' Text +'# => {1, 2}' Comment.Single +'\n\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'twice' Name +' ' Text +'{' Punctuation +' ' Text +'break' Keyword +' ' Text +'}' Punctuation +'\n' Text + +'value' Name +' ' Text +'# => nil' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'twice' Name.Function +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'yield' Keyword +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'if' Keyword +' ' Text +'i' Name +' ' Text +'==' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Skipping 1' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'next' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Got ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'twice' Name.Function +'\n ' Text +'v1' Name +' ' Text +'=' Operator +' ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'v1' Name +'\n\n ' Text +'v2' Name +' ' Text +'=' Operator +' ' Text +'yield' Keyword +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'v2' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'if' Keyword +' ' Text +'i' Name +' ' Text +'==' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'next' Keyword +' ' Text +'10' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n\n ' Text +'i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Output' Comment.Single +'\n' Text + +'# 10' Comment.Single +'\n' Text + +'# 3' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Foo' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'one' Name.Function +'\n ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'yield_with_self' Name.Function +'\n ' Text +'with' Keyword +' ' Text +'self' Keyword +' ' Text +'yield' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'yield_normally' Name.Function +'\n ' Text +'yield' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'one' Name.Function +'\n ' Text +'"' Literal.String.Double +'one' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'Foo' Name +'.' Operator +'new' Name +'.' Operator +'yield_with_self' Name +' ' Text +'{' Punctuation +' ' Text +'one' Name +' ' Text +'}' Punctuation +' ' Text +'# => 1' Comment.Single +'\n' Text + +'Foo' Name +'.' Operator +'new' Name +'.' Operator +'yield_normally' Name +' ' Text +'{' Punctuation +' ' Text +'one' Name +' ' Text +'}' Punctuation +' ' Text +'# => "one"' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'twice' Name.Function +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'yield' Keyword +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Got: ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'i' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Got: ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'i' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Got: ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n' Text + +'3' Literal.Number.Integer +'.' Operator +'times' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'puts' Name.Builtin +' ' Text +'i' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'struct' Keyword +' ' Text +'Int' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'times' Name.Function +'\n ' Text +'i' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'while' Keyword +' ' Text +'i' Name +' ' Text +'<' Operator +' ' Text +'self' Keyword +'\n ' Text +'yield' Keyword +' ' Text +'i' Name +'\n ' Text +'i' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'i' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'while' Keyword +' ' Text +'i' Name +' ' Text +'<' Operator +' ' Text +'3' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'i' Name +'\n ' Text +'i' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'greet' Name.Function +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +"Hi, I'm " Literal.String.Double +'#{' Literal.String.Interpol +'@name' Name.Variable.Instance +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Employee' Name.Class +' ' Text +'<' Operator +' ' Text +'Person' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'employee' Name +' ' Text +'=' Operator +' ' Text +'Employee' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'employee' Name +'.' Operator +'greet' Name +' ' Text +'# "Hi, I\'m John"' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Employee' Name.Class +' ' Text +'<' Operator +' ' Text +'Person' Name +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +',' Punctuation +' ' Text +'@company_name' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Employee' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Acme' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# OK' Comment.Single +'\n' Text + +'Employee' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'Peter' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# Error: wrong number of arguments' Comment.Single +'\n' Text + +"# for 'Employee:Class#new' (1 for 2)" Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'greet' Name.Function +'(' Punctuation +'msg' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hi, ' Literal.String.Double +'#{' Literal.String.Interpol +'msg' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Employee' Name.Class +' ' Text +'<' Operator +' ' Text +'Person' Name +'\n ' Text +'def' Keyword +' ' Text +'greet' Name.Function +'(' Punctuation +'msg' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello, ' Literal.String.Double +'#{' Literal.String.Interpol +'msg' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'p' Name.Builtin +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +'\n' Text + +'p' Name.Builtin +'.' Operator +'greet' Name +' ' Text +'"' Literal.String.Double +'everyone' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# "Hi, everyone"' Comment.Single +'\n\n' Text + +'e' Name +' ' Text +'=' Operator +' ' Text +'Employee' Name +'.' Operator +'new' Name +'\n' Text + +'e' Name +'.' Operator +'greet' Name +' ' Text +'"' Literal.String.Double +'everyone' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# "Hello, everyone"' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'greet' Name.Function +'(' Punctuation +'msg' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hi, ' Literal.String.Double +'#{' Literal.String.Interpol +'msg' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Employee' Name.Class +' ' Text +'<' Operator +' ' Text +'Person' Name +'\n ' Text +'def' Keyword +' ' Text +'greet' Name.Function +'(' Punctuation +'msg' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hi, this is a number: ' Literal.String.Double +'#{' Literal.String.Interpol +'msg' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'e' Name +' ' Text +'=' Operator +' ' Text +'Employee' Name +'.' Operator +'new' Name +'\n' Text + +'e' Name +'.' Operator +'greet' Name +' ' Text +'"' Literal.String.Double +'everyone' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# "Hi, everyone"' Comment.Single +'\n\n' Text + +'e' Name +'.' Operator +'greet' Name +' ' Text +'1' Literal.Number.Integer +' ' Text +'# "Hi, this is a number: 1"' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'greet' Name.Function +'(' Punctuation +'msg' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello, ' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# {msg}"' Comment.Single +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Employee' Name.Class +' ' Text +'<' Operator +' ' Text +'Person' Name +'\n ' Text +'def' Keyword +' ' Text +'greet' Name.Function +'(' Punctuation +'msg' Name +')' Punctuation +'\n ' Text +'super' Keyword +' ' Text +'# Same as: super(msg)' Comment.Single +'\n ' Text +'super' Keyword +'(' Punctuation +'"' Literal.String.Double +'another message' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'int_to_int' Name.Function +'(' Punctuation +'&' Operator +'block' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +' ' Text +'-' Operator +'>' Operator +' ' Text +'Int32' Name +')' Punctuation +'\n ' Text +'block' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'int_to_int' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'x' Name +'|' Operator +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Model' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'on_save' Name.Function +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'@on_save_callback' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'block' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'save' Name.Function +'\n ' Text +'if' Keyword +' ' Text +'callback' Name +' ' Text +'=' Operator +' ' Text +'@on_save_callback' Name.Variable.Instance +'\n ' Text +'callback' Name +'.' Operator +'call' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'model' Name +' ' Text +'=' Operator +' ' Text +'Model' Name +'.' Operator +'new' Name +'\n' Text + +'model' Name +'.' Operator +'on_save' Name +' ' Text +'{' Punctuation +' ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Saved!' Literal.String.Double +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n' Text + +'model' Name +'.' Operator +'save' Name +' ' Text +'# prints "Saved!"' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'some_proc' Name.Function +'(' Punctuation +'&' Operator +'block' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +' ' Text +'-' Operator +'>' Operator +')' Punctuation +'\n ' Text +'block' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'some_proc' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'x' Name +'|' Operator +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# void' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'some_proc' Name.Function +'(' Punctuation +'&' Operator +'block' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +' ' Text +'-' Operator +'>' Operator +' ' Text +'_' Name +')' Punctuation +'\n ' Text +'block' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'some_proc' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'x' Name +'|' Operator +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# 2' Comment.Single +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'some_proc' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'x' Name +'|' Operator +' ' Text +'x' Name +'.' Operator +'to_s' Name +' ' Text +'}' Punctuation +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# "1"' Comment.Single +'\n\n' Text + +'macro' Keyword +' ' Text +'update_x' Name.Function +'\n ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'update_x' Name +'\n' Text + +'x' Name +' ' Text +'# => 1' Comment.Single +'\n\n' Text + +'macro' Keyword +' ' Text +'dont_update_x' Name.Function +'\n ' Text +'%' Operator +'x' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +' ' Text +'%' Operator +'x' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'x' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'dont_update_x' Name +' ' Text +'# outputs 1' Comment.Single +'\n' Text + +'x' Name +' ' Text +'# => 0' Comment.Single +'\n\n' Text + +'macro' Keyword +' ' Text +'fresh_vars_sample' Name.Function +'(' Punctuation +'*' Operator +'names' Name +')' Punctuation +'\n ' Text +'# First declare vars' Comment.Single +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'for' Keyword +' ' Text +'name' Name +',' Punctuation +' ' Text +'index' Name +' ' Text +'in' Keyword +' ' Text +'names' Name +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Declaring: ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'%name{index}' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +"'\\n'" Literal.String.Char +'\n ' Text +'%' Operator +'name' Name +'{' Punctuation +'index' Name +'}' Punctuation +' ' Text +'=' Operator +' ' Text +'{{' Literal.String.Interpol +'index' Name +'}}' Literal.String.Interpol +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n\n ' Text +'# Then print them' Comment.Single +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'for' Keyword +' ' Text +'name' Name +',' Punctuation +' ' Text +'index' Name +' ' Text +'in' Keyword +' ' Text +'names' Name +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'%name{index}: ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'%' Operator +'name' Name +'{' Punctuation +'index' Name +'}' Punctuation +',' Punctuation +' ' Text +"'\\n'" Literal.String.Char +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n' Text + +'end' Keyword +'\n\n' Text + +'fresh_vars_sample' Name +' ' Text +'a' Name +',' Punctuation +' ' Text +'b' Name +',' Punctuation +' ' Text +'c' Name +'\n\n' Text + +'# Sample output:' Comment.Single +'\n' Text + +'# Declaring: __temp_255' Comment.Single +'\n' Text + +'# Declaring: __temp_256' Comment.Single +'\n' Text + +'# Declaring: __temp_257' Comment.Single +'\n' Text + +'# __temp_255: 0' Comment.Single +'\n' Text + +'# __temp_256: 1' Comment.Single +'\n' Text + +'# __temp_257: 2' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Object' Name.Class +'\n ' Text +'macro' Keyword +' ' Text +'instance_vars_names' Name.Function +'\n ' Text +'def' Keyword +' ' Text +'instance_vars_names' Name.Function +' ' Text +':' Punctuation +' ' Text +'Array' Name +'(' Punctuation +'String' Name +')' Punctuation +'\n ' Text +'{{' Literal.String.Interpol +' ' Text +'@type' Name.Variable.Instance +'.' Operator +'instance_vars' Name +'.' Operator +'map' Name +' ' Text +'&' Operator +'.' Operator +'name' Name +'.' Operator +'stringify' Name +' ' Text +'}}' Literal.String.Interpol +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@name' Name.Variable.Instance +',' Punctuation +' ' Text +'@age' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'person' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'30' Literal.Number.Integer +'\n' Text + +'person' Name +'.' Operator +'instance_vars_names' Name +' ' Text +'# => ["name", "age"]' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Object' Name.Class +'\n ' Text +'macro' Keyword +' ' Text +'has_instance_var?' Name.Function +'(' Punctuation +'name' Name +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'has_instance_var?' Name.Function +'(' Punctuation +'name' Name +')' Punctuation +' ' Text +':' Punctuation +' ' Text +'Bool' Name +'\n ' Text +'# We cannot access name inside the macro expansion here,' Comment.Single +'\n ' Text +'# instead we need to use the macro language to construct an array' Comment.Single +'\n ' Text +'# and do the inclusion check at runtime.' Comment.Single +'\n ' Text +'{{' Literal.String.Interpol +' ' Text +'@type' Name.Variable.Instance +'.' Operator +'instance_vars' Name +'.' Operator +'map' Name +' ' Text +'&' Operator +'.' Operator +'name' Name +'.' Operator +'stringify' Name +' ' Text +'}}' Literal.String.Interpol +'.' Operator +'includes?' Name +' ' Text +'name' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'person' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'30' Literal.Number.Integer +'\n' Text + +'person' Name +'.' Operator +'has_instance_var?' Name +'(' Punctuation +'"' Literal.String.Double +'name' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'# => true' Comment.Single +'\n' Text + +'person' Name +'.' Operator +'has_instance_var?' Name +'(' Punctuation +'"' Literal.String.Double +'birthday' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'# => false' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Parent' Name.Class +'\n ' Text +'macro' Keyword +' ' Text +'inherited' Name.Function +'\n ' Text +'def' Keyword +' ' Text +'{{' Literal.String.Interpol +'@type' Name.Variable.Instance +'.' Operator +'name' Name +'.' Operator +'downcase' Name +'.' Operator +'id' Name +'}}' Literal.String.Interpol +'\n ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Child' Name.Class +' ' Text +'<' Operator +' ' Text +'Parent' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'Child' Name +'.' Operator +'new' Name +'.' Operator +'child' Name +' ' Text +'# => 1' Comment.Single +'\n\n' Text + +'macro' Keyword +' ' Text +'method_missing' Name.Function +'(' Punctuation +'name' Name +',' Punctuation +' ' Text +'args' Name +',' Punctuation +' ' Text +'block' Name +')' Punctuation +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Got ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'{{' Literal.String.Interpol +'name' Name +'.' Operator +'id' Name +'.' Operator +'stringify' Name +'}}' Literal.String.Interpol +',' Punctuation +' ' Text +'"' Literal.String.Double +' with ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'{{' Literal.String.Interpol +'args' Name +'.' Operator +'size' Name +'}}' Literal.String.Interpol +',' Punctuation +' ' Text +'"' Literal.String.Double +' arguments' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +"'\\n'" Literal.String.Char +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +' ' Text +'# Prints: Got foo with 0 arguments' Comment.Single +'\n' Text + +'bar' Name +' ' Text +"'a'" Literal.String.Char +',' Punctuation +' ' Text +"'b'" Literal.String.Char +' ' Text +'# Prints: Got bar with 2 arguments' Comment.Single +'\n\n' Text + +'sizeof' Keyword.Pseudo +'(' Punctuation +'Int32' Name +')' Punctuation +' ' Text +'# => 4' Comment.Single +'\n' Text + +'sizeof' Keyword.Pseudo +'(' Punctuation +'Int64' Name +')' Punctuation +' ' Text +'# => 8' Comment.Single +'\n\n' Text + +'# On a 64 bits machine' Comment.Single +'\n' Text + +'sizeof' Keyword.Pseudo +'(' Punctuation +'Pointer' Name +'(' Punctuation +'Int32' Name +')' Punctuation +')' Punctuation +' ' Text +'# => 8' Comment.Single +'\n' Text + +'sizeof' Keyword.Pseudo +'(' Punctuation +'String' Name +')' Punctuation +' ' Text +'# => 8' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'sizeof' Keyword.Pseudo +'(' Punctuation +'typeof' Keyword.Pseudo +'(' Punctuation +'a' Name +')' Punctuation +')' Punctuation +' ' Text +'# => 4' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Foo' Name.Class +'\n ' Text +'macro' Keyword +' ' Text +'emphasize' Name.Function +'(' Punctuation +'value' Name +')' Punctuation +'\n ' Text +'"' Literal.String.Double +'***' Literal.String.Double +'#{' Literal.String.Interpol +' ' Text +'{' Literal.String.Interpol +'{' Literal.String.Interpol +'value' Name +'}' Literal.String.Interpol +'}' Literal.String.Interpol +' ' Text +'}' Literal.String.Interpol +'***' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'yield_with_self' Name.Function +'\n ' Text +'with' Keyword +' ' Text +'self' Keyword +' ' Text +'yield' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Foo' Name +'.' Operator +'new' Name +'.' Operator +'yield_with_self' Name +' ' Text +'{' Punctuation +' ' Text +'emphasize' Name +'(' Punctuation +'10' Literal.Number.Integer +')' Punctuation +' ' Text +'}' Punctuation +' ' Text +'# => "***10***"' Comment.Single +'\n\n' Text + +'# This generates:' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# def :foo' Comment.Single +'\n' Text + +'# 1' Comment.Single +'\n' Text + +'# end' Comment.Single +'\n' Text + +'define_method' Name +' ' Text +':foo' Literal.String.Symbol +',' Punctuation +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'macro' Keyword +' ' Text +'define_method' Name.Function +'(' Punctuation +'name' Name +',' Punctuation +' ' Text +'content' Name +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'{{' Literal.String.Interpol +'name' Name +'.' Operator +'id' Name +'}}' Literal.String.Interpol +'\n ' Text +'{{' Literal.String.Interpol +'content' Name +'}}' Literal.String.Interpol +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'# This correctly generates:' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# def foo' Comment.Single +'\n' Text + +'# 1' Comment.Single +'\n' Text + +'# end' Comment.Single +'\n' Text + +'define_method' Name +' ' Text +':foo' Literal.String.Symbol +',' Punctuation +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'macro' Keyword +' ' Text +'define_method' Name.Function +'(' Punctuation +'name' Name +',' Punctuation +' ' Text +'content' Name +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'{{' Literal.String.Interpol +'name' Name +'}}' Literal.String.Interpol +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'if' Keyword +' ' Text +'content' Name +' ' Text +'==' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'"' Literal.String.Double +'one' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'else' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'{{' Literal.String.Interpol +'content' Name +'}}' Literal.String.Interpol +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'define_method' Name +' ' Text +'foo' Name +',' Punctuation +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'define_method' Name +' ' Text +'bar' Name +',' Punctuation +' ' Text +'2' Literal.Number.Integer +'\n\n' Text + +'foo' Name +' ' Text +'# => one' Comment.Single +'\n' Text + +'bar' Name +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'{%' Literal.String.Interpol +' ' Text +'if' Keyword +' ' Text +'env' Name +'(' Punctuation +'"' Literal.String.Double +'TEST' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'We are in test mode' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n\n' Text + +'macro' Keyword +' ' Text +'define_dummy_methods' Name.Function +'(' Punctuation +'names' Name +')' Punctuation +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'for' Keyword +' ' Text +'name' Name +',' Punctuation +' ' Text +'index' Name +' ' Text +'in' Keyword +' ' Text +'names' Name +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'def' Keyword +' ' Text +'{{' Literal.String.Interpol +'name' Name +'.' Operator +'id' Name +'}}' Literal.String.Interpol +'\n ' Text +'{{' Literal.String.Interpol +'index' Name +'}}' Literal.String.Interpol +'\n ' Text +'end' Keyword +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n' Text + +'end' Keyword +'\n\n' Text + +'define_dummy_methods' Name +' ' Text +'[' Operator +'foo' Name +',' Punctuation +' ' Text +'bar' Name +',' Punctuation +' ' Text +'baz' Name +']' Operator +'\n\n' Text + +'foo' Name +' ' Text +'# => 0' Comment.Single +'\n' Text + +'bar' Name +' ' Text +'# => 1' Comment.Single +'\n' Text + +'baz' Name +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'macro' Keyword +' ' Text +'define_dummy_methods' Name.Function +'(' Punctuation +'hash' Name +')' Punctuation +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'for' Keyword +' ' Text +'key' Name +',' Punctuation +' ' Text +'value' Name +' ' Text +'in' Keyword +' ' Text +'hash' Name +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'def' Keyword +' ' Text +'{{' Literal.String.Interpol +'key' Name +'.' Operator +'id' Name +'}}' Literal.String.Interpol +'\n ' Text +'{{' Literal.String.Interpol +'value' Name +'}}' Literal.String.Interpol +'\n ' Text +'end' Keyword +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n' Text + +'end' Keyword +'\n\n' Text + +'define_dummy_methods' Name +'(' Punctuation +'{' Punctuation +'foo' Literal.String.Symbol +':' Punctuation +' ' Text +'10' Literal.Number.Integer +',' Punctuation +' ' Text +'bar' Literal.String.Symbol +':' Punctuation +' ' Text +'20' Literal.Number.Integer +'}' Punctuation +')' Punctuation +'\n' Text + +'foo' Name +' ' Text +'# => 10' Comment.Single +'\n' Text + +'bar' Name +' ' Text +'# => 20' Comment.Single +'\n\n' Text + +'{%' Literal.String.Interpol +' ' Text +'for' Keyword +' ' Text +'name' Name +',' Punctuation +' ' Text +'index' Name +' ' Text +'in' Keyword +' ' Text +'[' Operator +'"' Literal.String.Double +'foo' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'bar' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'baz' Literal.String.Double +'"' Literal.String.Double +']' Operator +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'def' Keyword +' ' Text +'{{' Literal.String.Interpol +'name' Name +'.' Operator +'id' Name +'}}' Literal.String.Interpol +'\n ' Text +'{{' Literal.String.Interpol +'index' Name +'}}' Literal.String.Interpol +'\n ' Text +'end' Keyword +'\n' Text + +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n\n' Text + +'foo' Name +' ' Text +'# => 0' Comment.Single +'\n' Text + +'bar' Name +' ' Text +'# => 1' Comment.Single +'\n' Text + +'baz' Name +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'macro' Keyword +' ' Text +'define_dummy_methods' Name.Function +'(' Punctuation +'*' Operator +'names' Name +')' Punctuation +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'for' Keyword +' ' Text +'name' Name +',' Punctuation +' ' Text +'index' Name +' ' Text +'in' Keyword +' ' Text +'names' Name +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'def' Keyword +' ' Text +'{{' Literal.String.Interpol +'name' Name +'.' Operator +'id' Name +'}}' Literal.String.Interpol +'\n ' Text +'{{' Literal.String.Interpol +'index' Name +'}}' Literal.String.Interpol +'\n ' Text +'end' Keyword +'\n ' Text +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n' Text + +'end' Keyword +'\n\n' Text + +'define_dummy_methods' Name +' ' Text +'foo' Name +',' Punctuation +' ' Text +'bar' Name +',' Punctuation +' ' Text +'baz' Name +'\n\n' Text + +'foo' Name +' ' Text +'# => 0' Comment.Single +'\n' Text + +'bar' Name +' ' Text +'# => 1' Comment.Single +'\n' Text + +'baz' Name +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'macro' Keyword +' ' Text +'println' Name.Function +'(' Punctuation +'*' Operator +'values' Name +')' Punctuation +'\n ' Text +'print' Name.Builtin +' ' Text +'{{' Literal.String.Interpol +'*' Operator +'values' Name +'}}' Literal.String.Interpol +',' Punctuation +' ' Text +"'\\n'" Literal.String.Char +'\n' Text + +'end' Keyword +'\n\n' Text + +'println' Name +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +' ' Text +'# outputs 123\\n' Comment.Single +'\n\n' Text + +'VALUES' Name.Constant +' ' Text +'=' Operator +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +'\n\n' Text + +'{%' Literal.String.Interpol +' ' Text +'for' Keyword +' ' Text +'value' Name +' ' Text +'in' Keyword +' ' Text +'VALUES' Name.Constant +' ' Text +'%}' Literal.String.Interpol +'\n ' Text +'puts' Name.Builtin +' ' Text +'{{' Literal.String.Interpol +'value' Name +'}}' Literal.String.Interpol +'\n' Text + +'{%' Literal.String.Interpol +' ' Text +'end' Keyword +' ' Text +'%}' Literal.String.Interpol +'\n\n' Text + +'until' Keyword +' ' Text +'some_condition' Name +'\n ' Text +'do_this' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# The above is the same as:' Comment.Single +'\n' Text + +'while' Keyword +' ' Text +'!' Operator +'some_condition' Name +'\n ' Text +'do_this' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'some_condition' Name +' ' Text +'?' Punctuation +' ' Text +'nil' Keyword.Constant +' ' Text +':' Punctuation +' ' Text +'3' Literal.Number.Integer +'\n' Text + +'# a is Int32 or Nil' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'a' Name +'\n ' Text +'# Since the only way to get here is if a is truthy,' Comment.Single +'\n ' Text +"# a can't be nil. So here a is Int32." Comment.Single +'\n ' Text +'a' Name +'.' Operator +'abs' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'some_expression' Name +'\n ' Text +'# here a is not nil' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'a' Name +' ' Text +'&&' Operator +' ' Text +'b' Name +'\n ' Text +'# here both a and b are guaranteed not to be Nil' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'@a' Name.Variable.Instance +'\n ' Text +'# here @a can be nil' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'# First option: assign it to a variable' Comment.Single +'\n' Text + +'if' Keyword +' ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'@a' Name.Variable.Instance +'\n ' Text +"# here a can't be nil" Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Second option: use `Object#try` found in the standard library' Comment.Single +'\n' Text + +'@a' Name.Variable.Instance +'.' Operator +'try' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'a' Name +'|' Operator +'\n ' Text +"# here a can't be nil" Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'method' Name +' ' Text +'# first call to a method that can return Int32 or Nil' Comment.Single +'\n ' Text +'# here we know that the first call did not return Nil' Comment.Single +'\n ' Text +'method' Name +' ' Text +'# second call can still return Int32 or Nil' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'become_older' Name.Function +'(' Punctuation +'by' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'+=' Operator +' ' Text +'by' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'john' Name +'.' Operator +'age' Name +' ' Text +'# => 0' Comment.Single +'\n\n' Text + +'john' Name +'.' Operator +'become_older' Name +'\n' Text + +'john' Name +'.' Operator +'age' Name +' ' Text +'# => 1' Comment.Single +'\n\n' Text + +'john' Name +'.' Operator +'become_older' Name +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'john' Name +'.' Operator +'age' Name +' ' Text +'# => 3' Comment.Single +'\n\n' Text + +'john' Name +'.' Operator +'become_older' Name +' ' Text +'by' Literal.String.Symbol +':' Punctuation +' ' Text +'5' Literal.Number.Integer +'\n\n' Text + +'def' Keyword +' ' Text +'some_method' Name.Function +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'z' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'w' Name +' ' Text +'=' Operator +' ' Text +'3' Literal.Number.Integer +')' Punctuation +'\n ' Text +'# do something...' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'some_method' Name +' ' Text +'10' Literal.Number.Integer +' ' Text +'# x = 10, y = 1, z = 2, w = 3' Comment.Single +'\n' Text + +'some_method' Name +' ' Text +'10' Literal.Number.Integer +',' Punctuation +' ' Text +'z' Literal.String.Symbol +':' Punctuation +' ' Text +'10' Literal.Number.Integer +' ' Text +'# x = 10, y = 1, z = 10, w = 3' Comment.Single +'\n' Text + +'some_method' Name +' ' Text +'10' Literal.Number.Integer +',' Punctuation +' ' Text +'w' Literal.String.Symbol +':' Punctuation +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'y' Literal.String.Symbol +':' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'z' Literal.String.Symbol +':' Punctuation +' ' Text +'3' Literal.Number.Integer +' ' Text +'# x = 10, y = 2, z = 3, w = 1' Comment.Single +'\n\n' Text + +'case' Keyword +' ' Text +'exp' Name +'\n' Text + +'when' Keyword +' ' Text +'value1' Name +',' Punctuation +' ' Text +'value2' Name +'\n ' Text +'do_something' Name +'\n' Text + +'when' Keyword +' ' Text +'value3' Name +'\n ' Text +'do_something_else' Name +'\n' Text + +'else' Keyword +'\n ' Text +'do_another_thing' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'case' Keyword +' ' Text +'var' Name +'\n' Text + +'when' Keyword +' ' Text +'String' Name +'\n ' Text +'# var : String' Comment.Single +'\n ' Text +'do_something' Name +'\n' Text + +'when' Keyword +' ' Text +'Int32' Name +'\n ' Text +'# var : Int32' Comment.Single +'\n ' Text +'do_something_else' Name +'\n' Text + +'else' Keyword +'\n ' Text +'# here var is neither a String nor an Int32' Comment.Single +'\n ' Text +'do_another_thing' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'case' Keyword +' ' Text +'num' Name +'\n' Text + +'when' Keyword +' ' Text +'.' Operator +'even?' Name +'\n ' Text +'do_something' Name +'\n' Text + +'when' Keyword +' ' Text +'.' Operator +'odd?' Name +'\n ' Text +'do_something_else' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'case' Keyword +'\n' Text + +'when' Keyword +' ' Text +'cond1' Name +',' Punctuation +' ' Text +'cond2' Name +'\n ' Text +'do_something' Name +'\n' Text + +'when' Keyword +' ' Text +'cond3' Name +'\n ' Text +'do_something_else' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'a' Name +'.responds_to?' Keyword.Pseudo +'(' Punctuation +':abs' Literal.String.Symbol +')' Punctuation +' ' Text +'# => true' Comment.Single +'\n' Text + +'a' Name +'.responds_to?' Keyword.Pseudo +'(' Punctuation +':size' Literal.String.Symbol +')' Punctuation +' ' Text +'# => false' Comment.Single +'\n\n' Text + +'foo_or_bar' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'foo|bar' Literal.String.Regex +'/' Literal.String.Regex +'\n' Text + +'heeello' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'h(e+)llo' Literal.String.Regex +'/' Literal.String.Regex +'\n' Text + +'integer' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'\\' Literal.String.Regex +'d+' Literal.String.Regex +'/' Literal.String.Regex +'\n\n' Text + +'r' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'foo' Literal.String.Regex +'/imx' Literal.String.Regex +'\n\n' Text + +'slash' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'\\/' Literal.String.Regex +'/' Literal.String.Regex +'\n\n' Text + +'r' Name +' ' Text +'=' Operator +' ' Text +'%r(' Literal.String.Regex +'regex with slash: /' Literal.String.Regex +')' Literal.String.Regex +'\n\n' Text + +'"' Literal.String.Double +'hello world' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'"' Literal.String.Double +'\\"' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# double quote' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\\\' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# backslash' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\e' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# escape' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\f' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# form feed' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# newline' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\r' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# carriage return' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\t' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# tab' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\v' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# vertical tab' Comment.Single +'\n\n' Text + +'"' Literal.String.Double +'\\101' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# == "A"' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\123' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# == "S"' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\12' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# == "\\n"' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\1' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# string with one character with code point 1' Comment.Single +'\n\n' Text + +'"' Literal.String.Double +'\\u0041' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# == "A"' Comment.Single +'\n\n' Text + +'"' Literal.String.Double +'\\u{41}' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# == "A"' Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\u{1F52E}' Literal.String.Escape +'"' Literal.String.Double +'\n\n' Text + +'"' Literal.String.Double +'hello\n world' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# same as "hello\\n world"' Comment.Single +'\n\n' Text + +'"' Literal.String.Double +'hello ' Literal.String.Double +'"' Literal.String.Double +' ' Text +'\\' Punctuation +'\n' Text + +'"' Literal.String.Double +'world, ' Literal.String.Double +'"' Literal.String.Double +' ' Text +'\\' Punctuation +'\n' Text + +'"' Literal.String.Double +'no newlines' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# same as "hello world, no newlines"' Comment.Single +'\n\n' Text + +'"' Literal.String.Double +'hello ' Literal.String.Double +'\\' Literal.String.Double +'\n world, ' Literal.String.Double +'\\' Literal.String.Double +'\n no newlines' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# same as "hello world, no newlines"' Comment.Single +'\n\n' Text + +'%(' Literal.String.Other +'hello ' Literal.String.Other +'(' Literal.String.Other +'"world"' Literal.String.Other +')' Literal.String.Other +')' Literal.String.Other +' ' Text +'# => "hello (\\"world\\")"' Comment.Single +'\n' Text + +'%[' Literal.String.Other +'hello ' Literal.String.Other +'[' Literal.String.Other +'"world"' Literal.String.Other +']' Literal.String.Other +']' Literal.String.Other +' ' Text +'# => "hello [\\"world\\"]"' Comment.Single +'\n' Text + +'%{' Literal.String.Other +'hello ' Literal.String.Other +'{' Literal.String.Other +'"world"' Literal.String.Other +'}' Literal.String.Other +'}' Literal.String.Other +' ' Text +'# => "hello {\\"world\\"}"' Comment.Single +'\n' Text + +'%<' Literal.String.Other +'hello ' Literal.String.Other +'<' Literal.String.Other +'"world"' Literal.String.Other +'>' Literal.String.Other +'>' Literal.String.Other +' ' Text +'# => "hello <\\"world\\">"' Comment.Single +'\n' Text + +'%|' Literal.String.Other +'hello "world"' Literal.String.Other +'|' Literal.String.Other +' ' Text +'# => "hello \\"world\\""' Comment.Single +'\n\n' Text + +'<<-' Operator +'' Literal.String.Heredoc +'XML' Literal.String.Delimiter +'' Literal.String.Heredoc +'\n' Text + +'<parent>\n' Literal.String.Heredoc + +' <child />\n' Literal.String.Heredoc + +'</parent>\n' Literal.String.Heredoc + +'XML\n' Literal.String.Delimiter + +'\n' Text + +'# Same as "Hello\\n world"' Comment.Single +'\n' Text + +'<<-' Operator +'' Literal.String.Heredoc +'STRING' Literal.String.Delimiter +'' Literal.String.Heredoc +'\n' Text + +' Hello\n' Literal.String.Heredoc + +' world\n' Literal.String.Heredoc + +' STRING\n' Literal.String.Delimiter + +'\n' Text + +'# Same as " Hello\\n world"' Comment.Single +'\n' Text + +'<<-' Operator +'' Literal.String.Heredoc +'STRING' Literal.String.Delimiter +'' Literal.String.Heredoc +'\n' Text + +' Hello\n' Literal.String.Heredoc + +' world\n' Literal.String.Heredoc + +' STRING\n' Literal.String.Delimiter + +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'"' Literal.String.Double +'sum = ' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +' ' Text +'+' Operator +' ' Text +'b' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +' ' Text +'# "sum = 3"' Comment.Single +'\n\n' Text + +'1.0' Literal.Number.Float +' ' Text +'# Float64' Comment.Single +'\n' Text + +'1.0_f32' Literal.Number.Float +' ' Text +'# Float32' Comment.Single +'\n' Text + +'1_f32' Literal.Number.Float +' ' Text +'# Float32' Comment.Single +'\n\n' Text + +'1e10' Literal.Number.Float +' ' Text +'# Float64' Comment.Single +'\n' Text + +'1.5e10' Literal.Number.Float +' ' Text +'# Float64' Comment.Single +'\n' Text + +'1.5e-7' Literal.Number.Float +' ' Text +'# Float64' Comment.Single +'\n\n' Text + +'+' Operator +'1.3' Literal.Number.Float +' ' Text +'# Float64' Comment.Single +'\n' Text + +'-' Operator +'0.5' Literal.Number.Float +' ' Text +'# Float64' Comment.Single +'\n\n' Text + +'1_000_000.111_111' Literal.Number.Float +' ' Text +'# better than 1000000.111111' Comment.Single +'\n\n' Text + +"'a'" Literal.String.Char +'\n' Text + +"'z'" Literal.String.Char +'\n' Text + +"'0'" Literal.String.Char +'\n' Text + +"'_'" Literal.String.Char +'\n' Text + +'"' Literal.String.Double +'ã\x81‚' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +"'\\''" Literal.String.Char +' ' Text +'# single quote' Comment.Single +'\n' Text + +"'\\\\'" Literal.String.Char +' ' Text +'# backslash' Comment.Single +'\n' Text + +"'\\e'" Literal.String.Char +' ' Text +'# escape' Comment.Single +'\n' Text + +"'\\f'" Literal.String.Char +' ' Text +'# form feed' Comment.Single +'\n' Text + +"'\\n'" Literal.String.Char +' ' Text +'# newline' Comment.Single +'\n' Text + +"'\\r'" Literal.String.Char +' ' Text +'# carriage return' Comment.Single +'\n' Text + +"'\\t'" Literal.String.Char +' ' Text +'# tab' Comment.Single +'\n' Text + +"'\\v'" Literal.String.Char +' ' Text +'# vertical tab' Comment.Single +'\n\n' Text + +'"' Literal.String.Double +'\\101' Literal.String.Escape +'"' Literal.String.Double +' ' Text +"# == 'A'" Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\123' Literal.String.Escape +'"' Literal.String.Double +' ' Text +"# == 'S'" Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\12' Literal.String.Escape +'"' Literal.String.Double +' ' Text +"# == '\\n'" Comment.Single +'\n' Text + +'"' Literal.String.Double +'\\1' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# code point 1' Comment.Single +'\n\n' Text + +"'\\u0041'" Literal.String.Char +' ' Text +"# == 'A'" Comment.Single +'\n\n' Text + +"'\\u{41}'" Literal.String.Char +' ' Text +"# == 'A'" Comment.Single +'\n' Text + +"'\\u{1F52E}'" Literal.String.Char +'\n\n' Text + +'{' Punctuation +'1' Literal.Number.Integer +' ' Text +'=' Operator +'>' Operator +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +' ' Text +'=' Operator +'>' Operator +' ' Text +'4' Literal.Number.Integer +'}' Punctuation +' ' Text +'# Hash(Int32, Int32)' Comment.Single +'\n' Text + +'{' Punctuation +'1' Literal.Number.Integer +' ' Text +'=' Operator +'>' Operator +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +"'a'" Literal.String.Char +' ' Text +'=' Operator +'>' Operator +' ' Text +'3' Literal.Number.Integer +'}' Punctuation +' ' Text +'# Hash(Int32 | Char, Int32)' Comment.Single +'\n\n' Text + +'{' Punctuation +'}' Punctuation +' ' Text +'of' Keyword +' ' Text +'Int32' Name +' ' Text +'=' Operator +'>' Operator +' ' Text +'Int32' Name +' ' Text +'# same as Hash(Int32, Int32).new' Comment.Single +'\n\n' Text + +'{' Punctuation +'key1' Literal.String.Symbol +':' Punctuation +' ' Text +"'a'" Literal.String.Char +',' Punctuation +' ' Text +'key2' Literal.String.Symbol +':' Punctuation +' ' Text +"'b'" Literal.String.Char +'}' Punctuation +' ' Text +'# Hash(Symbol, Char)' Comment.Single +'\n\n' Text + +'{' Punctuation +'"' Literal.String.Double +'key1' Literal.String.Double +'"' Literal.String.Double +':' Punctuation +' ' Text +"'a'" Literal.String.Char +',' Punctuation +' ' Text +'"' Literal.String.Double +'key2' Literal.String.Double +'"' Literal.String.Double +':' Punctuation +' ' Text +"'b'" Literal.String.Char +'}' Punctuation +' ' Text +'# Hash(String, Char)' Comment.Single +'\n\n' Text + +'MyType' Name +'{' Punctuation +'"' Literal.String.Double +'foo' Literal.String.Double +'"' Literal.String.Double +' ' Text +'=' Operator +'>' Operator +' ' Text +'"' Literal.String.Double +'bar' Literal.String.Double +'"' Literal.String.Double +'}' Punctuation +'\n\n' Text + +'tmp' Name +' ' Text +'=' Operator +' ' Text +'MyType' Name +'.' Operator +'new' Name +'\n' Text + +'tmp' Name +'[' Operator +'"' Literal.String.Double +'foo' Literal.String.Double +'"' Literal.String.Double +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'bar' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'tmp' Name +'\n\n' Text + +'tmp' Name +' ' Text +'=' Operator +' ' Text +'MyType' Name +'(' Punctuation +'typeof' Keyword.Pseudo +'(' Punctuation +'"' Literal.String.Double +'foo' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +',' Punctuation +' ' Text +'typeof' Keyword.Pseudo +'(' Punctuation +'"' Literal.String.Double +'bar' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +')' Punctuation +'.' Operator +'new' Name +'\n' Text + +'tmp' Name +'[' Operator +'"' Literal.String.Double +'foo' Literal.String.Double +'"' Literal.String.Double +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'bar' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'tmp' Name +'\n\n' Text + +'MyType' Name +'(' Punctuation +'String' Name +',' Punctuation +' ' Text +'String' Name +')' Punctuation +'{' Punctuation +'"' Literal.String.Double +'foo' Literal.String.Double +'"' Literal.String.Double +' ' Text +'=' Operator +'>' Operator +' ' Text +'"' Literal.String.Double +'bar' Literal.String.Double +'"' Literal.String.Double +'}' Punctuation +'\n\n' Text + +':hello' Literal.String.Symbol +'\n' Text + +':good_bye' Literal.String.Symbol +'\n\n' Text + +'# With spaces and symbols' Comment.Single +'\n' Text + +':"' Literal.String.Symbol +'symbol with spaces' Literal.String.Symbol +'"' Literal.String.Symbol +'\n\n' Text + +'# Ending with question and exclamation marks' Comment.Single +'\n' Text + +':question?' Literal.String.Symbol +'\n' Text + +':exclamation!' Literal.String.Symbol +'\n\n' Text + +'# For the operators' Comment.Single +'\n' Text + +':+' Literal.String.Symbol +'\n' Text + +':-' Literal.String.Symbol +'\n' Text + +':*' Literal.String.Symbol +'\n' Text + +':/' Literal.String.Symbol +'\n' Text + +':==' Literal.String.Symbol +'\n' Text + +':<' Literal.String.Symbol +'\n' Text + +':<=' Literal.String.Symbol +'\n' Text + +':>' Literal.String.Symbol +'\n' Text + +':>=' Literal.String.Symbol +'\n' Text + +':!' Literal.String.Symbol +'\n' Text + +':!=' Literal.String.Symbol +'\n' Text + +':=~' Literal.String.Symbol +'\n' Text + +':!~' Literal.String.Symbol +'\n' Text + +':&' Literal.String.Symbol +'\n' Text + +':|' Literal.String.Symbol +'\n' Text + +':^' Literal.String.Symbol +'\n' Text + +':~' Literal.String.Symbol +'\n' Text + +':**' Literal.String.Symbol +'\n' Text + +':>>' Literal.String.Symbol +'\n' Text + +':<<' Literal.String.Symbol +'\n' Text + +':%' Literal.String.Symbol +'\n' Text + +':[]' Literal.String.Symbol +'\n' Text + +':[]?' Literal.String.Symbol +'\n' Text + +':[]=' Literal.String.Symbol +'\n' Text + +':<=>' Literal.String.Symbol +'\n' Text + +':===' Literal.String.Symbol +'\n\n' Text + +'x' Name +'..' Operator +'y' Name +' ' Text +'# an inclusive range, in mathematics: [x, y]' Comment.Single +'\n' Text + +'x' Name +'...' Operator +'y' Name +' ' Text +'# an exclusive range, in mathematics: [x, y)' Comment.Single +'\n\n' Text + +'# A proc without arguments' Comment.Single +'\n' Text + +'-' Operator +'>' Operator +'{' Punctuation +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +' ' Text +'# Proc(Int32)' Comment.Single +'\n\n' Text + +'# A proc with one argument' Comment.Single +'\n' Text + +'-' Operator +'>' Operator +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'x' Name +'.' Operator +'to_s' Name +' ' Text +'}' Punctuation +' ' Text +'# Proc(Int32, String)' Comment.Single +'\n\n' Text + +'# A proc with two arguments:' Comment.Single +'\n' Text + +'-' Operator +'>' Operator +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +',' Punctuation +' ' Text +'y' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +' ' Text +'}' Punctuation +' ' Text +'# Proc(Int32, Int32, Int32)' Comment.Single +'\n\n' Text + +'Proc' Name +'(' Punctuation +'Int32' Name +',' Punctuation +' ' Text +'String' Name +')' Punctuation +'.' Operator +'new' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'x' Name +'|' Operator +' ' Text +'x' Name +'.' Operator +'to_s' Name +' ' Text +'}' Punctuation +' ' Text +'# Proc(Int32, String)' Comment.Single +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +',' Punctuation +' ' Text +'y' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +' ' Text +'}' Punctuation +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +' ' Text +'# => 3' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'one' Name.Function +'\n ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +'one' Name +'\n' Text + +'proc' Name +'.' Operator +'call' Name +' ' Text +'# => 1' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'plus_one' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +'plus_one' Name +'(' Punctuation +'Int32' Name +')' Punctuation +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +'41' Literal.Number.Integer +')' Punctuation +' ' Text +'# => 42' Comment.Single +'\n\n' Text + +'str' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'-' Operator +'>' Operator +'str' Name +'.' Operator +'count' Name +'(' Punctuation +'Char' Name +')' Punctuation +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +"'e'" Literal.String.Char +')' Punctuation +' ' Text +'# => 1' Comment.Single +'\n' Text + +'proc' Name +'.' Operator +'call' Name +'(' Punctuation +"'l'" Literal.String.Char +')' Punctuation +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'tuple' Name +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +"'x'" Literal.String.Char +'}' Punctuation +' ' Text +'# Tuple(Int32, String, Char)' Comment.Single +'\n' Text + +'tuple' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'# => 1 (Int32)' Comment.Single +'\n' Text + +'tuple' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'# => "hello" (String)' Comment.Single +'\n' Text + +'tuple' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +' ' Text +"# => 'x' (Char)" Comment.Single +'\n\n' Text + +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +' ' Text +'# Array(Int32)' Comment.Single +'\n' Text + +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +"'x'" Literal.String.Char +']' Operator +' ' Text +'# Array(Int32 | String | Char)' Comment.Single +'\n\n' Text + +'[' Operator +']' Operator +' ' Text +'of' Keyword +' ' Text +'Int32' Name +' ' Text +'# same as Array(Int32).new' Comment.Single +'\n\n' Text + +'%w(' Literal.String.Other +'one two three' Literal.String.Other +')' Literal.String.Other +' ' Text +'# ["one", "two", "three"]' Comment.Single +'\n\n' Text + +'%i(' Literal.String.Other +'one two three' Literal.String.Other +')' Literal.String.Other +' ' Text +'# [:one, :two, :three]' Comment.Single +'\n\n' Text + +'MyType' Name +'{' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +'}' Punctuation +'\n\n' Text + +'tmp' Name +' ' Text +'=' Operator +' ' Text +'MyType' Name +'.' Operator +'new' Name +'\n' Text + +'tmp' Name +' ' Text +'<<' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'tmp' Name +' ' Text +'<<' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'tmp' Name +' ' Text +'<<' Operator +' ' Text +'3' Literal.Number.Integer +'\n' Text + +'tmp' Name +'\n\n' Text + +'tmp' Name +' ' Text +'=' Operator +' ' Text +'MyType' Name +'(' Punctuation +'typeof' Keyword.Pseudo +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +')' Punctuation +')' Punctuation +'.' Operator +'new' Name +'\n' Text + +'tmp' Name +' ' Text +'<<' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'tmp' Name +' ' Text +'<<' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'tmp' Name +' ' Text +'<<' Operator +' ' Text +'3' Literal.Number.Integer +'\n' Text + +'tmp' Name +'\n\n' Text + +'MyType' Name +'(' Punctuation +'Int32' Name +' ' Text +'|' Operator +' ' Text +'String' Name +')' Punctuation +'{' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +'foo' Literal.String.Double +'"' Literal.String.Double +'}' Punctuation +'\n\n' Text + +'nil' Keyword.Constant +'\n\n' Text + +'1' Literal.Number.Integer +' ' Text +'# Int32' Comment.Single +'\n\n' Text + +'1_i8' Literal.Number.Integer +' ' Text +'# Int8' Comment.Single +'\n' Text + +'1_i16' Literal.Number.Integer +' ' Text +'# Int16' Comment.Single +'\n' Text + +'1_i32' Literal.Number.Integer +' ' Text +'# Int32' Comment.Single +'\n' Text + +'1_i64' Literal.Number.Integer +' ' Text +'# Int64' Comment.Single +'\n\n' Text + +'1_u8' Literal.Number.Integer +' ' Text +'# UInt8' Comment.Single +'\n' Text + +'1_u16' Literal.Number.Integer +' ' Text +'# UInt16' Comment.Single +'\n' Text + +'1_u32' Literal.Number.Integer +' ' Text +'# UInt32' Comment.Single +'\n' Text + +'1_u64' Literal.Number.Integer +' ' Text +'# UInt64' Comment.Single +'\n\n' Text + +'+' Operator +'10' Literal.Number.Integer +' ' Text +'# Int32' Comment.Single +'\n' Text + +'-' Operator +'20' Literal.Number.Integer +' ' Text +'# Int32' Comment.Single +'\n\n' Text + +'2147483648' Literal.Number.Integer +' ' Text +'# Int64' Comment.Single +'\n' Text + +'9223372036854775808' Literal.Number.Integer +' ' Text +'# UInt64' Comment.Single +'\n\n' Text + +'1_000_000' Literal.Number.Integer +' ' Text +'# better than 1000000' Comment.Single +'\n\n' Text + +'0b1101' Literal.Number.Bin +' ' Text +'# == 13' Comment.Single +'\n\n' Text + +'0o123' Literal.Number.Oct +' ' Text +'# == 83' Comment.Single +'\n\n' Text + +'0xFE012D' Literal.Number.Hex +' ' Text +'# == 16646445' Comment.Single +'\n' Text + +'0xfe012d' Literal.Number.Hex +' ' Text +'# == 16646445' Comment.Single +'\n\n' Text + +'true' Keyword.Constant +' ' Text +'# A Bool that is true' Comment.Single +'\n' Text + +'false' Keyword.Constant +' ' Text +'# A Bool that is false' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'ptr' Name +' ' Text +'=' Operator +' ' Text +'pointerof' Keyword.Pseudo +'(' Punctuation +'a' Name +')' Punctuation +'\n' Text + +'ptr' Name +'.' Operator +'value' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n\n' Text + +'a' Name +' ' Text +'# => 2' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Point' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'@x' Name.Variable.Instance +',' Punctuation +' ' Text +'@y' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'x' Name.Function +'\n ' Text +'@x' Name.Variable.Instance +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'x_ptr' Name.Function +'\n ' Text +'pointerof' Keyword.Pseudo +'(' Punctuation +'@x' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'point' Name +' ' Text +'=' Operator +' ' Text +'Point' Name +'.' Operator +'new' Name +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +'\n\n' Text + +'ptr' Name +' ' Text +'=' Operator +' ' Text +'point' Name +'.' Operator +'x_ptr' Name +'\n' Text + +'ptr' Name +'.' Operator +'value' Name +' ' Text +'=' Operator +' ' Text +'10' Literal.Number.Integer +'\n\n' Text + +'point' Name +'.' Operator +'x' Name +' ' Text +'# => 10' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'add' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Number' Name +',' Punctuation +' ' Text +'y' Name +' ' Text +':' Punctuation +' ' Text +'Number' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# Ok' Comment.Single +'\n' Text + +'add' Name +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +' ' Text +'# Ok' Comment.Single +'\n\n' Text + +"# Error: no overload matches 'add' with types Bool, Bool" Comment.Single +'\n' Text + +'add' Name +' ' Text +'true' Keyword.Constant +',' Punctuation +' ' Text +'false' Keyword.Constant +'\n\n' Text + +'def' Keyword +' ' Text +'add' Name.Function +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'add' Name +' ' Text +'true' Keyword.Constant +',' Punctuation +' ' Text +'false' Keyword.Constant +'\n\n' Text + +"# A class that has a + method but isn't a Number" Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'Six' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'+' Name.Function +'(' Punctuation +'other' Name +')' Punctuation +'\n ' Text +'6' Literal.Number.Integer +' ' Text +'+' Operator +' ' Text +'other' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'# add method without type restrictions' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'add' Name.Function +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# OK' Comment.Single +'\n' Text + +'add' Name +' ' Text +'Six' Name +'.' Operator +'new' Name +',' Punctuation +' ' Text +'10' Literal.Number.Integer +'\n\n' Text + +'# add method with type restrictions' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'restricted_add' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Number' Name +',' Punctuation +' ' Text +'y' Name +' ' Text +':' Punctuation +' ' Text +'Number' Name +')' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +"# Error: no overload matches 'restricted_add' with types Six, Int32" Comment.Single +'\n' Text + +'restricted_add' Name +' ' Text +'Six' Name +'.' Operator +'new' Name +',' Punctuation +' ' Text +'10' Literal.Number.Integer +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'==' Name.Function +'(' Punctuation +'other' Name +' ' Text +':' Punctuation +' ' Text +'self' Keyword +')' Punctuation +'\n ' Text +'other' Name +'.' Operator +'name' Name +' ' Text +'==' Operator +' ' Text +'name' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'==' Name.Function +'(' Punctuation +'other' Name +')' Punctuation +'\n ' Text +'false' Keyword.Constant +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'another_john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'peter' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'Peter' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'john' Name +' ' Text +'==' Operator +' ' Text +'another_john' Name +' ' Text +'# => true' Comment.Single +'\n' Text + +'john' Name +' ' Text +'==' Operator +' ' Text +'peter' Name +' ' Text +'# => false (names differ)' Comment.Single +'\n' Text + +'john' Name +' ' Text +'==' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'# => false (because 1 is not a Person)' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'compare' Name.Function +'(' Punctuation +'p1' Name +' ' Text +':' Punctuation +' ' Text +'self' Keyword +',' Punctuation +' ' Text +'p2' Name +' ' Text +':' Punctuation +' ' Text +'self' Keyword +')' Punctuation +'\n ' Text +'p1' Name +'.' Operator +'name' Name +' ' Text +'==' Operator +' ' Text +'p2' Name +'.' Operator +'name' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'john' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'peter' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'Peter' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'Person' Name +'.' Operator +'compare' Name +'(' Punctuation +'john' Name +',' Punctuation +' ' Text +'peter' Name +')' Punctuation +' ' Text +'# OK' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +' ' Text +'1' Literal.Number.Integer +' ' Text +'# OK' Comment.Single +'\n' Text + +'foo' Name +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# Error' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'.' Operator +'class' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +' ' Text +'Int32' Name +' ' Text +'# OK' Comment.Single +'\n' Text + +'foo' Name +' ' Text +'String' Name +' ' Text +'# Error' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'.' Operator +'class' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Got Int32' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'String' Name +'.' Operator +'class' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Got String' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +' ' Text +'Int32' Name +' ' Text +'# prints "Got Int32"' Comment.Single +'\n' Text + +'foo' Name +' ' Text +'String' Name +' ' Text +'# prints "Got String"' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'*' Operator +'args' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'*' Operator +'args' Name +' ' Text +':' Punctuation +' ' Text +'String' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +' ' Text +'# OK, invokes first overload' Comment.Single +'\n' Text + +'foo' Name +' ' Text +'"' Literal.String.Double +'a' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'b' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'c' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# OK, invokes second overload' Comment.Single +'\n' Text + +'foo' Name +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# Error' Comment.Single +'\n' Text + +'foo' Name +'(' Punctuation +')' Punctuation +' ' Text +'# Error' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'\n ' Text +'# This is the empty-tuple case' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'T' Name +')' Punctuation +'\n ' Text +'T' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# => Int32' Comment.Single +'\n' Text + +'foo' Name +'(' Punctuation +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'# => String' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'Array' Name +'(' Punctuation +'T' Name +')' Punctuation +')' Punctuation +'\n ' Text +'T' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +'(' Punctuation +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +']' Operator +')' Punctuation +' ' Text +'# => Int32' Comment.Single +'\n' Text + +'foo' Name +'(' Punctuation +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +'a' Literal.String.Double +'"' Literal.String.Double +']' Operator +')' Punctuation +' ' Text +'# => (Int32 | String)' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'(' Punctuation +'x' Name +' ' Text +':' Punctuation +' ' Text +'T' Name +'.' Operator +'class' Name +')' Punctuation +'\n ' Text +'Array' Name +'(' Punctuation +'T' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo' Name +'(' Punctuation +'Int32' Name +')' Punctuation +' ' Text +'# => Array(Int32)' Comment.Single +'\n' Text + +'foo' Name +'(' Punctuation +'String' Name +')' Punctuation +' ' Text +'# => Array(String)' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'# Increases age by one' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'become_older' Name.Function +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Increases age by the given number of years' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'become_older' Name.Function +'(' Punctuation +'years' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +')' Punctuation +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'+=' Operator +' ' Text +'years' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Increases age by the given number of years, as a String' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'become_older' Name.Function +'(' Punctuation +'years' Name +' ' Text +':' Punctuation +' ' Text +'String' Name +')' Punctuation +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'+=' Operator +' ' Text +'years' Name +'.' Operator +'to_i' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Yields the current age of this person and increases' Comment.Single +'\n ' Text +'# its age by the value returned by the block' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'become_older' Name.Function +'\n ' Text +'@age' Name.Variable.Instance +' ' Text +'+=' Operator +' ' Text +'yield' Keyword +' ' Text +'@age' Name.Variable.Instance +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'person' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'John' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'person' Name +'.' Operator +'become_older' Name +'\n' Text + +'person' Name +'.' Operator +'age' Name +' ' Text +'# => 1' Comment.Single +'\n\n' Text + +'person' Name +'.' Operator +'become_older' Name +' ' Text +'5' Literal.Number.Integer +'\n' Text + +'person' Name +'.' Operator +'age' Name +' ' Text +'# => 6' Comment.Single +'\n\n' Text + +'person' Name +'.' Operator +'become_older' Name +' ' Text +'"' Literal.String.Double +'12' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'person' Name +'.' Operator +'age' Name +' ' Text +'# => 18' Comment.Single +'\n\n' Text + +'person' Name +'.' Operator +'become_older' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'current_age' Name +'|' Operator +'\n ' Text +'current_age' Name +' ' Text +'<' Operator +' ' Text +'20' Literal.Number.Integer +' ' Text +'?' Operator +' ' Text +'10' Literal.Number.Integer +' ' Text +':' Punctuation +' ' Text +'30' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n' Text + +'person' Name +'.' Operator +'age' Name +' ' Text +'# => 28' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'a' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'Int32' Name +')' Punctuation +' ' Text +'# => true' Comment.Single +'\n' Text + +'a' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'String' Name +')' Punctuation +' ' Text +'# => false' Comment.Single +'\n' Text + +'a' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'Number' Name +')' Punctuation +' ' Text +'# => true' Comment.Single +'\n' Text + +'a' Name +'.is_a?' Keyword.Pseudo +'(' Punctuation +'Int32' Name +' ' Text +'|' Operator +' ' Text +'String' Name +')' Punctuation +' ' Text +'# => true' Comment.Single +'\n\n' Text + +'# One for each thread' Comment.Single +'\n' Text + +'@[' Operator +'ThreadLocal' Name.Decorator +']' Operator +'\n' Text + +'values' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +' ' Text +'of' Keyword +' ' Text +'Int32' Name +'\n\n' Text + +'@[' Operator +'AlwaysInline' Name.Decorator +']' Operator +'\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'\n ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'@[' Operator +'NoInline' Name.Decorator +']' Operator +'\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'\n ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'lib' Keyword +' ' Text +'LibFoo' Name.Namespace +'\n ' Text +'@[' Operator +'CallConvention' Name.Decorator +'(' Punctuation +'"' Literal.String.Double +'X86_StdCall' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +']' Operator +'\n ' Text +'fun' Keyword +' ' Text +'foo' Name.Function +' ' Text +':' Punctuation +' ' Text +'Int32' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'sum' Name.Function +'(' Punctuation +'*' Operator +'elements' Name +')' Punctuation +'\n ' Text +'total' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'elements' Name +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'value' Name +'|' Operator +'\n ' Text +'total' Name +' ' Text +'+=' Operator +' ' Text +'value' Name +'\n ' Text +'end' Keyword +'\n ' Text +'total' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'# elements is Tuple(Int32, Int32, Int32, Float64)' Comment.Single +'\n' Text + +'sum' Name +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'4.5' Literal.Number.Float +'\n\n' Text + +'if' Keyword +' ' Text +'a' Name +'.responds_to?' Keyword.Pseudo +'(' Punctuation +':abs' Literal.String.Symbol +')' Punctuation +'\n ' Text +"# here a's type will be reduced to those responding to the 'abs' method" Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'some_condition' Name +' ' Text +'?' Punctuation +' ' Text +'1' Literal.Number.Integer +' ' Text +':' Punctuation +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'# a : Int32 | String' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'a' Name +'.responds_to?' Keyword.Pseudo +'(' Punctuation +':abs' Literal.String.Symbol +')' Punctuation +'\n ' Text +"# here a will be Int32, since Int32#abs exists but String#abs doesn't" Comment.Single +'\n' Text + +'else' Keyword +'\n ' Text +'# here a will be String' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'(' Punctuation +'a' Name +' ' Text +'=' Operator +' ' Text +'@a' Name.Variable.Instance +')' Punctuation +'.responds_to?' Keyword.Pseudo +'(' Punctuation +':abs' Literal.String.Symbol +')' Punctuation +'\n ' Text +'# here a is guaranteed to respond to `abs`' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'capture' Name.Function +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'block' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'invoke' Name.Function +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'block' Name +'.' Operator +'call' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'capture' Name +' ' Text +'{' Punctuation +' ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n' Text + +'invoke' Name +'(' Punctuation +'&' Operator +'proc' Name +')' Punctuation +' ' Text +'# prints "Hello"' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'capture' Name.Function +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'block' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'twice' Name.Function +'\n ' Text +'yield' Keyword +'\n ' Text +'yield' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'proc' Name +' ' Text +'=' Operator +' ' Text +'capture' Name +' ' Text +'{' Punctuation +' ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n' Text + +'twice' Name +' ' Text +'&' Operator +'proc' Name +'\n\n' Text + +'twice' Name +' ' Text +'&' Operator +'-' Operator +'>' Operator +'{' Punctuation +' ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n\n' Text + +'def' Keyword +' ' Text +'say_hello' Name.Function +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'twice' Name +' ' Text +'&' Operator +'-' Operator +'>' Operator +'say_hello' Name +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'wrap_foo' Name.Function +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Before foo' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'foo' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'x' Name +'|' Operator +'\n ' Text +'yield' Keyword +' ' Text +'x' Name +'\n ' Text +'end' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'After foo' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'wrap_foo' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'puts' Name.Builtin +' ' Text +'i' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'foo' Name.Function +'\n ' Text +'yield' Keyword +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'wrap_foo' Name.Function +'(' Punctuation +'&' Operator +'block' Name +' ' Text +':' Punctuation +' ' Text +'Int32' Name +' ' Text +'-' Operator +'>' Operator +' ' Text +'_' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Before foo' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'foo' Name +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'After foo' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'wrap_foo' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'puts' Name.Builtin +' ' Text +'i' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'foo_forward' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'break' Keyword +' ' Text +'# error' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'while' Keyword +' ' Text +'(' Punctuation +'a' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'<' Operator +' ' Text +'20' Literal.Number.Integer +'\n ' Text +'if' Keyword +' ' Text +'a' Name +' ' Text +'==' Operator +' ' Text +'10' Literal.Number.Integer +'\n ' Text +"# goes to 'puts a'" Comment.Single +'\n ' Text +'break' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n' Text + +'puts' Name.Builtin +' ' Text +'a' Name +' ' Text +'# => 10' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'private' Keyword +' ' Text +'def' Keyword +' ' Text +'say' Name.Function +'(' Punctuation +'message' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'message' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'say_hello' Name.Function +'\n ' Text +'say' Name +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# OK, no receiver' Comment.Single +'\n ' Text +'self' Keyword +'.' Operator +'say' Name +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# Error, self is a receiver' Comment.Single +'\n\n ' Text +'other' Name +' ' Text +'=' Operator +' ' Text +'Person' Name +'.' Operator +'new' Name +' ' Text +'"' Literal.String.Double +'Other' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'other' Name +'.' Operator +'say' Name +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# Error, other is a receiver' Comment.Single +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Employee' Name.Class +' ' Text +'<' Operator +' ' Text +'Person' Name +'\n ' Text +'def' Keyword +' ' Text +'say_bye' Name.Function +'\n ' Text +'say' Name +' ' Text +'"' Literal.String.Double +'bye' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# OK' Comment.Single +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'module' Keyword +' ' Text +'Namespace' Name.Namespace +'\n ' Text +'class' Keyword +' ' Text +'Foo' Name.Class +'\n ' Text +'protected' Keyword +' ' Text +'def' Keyword +' ' Text +'foo' Name.Function +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hello' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'class' Keyword +' ' Text +'Bar' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'bar' Name.Function +'\n ' Text +'# Works, because Foo and Bar are under Namespace' Comment.Single +'\n ' Text +'Foo' Name +'.' Operator +'new' Name +'.' Operator +'foo' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'Namespace' Name +'::' Operator +'Bar' Name +'.' Operator +'new' Name +'.' Operator +'bar' Name +'\n\n' Text + +'class' Keyword +' ' Text +'Person' Name.Class +'\n ' Text +'protected' Keyword +' ' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'say' Name.Function +'(' Punctuation +'message' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'message' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'say_hello' Name.Function +'\n ' Text +'Person' Name +'.' Operator +'say' Name +' ' Text +'"' Literal.String.Double +'hello' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'buffer' Name +' ' Text +'=' Operator +' ' Text +'uninitialized' Keyword.Pseudo +' ' Text +'UInt8' Name +'[' Operator +'256' Literal.Number.Integer +']' Operator +'\n\n' Text + +'foo' Name +' ' Text +'=' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +'5' Literal.Number.Integer +')' Punctuation +' ' Text +'>' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'?' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +':' Punctuation +' ' Text +'nil' Keyword.Constant +'\n\n' Text + +'foo' Name +'.' Operator +'not_nil!' Name +'.' Operator +'to_i' Name +'\n' Text |
