Only check for back references in end patterns

Back references can occur in match values but should not
be treated differently when present there since they refer
to groups inside the match.

Close #370
This commit is contained in:
Kevin Sawicki
2013-03-24 23:15:26 -04:00
parent 5015ca94bc
commit 0080e09065
2 changed files with 8 additions and 2 deletions

View File

@@ -159,10 +159,10 @@ class Pattern
backReferences: null
anchored: false
constructor: (@grammar, { name, contentName, @include, match, begin, end, captures, beginCaptures, endCaptures, patterns, @popRule, hasBackReferences}) ->
constructor: (@grammar, { name, contentName, @include, match, begin, end, captures, beginCaptures, endCaptures, patterns, @popRule, @hasBackReferences}) ->
@scopeName = name ? contentName # TODO: We need special treatment of contentName
if match
if @hasBackReferences = hasBackReferences ? /\\\d+/.test(match)
if (end or @popRule) and @hasBackReferences ?= /\\\d+/.test(match)
@match = match
else
@regexSource = match