From cfa009d41c829fdb1b02ef0017a402ba08db2168 Mon Sep 17 00:00:00 2001 From: Niols Date: Mon, 19 Jun 2023 01:37:31 +0200 Subject: [PATCH] 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