Project

General

Profile

Feature #4513

allow whitespace following EOL continuation backslash

Added by Rich_Morin (Rich Morin) about 7 years ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:<unknown>]

Description

In a few programming languages, the displayed or printed program can hide
critical syntactic and/or semantic information. For example, in make(1)
and Python, the difference between initial tabs and spaces can cause bugs
that are not visually apparent.

Ruby has a minor instance of this problem, in that spaces or tabs
between a backslash and the EOL will prevent the line from being continued:

 >> a \
 ?> = 2
 => 2
 >> b \ 
 SyntaxError: compile error
 (irb):3: syntax error, unexpected $undefined, expecting $end
    from (irb):3

Could Ruby open up its syntax to allow any number of intervening spaces or tabs before the EOL?


Related issues

Related to Ruby trunk - Bug #14597: Ripper Issue - introduced between 62674 & 62681Closed

Associated revisions

Revision 62178
Added by nobu (Nobuyoshi Nakada) 3 months ago

parse.y: named backslash

  • parse.y: named backslash to show unexpected character.

Revision 62663
Added by nobu (Nobuyoshi Nakada) about 2 months ago

parse.y: named whitespaces

  • parse.y: named escaped whitespaces to show unexpected character. bare whitespaces should not appear outside of word_list.

Revision 62675
Added by nobu (Nobuyoshi Nakada) about 2 months ago

parse.y: tSPACE for old bison

  • parse.y (tSPACE): define a separate token for escaped space, to fix redefining user token number of ' ' error at word list separator on bison 2.

History

#1 [ruby-core:43441] Updated by nahi (Hiroshi Nakamura) about 6 years ago

  • Description updated (diff)
  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

Regardless it's acceptable or not, we want to check nobu's local patches first. Don't you have that?

#2 [ruby-core:49706] Updated by mame (Yusuke Endoh) over 5 years ago

  • Target version set to 2.6

#3 [ruby-core:51137] Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Priority changed from Normal to 3

It is easy to change, but I doubt if it is useful.

#4 Updated by naruse (Yui NARUSE) 4 months ago

  • Target version deleted (2.6)

#5 [ruby-core:85679] Updated by nobu (Nobuyoshi Nakada) 2 months ago

  • Description updated (diff)

Warning for a backslash followed by spaces is:

Old:

$ ruby2.5 -e ' \ '
-e:1: syntax error, unexpected $undefined

Now:

$ ruby -e ' \ '
-e:1: syntax error, unexpected backslash

Does this help you?

#6 Updated by nobu (Nobuyoshi Nakada) 2 months ago

  • Status changed from Assigned to Feedback

#7 Updated by nobu (Nobuyoshi Nakada) about 1 month ago

  • Related to Bug #14597: Ripper Issue - introduced between 62674 & 62681 added

#8 [ruby-core:86292] Updated by nobu (Nobuyoshi Nakada) about 1 month ago

  • Status changed from Feedback to Closed

Now:

$ ruby -e ' \ '
-e:1: syntax error, unexpected escaped space

Close this for now.

#9 Updated by nobu (Nobuyoshi Nakada) about 1 month ago

  • Description updated (diff)

Also available in: Atom PDF