Normalize :: syntax (#5048)

* normalize :: syntax

* fixes from code review
This commit is contained in:
Julian Rosse 2018-05-13 15:41:43 -04:00 committed by Geoffrey Booth
parent 7dbdca8c54
commit 41185ca7ac
7 changed files with 181 additions and 156 deletions

View File

@ -603,6 +603,11 @@
function() {
return new Access(new PropertyName('prototype'));
}),
o('?::',
function() {
return new Access(new PropertyName('prototype'),
'soak');
}),
o('Index')
],
// Indexing into an object or array using bracket notation.

View File

@ -1634,7 +1634,7 @@
// Other regexes.
HERECOMMENT_ILLEGAL = /\*\//;
LINE_CONTINUER = /^\s*(?:,|\??\.(?![.\d])|::)/;
LINE_CONTINUER = /^\s*(?:,|\??\.(?![.\d])|\??::)/;
STRING_INVALID_ESCAPE = /((?:^|[^\\])(?:\\\\)*)\\(?:(0[0-7]|[1-7])|(x(?![\da-fA-F]{2}).{0,2})|(u\{(?![\da-fA-F]{1,}\})[^}]*\}?)|(u(?!\{|[\da-fA-F]{4}).{0,4}))/; // Make sure the escape isnt escaped.
// octal escape

File diff suppressed because one or more lines are too long

View File

@ -371,6 +371,7 @@ grammar =
o ':: Property', -> [LOC(1)(new Access new PropertyName('prototype')), LOC(2)(new Access $2)]
o '?:: Property', -> [LOC(1)(new Access new PropertyName('prototype'), 'soak'), LOC(2)(new Access $2)]
o '::', -> new Access new PropertyName 'prototype'
o '?::', -> new Access new PropertyName('prototype'), 'soak'
o 'Index'
]

View File

@ -1293,7 +1293,7 @@ POSSIBLY_DIVISION = /// ^ /=?\s ///
# Other regexes.
HERECOMMENT_ILLEGAL = /\*\//
LINE_CONTINUER = /// ^ \s* (?: , | \??\.(?![.\d]) | :: ) ///
LINE_CONTINUER = /// ^ \s* (?: , | \??\.(?![.\d]) | \??:: ) ///
STRING_INVALID_ESCAPE = ///
( (?:^|[^\\]) (?:\\\\)* ) # Make sure the escape isnt escaped.

View File

@ -70,6 +70,12 @@ test "`?.` and `::` should continue lines", ->
::
?.foo
)
ok not (
Date
?::
?.foo
)
#eq Object::toString, Date?.
#prototype
#::

View File

@ -303,7 +303,16 @@ test "#2567: Optimization of negated existential produces correct result", ->
test "#2508: Existential access of the prototype", ->
eq NonExistent?::nothing, undefined
eq(
NonExistent
?::nothing
undefined
)
ok Object?::toString
ok(
Object
?::toString
)
test "floor division operator", ->
eq 2, 7 // 3