Bug in regular expression semantics?
pidgeot18 at gmail.com
Tue Dec 11 13:39:09 PST 2012
I am currently working on building an executable version of the
semantics of regular expression pattern matching, and I think I've found
in a bug in how they are specified in both the released version of
ECMA-262 and the latest working draft.
In §126.96.36.199, it says that:
The production Term :: Assertion evaluates by returning an internal
Matcher closure that takes two arguments, a State x and a Continuation
c, and performs the following:
1. Evaluate Assertion to obtain an AssertionTester t.
[ ... ]
However, the definition of the negative and positive lookahead
assertions in §188.8.131.52 do not return AssertionTesters (like the ^, $,
\b, and \B assertions do) but matchers:
The production Assertion :: ( ? = Disjunction ) evaluates as follows:
1. Evaluate Disjunction to obtain a Matcher m.
2. Return an internal Matcher closure that takes two arguments, a State
x and a Continuation c, and performs the following steps:
1. Let d be a Continuation that always returns its State argument as
a successful MatchResult.
2. Call m(x, d) and let r be its result.
3. If r is failure, return failure.
4. Let y be r's State.
5. Let cap be y's captures internal array.
6. Let xe be x's endIndex.
7. Let z be the State (xe, cap).
8. Call c(z) and return its result.
More information about the es-discuss