• Iain Ireland's avatar
    [regexp] Rewrite error handling · e80ca24c
    Iain Ireland authored
    This patch modifies irregexp's error handling. Instead of representing
    errors as C strings, they are represented as an enumeration value
    (RegExpError), and only converted to strings when throwing the error
    object in regexp.cc. This makes it significantly easier to integrate
    into SpiderMonkey. A few notes:
    
    1. Depending on whether the stack overflows during parsing or
       analysis, the stack overflow message can vary ("Stack overflow" or
       "Maximum call stack size exceeded"). I kept that behaviour in this
       patch, under the assumption that stack overflow messages are
       (sadly) the sorts of things that real world code ends up depending
       on.
    
    2. Depending on the point in code where the error was identified,
       invalid unicode escapes could be reported as "Invalid Unicode
       escape", "Invalid unicode escape", or "Invalid Unicode escape
       sequence". I fervently hope that nobody depends on the specific
       wording of a syntax error, so I standardized on the first one. (It
       was both the most common, and the most consistent with other
       "Invalid X escape" messages.)
    
    3. In addition to changing the representation, this patch also adds an
       error_pos field to RegExpParser and RegExpCompileData, which stores
       the position at which an error occurred. This is used by
       SpiderMonkey to provide more helpful messages about where a syntax
       error occurred in large regular expressions.
    
    4. This model is closer to V8's existing MessageTemplate
       infrastructure. I considered trying to integrate it more closely
       with MessageTemplate, but since one of our stated goals for this
       project was to make it easier to use irregexp outside of V8, I
       decided to hold off.
    
    R=jgruber@chromium.org
    
    Bug: v8:10303
    Change-Id: I62605fd2def2fc539f38a7e0eefa04d36e14bbde
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2091863
    Commit-Queue: Jakob Gruber <jgruber@chromium.org>
    Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#66784}
    e80ca24c
Name
Last commit
Last update
build_overrides Loading commit data...
custom_deps Loading commit data...
docs Loading commit data...
gni Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.clang-tidy Loading commit data...
.editorconfig Loading commit data...
.flake8 Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.vpython Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
COMMON_OWNERS Loading commit data...
DEPS Loading commit data...
ENG_REVIEW_OWNERS Loading commit data...
INFRA_OWNERS Loading commit data...
INTL_OWNERS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
MIPS_OWNERS Loading commit data...
OWNERS Loading commit data...
PPC_OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
S390_OWNERS Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...