back to scratko.xyz
summaryrefslogtreecommitdiff
path: root/lexical_analysis.h
diff options
context:
space:
mode:
Diffstat (limited to 'lexical_analysis.h')
-rw-r--r--lexical_analysis.h56
1 files changed, 7 insertions, 49 deletions
diff --git a/lexical_analysis.h b/lexical_analysis.h
index e0f791a..3266ad7 100644
--- a/lexical_analysis.h
+++ b/lexical_analysis.h
@@ -1,54 +1,7 @@
#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);
+#include "shell.h"
int is_double_quotes_pair(struct param_type params);
int escape_double_quotes_or_backslash(int ch, struct param_type params);
@@ -60,19 +13,23 @@ 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_special_token(int ch, int next_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,
@@ -81,4 +38,5 @@ int pipeline_token_processing(struct w_queue *word_chain,
int special_tokens(struct w_queue *word_chain, struct c_queue *cmdlines,
struct dynamic_array *tmp_word, int ch,
struct param_type *params);
+
#endif