Skip to content

Commit

Permalink
Move back lex buffer if double brace is not meaningful
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Jun 14, 2022
1 parent 9bac8a7 commit 5d4a3d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Compiler/Facilities/prim-lexing.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ type internal LexBuffer<'Char> =
member LexemeContains: 'Char -> bool

/// The length of the lexeme.
member LexemeLength: int
member LexemeLength: int with get, set

/// Fast helper to turn the matched characters into a string, avoiding an intermediate array.
static member LexemeString: LexBuffer<char> -> string
Expand Down
6 changes: 6 additions & 0 deletions src/Compiler/lex.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,9 @@ rule token args skip = parse
// Note, we do not update the 'm', any incomplete-interpolation error
// will be reported w.r.t. the first '{'
args.stringNest <- (counter + 1, style, isDoubleDollar, m) :: rest
| _ when isDouble ->
lexbuf.LexemeLength <- 1
lexbuf.EndPos <- lexbuf.EndPos.ShiftColumnBy -1
| _ -> ()
// To continue token-by-token lexing may involve picking up the new args.stringNes
let cont = LexCont.Token(args.ifdefStack, args.stringNest)
Expand Down Expand Up @@ -887,6 +890,9 @@ rule token args skip = parse
RBRACE cont

| _ ->
if isDouble then
lexbuf.LexemeLength <- 1
lexbuf.EndPos <- lexbuf.EndPos.ShiftColumnBy -1
let cont = LexCont.Token(args.ifdefStack, args.stringNest)
RBRACE cont
}
Expand Down

0 comments on commit 5d4a3d7

Please sign in to comment.