]> git.eshelyaron.com Git - emacs.git/commitdiff
semantic: Fix wisent parser recursion
authorMartin Stein <Martin.Stein.Math@gmx.net>
Mon, 16 Feb 2015 14:01:12 +0000 (09:01 -0500)
committerDavid Engster <deng@randomsample.de>
Fri, 20 Jan 2017 21:59:45 +0000 (22:59 +0100)
* lisp/cedet/semantic/wisent/wisent.el (wisent-parse): The semantic
 action might be an EXPAND, EXPANDFULL or some similar action calling
 the parser recursively. If the last token of the recursively called
 parsing step failed to match it ends up in wisent-lookahead, and
 function wisent-parse-stream pushs it back onto
 wisent-lex-istream. From there on it simply ends up occuring twice on
 the unmatched-syntax-cache, or worse might even lead to parse errors
 in rare cases.

Copyright-paperwork-exempt: yes

lisp/cedet/semantic/wisent/wisent.el

index 36dff0197922a7fbe15710f16d9b0648f7ec3d0e..195829436185d445ff08b48c57218654f40f9715 100644 (file)
@@ -377,7 +377,7 @@ automaton has only one entry point."
          (wisent-parse-lexer-function lexer)
          (wisent-recovering nil)
          (wisent-input (wisent-parse-start start starts))
-         state tokid choices choice)
+         state tokid choices choice wisent-lookahead-save)
     (setq wisent-nerrs     0 ;; Reset parse error counter
           wisent-lookahead nil) ;; and lookahead token
     (aset stack 0 0) ;; Initial state
@@ -469,7 +469,12 @@ automaton has only one entry point."
        ;; Reduce by rule (call semantic action)
        ;; -------------------------------------
        (t
+        ;; save the global variable wisent-lookahead,
+        ;; as the semantic action might be an expand or expandfull
+        ;; which calls this function recursively
+        (setq wisent-lookahead-save wisent-lookahead)
         (setq sp (funcall wisent-loop stack sp gotos))
+        (setq wisent-lookahead wisent-lookahead-save)
         (or wisent-input (setq wisent-input (wisent-lexer))))))
     (run-hooks 'wisent-post-parse-hook)
     (car (aref stack 1))))