Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.5 KiB

  1. ;; Copyright (C) 2015-2016, 2018-2019 Free Software Foundation, Inc
  2. ;; Author: Rocky Bernstein <rocky@gnu.org>
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. (require 'load-relative)
  14. (require-relative-list '("../common/regexp" "../common/loc" "../common/track")
  15. "realgud-")
  16. (declare-function realgud-goto-line-for-pt 'realgud-track)
  17. (declare-function make-realgud-loc-pat 'realgud-regexp)
  18. (defconst realgud:js-term-escape "[[0-9]+[GKJ]"
  19. "Escape sequence regular expression pattern trepanjs often puts
  20. in around prompts")
  21. (defconst realgud:js-file-regexp "\\([^ \t\n]+\\)\\(?: \\[.*\\]\\)?")
  22. (declare-function realgud-goto-line-for-pt 'realgud-track)
  23. ;; Regular expression that describes a javascript backtrace line.
  24. ;; at /tmp/foo.pl line 7
  25. ;; main::__ANON__('Illegal division by zero at /tmp/foo.pl line 4.\x{a}') called at /tmp/foo.pl line 4
  26. ;; main::foo(3) called at /tmp/foo.pl line 8
  27. (defconst realgud:js-backtrace-loc-pat
  28. (make-realgud-loc-pat
  29. :regexp (format "^\\(?:[<]?[\t ]+at \\)?\\([^:]+\\) (\\(.*\\):%s:%s)"
  30. realgud:regexp-captured-num realgud:regexp-captured-num)
  31. :file-group 2
  32. :line-group 3
  33. :char-offset-group 4)
  34. "A realgud-loc-pat struct that describes a V8 backtrace location")
  35. ;; Regular expression that describes a javascript backtrace line.
  36. ;; For example:
  37. ;; 1 breakpoint y /usr/local/lib/node_modules/trepanjs/bin/trepanjs:1
  38. ;; breakpoint already hit 1 time
  39. ;; 2 breakpoint y /usr/local/lib/node_modules/trepanjs/bin/trepanjs:5
  40. ; 3 breakpoint y /usr/local/lib/node_modules/trepanjs/bin/trepanjs:6
  41. (defconst realgud:js-debugger-backtrace-pat
  42. (make-realgud-loc-pat
  43. :regexp (format "^%s[ \t]+\\(breakpoint\\)[ \t]+\\([yn]\\)[ \t]+.*at \\(.+\\):%s"
  44. realgud:regexp-captured-num realgud:regexp-captured-num)
  45. :num 1
  46. :text-group 2 ;; misnamed Is "breakpoint" or "watchpoint"
  47. :string 3 ;; misnamed. Is "y/n"
  48. :file-group 4
  49. :line-group 5)
  50. "A realgud-loc-pat struct that describes a V8 breakpoint location")
  51. (defconst realgud:js-file-line-loc-pat
  52. (make-realgud-loc-pat
  53. :regexp (format "^\\([^:]+\\):%s" realgud:regexp-captured-num)
  54. :file-group 1
  55. :line-group 2)
  56. "A realgud-loc-pat struct that describes a V8 file/line location")
  57. (defconst realgud:js-file-line-loc-pat
  58. (make-realgud-loc-pat
  59. :regexp (format "^\\([^:]+\\):%s" realgud:regexp-captured-num)
  60. :file-group 1
  61. :line-group 2)
  62. "A realgud-loc-pat struct that describes a V8 file/line location")
  63. ;; FIXME: there is probably a less redundant way to do the following
  64. ;; FNS.
  65. (defun realgud:js-goto-file-line (pt)
  66. "Display the location mentioned by the js file/line warning or error."
  67. (interactive "d")
  68. (realgud-goto-line-for-pt pt "file-line"))
  69. (defun realgud:js-goto-syntax-error-line (pt)
  70. "Display the location mentioned in a Syntax error line
  71. described by PT."
  72. (interactive "d")
  73. (realgud-goto-line-for-pt pt "syntax-error"))
  74. (provide-me "realgud-lang-")