textbringer-tree-sitter 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CLAUDE.md +8 -0
- data/lib/textbringer/tree_sitter/node_maps/ruby.rb +4 -79
- data/lib/textbringer/tree_sitter/node_maps/sql.rb +14 -21
- data/lib/textbringer/tree_sitter/version.rb +1 -1
- data/lib/textbringer/tree_sitter_adapter.rb +7 -5
- data/samples/Sample.java +289 -0
- data/samples/sample.c +176 -0
- data/samples/sample.cob +174 -0
- data/samples/sample.cr +321 -0
- data/samples/sample.cs +273 -0
- data/samples/sample.ex +307 -0
- data/samples/sample.groovy +258 -0
- data/samples/sample.haml +154 -0
- data/samples/sample.html +168 -0
- data/samples/sample.js +266 -0
- data/samples/sample.json +68 -0
- data/samples/sample.pas +276 -0
- data/samples/sample.php +303 -0
- data/samples/sample.py +290 -0
- data/samples/sample.rb +160 -0
- data/samples/sample.rs +391 -0
- data/samples/sample.sh +142 -0
- data/samples/sample.sql +352 -0
- data/samples/sample.swift +482 -0
- data/samples/sample.tf +150 -0
- data/samples/sample.yaml +182 -0
- metadata +22 -1
data/samples/sample.cob
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
* COBOL Sample Program
|
|
2
|
+
* Demonstrates all major language features
|
|
3
|
+
IDENTIFICATION DIVISION.
|
|
4
|
+
PROGRAM-ID. SAMPLE-PROGRAM.
|
|
5
|
+
AUTHOR. Sample.
|
|
6
|
+
|
|
7
|
+
ENVIRONMENT DIVISION.
|
|
8
|
+
CONFIGURATION SECTION.
|
|
9
|
+
INPUT-OUTPUT SECTION.
|
|
10
|
+
FILE-CONTROL.
|
|
11
|
+
SELECT EMPLOYEE-FILE
|
|
12
|
+
ASSIGN TO "employees.dat"
|
|
13
|
+
ORGANIZATION IS SEQUENTIAL
|
|
14
|
+
ACCESS MODE IS SEQUENTIAL
|
|
15
|
+
FILE STATUS IS WS-FILE-STATUS.
|
|
16
|
+
|
|
17
|
+
DATA DIVISION.
|
|
18
|
+
FILE SECTION.
|
|
19
|
+
FD EMPLOYEE-FILE.
|
|
20
|
+
01 EMPLOYEE-RECORD.
|
|
21
|
+
05 EMP-ID PIC 9(5).
|
|
22
|
+
05 EMP-NAME PIC X(30).
|
|
23
|
+
05 EMP-SALARY PIC 9(7)V99.
|
|
24
|
+
05 EMP-DEPARTMENT PIC X(20).
|
|
25
|
+
|
|
26
|
+
WORKING-STORAGE SECTION.
|
|
27
|
+
* --- Variables ---
|
|
28
|
+
01 WS-FILE-STATUS PIC XX.
|
|
29
|
+
01 WS-EOF PIC 9 VALUE ZERO.
|
|
30
|
+
01 WS-COUNTER PIC 9(3) VALUE ZEROS.
|
|
31
|
+
01 WS-TOTAL-SALARY PIC 9(10)V99 VALUE ZEROES.
|
|
32
|
+
01 WS-AVERAGE PIC 9(7)V99.
|
|
33
|
+
01 WS-NAME PIC X(30) VALUE SPACES.
|
|
34
|
+
01 WS-MESSAGE PIC X(80) VALUE LOW-VALUE.
|
|
35
|
+
|
|
36
|
+
* --- Numbers ---
|
|
37
|
+
01 WS-INTEGER PIC 9(5) VALUE 42.
|
|
38
|
+
01 WS-NEGATIVE PIC S9(5) VALUE -17.
|
|
39
|
+
01 WS-DECIMAL PIC 9(5)V99 VALUE 3.14.
|
|
40
|
+
|
|
41
|
+
* --- String ---
|
|
42
|
+
01 WS-GREETING PIC X(20) VALUE "Hello, World!".
|
|
43
|
+
|
|
44
|
+
* --- Table / Array ---
|
|
45
|
+
01 WS-SCORE-TABLE.
|
|
46
|
+
05 WS-SCORE PIC 9(3) OCCURS 10 TIMES.
|
|
47
|
+
|
|
48
|
+
01 WS-MONTH-TABLE.
|
|
49
|
+
05 WS-MONTH-ENTRY OCCURS 12 TIMES.
|
|
50
|
+
10 WS-MONTH-NAME PIC X(10).
|
|
51
|
+
10 WS-MONTH-DAYS PIC 99.
|
|
52
|
+
|
|
53
|
+
* --- Condition names (88 levels) ---
|
|
54
|
+
01 WS-STATUS PIC X.
|
|
55
|
+
88 STATUS-ACTIVE VALUE "A".
|
|
56
|
+
88 STATUS-INACTIVE VALUE "I".
|
|
57
|
+
88 STATUS-DELETED VALUE "D".
|
|
58
|
+
|
|
59
|
+
01 WS-RESULT PIC 9(5).
|
|
60
|
+
01 WS-A PIC 9(3).
|
|
61
|
+
01 WS-B PIC 9(3).
|
|
62
|
+
01 WS-TEMP PIC 9(5).
|
|
63
|
+
01 WS-INDEX PIC 9(3).
|
|
64
|
+
|
|
65
|
+
PROCEDURE DIVISION.
|
|
66
|
+
MAIN-PROGRAM.
|
|
67
|
+
* --- Display ---
|
|
68
|
+
DISPLAY "=== COBOL Sample Program ===".
|
|
69
|
+
DISPLAY WS-GREETING.
|
|
70
|
+
|
|
71
|
+
* --- MOVE ---
|
|
72
|
+
MOVE "Alice" TO WS-NAME.
|
|
73
|
+
MOVE 100 TO WS-A.
|
|
74
|
+
MOVE 200 TO WS-B.
|
|
75
|
+
DISPLAY "Name: " WS-NAME.
|
|
76
|
+
|
|
77
|
+
* --- Arithmetic: ADD ---
|
|
78
|
+
ADD WS-A TO WS-B GIVING WS-RESULT.
|
|
79
|
+
DISPLAY "Add: " WS-RESULT.
|
|
80
|
+
|
|
81
|
+
* --- Arithmetic: SUBTRACT ---
|
|
82
|
+
SUBTRACT WS-A FROM WS-B GIVING WS-RESULT.
|
|
83
|
+
DISPLAY "Subtract: " WS-RESULT.
|
|
84
|
+
|
|
85
|
+
* --- Arithmetic: MULTIPLY ---
|
|
86
|
+
MULTIPLY WS-A BY WS-B GIVING WS-RESULT.
|
|
87
|
+
DISPLAY "Multiply: " WS-RESULT.
|
|
88
|
+
|
|
89
|
+
* --- Arithmetic: DIVIDE ---
|
|
90
|
+
DIVIDE WS-B BY WS-A GIVING WS-RESULT.
|
|
91
|
+
DISPLAY "Divide: " WS-RESULT.
|
|
92
|
+
|
|
93
|
+
* --- Arithmetic: COMPUTE ---
|
|
94
|
+
COMPUTE WS-RESULT = (WS-A + WS-B) * 2 - 10.
|
|
95
|
+
DISPLAY "Compute: " WS-RESULT.
|
|
96
|
+
|
|
97
|
+
* --- IF / ELSE ---
|
|
98
|
+
IF WS-A GREATER THAN WS-B
|
|
99
|
+
DISPLAY "A is greater"
|
|
100
|
+
ELSE IF WS-A LESS THAN WS-B
|
|
101
|
+
DISPLAY "B is greater"
|
|
102
|
+
ELSE IF WS-A EQUAL TO WS-B
|
|
103
|
+
DISPLAY "Equal"
|
|
104
|
+
END-IF.
|
|
105
|
+
|
|
106
|
+
* --- IF with AND / OR / NOT ---
|
|
107
|
+
IF WS-A GREATER THAN 0 AND WS-B GREATER THAN 0
|
|
108
|
+
DISPLAY "Both positive"
|
|
109
|
+
END-IF.
|
|
110
|
+
|
|
111
|
+
IF WS-A GREATER THAN 100 OR WS-B GREATER THAN 100
|
|
112
|
+
DISPLAY "At least one over 100"
|
|
113
|
+
END-IF.
|
|
114
|
+
|
|
115
|
+
IF NOT WS-A EQUAL TO ZERO
|
|
116
|
+
DISPLAY "A is not zero"
|
|
117
|
+
END-IF.
|
|
118
|
+
|
|
119
|
+
* --- EVALUATE (switch/case) ---
|
|
120
|
+
EVALUATE WS-INTEGER
|
|
121
|
+
WHEN 1 THRU 10
|
|
122
|
+
DISPLAY "Small"
|
|
123
|
+
WHEN 11 THRU 100
|
|
124
|
+
DISPLAY "Medium"
|
|
125
|
+
WHEN OTHER
|
|
126
|
+
DISPLAY "Large"
|
|
127
|
+
END-EVALUATE.
|
|
128
|
+
|
|
129
|
+
* --- PERFORM (loop) ---
|
|
130
|
+
PERFORM DISPLAY-LINE
|
|
131
|
+
VARYING WS-INDEX FROM 1 BY 1
|
|
132
|
+
UNTIL WS-INDEX GREATER THAN 5.
|
|
133
|
+
|
|
134
|
+
* --- PERFORM with TIMES ---
|
|
135
|
+
PERFORM DISPLAY-LINE 3 TIMES.
|
|
136
|
+
|
|
137
|
+
* --- PERFORM with TEST BEFORE ---
|
|
138
|
+
MOVE 1 TO WS-INDEX.
|
|
139
|
+
PERFORM WITH TEST BEFORE
|
|
140
|
+
UNTIL WS-INDEX GREATER THAN 10
|
|
141
|
+
DISPLAY "Index: " WS-INDEX
|
|
142
|
+
ADD 1 TO WS-INDEX
|
|
143
|
+
END-PERFORM.
|
|
144
|
+
|
|
145
|
+
* --- PERFORM with TEST AFTER ---
|
|
146
|
+
MOVE 1 TO WS-INDEX.
|
|
147
|
+
PERFORM WITH TEST AFTER
|
|
148
|
+
UNTIL WS-INDEX GREATER THAN 5
|
|
149
|
+
DISPLAY "After: " WS-INDEX
|
|
150
|
+
ADD 1 TO WS-INDEX
|
|
151
|
+
END-PERFORM.
|
|
152
|
+
|
|
153
|
+
* --- Table operations ---
|
|
154
|
+
PERFORM VARYING WS-INDEX FROM 1 BY 1
|
|
155
|
+
UNTIL WS-INDEX GREATER THAN 10
|
|
156
|
+
COMPUTE WS-SCORE(WS-INDEX) = WS-INDEX * 10
|
|
157
|
+
END-PERFORM.
|
|
158
|
+
|
|
159
|
+
* --- ACCEPT ---
|
|
160
|
+
ACCEPT WS-NAME FROM COMMAND-LINE.
|
|
161
|
+
|
|
162
|
+
* --- String operations ---
|
|
163
|
+
MOVE "Hello, World!" TO WS-GREETING.
|
|
164
|
+
|
|
165
|
+
* --- GO TO ---
|
|
166
|
+
GO TO FINAL-SECTION.
|
|
167
|
+
|
|
168
|
+
DISPLAY-LINE.
|
|
169
|
+
DISPLAY "Line: " WS-INDEX.
|
|
170
|
+
|
|
171
|
+
FINAL-SECTION.
|
|
172
|
+
* --- STOP RUN ---
|
|
173
|
+
DISPLAY "=== Program Complete ===".
|
|
174
|
+
STOP RUN.
|
data/samples/sample.cr
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# Single line comment
|
|
2
|
+
|
|
3
|
+
# Crystal sample - Ruby-like syntax with static typing
|
|
4
|
+
|
|
5
|
+
# --- Require ---
|
|
6
|
+
require "json"
|
|
7
|
+
require "http/client"
|
|
8
|
+
|
|
9
|
+
# --- Constants ---
|
|
10
|
+
MAX_SIZE = 100
|
|
11
|
+
PI = 3.14159
|
|
12
|
+
|
|
13
|
+
# --- Modules ---
|
|
14
|
+
module Greeter
|
|
15
|
+
abstract def greet(name : String) : String
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# --- Enums ---
|
|
19
|
+
enum Color
|
|
20
|
+
Red
|
|
21
|
+
Green
|
|
22
|
+
Blue
|
|
23
|
+
|
|
24
|
+
def display : String
|
|
25
|
+
to_s.downcase
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# --- Struct ---
|
|
30
|
+
struct Point
|
|
31
|
+
property x : Float64
|
|
32
|
+
property y : Float64
|
|
33
|
+
|
|
34
|
+
def initialize(@x : Float64, @y : Float64)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def distance(other : Point) : Float64
|
|
38
|
+
Math.sqrt((x - other.x) ** 2 + (y - other.y) ** 2)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_s(io : IO) : Nil
|
|
42
|
+
io << "(#{x}, #{y})"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# --- Abstract class ---
|
|
47
|
+
abstract class Animal
|
|
48
|
+
getter name : String
|
|
49
|
+
getter age : Int32
|
|
50
|
+
|
|
51
|
+
def initialize(@name : String, @age : Int32 = 0)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
abstract def speak : String
|
|
55
|
+
|
|
56
|
+
def to_s(io : IO) : Nil
|
|
57
|
+
io << "#{name}: #{speak}"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# --- Class with inheritance ---
|
|
62
|
+
class Dog < Animal
|
|
63
|
+
include Greeter
|
|
64
|
+
|
|
65
|
+
getter breed : String
|
|
66
|
+
|
|
67
|
+
def initialize(name : String, age : Int32, @breed : String = "Mixed")
|
|
68
|
+
super(name, age)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def speak : String
|
|
72
|
+
"Woof!"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def greet(person : String) : String
|
|
76
|
+
"Woof! Hello, #{person}!"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# --- Generic class ---
|
|
81
|
+
class Container(T)
|
|
82
|
+
@items = [] of T
|
|
83
|
+
|
|
84
|
+
def add(item : T) : Nil
|
|
85
|
+
@items << item
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def get(index : Int32) : T?
|
|
89
|
+
@items[index]?
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def size : Int32
|
|
93
|
+
@items.size
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def each(&block : T -> _)
|
|
97
|
+
@items.each { |item| yield item }
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# --- Strings ---
|
|
102
|
+
single = 'A' # Char in Crystal
|
|
103
|
+
double = "Hello, World!"
|
|
104
|
+
interpolated = "Sum: #{1 + 2}"
|
|
105
|
+
escaped = "tab\tnewline\nnull\0"
|
|
106
|
+
heredoc = <<-HEREDOC
|
|
107
|
+
This is a heredoc
|
|
108
|
+
with #{interpolated}
|
|
109
|
+
HEREDOC
|
|
110
|
+
raw = %q(no interpolation #{here})
|
|
111
|
+
command = `echo hello`
|
|
112
|
+
symbol = :my_symbol
|
|
113
|
+
regex = /pattern[a-z]+/i
|
|
114
|
+
|
|
115
|
+
# --- Numbers ---
|
|
116
|
+
integer = 42
|
|
117
|
+
negative = -17
|
|
118
|
+
hex = 0xFF
|
|
119
|
+
octal = 0o77
|
|
120
|
+
binary = 0b1010
|
|
121
|
+
float_val = 3.14
|
|
122
|
+
scientific = 1.5e10
|
|
123
|
+
underscore = 1_000_000
|
|
124
|
+
|
|
125
|
+
i8_val = 42_i8
|
|
126
|
+
i16_val = 42_i16
|
|
127
|
+
i32_val = 42_i32
|
|
128
|
+
i64_val = 42_i64
|
|
129
|
+
u8_val = 42_u8
|
|
130
|
+
u32_val = 42_u32
|
|
131
|
+
f32_val = 3.14_f32
|
|
132
|
+
f64_val = 3.14_f64
|
|
133
|
+
|
|
134
|
+
# --- Booleans & Nil ---
|
|
135
|
+
yes = true
|
|
136
|
+
no = false
|
|
137
|
+
nothing = nil
|
|
138
|
+
|
|
139
|
+
# --- Variables ---
|
|
140
|
+
local_var = "local"
|
|
141
|
+
@instance_var = "instance" # in class context
|
|
142
|
+
@@class_var = "class" # in class context
|
|
143
|
+
|
|
144
|
+
# --- Collections ---
|
|
145
|
+
array = [1, 2, 3, 4, 5]
|
|
146
|
+
empty_array = [] of Int32
|
|
147
|
+
tuple = {1, "hello", true}
|
|
148
|
+
named_tuple = {name: "Alice", age: 30}
|
|
149
|
+
hash = {"name" => "Alice", "age" => 30}
|
|
150
|
+
set = Set{1, 2, 3}
|
|
151
|
+
range = (1..10)
|
|
152
|
+
exclusive = (1...10)
|
|
153
|
+
|
|
154
|
+
# --- Control flow ---
|
|
155
|
+
if integer > 0
|
|
156
|
+
puts "positive"
|
|
157
|
+
elsif integer < 0
|
|
158
|
+
puts "negative"
|
|
159
|
+
else
|
|
160
|
+
puts "zero"
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
unless integer == 0
|
|
164
|
+
puts "not zero"
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Ternary
|
|
168
|
+
result = integer > 0 ? "positive" : "non-positive"
|
|
169
|
+
|
|
170
|
+
# --- Case ---
|
|
171
|
+
case integer
|
|
172
|
+
when 0
|
|
173
|
+
puts "zero"
|
|
174
|
+
when 1..10
|
|
175
|
+
puts "small"
|
|
176
|
+
when .> 100
|
|
177
|
+
puts "big"
|
|
178
|
+
else
|
|
179
|
+
puts "other"
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# --- Case with type ---
|
|
183
|
+
value = 42.as(Int32 | String | Nil)
|
|
184
|
+
case value
|
|
185
|
+
when Int32
|
|
186
|
+
puts "integer: #{value}"
|
|
187
|
+
when String
|
|
188
|
+
puts "string: #{value}"
|
|
189
|
+
when nil
|
|
190
|
+
puts "nil"
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# --- Loops ---
|
|
194
|
+
10.times do |i|
|
|
195
|
+
break if i == 5
|
|
196
|
+
next if i == 3
|
|
197
|
+
puts i
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
array.each do |item|
|
|
201
|
+
puts item
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
i = 10
|
|
205
|
+
while i > 0
|
|
206
|
+
i -= 1
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
until i >= 10
|
|
210
|
+
i += 1
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
loop do
|
|
214
|
+
i += 1
|
|
215
|
+
break if i > 20
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# --- Operators ---
|
|
219
|
+
sum = 1 + 2
|
|
220
|
+
diff = 5 - 3
|
|
221
|
+
prod = 4 * 2
|
|
222
|
+
quot = 10 / 3
|
|
223
|
+
modulo = 10 % 3
|
|
224
|
+
power = 2 ** 8
|
|
225
|
+
bit_and = 0xFF & 0x0F
|
|
226
|
+
bit_or = 0x10 | 0x01
|
|
227
|
+
bit_xor = 0xFF ^ 0x0F
|
|
228
|
+
bit_not = ~0
|
|
229
|
+
lshift = 1 << 4
|
|
230
|
+
rshift = 16 >> 2
|
|
231
|
+
logic = true && false || !nil
|
|
232
|
+
spaceship = 1 <=> 2
|
|
233
|
+
|
|
234
|
+
# --- Methods ---
|
|
235
|
+
def add(a : Int32, b : Int32) : Int32
|
|
236
|
+
a + b
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def greet(name : String, greeting = "Hello") : String
|
|
240
|
+
"#{greeting}, #{name}!"
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def variadic(*args : Int32) : Int32
|
|
244
|
+
args.sum
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# --- Blocks & Procs ---
|
|
248
|
+
square = ->(x : Int32) { x * x }
|
|
249
|
+
result = square.call(5)
|
|
250
|
+
|
|
251
|
+
def with_logging(&block : -> _)
|
|
252
|
+
puts "Before"
|
|
253
|
+
yield
|
|
254
|
+
puts "After"
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
with_logging { puts "Inside" }
|
|
258
|
+
|
|
259
|
+
# --- Exception handling ---
|
|
260
|
+
begin
|
|
261
|
+
raise "Something went wrong"
|
|
262
|
+
rescue ex : RuntimeError
|
|
263
|
+
puts "Caught: #{ex.message}"
|
|
264
|
+
rescue ex : Exception
|
|
265
|
+
puts "General: #{ex.message}"
|
|
266
|
+
ensure
|
|
267
|
+
puts "cleanup"
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# --- Type checking ---
|
|
271
|
+
dog = Dog.new("Rex", 5, "Labrador")
|
|
272
|
+
puts dog.speak
|
|
273
|
+
puts dog.is_a?(Animal) # true
|
|
274
|
+
puts dog.responds_to?(:speak) # true
|
|
275
|
+
puts typeof(dog) # Dog
|
|
276
|
+
puts sizeof(Int32) # 4
|
|
277
|
+
puts offsetof(Point, @x)
|
|
278
|
+
|
|
279
|
+
# --- Macros ---
|
|
280
|
+
macro define_method(name, content)
|
|
281
|
+
def {{name}}
|
|
282
|
+
{{content}}
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
define_method(:hello, puts "hello!")
|
|
287
|
+
|
|
288
|
+
# --- Annotations ---
|
|
289
|
+
@[Deprecated("Use new_method instead")]
|
|
290
|
+
def old_method
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# --- Alias ---
|
|
294
|
+
alias StringArray = Array(String)
|
|
295
|
+
|
|
296
|
+
# --- Lib (C bindings) ---
|
|
297
|
+
lib LibC
|
|
298
|
+
fun puts(str : UInt8*) : Int32
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
# --- Pointers (unsafe) ---
|
|
302
|
+
ptr = Pointer(Int32).malloc(1)
|
|
303
|
+
ptr.value = 42
|
|
304
|
+
puts ptr.value
|
|
305
|
+
|
|
306
|
+
# --- with ---
|
|
307
|
+
dog = Dog.new("Max", 3)
|
|
308
|
+
with dog
|
|
309
|
+
puts name
|
|
310
|
+
puts speak
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# --- Uninitialized ---
|
|
314
|
+
x = uninitialized Int32
|
|
315
|
+
|
|
316
|
+
# --- Self ---
|
|
317
|
+
class Example
|
|
318
|
+
def self.class_method
|
|
319
|
+
"class method on #{self}"
|
|
320
|
+
end
|
|
321
|
+
end
|