https://github.com/iaceene/minishell-parser
This repository contains the parsing module for a custom Minishell implementation in C. The parser processes user input, tokenizes commands, handles operators (pipes, redirections, etc.), and structures the data for execution. Designed to be efficient and modular, this parser serves as the foundation for command execution in a shell environment.
https://github.com/iaceene/minishell-parser
42minishell 42project 42school bash bash-parser c-programming command-line custom-shell minishell minishell-42 minishell-project shell shell-interpreter shell-scripting terminal unix-shell
Last synced: 8 days ago
JSON representation
This repository contains the parsing module for a custom Minishell implementation in C. The parser processes user input, tokenizes commands, handles operators (pipes, redirections, etc.), and structures the data for execution. Designed to be efficient and modular, this parser serves as the foundation for command execution in a shell environment.
- Host: GitHub
- URL: https://github.com/iaceene/minishell-parser
- Owner: iaceene
- License: mit
- Created: 2025-03-20T02:28:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-12T23:11:23.000Z (about 1 year ago)
- Last Synced: 2025-05-13T00:19:13.593Z (about 1 year ago)
- Topics: 42minishell, 42project, 42school, bash, bash-parser, c-programming, command-line, custom-shell, minishell, minishell-42, minishell-project, shell, shell-interpreter, shell-scripting, terminal, unix-shell
- Homepage: http://yaajagro.tech
- Size: 2.72 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# 🐚 Minishell Parser

## 📌 Overview
This repository contains the **parsing module** for a custom **Minishell** implementation in C. The parser is responsible for:
🔹 **Lexical analysis** – Tokenizing user input into meaningful components.
🔹 **Syntax validation** – Ensuring correct command structure and detecting errors.
🔹 **Expansion handling** – Processing environment variables and special characters.
🔹 **Command structuring** – Organizing parsed data for execution.
## Project Structure
```
components/parser/
├── expander/
│ ├── expander.c
│ ├── expander_utiles.c
│ ├── expander_utiles_tree.c
│ ├── expander_utiles_two.c
│ ├── handlers.c
├── herdoc/
│ ├── herdoc.c
│ ├── herdoc_utile_one.c
├── init/
│ ├── parser.c
│ ├── parser_utiles.c
├── lexer/
│ ├── final_step.c
│ ├── lexer.c
│ ├── lexer_utiles.c
│ ├── syntax_checker.c
│ ├── syntax_utiles.c
│ ├── syntax_utiles_two.c
├── prompt/
│ ├── get_cli.c
│ ├── prompt.c
│ ├── prompt_utiles.c
└── parser.h
```
## ✨ Features
✅ Tokenizes shell commands into structured data.
✅ Supports pipes (`|`), redirections (`>`, `<`), and heredocs (`<<`).
✅ Handles **single** (`'`) and **double** (`"`) quotes correctly.
✅ Expands **environment variables** (`$VAR`).
✅ Validates syntax before execution.
# Minishell Parser
## Features
- **Lexical Analysis**: Tokenizes input commands.
- **Syntax Checking**: Validates command structures.
- **Expansion**: Handles variables, wildcards, and heredoc.
- **Command Parsing**: Builds AST-like structures for execution.
- **Redirections & Pipes**: Parses input/output redirections and command pipelines.
## Installation & Usage
```sh
git clone https://github.com/iaceene/Minishell-Parser.git
cd Minishell-Parser
# if you are using Mac
./Parser_Mac
# if you are using Linux
./Parser_Linux
```
## Example Commands & Parsing Output
```
yaajagro@e1r7p7 $ ls -la
COMMAND --> [ls] ARG [-la]
yaajagro@e1r7p7 $ ls | ls -la | cat -e | grep $USER
COMMAND --> [ls]
PIPED TO
COMMAND --> [ls] ARG [-la]
PIPED TO
COMMAND --> [cat] ARG [-e]
PIPED TO
COMMAND --> [grep] ARG [yaajagro]
yaajagro@e1r7p7 $ ls > file1 < file2 >> appFile
COMMAND --> [ls]
OUTFILE [file1]
INFILE [file2]
APPEND [appFile]
yaajagro@e1r7p7 $ << eof cat -e | ls -la
> this heredoc
> eof
COMMAND --> [cat] ARG [-e]
HERDOC fd [4] content [this heredoc]
COMMAND --> [ls] ARG [-la]
```
## 👤 Author
Developed by **[Yassine Ajagrou](https://github.com/iaceene)**, For the source code or questions, [Send me an email](mailto:yassineajagrou986@gmail.com?subject=Hello%20Yassine%2C%20I%20want%20the%20source%20code%2C%20how%20can%20I%20get%20it%3F&body=Hello%20Yassine%2C%20I%20want%20the%20source%20code%2C%20how%20can%20I%20get%20it%3F)
.