From acdb35cc275cda27a5db6c71d7972bb2d2e9c816 Mon Sep 17 00:00:00 2001 From: Niols Date: Mon, 19 Jun 2023 01:31:18 +0200 Subject: [PATCH 1/5] Get rid of assignment words in `word_cst`s --- src/CST.mli | 1 - src/CSTHelpers.ml | 4 ++-- src/assignment.ml | 41 ++++++++++++++++++++++++++++------------- src/engine.ml | 2 +- src/prelexerState.ml | 42 ------------------------------------------ 5 files changed, 31 insertions(+), 59 deletions(-) diff --git a/src/CST.mli b/src/CST.mli index e0bfe67..9674630 100644 --- a/src/CST.mli +++ b/src/CST.mli @@ -319,7 +319,6 @@ and word_cst = word_component list and word_component = | WordSubshell of subshell_kind * program located | WordName of string - | WordAssignmentWord of assignment_word | WordDoubleQuoted of word | WordSingleQuoted of word | WordTildePrefix of string diff --git a/src/CSTHelpers.ml b/src/CSTHelpers.ml index 52a8615..2f08e35 100644 --- a/src/CSTHelpers.ml +++ b/src/CSTHelpers.ml @@ -139,8 +139,8 @@ let unName (Name s) = s let word_of_name (Name w) = Word (w, [WordName w]) -let word_of_assignment_word (Name n, (Word (s, _) as w)) = - Word (n ^ "=" ^ s, [WordAssignmentWord (Name n, w)]) +let word_of_assignment_word (Name name, Word (word_str, word_cst)) = + Word (name ^ "=" ^ word_str, WordLiteral (name ^ "=") :: word_cst) let string_of_word (Word (s, _)) = s diff --git a/src/assignment.ml b/src/assignment.ml index e1f0a8b..15f03b5 100644 --- a/src/assignment.ml +++ b/src/assignment.ml @@ -41,18 +41,33 @@ open Name *) -let recognize_assignment checkpoint pretoken word_cst = FirstSuccessMonad.( +let recognize_assignment checkpoint pretoken (Word (word_str, word_cst)) = + FirstSuccessMonad.( match word_cst with - | [WordAssignmentWord ((Name n) as name, w)] -> - if is_name n then - let (_, pstart, pstop) = pretoken in - let token = ASSIGNMENT_WORD (name, w) in - if accepted_token checkpoint (token, pstart, pstop) <> Wrong then - return token - else - fail - else - fail - | _ -> - fail + | WordLiteral literal :: word_cst_leftover -> + ( + match String.index_opt literal '=' with + | None | Some 0 -> fail + | Some i -> + let name = String.sub literal 0 i in + if is_name name then + let (_, pstart, pstop) = pretoken in + let literal_leftover = String.sub literal (i + 1) (String.length literal - i - 1) in + let word_str_leftover = String.sub word_str (i + 1) (String.length word_str - i - 1) in + let word_cst = + if literal_leftover = "" then + word_cst_leftover + else + WordLiteral literal_leftover :: word_cst_leftover + in + let word = Word (word_str_leftover, word_cst) in + let token = ASSIGNMENT_WORD (Name name, word) in + if accepted_token checkpoint (token, pstart, pstop) <> Wrong then + return token + else + fail + else + fail + ) + | _ -> fail ) diff --git a/src/engine.ml b/src/engine.ml index 4eecb8e..8c1af25 100644 --- a/src/engine.ml +++ b/src/engine.ml @@ -336,7 +336,7 @@ module Lexer (U : sig end) : Lexer = struct | _ -> false in let token = FirstSuccessMonad.( - (recognize_assignment checkpoint p cst) + (recognize_assignment checkpoint p (Word (w0, cst))) +> (recognize_reserved_word_if_relevant well_delimited_keyword checkpoint p w) +> return word diff --git a/src/prelexerState.ml b/src/prelexerState.ml index 60b1032..a22f178 100644 --- a/src/prelexerState.ml +++ b/src/prelexerState.ml @@ -287,46 +287,6 @@ let is_assignment_mark = function | AssignmentMark -> true | _ -> false -let recognize_assignment current = - let rhs, prefix = take_until is_assignment_mark (buffer current) in - if prefix = buffer current then ( - current - ) else - let buffer = AtomBuffer.make (rhs @ List.tl prefix) in - let current' = { current with buffer } in - match prefix with - | AssignmentMark :: WordComponent (s, _) :: prefix -> - assert (s.[String.length s - 1] = '='); (* By after_equal unique call. *) - (* [s] is a valid name. We have an assignment here. *) - let lhs = try String.(sub s 0 (length s - 1)) with _ -> assert false in - - (* FIXME: The following check could be done directly with - ocamllex rules, right?*) - - if Name.is_name lhs then ( - let rhs_string = contents_of_atom_list rhs in - let crhs = components_of_atom_list rhs in - let cst = WordComponent ( - s ^ rhs_string, - WordAssignmentWord (Name lhs, Word (rhs_string, crhs))) - in - let buffer = AtomBuffer.make (cst :: prefix) in - { current with buffer } - ) else - (* - If [lhs] is not a name, then the corresponding word - literal must be merged with the preceding one, if it exists. - *) ( - begin match List.rev rhs with - | WordComponent (s_rhs, WordLiteral s_rhs') :: rev_rhs -> - let word = WordComponent (s ^ s_rhs, WordLiteral (s ^ s_rhs')) in - let buffer = AtomBuffer.make (List.rev rev_rhs @ word :: prefix) in - { current with buffer } - | _ -> - current' - end) - | _ -> current' - (** [(return ?with_newline lexbuf current tokens)] returns a list of pretokens consisting of, in that order: @@ -349,8 +309,6 @@ let return ?(with_newline=false) lexbuf (current : prelexer_state) tokens = not (List.exists (function (Pretoken.PreWord _)->true |_-> false) tokens) ); - let current = recognize_assignment current in - let flush_word b = let buf = Buffer.create 13 in List.iter (function WordComponent (s, _) -> Buffer.add_string buf s From e2b0d8130c73fc8c0469dd35f654799146409c4c Mon Sep 17 00:00:00 2001 From: Niols Date: Sun, 18 Jun 2023 21:14:31 +0200 Subject: [PATCH 2/5] Move `merge_leading_literals` to `CSTHelpers` --- src/CSTHelpers.ml | 14 ++++++++++++++ src/CSTHelpers.mli | 3 +++ src/tildePrefix.ml | 17 +---------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/CSTHelpers.ml b/src/CSTHelpers.ml index 2f08e35..b29529c 100644 --- a/src/CSTHelpers.ml +++ b/src/CSTHelpers.ml @@ -230,3 +230,17 @@ let io_redirect_list_of_simple_command = function io_redirect_list_of_cmd_suffix cmd_suffix'.value | SimpleCommand_CmdName _ -> [] + +let merge_leading_literals = + let buf = Buffer.create 80 in + let rec extract_leading_literals = function + | WordLiteral lit :: rest -> + Buffer.add_string buf lit; + extract_leading_literals rest + | rest -> rest + in + fun word -> + let rest = extract_leading_literals word in + let lit = Buffer.contents buf in + Buffer.reset buf; + if lit = "" then word else WordLiteral lit :: rest diff --git a/src/CSTHelpers.mli b/src/CSTHelpers.mli index 28e0fa2..e5d8388 100644 --- a/src/CSTHelpers.mli +++ b/src/CSTHelpers.mli @@ -71,3 +71,6 @@ val io_redirect_list_of_cmd_prefix : cmd_prefix -> io_redirect' list val io_redirect_list_of_cmd_suffix : cmd_suffix -> io_redirect' list val io_redirect_list_of_simple_command : simple_command -> io_redirect' list val io_redirect_list_of_redirect_list : redirect_list -> io_redirect' list + +(** Merges several leading [WordLiteral] into one. *) +val merge_leading_literals : word_cst -> word_cst diff --git a/src/tildePrefix.ml b/src/tildePrefix.ml index 7d75b65..aa0c4df 100644 --- a/src/tildePrefix.ml +++ b/src/tildePrefix.ml @@ -61,25 +61,10 @@ let extract_tilde_prefix_from_literal (literal : string) : word_cst = let (first, rest) = ExtPervasives.string_split i literal in [WordTildePrefix (strip_tilde first); WordLiteral rest] -(** Merges several leading [WordLiteral] into one. *) -let merge_leading_literals : word_cst -> word_cst = - let buf = Buffer.create 80 in - let rec extract_leading_literals = function - | WordLiteral lit :: rest -> - Buffer.add_string buf lit; - extract_leading_literals rest - | rest -> rest - in - fun word -> - let rest = extract_leading_literals word in - let lit = Buffer.contents buf in - Buffer.reset buf; - if lit = "" then word else WordLiteral lit :: rest - (** Extracts the tilde-prefix at the beginning of the given word CST if there is one. Otherwise, returns the word as-is. *) let extract_tilde_prefix_from_word_if_present (word : word_cst) : word_cst = - match merge_leading_literals word with + match CSTHelpers.merge_leading_literals word with | WordLiteral literal :: word when starts_with_tilde literal -> extract_tilde_prefix_from_literal literal @ word | word -> word From 325ba8b4d51f758b6375f7aaccf51b11a20ebb0d Mon Sep 17 00:00:00 2001 From: Niols Date: Sun, 18 Jun 2023 23:56:01 +0200 Subject: [PATCH 3/5] Make `TildePrefix.recognize` aware of its surroundings --- src/prelexerState.ml | 4 ++-- src/tildePrefix.ml | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/prelexerState.ml b/src/prelexerState.ml index a22f178..d396b0f 100644 --- a/src/prelexerState.ml +++ b/src/prelexerState.ml @@ -188,7 +188,7 @@ let string_of_word (Word (s, _)) = s let string_of_attribute = function | NoAttribute -> "" - | ParameterLength -> "#" + | ParameterLength -> "#" | UseDefaultValues (p, w) -> p ^ string_of_word w | AssignDefaultValues (p, w) -> p ^ string_of_word w | IndicateErrorifNullorUnset (p, w) -> p ^ string_of_word w @@ -366,7 +366,7 @@ let return ?(with_newline=false) lexbuf (current : prelexer_state) tokens = | QuotingMark _ -> [] ) (buffer current))) in - let csts = TildePrefix.recognize csts in + let csts = TildePrefix.recognize ~in_assignment:false csts in (* FIXME: sometimes should be true *) [Pretoken.PreWord (w, csts)] in let tokens = if with_newline then tokens @ [Pretoken.NEWLINE] else tokens in diff --git a/src/tildePrefix.ml b/src/tildePrefix.ml index aa0c4df..162e239 100644 --- a/src/tildePrefix.ml +++ b/src/tildePrefix.ml @@ -121,12 +121,10 @@ let rec concat_words_with_colon (words : word_cst list) : word_cst = (** Recognises tilde prefixes in a word, that is recognises eg. [WordLiteral "~foo"] and replaces it by [WordTildePrefix "foo"] when in the right position. *) -let recognize (word : word_cst) = - match word with - | [WordAssignmentWord (name, Word (s, word))] -> +let recognize ~in_assignment (word : word_cst) = + if in_assignment then let words = split_word_on_colon word in let words = List.map extract_tilde_prefix_from_word_if_present words in - let word = concat_words_with_colon words in - [WordAssignmentWord (name, Word (s, word))] - | _ -> + concat_words_with_colon words + else extract_tilde_prefix_from_word_if_present word From cfa009d41c829fdb1b02ef0017a402ba08db2168 Mon Sep 17 00:00:00 2001 From: Niols Date: Mon, 19 Jun 2023 01:37:31 +0200 Subject: [PATCH 4/5] Re-recognize tilde-prefixes in assignment words --- src/assignment.ml | 3 +++ src/prelexerState.ml | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/assignment.ml b/src/assignment.ml index 15f03b5..88369fc 100644 --- a/src/assignment.ml +++ b/src/assignment.ml @@ -60,6 +60,9 @@ let recognize_assignment checkpoint pretoken (Word (word_str, word_cst)) = else WordLiteral literal_leftover :: word_cst_leftover in + (* Now that we know we're in an assignment, we know there are + potentially more tilde prefixes to recognize. *) + let word_cst = TildePrefix.recognize ~in_assignment:true word_cst in let word = Word (word_str_leftover, word_cst) in let token = ASSIGNMENT_WORD (Name name, word) in if accepted_token checkpoint (token, pstart, pstop) <> Wrong then diff --git a/src/prelexerState.ml b/src/prelexerState.ml index d396b0f..a0c26d0 100644 --- a/src/prelexerState.ml +++ b/src/prelexerState.ml @@ -366,7 +366,9 @@ let return ?(with_newline=false) lexbuf (current : prelexer_state) tokens = | QuotingMark _ -> [] ) (buffer current))) in - let csts = TildePrefix.recognize ~in_assignment:false csts in (* FIXME: sometimes should be true *) + (* At this point, we cannot say whether this will be an assignment word, + so we do a minimal tilde prefixes recognition. *) + let csts = TildePrefix.recognize ~in_assignment:false csts in [Pretoken.PreWord (w, csts)] in let tokens = if with_newline then tokens @ [Pretoken.NEWLINE] else tokens in From a52431cd6ff4055174ea7bdb7b4f5bc85617cc19 Mon Sep 17 00:00:00 2001 From: Niols Date: Mon, 19 Jun 2023 02:01:04 +0200 Subject: [PATCH 5/5] Fix expectations of corresponding tests --- .../alias-alias.t/expected.json | 38 +---- .../alias-commands-words-only.t/expected.json | 19 +-- .../alias-cycle.t/expected.json | 29 +--- .../alias-mixed-arguments.t/expected.json | 76 +-------- .../alias-multiple-arguments.t/expected.json | 57 +------ .../expected.json | 58 ++----- .../toplevel-alias.t/expected.json | 19 +-- .../toplevel-unalias.t/expected.json | 29 +--- .../unalias-a.t/expected.json | 38 +---- .../expected.json | 38 +---- .../2.6.1-tilde-prefix/login.t/expected.json | 160 +----------------- .../assignment-words.t/expected.json | 19 +-- .../expected.json | 19 +-- .../good/assignment-empty.t/expected.json | 17 +- .../good/assignment-eof.t/expected.json | 19 +-- 15 files changed, 89 insertions(+), 546 deletions(-) diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-alias.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-alias.t/expected.json index be5daab..2e093a7 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-alias.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-alias.t/expected.json @@ -43,23 +43,8 @@ "rename=alias", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "rename" - ], - [ - "Word", - "alias", - [ - [ - "WordLiteral", - "alias" - ] - ] - ] - ] + "WordLiteral", + "rename=alias" ] ] ] @@ -109,23 +94,8 @@ "time=date", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "time" - ], - [ - "Word", - "date", - [ - [ - "WordLiteral", - "date" - ] - ] - ] - ] + "WordLiteral", + "time=date" ] ] ] diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-commands-words-only.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-commands-words-only.t/expected.json index c8e0f16..b8e985d 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-commands-words-only.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-commands-words-only.t/expected.json @@ -41,23 +41,8 @@ "show=echo", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "show" - ], - [ - "Word", - "echo", - [ - [ - "WordLiteral", - "echo" - ] - ] - ] - ] + "WordLiteral", + "show=echo" ] ] ] diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-cycle.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-cycle.t/expected.json index 282ecbd..e4727db 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-cycle.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-cycle.t/expected.json @@ -41,29 +41,18 @@ "ls='ls -h -t -l'", [ [ - "WordAssignmentWord", + "WordLiteral", + "ls=" + ], + [ + "WordSingleQuoted", [ + "Word", + "ls -h -t -l", [ - "Name", - "ls" - ], - [ - "Word", - "'ls -h -t -l'", [ - [ - "WordSingleQuoted", - [ - "Word", - "ls -h -t -l", - [ - [ - "WordLiteral", - "ls -h -t -l" - ] - ] - ] - ] + "WordLiteral", + "ls -h -t -l" ] ] ] diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-mixed-arguments.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-mixed-arguments.t/expected.json index 29d0bc8..1825339 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-mixed-arguments.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-mixed-arguments.t/expected.json @@ -45,23 +45,8 @@ "titi=TITI", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "titi" - ], - [ - "Word", - "TITI", - [ - [ - "WordLiteral", - "TITI" - ] - ] - ] - ] + "WordLiteral", + "titi=TITI" ] ] ] @@ -71,23 +56,8 @@ "toto=TOTO", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "toto" - ], - [ - "Word", - "TOTO", - [ - [ - "WordLiteral", - "TOTO" - ] - ] - ] - ] + "WordLiteral", + "toto=TOTO" ] ] ] @@ -143,23 +113,8 @@ "tata=TATA", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "tata" - ], - [ - "Word", - "TATA", - [ - [ - "WordLiteral", - "TATA" - ] - ] - ] - ] + "WordLiteral", + "tata=TATA" ] ] ] @@ -180,23 +135,8 @@ "tutu=TUTU", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "tutu" - ], - [ - "Word", - "TUTU", - [ - [ - "WordLiteral", - "TUTU" - ] - ] - ] - ] + "WordLiteral", + "tutu=TUTU" ] ] ] diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-multiple-arguments.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-multiple-arguments.t/expected.json index 720eeec..c7c330e 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-multiple-arguments.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-multiple-arguments.t/expected.json @@ -47,23 +47,8 @@ "show=echo", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "show" - ], - [ - "Word", - "echo", - [ - [ - "WordLiteral", - "echo" - ] - ] - ] - ] + "WordLiteral", + "show=echo" ] ] ] @@ -73,23 +58,8 @@ "list=ls", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "list" - ], - [ - "Word", - "ls", - [ - [ - "WordLiteral", - "ls" - ] - ] - ] - ] + "WordLiteral", + "list=ls" ] ] ] @@ -99,23 +69,8 @@ "coocoo=kiki", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "coocoo" - ], - [ - "Word", - "kiki", - [ - [ - "WordLiteral", - "kiki" - ] - ] - ] - ] + "WordLiteral", + "coocoo=kiki" ] ] ] diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-with-final-whitespace.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-with-final-whitespace.t/expected.json index b851b91..42f9229 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-with-final-whitespace.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/alias-with-final-whitespace.t/expected.json @@ -51,29 +51,18 @@ "x='echo '", [ [ - "WordAssignmentWord", + "WordLiteral", + "x=" + ], + [ + "WordSingleQuoted", [ + "Word", + "echo ", [ - "Name", - "x" - ], - [ - "Word", - "'echo '", [ - [ - "WordSingleQuoted", - [ - "Word", - "echo ", - [ - [ - "WordLiteral", - "echo " - ] - ] - ] - ] + "WordLiteral", + "echo " ] ] ] @@ -126,29 +115,18 @@ "z='a '", [ [ - "WordAssignmentWord", + "WordLiteral", + "z=" + ], + [ + "WordSingleQuoted", [ + "Word", + "a ", [ - "Name", - "z" - ], - [ - "Word", - "'a '", [ - [ - "WordSingleQuoted", - [ - "Word", - "a ", - [ - [ - "WordLiteral", - "a " - ] - ] - ] - ] + "WordLiteral", + "a " ] ] ] diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/toplevel-alias.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/toplevel-alias.t/expected.json index e3d7aba..e690e32 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/toplevel-alias.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/toplevel-alias.t/expected.json @@ -41,23 +41,8 @@ "foo=for", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "foo" - ], - [ - "Word", - "for", - [ - [ - "WordLiteral", - "for" - ] - ] - ] - ] + "WordLiteral", + "foo=for" ] ] ] diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/toplevel-unalias.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/toplevel-unalias.t/expected.json index d8b65c8..5eb2844 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/toplevel-unalias.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/toplevel-unalias.t/expected.json @@ -45,29 +45,18 @@ "foo='ls -l'", [ [ - "WordAssignmentWord", + "WordLiteral", + "foo=" + ], + [ + "WordSingleQuoted", [ + "Word", + "ls -l", [ - "Name", - "foo" - ], - [ - "Word", - "'ls -l'", [ - [ - "WordSingleQuoted", - [ - "Word", - "ls -l", - [ - [ - "WordLiteral", - "ls -l" - ] - ] - ] - ] + "WordLiteral", + "ls -l" ] ] ] diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/unalias-a.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/unalias-a.t/expected.json index cc6b409..4669fea 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/unalias-a.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/unalias-a.t/expected.json @@ -47,23 +47,8 @@ "tata=TATA", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "tata" - ], - [ - "Word", - "TATA", - [ - [ - "WordLiteral", - "TATA" - ] - ] - ] - ] + "WordLiteral", + "tata=TATA" ] ] ] @@ -73,23 +58,8 @@ "titi=TITI", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "titi" - ], - [ - "Word", - "TITI", - [ - [ - "WordLiteral", - "TITI" - ] - ] - ] - ] + "WordLiteral", + "titi=TITI" ] ] ] diff --git a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/unalias-multiple-arguments.t/expected.json b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/unalias-multiple-arguments.t/expected.json index 9409c44..ea4a49f 100644 --- a/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/unalias-multiple-arguments.t/expected.json +++ b/tests/golden/good/2.3-token-recognition/2.3.1-alias-substitution/unalias-multiple-arguments.t/expected.json @@ -45,23 +45,8 @@ "show=echo", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "show" - ], - [ - "Word", - "echo", - [ - [ - "WordLiteral", - "echo" - ] - ] - ] - ] + "WordLiteral", + "show=echo" ] ] ] @@ -111,23 +96,8 @@ "list=ls", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "list" - ], - [ - "Word", - "ls", - [ - [ - "WordLiteral", - "ls" - ] - ] - ] - ] + "WordLiteral", + "list=ls" ] ] ] diff --git a/tests/golden/good/2.6-word-expansions/2.6.1-tilde-prefix/login.t/expected.json b/tests/golden/good/2.6-word-expansions/2.6.1-tilde-prefix/login.t/expected.json index c42bc96..db92714 100644 --- a/tests/golden/good/2.6-word-expansions/2.6.1-tilde-prefix/login.t/expected.json +++ b/tests/golden/good/2.6-word-expansions/2.6.1-tilde-prefix/login.t/expected.json @@ -537,27 +537,8 @@ "W=~knuth/foo/bar", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "W" - ], - [ - "Word", - "~knuth/foo/bar", - [ - [ - "WordTildePrefix", - "knuth" - ], - [ - "WordLiteral", - "/foo/bar" - ] - ] - ] - ] + "WordLiteral", + "W=~knuth/foo/bar" ] ] ] @@ -607,47 +588,8 @@ "X=~kn:~/bin:~darkvador/secret", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "X" - ], - [ - "Word", - "~kn:~/bin:~darkvador/secret", - [ - [ - "WordTildePrefix", - "kn" - ], - [ - "WordLiteral", - ":" - ], - [ - "WordTildePrefix", - "" - ], - [ - "WordLiteral", - "/bin" - ], - [ - "WordLiteral", - ":" - ], - [ - "WordTildePrefix", - "darkvador" - ], - [ - "WordLiteral", - "/secret" - ] - ] - ] - ] + "WordLiteral", + "X=~kn:~/bin:~darkvador/secret" ] ] ] @@ -697,51 +639,8 @@ "Y=~kn:/bonjour:~/bonsoir:and/this/one", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "Y" - ], - [ - "Word", - "~kn:/bonjour:~/bonsoir:and/this/one", - [ - [ - "WordTildePrefix", - "kn" - ], - [ - "WordLiteral", - ":" - ], - [ - "WordLiteral", - "/bonjour" - ], - [ - "WordLiteral", - ":" - ], - [ - "WordTildePrefix", - "" - ], - [ - "WordLiteral", - "/bonsoir" - ], - [ - "WordLiteral", - ":" - ], - [ - "WordLiteral", - "and/this/one" - ] - ] - ] - ] + "WordLiteral", + "Y=~kn:/bonjour:~/bonsoir:and/this/one" ] ] ] @@ -791,51 +690,8 @@ "Z=/bonjour:~kn:~/bonsoir:and/this/one", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "Z" - ], - [ - "Word", - "/bonjour:~kn:~/bonsoir:and/this/one", - [ - [ - "WordLiteral", - "/bonjour" - ], - [ - "WordLiteral", - ":" - ], - [ - "WordTildePrefix", - "kn" - ], - [ - "WordLiteral", - ":" - ], - [ - "WordTildePrefix", - "" - ], - [ - "WordLiteral", - "/bonsoir" - ], - [ - "WordLiteral", - ":" - ], - [ - "WordLiteral", - "and/this/one" - ] - ] - ] - ] + "WordLiteral", + "Z=/bonjour:~kn:~/bonsoir:and/this/one" ] ] ] diff --git a/tests/golden/good/2.9-shell-commands/2.9.1-simple-commands/assignment-words.t/expected.json b/tests/golden/good/2.9-shell-commands/2.9.1-simple-commands/assignment-words.t/expected.json index 68e6513..a7afd56 100644 --- a/tests/golden/good/2.9-shell-commands/2.9.1-simple-commands/assignment-words.t/expected.json +++ b/tests/golden/good/2.9-shell-commands/2.9.1-simple-commands/assignment-words.t/expected.json @@ -102,23 +102,8 @@ "CC=cc", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "CC" - ], - [ - "Word", - "cc", - [ - [ - "WordLiteral", - "cc" - ] - ] - ] - ] + "WordLiteral", + "CC=cc" ] ] ] diff --git a/tests/golden/good/2.9-shell-commands/2.9.4-compound-commands/for/for-assignment-in-wordlist.t/expected.json b/tests/golden/good/2.9-shell-commands/2.9.4-compound-commands/for/for-assignment-in-wordlist.t/expected.json index 382f1c8..18df045 100644 --- a/tests/golden/good/2.9-shell-commands/2.9.4-compound-commands/for/for-assignment-in-wordlist.t/expected.json +++ b/tests/golden/good/2.9-shell-commands/2.9.4-compound-commands/for/for-assignment-in-wordlist.t/expected.json @@ -35,23 +35,8 @@ "BOOT_START=start_on_boot", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "BOOT_START" - ], - [ - "Word", - "start_on_boot", - [ - [ - "WordLiteral", - "start_on_boot" - ] - ] - ] - ] + "WordLiteral", + "BOOT_START=start_on_boot" ] ] ] diff --git a/tests/golden/good/assignment-empty.t/expected.json b/tests/golden/good/assignment-empty.t/expected.json index 34376dd..bfa5d6f 100644 --- a/tests/golden/good/assignment-empty.t/expected.json +++ b/tests/golden/good/assignment-empty.t/expected.json @@ -18,17 +18,18 @@ [ "Command_SimpleCommand", [ - "SimpleCommand_CmdName", + "SimpleCommand_CmdPrefix", [ - "CmdName_Word", + "CmdPrefix_AssignmentWord", [ - "Word", - "A=", [ - [ - "WordLiteral", - "A=" - ] + "Name", + "A" + ], + [ + "Word", + "", + [] ] ] ] diff --git a/tests/golden/good/assignment-eof.t/expected.json b/tests/golden/good/assignment-eof.t/expected.json index 07d03e5..f14e2bb 100644 --- a/tests/golden/good/assignment-eof.t/expected.json +++ b/tests/golden/good/assignment-eof.t/expected.json @@ -39,23 +39,8 @@ "b=c", [ [ - "WordAssignmentWord", - [ - [ - "Name", - "b" - ], - [ - "Word", - "c", - [ - [ - "WordLiteral", - "c" - ] - ] - ] - ] + "WordLiteral", + "b=c" ] ] ]