<?xml version="1.0" encoding="UTF-8" ?>
  <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Gautam Shetty</title>
        <link>https://www.gautamshetty.com</link>
        <description>This is my portfolio RSS feed</description>
        <item>
          <title>My master's journey</title>
          <link>https://www.gautamshetty.com/diary/masters-journey</link>
          <description>Reflections on my journey through the master's program—exploring personal growth, self-realization, and the challenges faced along the way.</description>
          <pubDate>Fri, 15 Aug 2025 00:00:00 GMT</pubDate>
          <content:encoded><![CDATA[
When I look back at the last three years, it feels like a long and winding journey. Deciding to pursue a master’s in Computer Science at Dalhousie University was not an easy choice. By 2022, I had already taken a few steps into the industry. The pandemic had also created a lot of uncertainty, which made the decision even harder. But deep down, I wanted to challenge myself in a new way, and that’s how I began my journey in the Fall of 2022.

The early days were tough. I had little to no research experience before joining, and suddenly I was surrounded by research discussions, papers, and experiments. Adjusting to this new environment was not smooth. It often felt like I was running behind everyone else.

For almost half a year, I chased a very ambitious goal. I spent hours planning and working on it, but the results were not adding up. It was frustrating. After many discussions with my supervisor, I realized I needed to rethink my approach. I shifted towards a more realistic and achievable goal. That decision made all the difference. By mid to late 2023, I had started to find my rhythm in research.

The process was slow, but it taught me more than I ever expected. I learned the importance of balancing ambition with realistic goals. I learned how dangerous procrastination can be, and how small daily efforts add up over time. I am not perfect, but I am much better now than when I started. I also learned how to plan projects carefully, take responsibility, and honor commitments—skills that go beyond academics.

<img
  src="/diary/DAL_Convocation.jpg"
  style={{
    display: "block",
    marginLeft: "auto",
    marginRight: "auto",
    width: "100%",
  }}
/>

By the Summer of 2025, I completed my program. It wasn’t just about the degree. It was about growth, patience, and self-realization.

I owe a lot of this journey to my supervisor and my lab colleagues. Their constant support and motivation kept me going, especially when I doubted myself. For that, I will always be grateful.

This chapter may be closing, but the lessons will stay with me as I move forward.
]]></content:encoded>
        </item>
<item>
          <title>Tree sitter very beginner guide to implement and use queries</title>
          <link>https://www.gautamshetty.com/blog/tree-sitter-beginner-queries</link>
          <description>Learn how to implement and use Tree-sitter queries for syntax highlighting, code navigation, and static analysis.</description>
          <pubDate>Wed, 06 Mar 2024 00:00:00 GMT</pubDate>
          <content:encoded><![CDATA[
<img
  src="https://tree-sitter.github.io/tree-sitter/assets/images/tree-sitter-small.png"
  style={{ display: "block", marginLeft: "auto", marginRight: "auto" }}
/>

<span style={{ textAlign: "center" }}>
  In the realm of code editing and syntax highlighting, <b>Tree-sitter</b>{" "}
  stands out as a groundbreaking tool that offers a robust solution for
  understanding the structure of source code in various programming languages.
  It's a parser generator tool and an incremental parsing library that allows
  developers to maintain high performance and precise syntax highlighting, code
  formatting, and more. This post delves into the core aspect of Tree-sitter
  that makes these features possible: <b>Tree-sitter queries</b>.
</span>

Have you not set up tree-sitter on your machine yet? Check this post - <a href="/blog/tree-sitter-101">Tree-sitter 101</a>.

## What are Tree-sitter Queries?

Tree-sitter queries are a powerful mechanism for extracting information and patterns from the syntax tree generated by Tree-sitter. They allow developers to specify patterns in a language-agnostic way, enabling actions like syntax highlighting, code navigation, and other forms of static analysis across many programming languages with minimal effort.

A Tree-sitter query consists of a series of patterns that match nodes in the syntax tree based on their type, content, and relationships to other nodes. <br /> These queries can be written in a S-expression syntax, making them both readable and expressive.

## Why Use Tree-sitter Queries?

- <strong>Syntax Highlighting</strong>: With queries, syntax highlighting can
  adapt to the structure of the code rather than just the text, providing a more
  accurate and visually helpful highlighting.
- <strong>Code Navigation</strong>: Queries enable more sophisticated code
  navigation features, like jumping to definitions, finding references, and
  viewing documentation, by understanding the code's semantics.
- <strong>Refactoring Tools</strong>: They can be used to build refactoring
  tools that operate with an understanding of the code's syntax and semantics,
  making automated changes safer and more reliable.
- <strong>Static Analysis</strong>: Tree-sitter queries allow for detailed
  static analysis by querying the code for patterns that might indicate bugs or
  code smells.

## Writing Your First Tree-sitter Query

To get started with Tree-sitter queries, you first need to have Tree-sitter installed and set up for your target language. Once you have a parsed syntax tree, you can begin writing queries.

Here's a simple example to highlight function definitions in a JavaScript file:

```scheme
; Match function declarations
((function_declaration
  name: (identifier) @function.name)
 (highlight @function.name "function.name"))

; Match variable declarations that are initialized with a function
((variable_declaration
  declarators: (variable_declarator
                value: (function) @function.name))
 (highlight @function.name "function.name"))
```

This query has two patterns: one for matching named function declarations and another for matching variables that are initialized with a function. The `@function.name` part is a capture name, which is used to refer to the matched nodes in the actions that follow (in this case, highlighting with the tag "`function.name`").
]]></content:encoded>
        </item>
<item>
          <title>Affection in the deceptive world</title>
          <link>https://www.gautamshetty.com/diary/affection-in-the-deceptive-world</link>
          <description>Love is a bliss, but can be cruel in this world</description>
          <pubDate>Wed, 28 Feb 2024 00:00:00 GMT</pubDate>
          <content:encoded><![CDATA[
<img
  src="/diary/cover_affection_in_the_deceptive_world.jpeg"
  style={{
    display: "block",
    marginLeft: "auto",
    marginRight: "auto",
    width: "75%",
  }}
/>

<span style={{ textAlign: "center" }}>
In a world so wide and full of deceit, <br />
Love's a bliss, yet cruel, bittersweet. <br />
Affection blooms in a deceptive land, <br />
Where hearts entwine, like shifting sand. <br />

In the gentle dawn of love's embrace, <br />
Hope emerges, painting a tender grace. <br />
But shadows lurk, with tricks untold, <br />
A dance of illusions, love's story unfolds. <br />

Through whispers sweet and promises bright, <br />
Hearts take flight, chasing the elusive light. <br />
Yet, in the maze of a world unkind, <br />
Love's bliss, at times, is hard to find. <br />

Deceptive faces wear affection's guise, <br />
Yet behind the mask, truth often lies. <br />
In this complex world of fleeting dreams, <br />
Love's tender glow may not be as it seems. <br />

But still, we seek love's warm embrace, <br />
Braving storms, finding solace in the chase. <br />
For in a world that's both cruel and kind, <br />
Love remains a bliss we hope to find. <br />

<br />~ <i>Gautam</i>
</span>
]]></content:encoded>
        </item>
<item>
          <title>The Essence of Being</title>
          <link>https://www.gautamshetty.com/diary/self-realization</link>
          <description>A journey towards self-realization</description>
          <pubDate>Fri, 26 Jan 2024 00:00:00 GMT</pubDate>
          <content:encoded><![CDATA[
In the chaotic dance of daily life, it's easy to lose sight of ourselves amidst responsibilities, expectations, and societal pressures. Yet, in the quiet spaces between our thoughts, the art of self-realization awaits—a journey of introspection, growth, and profound understanding.

<img
  src="/diary/LightofHopeAbrahamHunter.jpg"
  style={{ display: "block", marginLeft: "auto", marginRight: "auto" }}
/>

> Painting: Light of Hope by Abraham Hunter

<i>typing ...</i>

&#9888; Check back later!
]]></content:encoded>
        </item>
