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.
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
✅ 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.
- 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.
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_Linuxyaajagro@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]
Developed by Yassine Ajagrou, For the source code or questions, Send me an email
.
