#ifndef LEXICAL_ANALYSIS_H_SENTRY #define LEXICAL_ANALYSIS_H_SENTRY #include "queue.h" #include "dynamic_array.h" #include #include 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