mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00
Throw proper SyntaxError if unable to parse a regular expression
This commit is contained in:
parent
30a04e1992
commit
8f9e999236
|
@ -18,7 +18,7 @@ otto: build
|
|||
test-otto:
|
||||
$(TEST) $(WITH_otto)
|
||||
|
||||
test.otto: otto
|
||||
test.otto:
|
||||
$(TEST) $(WITH_otto) | tee $@
|
||||
|
||||
test.otto-:
|
||||
|
@ -36,9 +36,9 @@ test.v8-:
|
|||
release: otto gauntlet
|
||||
|
||||
clean:
|
||||
rm -f test.otto digest.json
|
||||
rm -f test.otto digest.json .node.tmp.js
|
||||
|
||||
digest.json:
|
||||
digest.json: test.otto
|
||||
./digest < test.otto > $@
|
||||
|
||||
digest.json-:
|
||||
|
@ -69,6 +69,10 @@ try-tmp: tmp.js
|
|||
cat shim.js $< | $(otto)
|
||||
@echo PASS
|
||||
|
||||
node-try-tmp: tmp.js
|
||||
cat shim.js $< > .node.tmp.js
|
||||
node ./.node.tmp.js
|
||||
|
||||
look: .fail
|
||||
cat $<
|
||||
@echo `readlink $<`
|
||||
|
|
|
@ -50,8 +50,13 @@ func (runtime *_runtime) newRegExpObject(pattern string, flags string) *_object
|
|||
re2pattern = fmt.Sprintf("(?%s:%s)", re2flags, re2pattern)
|
||||
}
|
||||
|
||||
regularExpression, err := regexp.Compile(re2pattern)
|
||||
if err != nil {
|
||||
panic(newSyntaxError("Invalid regular expression: %s", err.Error()[22:]))
|
||||
}
|
||||
|
||||
self._RegExp = &_regExpObject{
|
||||
RegularExpression: regexp.MustCompile(re2pattern),
|
||||
RegularExpression: regularExpression,
|
||||
Global: global,
|
||||
IgnoreCase: ignoreCase,
|
||||
Multiline: multiline,
|
||||
|
|
Loading…
Reference in New Issue
Block a user