explication de la methode de parsing
This commit is contained in:
36
README.md
36
README.md
@@ -10,10 +10,10 @@
|
||||
- **expensions :**
|
||||
- `$` *variable expension*
|
||||
- `$?` *exit return of last executed process*
|
||||
- **quotes :** --> [ressource](https://linuxhandbook.com/quotes-in-bash/)
|
||||
- **quotes :** [ressource](https://linuxhandbook.com/quotes-in-bash/)
|
||||
- `'` *(ignore any special characters)*
|
||||
- `"` *(ignore any special characters except '$')*
|
||||
- **redirections & heredocs :** --> [ressource](https://www.gnu.org/software/bash/manual/html_node/Redirections.html) / [heredocs for readability](https://www.techrepublic.com/article/use-heredoc-in-shell-scripts/)
|
||||
- **redirections & heredocs :** [ressource](https://www.gnu.org/software/bash/manual/html_node/Redirections.html) / [heredocs for readability](https://www.techrepublic.com/article/use-heredoc-in-shell-scripts/)
|
||||
- `<` *redirect input*
|
||||
- `>` *redirect output*
|
||||
- `<<` *read input until empty line --* **? doesn't update history ?**
|
||||
@@ -29,12 +29,11 @@
|
||||
- `export`
|
||||
- `unset`
|
||||
- ~~`exit`~~
|
||||
- **builtins (don't need to be) :**
|
||||
- **builtins (don't need to be) :** [source](https://git.42l.fr/Fabien/minishell)
|
||||
- `env`
|
||||
- ~~`echo`~~
|
||||
- `echo -n`
|
||||
|
||||
--> [source of a minishell with an interesting README](https://git.42l.fr/Fabien/minishell)
|
||||
|
||||
---
|
||||
|
||||
@@ -88,6 +87,8 @@ EXEMPLE : . .
|
||||
- 'a"r'g'"1'
|
||||
- 'arg"1"'arg2'arg3'
|
||||
|
||||
### tentative methode 1
|
||||
#### pseudo code :
|
||||
```
|
||||
int q; // first quote
|
||||
int c; // count
|
||||
@@ -136,8 +137,9 @@ while (str[i])
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
### application :
|
||||
```
|
||||
['][a][r][g][1][ ]['][a][r][g][2]["][ ][a][r][g][3]["]
|
||||
c = 0 . . . . . . . . . . . . . . . . . .
|
||||
c = 1 . . . . . . . . . . . . . . . . . str[i] == ' ; q == 0 c == 0 -> c++; q = '
|
||||
@@ -175,14 +177,16 @@ c = . . . . . . . 1 . . str[i] == " ; q != " c == 2 ->
|
||||
ERROR ...
|
||||
c = . . . . . . . . 1 . str[i] != ' | " ; ->
|
||||
c = . . . . . . . . . 0 str[i] != ' | " ; ->
|
||||
```
|
||||
|
||||
#### erreur :
|
||||
-> comment le programme sait que cette fois il doit decrementer "c" ?
|
||||
en retenant dans l'ordre toutes les dernieres valeurs de "q" !
|
||||
-> donc plutot partir sur une recursive
|
||||
|
||||
```
|
||||
|
||||
deuxieme methode :
|
||||
### tentative methode 2 :
|
||||
#### exemple :
|
||||
```
|
||||
.--------------------------------------------.
|
||||
: .--------------------------------------. :
|
||||
@@ -191,15 +195,25 @@ deuxieme methode :
|
||||
: : : .--. : .--. : : .--. : : : :
|
||||
'__"__'__"__"__"__'__'__"__"__'__'__"__'__"__'
|
||||
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16
|
||||
|
||||
|
||||
piege :
|
||||
```
|
||||
-> repérer les paires de quotes ou dquotes
|
||||
-> piège :
|
||||
```
|
||||
| |
|
||||
.--. .--. v v .--.
|
||||
'__"__'__"__"__"__'__'__"__"__'__'__"__'__"__'
|
||||
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
|
||||
```
|
||||
|
||||
0. envoyer une copie de la str dans une fonction
|
||||
1. chercher la premiere pair
|
||||
2. l'effacer
|
||||
3. recommencer en boucle
|
||||
4. stop quand la premier quote a trouvé sa paire
|
||||
5. renvoyer l'emplacement de la pair
|
||||
|
||||
exemple :
|
||||
```
|
||||
.--.
|
||||
1 : '__"__'__"__"__"__'__'__"__"__'__'__"__'__"__'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user