Function: wisent-parse-region
wisent-parse-region is a byte-compiled function defined in
wisent.el.gz.
Signature
(wisent-parse-region START END &optional GOAL DEPTH RETURNONERROR)
Documentation
Parse the area between START and END using the Wisent LALR parser.
Return the list of semantic tags found.
Optional arguments GOAL is a nonterminal symbol to start parsing at,
DEPTH is the lexical depth to scan, and RETURNONERROR is a flag to
stop parsing on syntax error, when non-nil.
The LALR parser automaton must be available in buffer local variable
semantic--parse-table.
Must be installed by semantic-install-function-overrides to override
the standard function semantic-parse-region.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/wisent.el.gz
(defun wisent-parse-region (start end &optional goal depth returnonerror)
"Parse the area between START and END using the Wisent LALR parser.
Return the list of semantic tags found.
Optional arguments GOAL is a nonterminal symbol to start parsing at,
DEPTH is the lexical depth to scan, and RETURNONERROR is a flag to
stop parsing on syntax error, when non-nil.
The LALR parser automaton must be available in buffer local variable
`semantic--parse-table'.
Must be installed by `semantic-install-function-overrides' to override
the standard function `semantic-parse-region'."
(if (or (< start (point-min)) (> end (point-max)) (< end start))
(error "Invalid bounds [%s %s] passed to `wisent-parse-region'"
start end))
(let* ((case-fold-search semantic-case-fold)
(wisent-lex-istream (semantic-lex start end depth))
ptree tag cooked lstack wisent-lex-lookahead)
;; Loop while there are lexical tokens available
(while wisent-lex-istream
;; Parse
(setq wisent-lex-lookahead (car lstack)
tag (semantic-safe "wisent-parse-region: %s"
(wisent-parse semantic--parse-table
wisent-lexer-function
wisent-error-function
goal)))
;; Manage returned lookahead token
(if wisent-lookahead
(if (eq (car lstack) wisent-lookahead)
;; It is already at top of lookahead stack
(progn
(setq tag nil)
(while lstack
;; Collect unmatched tokens from lookahead stack
(run-hook-with-args
'wisent-discarding-token-functions (car lstack))
(setq lstack (cdr lstack))))
;; Push new lookahead token into the stack
(setq lstack (cons wisent-lookahead lstack))))
;; Manage the parser result
(cond
;; Parse succeeded, cook result
((consp tag)
(setq lstack nil ;; Clear the lookahead stack
cooked (semantic--tag-expand tag)
ptree (append cooked ptree))
(while cooked
(setq tag (car cooked)
cooked (cdr cooked))
(or (semantic--tag-get-property tag 'reparse-symbol)
(semantic--tag-put-property tag 'reparse-symbol goal)))
)
;; Return on error if requested
(returnonerror
(setq wisent-lex-istream nil)
))
;; Work in progress...
(if wisent-lex-istream
(and (eq semantic-working-type 'percent)
(boundp 'semantic--progress-reporter)
semantic--progress-reporter
(progress-reporter-update
semantic--progress-reporter
(floor (* 100.0 (semantic-lex-token-start
(car wisent-lex-istream)))
(point-max))))))
;; Return parse tree
(nreverse ptree)))