Module: Latexmath::NativeRecursionGuard
- Included in:
- Latexmath
- Defined in:
- lib/latexmath/parser/native_recursion_guard.rb
Overview
Parsanol::Native.raise_native_parse_error translates a native failure. While Latexmath's own native call runs on this thread, this hook turns a recursion-limit failure into NativeRecursionLimit; every other failure, and every other caller of Parsanol, is unaffected. (The same guard as amath's.)
Constant Summary collapse
- MESSAGE =
/\A(?:Maximum recursion depth \(\d+\) exceeded|Recursion limit exceeded\b)/- KEY =
:latexmath_native_recursion_guard
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.installed? ⇒ Boolean
27 28 29 |
# File 'lib/latexmath/parser/native_recursion_guard.rb', line 27 def self.installed? Parsanol::Native.singleton_class.ancestors.include?(self) end |
Instance Method Details
#raise_native_parse_error(error, grammar, input) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/latexmath/parser/native_recursion_guard.rb', line 31 def raise_native_parse_error(error, grammar, input) if Thread.current[KEY] && error..match?(MESSAGE) raise NativeRecursionLimit, error..lines.first.strip, cause: nil end super end |