Skip to content

Commit

Permalink
Re-recognize tilde-prefixes in assignment words
Browse files Browse the repository at this point in the history
  • Loading branch information
Niols committed Sep 17, 2023
1 parent 325ba8b commit cfa009d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/assignment.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/prelexerState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cfa009d

Please sign in to comment.