diff options
author | scratko <m@scratko.xyz> | 2024-06-12 18:52:28 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-06-12 18:52:28 +0300 |
commit | 1ee0911f2def54f1b63d18b0924ac65c2db92f11 (patch) | |
tree | 945cf5fc2e0e3fe3095349950ff51e4b561a1f8e /lexical_analysis.h | |
parent | 8bcfbe6a15f6195c3501b9bde633081da67179d1 (diff) | |
download | shell-1ee0911f2def54f1b63d18b0924ac65c2db92f11.tar.gz shell-1ee0911f2def54f1b63d18b0924ac65c2db92f11.tar.bz2 shell-1ee0911f2def54f1b63d18b0924ac65c2db92f11.zip |
version shell-V with commented out code
Diffstat (limited to 'lexical_analysis.h')
-rw-r--r-- | lexical_analysis.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/lexical_analysis.h b/lexical_analysis.h new file mode 100644 index 0000000..e0f791a --- /dev/null +++ b/lexical_analysis.h @@ -0,0 +1,84 @@ +#ifndef LEXICAL_ANALYSIS_H_SENTRY +#define LEXICAL_ANALYSIS_H_SENTRY + +#include "queue.h" +#include "dynamic_array.h" + +#include <stdio.h> +#include <stdlib.h> + +enum { + new_line = 10, + whitespace = ' ', + tab = 9, + backslash = '\\', + double_quotes = '"' +}; + +/* two-letter tokens */ +enum { + append = '>' + 1, + and = '&' + 1, + or = '|' + 1 +}; + +/* storing file names to redirect standard input/output streams */ +struct io_type { + char *input_stream; + char *output_stream; + char *output_stream_to_append; +}; + +struct param_type { + int is_word; + int escape_sequences; + unsigned int double_quotes_counter; + char stored_symbol; + int empty_word_flag; + int tokens; + int wrong_command; + struct io_type streams; + int last_execution_status; + int pipeline; +}; + + +int filename_waiting(struct param_type *params); +void add_filename(struct dynamic_array *tmp_word, struct param_type *params); +void add_word(struct w_queue *word_chain, struct dynamic_array *tmp_word, + struct param_type *params); +int is_stream_redirection_set(const struct param_type *params); +char** create_cmdline(const struct w_queue *word_chain, int word_counter); + +int is_double_quotes_pair(struct param_type params); +int escape_double_quotes_or_backslash(int ch, struct param_type params); +int double_quotes_again(int ch, struct param_type params); +int check_separation(int ch, struct param_type params); +int ignore_spaces(int ch, struct param_type params); +int change_mode(int ch, struct param_type params); +int start_escape_sequence(int ch, struct param_type params); +int is_empty_word(int ch, struct param_type params); +int command_execution_condition(struct param_type *params); + +int is_special_token(int ch); +int is_redirect_token(int ch, int next_ch); +int excessive_words(int ch, struct param_type *params); +void add_word_or_filename(struct w_queue *word_chain, + struct dynamic_array *tmp_word, + struct param_type *params); +int validate_redirections(int ch, int next_ch, struct param_type *params); +int is_double_token(struct param_type *params); + +int stream_redirect_tokens(struct w_queue *word_chain, + struct dynamic_array *tmp_word, + int ch, struct param_type *params); +int double_quotes_again(int ch, struct param_type params); +int pipeline_token_processing(struct w_queue *word_chain, + struct c_queue *cmdlines, + struct dynamic_array *tmp_word, + struct param_type *params); + +int special_tokens(struct w_queue *word_chain, struct c_queue *cmdlines, + struct dynamic_array *tmp_word, int ch, + struct param_type *params); +#endif |