queries
bash.scm c.scm cpp.scm css.scm dockerfile.scm go.scm html.scm javascript.scm lua.scm markdown.scm php.scm python.scm sql.scm tsx.scm typescript.scmsamples
format.txt lsp.c ollama.py test.c test.cpp test.css test.dockerfile test.html test.js test.lua test.md test.php test.py test.rb test.sh test.sql test.ts test.tsxvendor
github.com
mitjafelicijan
go-tree-sitter
.gitignore LICENSE Makefile README.md alloc.c alloc.h api.h array.h atomic.h bindings.c bindings.go bindings.h bits.h clock.h error_costs.h get_changed_ranges.c get_changed_ranges.h host.h iter.go language.c language.h length.h lexer.c lexer.h node.c parser.c parser.h point.h ptypes.h query.c reduce_action.h reusable_node.h stack.c stack.h subtree.c subtree.h test_grammar.go test_grammar.js test_grammar_generate.sh tree.c tree.h tree_cursor.c tree_cursor.h umachine.h unicode.h urename.h utf.h utf16.h utf8.h wasm_store.c wasm_store.hnsf
termbox-go
AUTHORS LICENSE README.md api.go api_common.go api_windows.go collect_terminfo.py escwait.go escwait_darwin.go syscalls_darwin.go syscalls_darwin_amd64.go syscalls_dragonfly.go syscalls_freebsd.go syscalls_linux.go syscalls_netbsd.go syscalls_openbsd.go syscalls_windows.go termbox.go termbox_common.go termbox_windows.go terminfo.go terminfo_builtin.go
samples/test.php
raw
1<?php
2
3// A simple PHP script
4
5namespace App;
6
7use Exception;
8
9class User {
10 private $name;
11 private $email;
12
13 public function __construct($name, $email) {
14 $this->name = $name;
15 $this->email = $email;
16 }
17
18 public function getName() {
19 return $this->name;
20 }
21
22 public function getEmail() {
23 return $this->email;
24 }
25
26 public function save() {
27 // Simulate saving to database
28 echo "Saving user {$this->name} to database.\n";
29 return true;
30 }
31}
32
33function processUsers($users) {
34 foreach ($users as $user) {
35 try {
36 if ($user->save()) {
37 echo "User saved successfully.\n";
38 }
39 } catch (Exception $e) {
40 echo "Error: " . $e->getMessage() . "\n";
41 }
42 }
43}
44
45// Data array
46$users_data = [
47 ['name' => 'Alice', 'email' => 'alice@example.com'],
48 ['name' => 'Bob', 'email' => 'bob@example.com'],
49];
50
51$user_objects = [];
52
53// Loop and create objects
54if (!empty($users_data)) {
55 foreach ($users_data as $data) {
56 $user_objects[] = new User($data['name'], $data['email']);
57 }
58}
59
60// Call function
61processUsers($user_objects);
62
63// Alternative syntax for control structures
64$count = 0;
65while ($count < 3):
66 echo "Count is $count\n";
67 $count++;
68endwhile;
69
70echo "Script completed.\n";
71
72?>