<item>
          <title>Tree-sitter 101: A Leaf-to-Root Beginner's Guide</title>
          <link>https://www.gautamshetty.com/blog/tree-sitter-101</link>
          <description>Discover the basics of Tree-sitter, a powerful parsing framework, and learn how to install and use it for program analysis across various programming languages.</description>
          <pubDate>Sat, 16 Dec 2023 00:00:00 GMT</pubDate>
          <content:encoded><![CDATA[
Welcome to the first installment of our Tree-sitter series! In this series, we will introduce you to the powerful world of the Tree-sitter parsing framework. Our focus, at least initially, is on helping you use existing grammars to build program analysis tools that can operate across various programming languages. We won't dive into creating new grammars for entirely new programming languages just yet. So, let's start from the very beginning and get you started with Tree-sitter.

## Installing Tree-sitter

The first step in your Tree-sitter journey is to get the Tree-sitter command-line program up and running. Here are a few methods you can choose from:

### Native Package Manager

If you are using a platform that has Tree-sitter available in its native package manager, you can use it to install Tree-sitter. For example, on Arch Linux, you can use <em>'pacman'</em>:

```bash
sudo pacman -S tree-sitter
tree-sitter --version
```

Similarly, on macOS, you can use Homebrew:

```bash
brew install tree-sitter
tree-sitter --version
```

### Precompiled Binary

If your platform doesn't have Tree-sitter in its package manager or the available version is outdated, you can download a precompiled binary from the Tree-sitter releases page on GitHub.

Here's how you can do it:

```bash
curl -OL https://github.com/tree-sitter/tree-sitter/releases/download/v0.20.8/tree-sitter-linux-x64.gz
mkdir -p $HOME/bin
gunzip tree-sitter-linux-x64.gz > $HOME/bin/tree-sitter
chmod u+x $HOME/bin/tree-sitter
export PATH=$HOME/bin:$PATH
tree-sitter --version
```

> **Note:** <em>The provided release version may be obsolete at the time you are reading this, get the latest from here:</em> -> [Tree-sitter releases](https://github.com/tree-sitter/tree-sitter/releases)

### NPM Package

If you prefer using NPM, you can install the Tree-sitter command-line program via the 'tree-sitter-cli' package:

```bash
npm install tree-sitter-cli
npx tree-sitter --version
```

This option is particularly useful when you're working on grammar development as it allows you to include Tree-sitter as part of a CI build.

## Installing a Grammar

Now that you have the Tree-sitter program installed, it's time to set up a grammar. By default, Tree-sitter doesn't install any language grammars because it doesn't know which languages you want to work with. Let's install the Tree-sitter Python grammar as an example.

First, you need to generate a configuration file for Tree-sitter. This file tells Tree-sitter where to find language grammars. Run the following command to generate the configuration file:

```bash
tree-sitter init-config
```

This will create a configuration file at ~/.tree-sitter/config.json. Open this file in your text editor. In the file, you'll find a parser-directories section:

```json
{
  "parser-directories": [
    "/home/dcreager/github",
    "/home/dcreager/src",
    "/home/dcreager/source"
  ]
}
```

You can choose any directories you like to store your grammar definitions. Tree-sitter will look for subdirectories in these locations with names matching the pattern tree-sitter-[language], and it will automatically generate and compile those grammars when needed.

To work with the Tree-sitter Python grammar, clone it into one of the directories listed in the config file. In this example, we'll use ~/src:

```bash
mkdir -p ~/src
cd ~/src
git clone https://github.com/tree-sitter/tree-sitter-python

```

## Parsing Some Code

With the Python grammar installed, you can now parse Python code using the Tree-sitter command-line tool. Let's test it on an example Python script:

```bash
cat example.py
import utils

def add_four(x):
  return x + 4

print(add_four(5))

tree-sitter parse example.py
```

You should see a parse tree generated for the Python code. Tree-sitter breaks down the code into a structured tree, making it easier for you to analyze and manipulate the code's syntax.

Feel free to explore further by parsing example files from other languages. Just clone the corresponding language grammar into the same directory you specified in the configuration file and use the tree-sitter parse command to analyze the code.

That's it for our beginner's guide to Tree-sitter. In the next posts of this series, we'll delve deeper into using Tree-sitter for various programming language analysis tasks. So, stay tuned for more exciting Tree-sitter adventures!
]]></content:encoded>
        </item>
    </channel>
  </rss>