-
Notifications
You must be signed in to change notification settings - Fork 0
Simulation Flow
KIM CHAN HEE edited this page Mar 10, 2023
·
1 revision
- Initialize
- Readline
- Lexical analysis (=Tokenizing)
- Syntax analysis (=Make Parse Tree)
- Parameter and Variable Expansions
- Word Splitting
- Pathname Expansions
- Quote Removal
- Redirection
- Builtin Commands
- Simple Command Execution
- Shell setting
- Validator
- Used by readline library.
- Accepts input up to and including the newline character ('\n').
- Checking this time EOF
- Pass the received characters to the parser as a null-terminated string, excluding newline characters ('\n').
- Add history
- How to use ?
- brew install readline
- Makefile env
- RDLINE_DIR = $(shell brew --prefix readline)
- READLINE = -L$(RDLINE_DIR)/lib/ -lreadline
- INCS = -I ./include -I$(RDLINE_DIR)/include
-
Types of Token
- WORD
- OPERATOR
- BRACE_LEFT((), BRACE_RIGHT()), LOGICAL_AND(&&), LOGICAL_OR(||), PIPELINE(|), RDIR_IN(<), RDIR_OUT(>), RDIR_HEREDOC(<<), RDIR_APPEND(>>)
-
Split by
- blank: space, tab, (Do not include newline)
- operator (consist of non blank metacharacters): "(", ")", "|", "||", "&&", "<", ">", "<<", ">>"
-
Notes
- Unclosed quote, Unclosed Double quote, Unpaired Bracket,Unpaired Operator -> syntax error
-
Positional Parameters: $N (N is digit)
-
Special Parameters
- ?: exit status of the most recent pipeline
- *: wild card
-
Environment Variables: ${VARIABLE_NAME}
- Error case
- No such file or directory(/contains && does not exist)
- No such file or directory(/contains && does not exist)
- Permission denied(Include && Exist But Permissions denied)
- No such file or directory(/contains && Exist But No such file)
- command not found(/none && does not exist)