How tablerase/42_minishell works
Main Components
• Input Handling: Represented by the integration with Readline (as seen in several parts of the README) – handling dynamic user input and line reading.
• Lexing Module: The “lexer” directories/files (Sources/mandatory/lexer) and related headers handle tokenizing the input. This module checks for lexing errors (e.g., unmatched quotes).
• Parsing Module: Found under Sources/mandatory/parser. This module takes the list of tokens from the lexer and constructs commands (including handling of arguments, redirections, and here_docs).
• Builtin Commands: Located in Sources/mandatory/builtin, handling built-in functions like exit, cd, pwd, export, etc.
• Execution & Pipes: The Sources/mandatory/execution and Sources/mandatory/pipes directories elaborate how commands are executed, how redirections are applied, pipes are set up, and how external processes are launched.
• Utility Functions: Common routines (in Sources/mandatory/utils) and helper modules that support array handling, memory freeing, and more.
• Libft Integration: An external library (libft) that provides additional utility functions (like string, memory, list handling) which the shell uses.
Specify Relationships and Interactions
• Data flows from Readline input into the Lexing component.
• Lexical tokens are passed to the Parser, which builds a command listing.
• The Execution module handles initiating command processes, applying redirections (with special handling for things like here_doc) and managing resources.
• A separate subsystem deals with signal handling where events (SIGINT, SIGQUIT, SIGEOF) are caught and influence the current state of input, heredoc processing, or command execution.
• Libft is used as a support library ensuring fundamental operations (like formatted output via ft_printf) are consistent across modules.
• Dependencies between modules are clearly visible: the Parser depends on the output of the Lexer, while the Executor depends on both the Parser and the Pipes module.
Architectural Patterns and Design Principles
• Modular Design: The project is clearly split into modules (lexer, parser, executor, builtins, utilities) ensuring separation of concerns.
• Pipeline or Data Flow Architecture: Input flows sequentially through lexing -> parsing -> command execution.
• Error Handling & Signal Interception: Specialized design for handling errors (lexical errors, here_doc interrupts) and signals (leveraging Readline settings and modifications to keep input/signal handling coherent).