~andyc/oil

bd2b0712ce6defbfa8d264737640a2ec7a71104d — Andy Chu a month ago 61e0769
[oil-language] Explicitly disallow #'''

It should be written \' instead.
2 files changed, 16 insertions(+), 2 deletions(-)

M frontend/lexer_def.py
M spec/oil-expr.test.sh
M frontend/lexer_def.py => frontend/lexer_def.py +3 -2
@@ 511,10 511,11 @@ EXPR_CHARS = [

  R(r'\\x[0-9a-fA-F]{2}', Id.Char_Hex),

  # Because 'a' is a string, we use the syntax #'a' for char literals
  # Because 'a' is a string, we use the syntax #'a' for char literals.
  # We explicitly leave out #''' because it's confusing.
  # TODO: extend this to a valid utf-8 code point (rune), rather than a single
  # byte.
  R(r"#'.'", Id.Char_Pound),
  R(r"#'[^']'", Id.Char_Pound),
  _U_BRACED_CHAR,
] 


M spec/oil-expr.test.sh => spec/oil-expr.test.sh +13 -0
@@ 362,6 362,19 @@ echo "$a $A"
97 65
## END

#### The literal #''' isn't accepted (use \' instead)

# This looks too much like triple quoted strings!

echo nope
const bad = #'''
echo "$bad"

## status: 2
## STDOUT:
nope
## END

#### Float Literals
shopt -s oil:basic
# 1+2 2.3