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.
@@ -0,0 +1,258 @@
1
+ // Line comment
2
+ /* Block comment */
3
+ /**
4
+ * Groovydoc comment
5
+ * @author Sample
6
+ */
7
+
8
+ package com.example.sample
9
+
10
+ import java.util.List
11
+ import java.util.Map
12
+
13
+ // --- Constants ---
14
+ final PI = 3.14159
15
+ final MAX_SIZE = 100
16
+
17
+ // --- Enums ---
18
+ enum Color {
19
+ RED, GREEN, BLUE
20
+
21
+ String display() {
22
+ return name().toLowerCase()
23
+ }
24
+ }
25
+
26
+ // --- Interface ---
27
+ interface Greeter {
28
+ String greet(String name)
29
+ }
30
+
31
+ // --- Trait ---
32
+ trait Loggable {
33
+ void log(String message) {
34
+ println "[LOG] ${message}"
35
+ }
36
+ }
37
+
38
+ // --- Abstract class ---
39
+ abstract class Animal {
40
+ String name
41
+ int age
42
+
43
+ Animal(String name, int age = 0) {
44
+ this.name = name
45
+ this.age = age
46
+ }
47
+
48
+ abstract String speak()
49
+
50
+ @Override
51
+ String toString() {
52
+ return "${name}: ${speak()}"
53
+ }
54
+ }
55
+
56
+ // --- Class with trait and interface ---
57
+ class Dog extends Animal implements Greeter, Loggable {
58
+ String breed
59
+
60
+ Dog(String name, int age, String breed = 'Mixed') {
61
+ super(name, age)
62
+ this.breed = breed
63
+ }
64
+
65
+ @Override
66
+ String speak() {
67
+ return 'Woof!'
68
+ }
69
+
70
+ @Override
71
+ String greet(String person) {
72
+ log("Greeting ${person}")
73
+ return "Woof! Hello, ${person}!"
74
+ }
75
+ }
76
+
77
+ // --- Strings ---
78
+ def single = 'single quoted'
79
+ def double = "double quoted with ${1 + 2}"
80
+ def gstring = "GString: name=${single}"
81
+ def multilineSingle = '''
82
+ multi-line
83
+ single quoted
84
+ '''
85
+ def multilineDouble = """
86
+ multi-line
87
+ double: ${single}
88
+ """
89
+ def slashy = /pattern[a-z]+/
90
+ def dollarSlashy = $/dollar/slashy/$
91
+ def escaped = "tab\tnewline\n"
92
+
93
+ // --- Numbers ---
94
+ def integer = 42
95
+ def negative = -17
96
+ def longVal = 1234567890L
97
+ def bigInt = 1234567890123456789G
98
+ def floatVal = 3.14f
99
+ def doubleVal = 2.71828d
100
+ def bigDec = 3.14159G
101
+ def hex = 0xFF
102
+ def octal = 0o77
103
+ def binary = 0b1010
104
+
105
+ // --- Booleans & Null ---
106
+ def yes = true
107
+ def no = false
108
+ def nothing = null
109
+
110
+ // --- Variables ---
111
+ def dynamicVar = 'dynamic'
112
+ String typedVar = 'typed'
113
+ var inferredVar = 'inferred' // Groovy 3+
114
+
115
+ // --- Collections ---
116
+ def list = [1, 2, 3, 4, 5]
117
+ def emptyList = []
118
+ def linkedList = [1, 2, 3] as LinkedList
119
+
120
+ def map = [name: 'Alice', age: 30, active: true]
121
+ def emptyMap = [:]
122
+ def typedMap = ['key': 'value'] as HashMap
123
+
124
+ def range = 1..10
125
+ def halfOpen = 1..<10
126
+
127
+ def set = [1, 2, 3] as Set
128
+
129
+ // --- Control flow ---
130
+ if (integer > 0) {
131
+ println 'positive'
132
+ } else if (integer < 0) {
133
+ println 'negative'
134
+ } else {
135
+ println 'zero'
136
+ }
137
+
138
+ // --- Switch ---
139
+ switch (integer) {
140
+ case 0:
141
+ println 'zero'
142
+ break
143
+ case 1..10:
144
+ println 'small'
145
+ break
146
+ case ~/\d{3}/:
147
+ println 'three digits'
148
+ break
149
+ case Integer:
150
+ println 'integer type'
151
+ break
152
+ default:
153
+ println 'other'
154
+ break
155
+ }
156
+
157
+ // --- Loops ---
158
+ for (i in 0..<10) {
159
+ if (i == 5) break
160
+ if (i == 3) continue
161
+ println i
162
+ }
163
+
164
+ for (item in list) {
165
+ println item
166
+ }
167
+
168
+ def j = 10
169
+ while (j > 0) {
170
+ j--
171
+ }
172
+
173
+ do {
174
+ j++
175
+ } while (j < 5)
176
+
177
+ // --- Closures ---
178
+ def square = { int x -> x * x }
179
+ def printer = { println it }
180
+ def multiLine = { a, b ->
181
+ def sum = a + b
182
+ return sum * 2
183
+ }
184
+
185
+ list.each { println it }
186
+ def doubled = list.collect { it * 2 }
187
+ def evens = list.findAll { it % 2 == 0 }
188
+
189
+ // --- Operators ---
190
+ def sum = 1 + 2
191
+ def concat = 'Hello' + ' ' + 'World'
192
+ def spaceship = 1 <=> 2
193
+ def elvis = nothing ?: 'default'
194
+ def safe = nothing?.toString()
195
+ def spread = list*.toString()
196
+ def membership = 1 in list
197
+ def typeCheck = integer instanceof Integer
198
+ def power = 2 ** 8
199
+ def regex = 'hello' ==~ /h.*/
200
+
201
+ // --- GPath ---
202
+ def xmlText = '<root><child name="test">value</child></root>'
203
+
204
+ // --- Methods ---
205
+ def add(int a, int b) {
206
+ return a + b
207
+ }
208
+
209
+ String greetPerson(String name, String greeting = 'Hello') {
210
+ "${greeting}, ${name}!"
211
+ }
212
+
213
+ def variadic(String... args) {
214
+ args.each { println it }
215
+ }
216
+
217
+ // --- Exception handling ---
218
+ try {
219
+ throw new RuntimeException('Something went wrong')
220
+ } catch (RuntimeException e) {
221
+ println "Caught: ${e.message}"
222
+ } catch (Exception e) {
223
+ println "General: ${e.message}"
224
+ } finally {
225
+ println 'cleanup'
226
+ }
227
+
228
+ // --- Assert ---
229
+ assert integer == 42
230
+ assert list.size() == 5 : 'Expected 5 items'
231
+
232
+ // --- As / Type coercion ---
233
+ def str = 42 as String
234
+ def nums = '1,2,3'.split(',') as List
235
+
236
+ // --- Object creation ---
237
+ def dog = new Dog('Rex', 5, 'Labrador')
238
+ println dog.speak()
239
+ println dog.greet('World')
240
+
241
+ if (dog instanceof Animal) {
242
+ println "Is an animal"
243
+ }
244
+
245
+ // --- Safe navigation ---
246
+ def length = dog?.name?.length()
247
+
248
+ // --- Spread operator ---
249
+ def names = [new Dog('A', 1), new Dog('B', 2)]*.name
250
+
251
+ // --- Builder pattern (typical Groovy) ---
252
+ def builder = new StringBuilder()
253
+ builder.with {
254
+ append 'Hello'
255
+ append ', '
256
+ append 'World!'
257
+ }
258
+ println builder.toString()
@@ -0,0 +1,154 @@
1
+ -# This is a HAML comment
2
+ / This is also a HAML comment
3
+
4
+ /
5
+ Multi-line
6
+ comment block
7
+
8
+ !!! 5
9
+ %html{ lang: "en" }
10
+ %head
11
+ %meta{ charset: "UTF-8" }
12
+ %meta{ name: "viewport", content: "width=device-width, initial-scale=1.0" }
13
+ %title Sample HAML Page
14
+ %link{ rel: "stylesheet", href: "style.css" }
15
+ :css
16
+ body {
17
+ font-family: sans-serif;
18
+ margin: 0;
19
+ padding: 20px;
20
+ }
21
+ .highlight {
22
+ color: #ff0000;
23
+ }
24
+
25
+ %body
26
+ -# --- Header ---
27
+ %header#top-header.site-header
28
+ %h1 Sample HAML Page
29
+ %nav{ "aria-label" => "Main navigation" }
30
+ %ul
31
+ %li
32
+ %a{ href: "#section1" } Section 1
33
+ %li
34
+ %a{ href: "#section2" } Section 2
35
+ %li
36
+ %a{ href: "#section3" } Section 3
37
+
38
+ -# --- Main content ---
39
+ %main#main-content{ role: "main" }
40
+
41
+ -# --- Text content ---
42
+ %article
43
+ %h2#section1 Section 1: Text
44
+ %p
45
+ This is a paragraph with
46
+ %strong bold
47
+ ,
48
+ %em italic
49
+ , and
50
+ %code inline code
51
+ text.
52
+ %p Special entities: &amp; &lt; &gt;
53
+
54
+ %blockquote{ cite: "https://example.com" }
55
+ A famous quote goes here.
56
+
57
+ %pre
58
+ %code
59
+ :plain
60
+ function hello() {
61
+ console.log("Hello!");
62
+ }
63
+
64
+ -# --- Forms ---
65
+ %article
66
+ %h2#section2 Section 2: Forms
67
+ %form{ action: "/submit", method: "post" }
68
+ %fieldset
69
+ %legend User Information
70
+
71
+ %label{ for: "name" } Name:
72
+ %input{ type: "text", id: "name", name: "name", required: true, placeholder: "Enter your name" }
73
+
74
+ %label{ for: "email" } Email:
75
+ %input{ type: "email", id: "email", name: "email", required: true }
76
+
77
+ %label{ for: "bio" } Bio:
78
+ %textarea{ id: "bio", name: "bio", rows: 4, cols: 50 }
79
+
80
+ %label{ for: "color" } Color:
81
+ %select{ id: "color", name: "color" }
82
+ %optgroup{ label: "Primary" }
83
+ %option{ value: "red" } Red
84
+ %option{ value: "blue", selected: true } Blue
85
+
86
+ %button{ type: "submit" } Submit
87
+
88
+ -# --- Ruby code ---
89
+ %article
90
+ %h2#section3 Section 3: Dynamic Content
91
+
92
+ - items = ["apple", "banana", "cherry"]
93
+ %ul
94
+ - items.each do |item|
95
+ %li= item
96
+
97
+ - if items.length > 0
98
+ %p
99
+ Total items:
100
+ = items.length
101
+ - else
102
+ %p No items
103
+
104
+ - (1..5).each do |i|
105
+ .item{ class: "item-#{i}" }
106
+ = "Item #{i}"
107
+
108
+ -# String interpolation
109
+ %p= "Current time: #{Time.now}"
110
+
111
+ -# --- Classes and IDs ---
112
+ .container
113
+ .row
114
+ .col-6.text-left
115
+ %p Left column
116
+ .col-6.text-right
117
+ %p Right column
118
+
119
+ #sidebar.sidebar.collapsed
120
+ %h3 Sidebar
121
+ %ul.nav-list
122
+ %li.nav-item.active
123
+ %a.nav-link{ href: "#" } Home
124
+ %li.nav-item
125
+ %a.nav-link{ href: "#" } About
126
+
127
+ -# --- Footer ---
128
+ %footer
129
+ %p &copy; 2024 Sample HAML Page
130
+
131
+ -# --- Media ---
132
+ %article
133
+ %img{ src: "image.jpg", alt: "Sample", width: 400, height: 300, loading: "lazy" }
134
+ %br
135
+ %hr
136
+
137
+ -# --- Data attributes ---
138
+ .widget{ data: { id: 42, name: "widget", active: true } }
139
+ %p Widget content
140
+
141
+ -# --- Boolean attributes ---
142
+ %input{ type: "checkbox", checked: true, disabled: false }
143
+
144
+ -# --- Multiline attributes ---
145
+ %a{ href: "https://example.com",
146
+ target: "_blank",
147
+ rel: "noopener noreferrer",
148
+ class: "external-link" }
149
+ External Link
150
+
151
+ :javascript
152
+ document.addEventListener('DOMContentLoaded', function() {
153
+ console.log('Page loaded');
154
+ });
@@ -0,0 +1,168 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Sample HTML</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <style>
9
+ body {
10
+ font-family: sans-serif;
11
+ margin: 0;
12
+ padding: 20px;
13
+ }
14
+ .highlight {
15
+ color: #ff0000;
16
+ background-color: #ffffcc;
17
+ }
18
+ #main-content {
19
+ max-width: 800px;
20
+ margin: 0 auto;
21
+ }
22
+ </style>
23
+ </head>
24
+ <body>
25
+ <!-- This is an HTML comment -->
26
+ <header id="top-header" class="site-header">
27
+ <h1>Sample HTML Page</h1>
28
+ <nav aria-label="Main navigation">
29
+ <ul>
30
+ <li><a href="#section1">Section 1</a></li>
31
+ <li><a href="#section2">Section 2</a></li>
32
+ <li><a href="#section3">Section 3</a></li>
33
+ </ul>
34
+ </nav>
35
+ </header>
36
+
37
+ <main id="main-content" role="main">
38
+ <article>
39
+ <h2 id="section1">Section 1: Text Content</h2>
40
+ <p>This is a paragraph with <strong>bold</strong>, <em>italic</em>,
41
+ and <code>inline code</code> text.</p>
42
+ <p>Special entities: &amp; &lt; &gt; &quot; &copy; &#8212;</p>
43
+
44
+ <blockquote cite="https://example.com">
45
+ A famous quote goes here.
46
+ </blockquote>
47
+
48
+ <pre><code>function hello() {
49
+ console.log("Hello!");
50
+ }</code></pre>
51
+ </article>
52
+
53
+ <article>
54
+ <h2 id="section2">Section 2: Forms</h2>
55
+ <form action="/submit" method="post" enctype="multipart/form-data">
56
+ <fieldset>
57
+ <legend>User Information</legend>
58
+
59
+ <label for="name">Name:</label>
60
+ <input type="text" id="name" name="name" required
61
+ placeholder="Enter your name" maxlength="100">
62
+
63
+ <label for="email">Email:</label>
64
+ <input type="email" id="email" name="email" required>
65
+
66
+ <label for="age">Age:</label>
67
+ <input type="number" id="age" name="age" min="0" max="150">
68
+
69
+ <label for="bio">Bio:</label>
70
+ <textarea id="bio" name="bio" rows="4" cols="50"></textarea>
71
+
72
+ <label for="color">Favorite Color:</label>
73
+ <select id="color" name="color">
74
+ <optgroup label="Primary">
75
+ <option value="red">Red</option>
76
+ <option value="blue" selected>Blue</option>
77
+ </optgroup>
78
+ <optgroup label="Secondary">
79
+ <option value="green">Green</option>
80
+ <option value="purple">Purple</option>
81
+ </optgroup>
82
+ </select>
83
+
84
+ <input type="checkbox" id="agree" name="agree">
85
+ <label for="agree">I agree to the terms</label>
86
+
87
+ <button type="submit">Submit</button>
88
+ <button type="reset">Reset</button>
89
+ </fieldset>
90
+ </form>
91
+ </article>
92
+
93
+ <article>
94
+ <h2 id="section3">Section 3: Media &amp; Tables</h2>
95
+
96
+ <figure>
97
+ <img src="image.jpg" alt="Sample image" width="400" height="300"
98
+ loading="lazy">
99
+ <figcaption>A sample image caption</figcaption>
100
+ </figure>
101
+
102
+ <video controls width="400" poster="poster.jpg">
103
+ <source src="video.mp4" type="video/mp4">
104
+ <source src="video.webm" type="video/webm">
105
+ Your browser does not support video.
106
+ </video>
107
+
108
+ <audio controls>
109
+ <source src="audio.mp3" type="audio/mpeg">
110
+ </audio>
111
+
112
+ <table>
113
+ <caption>Sample Data</caption>
114
+ <thead>
115
+ <tr>
116
+ <th scope="col">Name</th>
117
+ <th scope="col">Value</th>
118
+ <th scope="col">Description</th>
119
+ </tr>
120
+ </thead>
121
+ <tbody>
122
+ <tr>
123
+ <td>Alpha</td>
124
+ <td>100</td>
125
+ <td>First item</td>
126
+ </tr>
127
+ <tr>
128
+ <td>Beta</td>
129
+ <td>200</td>
130
+ <td>Second item</td>
131
+ </tr>
132
+ </tbody>
133
+ <tfoot>
134
+ <tr>
135
+ <td colspan="3">Total: 300</td>
136
+ </tr>
137
+ </tfoot>
138
+ </table>
139
+ </article>
140
+
141
+ <aside>
142
+ <h3>Related Links</h3>
143
+ <ul>
144
+ <li><a href="https://example.com" target="_blank" rel="noopener">Example</a></li>
145
+ </ul>
146
+ </aside>
147
+ </main>
148
+
149
+ <footer>
150
+ <p>&copy; 2024 Sample Page. All rights reserved.</p>
151
+ <address>
152
+ Contact: <a href="mailto:test@example.com">test@example.com</a>
153
+ </address>
154
+ </footer>
155
+
156
+ <!-- Self-closing tags -->
157
+ <br>
158
+ <hr>
159
+ <img src="icon.png" alt="">
160
+
161
+ <script src="app.js" defer></script>
162
+ <script>
163
+ document.addEventListener('DOMContentLoaded', function() {
164
+ console.log('Page loaded');
165
+ });
166
+ </script>
167
+ </body>
168
+ </html>