mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
token_type: assign token_type to worddesc during wordsplit
Also added some tests for that part.
This commit is contained in:
parent
4d6a64bf6a
commit
3ec90f7770
6 changed files with 254 additions and 11 deletions
177
test.sh
177
test.sh
|
|
@ -607,4 +607,181 @@ expecting <<EOF
|
|||
╰─ redirections = (empty redir list)
|
||||
EOF
|
||||
|
||||
when_run <<EOF "token type attribution is correct"
|
||||
.debug
|
||||
.exec
|
||||
()|||&&>>><<<
|
||||
EOF
|
||||
expecting <<EOF
|
||||
[dbg: 1]
|
||||
[exec: 0]
|
||||
╰─ t_simple_cmd
|
||||
├─ line = 0
|
||||
├─ t_wordlist
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [(]
|
||||
│ │ ├─ marker = [ ]
|
||||
│ │ ├─ flags = 0
|
||||
│ │ ╰─ t_token_type = OPEN_PARENTH_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [)]
|
||||
│ │ ├─ marker = [ ]
|
||||
│ │ ├─ flags = 0
|
||||
│ │ ╰─ t_token_type = CLOSE_PARENTH_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [||]
|
||||
│ │ ├─ marker = [ ]
|
||||
│ │ ├─ flags = 0
|
||||
│ │ ╰─ t_token_type = OR_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [|]
|
||||
│ │ ├─ marker = [ ]
|
||||
│ │ ├─ flags = 0
|
||||
│ │ ╰─ t_token_type = PIPE_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [&&]
|
||||
│ │ ├─ marker = [ ]
|
||||
│ │ ├─ flags = 0
|
||||
│ │ ╰─ t_token_type = AND_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [>>]
|
||||
│ │ ├─ marker = [ ]
|
||||
│ │ ├─ flags = 0
|
||||
│ │ ╰─ t_token_type = OUT_APPEND_REDIR_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [>]
|
||||
│ │ ├─ marker = [ ]
|
||||
│ │ ├─ flags = 0
|
||||
│ │ ╰─ t_token_type = OUT_TRUNC_REDIR_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [<<]
|
||||
│ │ ├─ marker = [ ]
|
||||
│ │ ├─ flags = 0
|
||||
│ │ ╰─ t_token_type = HERE_DOC_REDIR_TOKEN
|
||||
│ ╰─ t_worddesc
|
||||
│ ├─ word = [<]
|
||||
│ ├─ marker = [ ]
|
||||
│ ├─ flags = 0
|
||||
│ ╰─ t_token_type = IN_REDIR_TOKEN
|
||||
╰─ redirections = (empty redir list)
|
||||
EOF
|
||||
|
||||
when_run <<EOF "token type attribution is correct when tokens are double-quoted"
|
||||
.debug
|
||||
.exec
|
||||
"(" ")" "|" "||" "&&" ">" ">>" "<" "<<"
|
||||
EOF
|
||||
expecting <<EOF
|
||||
[dbg: 1]
|
||||
[exec: 0]
|
||||
╰─ t_simple_cmd
|
||||
├─ line = 0
|
||||
├─ t_wordlist
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ["("]
|
||||
│ │ ├─ marker = [ " ]
|
||||
│ │ ├─ flags = 34
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [")"]
|
||||
│ │ ├─ marker = [ " ]
|
||||
│ │ ├─ flags = 34
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ["|"]
|
||||
│ │ ├─ marker = [ " ]
|
||||
│ │ ├─ flags = 34
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ["||"]
|
||||
│ │ ├─ marker = [ "" ]
|
||||
│ │ ├─ flags = 34
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ["&&"]
|
||||
│ │ ├─ marker = [ "" ]
|
||||
│ │ ├─ flags = 34
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [">"]
|
||||
│ │ ├─ marker = [ " ]
|
||||
│ │ ├─ flags = 34
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [">>"]
|
||||
│ │ ├─ marker = [ "" ]
|
||||
│ │ ├─ flags = 34
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ["<"]
|
||||
│ │ ├─ marker = [ " ]
|
||||
│ │ ├─ flags = 34
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ╰─ t_worddesc
|
||||
│ ├─ word = ["<<"]
|
||||
│ ├─ marker = [ "" ]
|
||||
│ ├─ flags = 34
|
||||
│ ╰─ t_token_type = WORD_TOKEN
|
||||
╰─ redirections = (empty redir list)
|
||||
EOF
|
||||
|
||||
when_run <<EOF "token type attribution is correct when tokens are single-quoted"
|
||||
.debug
|
||||
.exec
|
||||
'(' ')' '|' '||' '&&' '>' '>>' '<' '<<'
|
||||
EOF
|
||||
expecting <<EOF
|
||||
[dbg: 1]
|
||||
[exec: 0]
|
||||
╰─ t_simple_cmd
|
||||
├─ line = 0
|
||||
├─ t_wordlist
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ['(']
|
||||
│ │ ├─ marker = [ ' ]
|
||||
│ │ ├─ flags = 2
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = [')']
|
||||
│ │ ├─ marker = [ ' ]
|
||||
│ │ ├─ flags = 2
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ['|']
|
||||
│ │ ├─ marker = [ ' ]
|
||||
│ │ ├─ flags = 2
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ['||']
|
||||
│ │ ├─ marker = [ '' ]
|
||||
│ │ ├─ flags = 2
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ['&&']
|
||||
│ │ ├─ marker = [ '' ]
|
||||
│ │ ├─ flags = 2
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ['>']
|
||||
│ │ ├─ marker = [ ' ]
|
||||
│ │ ├─ flags = 2
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ['>>']
|
||||
│ │ ├─ marker = [ '' ]
|
||||
│ │ ├─ flags = 2
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ├─ t_worddesc
|
||||
│ │ ├─ word = ['<']
|
||||
│ │ ├─ marker = [ ' ]
|
||||
│ │ ├─ flags = 2
|
||||
│ │ ╰─ t_token_type = WORD_TOKEN
|
||||
│ ╰─ t_worddesc
|
||||
│ ├─ word = ['<<']
|
||||
│ ├─ marker = [ '' ]
|
||||
│ ├─ flags = 2
|
||||
│ ╰─ t_token_type = WORD_TOKEN
|
||||
╰─ redirections = (empty redir list)
|
||||
EOF
|
||||
|
||||
finalize
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue