fixing regexp literals versus division, with tests
This commit is contained in:
parent
2f658ba925
commit
afa26c37f1
|
@ -32,7 +32,7 @@
|
||||||
WHITESPACE = /^([ \t]+)/;
|
WHITESPACE = /^([ \t]+)/;
|
||||||
COMMENT = /^(((\n?[ \t]*)?#[^\n]*)+)/;
|
COMMENT = /^(((\n?[ \t]*)?#[^\n]*)+)/;
|
||||||
CODE = /^((-|=)>)/;
|
CODE = /^((-|=)>)/;
|
||||||
REGEX = /^(\/(.*?)([^\\]|\\\\)\/[imgy]{0,4})/;
|
REGEX = /^(\/(\S.*?)?([^\\]|\\\\)\/[imgy]{0,4})/;
|
||||||
MULTI_DENT = /^((\n([ \t]*))+)(\.)?/;
|
MULTI_DENT = /^((\n([ \t]*))+)(\.)?/;
|
||||||
LAST_DENTS = /\n([ \t]*)/g;
|
LAST_DENTS = /\n([ \t]*)/g;
|
||||||
LAST_DENT = /\n([ \t]*)/;
|
LAST_DENT = /\n([ \t]*)/;
|
||||||
|
@ -47,7 +47,8 @@
|
||||||
// Tokens which a regular expression will never immediately follow, but which
|
// Tokens which a regular expression will never immediately follow, but which
|
||||||
// a division operator might.
|
// a division operator might.
|
||||||
// See: http://www.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
|
// See: http://www.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
|
||||||
NOT_REGEX = ['IDENTIFIER', 'NUMBER', 'REGEX', 'STRING', ')', '++', '--', ']', '}', 'FALSE', 'NULL', 'TRUE'];
|
// Our list is shorter, due to sans-parentheses method calls.
|
||||||
|
NOT_REGEX = ['NUMBER', 'REGEX', '++', '--', 'FALSE', 'NULL', 'TRUE'];
|
||||||
// Tokens which could legitimately be invoked or indexed.
|
// Tokens which could legitimately be invoked or indexed.
|
||||||
CALLABLE = ['IDENTIFIER', 'SUPER', ')', ']', '}', 'STRING', '@'];
|
CALLABLE = ['IDENTIFIER', 'SUPER', ')', ']', '}', 'STRING', '@'];
|
||||||
// Tokens that indicate an access -- keywords immediately following will be
|
// Tokens that indicate an access -- keywords immediately following will be
|
||||||
|
|
|
@ -54,7 +54,7 @@ OPERATOR : /^([+\*&|\/\-%=<>:!?]+)/
|
||||||
WHITESPACE : /^([ \t]+)/
|
WHITESPACE : /^([ \t]+)/
|
||||||
COMMENT : /^(((\n?[ \t]*)?#[^\n]*)+)/
|
COMMENT : /^(((\n?[ \t]*)?#[^\n]*)+)/
|
||||||
CODE : /^((-|=)>)/
|
CODE : /^((-|=)>)/
|
||||||
REGEX : /^(\/(.*?)([^\\]|\\\\)\/[imgy]{0,4})/
|
REGEX : /^(\/(\S.*?)?([^\\]|\\\\)\/[imgy]{0,4})/
|
||||||
MULTI_DENT : /^((\n([ \t]*))+)(\.)?/
|
MULTI_DENT : /^((\n([ \t]*))+)(\.)?/
|
||||||
LAST_DENTS : /\n([ \t]*)/g
|
LAST_DENTS : /\n([ \t]*)/g
|
||||||
LAST_DENT : /\n([ \t]*)/
|
LAST_DENT : /\n([ \t]*)/
|
||||||
|
@ -71,10 +71,9 @@ HEREDOC_INDENT : /^[ \t]+/mg
|
||||||
# Tokens which a regular expression will never immediately follow, but which
|
# Tokens which a regular expression will never immediately follow, but which
|
||||||
# a division operator might.
|
# a division operator might.
|
||||||
# See: http://www.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
|
# See: http://www.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
|
||||||
|
# Our list is shorter, due to sans-parentheses method calls.
|
||||||
NOT_REGEX: [
|
NOT_REGEX: [
|
||||||
'IDENTIFIER', 'NUMBER', 'REGEX', 'STRING',
|
'NUMBER', 'REGEX', '++', '--', 'FALSE', 'NULL', 'TRUE'
|
||||||
')', '++', '--', ']', '}',
|
|
||||||
'FALSE', 'NULL', 'TRUE'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Tokens which could legitimately be invoked or indexed.
|
# Tokens which could legitimately be invoked or indexed.
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
ok 'x'.match(/x/g)
|
||||||
|
ok 'x'.match /x/g
|
||||||
|
ok 'x'.match(/x/)
|
||||||
|
ok 'x'.match /x/
|
||||||
|
|
||||||
|
ok 4 / 2 / 1 is 2
|
||||||
|
|
||||||
|
y: 4
|
||||||
|
x: 2
|
||||||
|
g: 1
|
||||||
|
|
||||||
|
ok y / x/g is 2
|
Loading…
Reference in New Issue