Re: [cedet-semantic] using semantic/wisent as a parser
Brought to you by:
zappo
From: Joe C. <jco...@ma...> - 2004-04-16 00:13:35
|
> ;;;###autoload > (defun semantic-default-simple-setup () > "Set up a buffer for semantic parsing of the SIMPLE language." > (semantic-install-function-overrides > '((parse-region . semantic-simple-parse-region) > (parse-changes . semantic-simple-parse-changes))) [...] In fact your problem is in the above code. First you define a override to semantic-parse-region in simple-mode (looks correct), but then you override it again locally in the buffer with the undefined function `semantic-simple-parse-region'. IMO, you should just remove the above call to `semantic-install-function-overrides'. Thanks. I revised that function so that it looks like this: (defun semantic-default-simple-setup () "Set up a buffer for semantic parsing of a SIMPLE language." (setq semantic--parse-table t document-comment-start "/*" document-comment-end " */" )) But upon running M-: (semantic-parse-region (point-min) (point-max)) or M-: (semantic-parse-region (point-min) (point-max) 'expr) where `expr' is my start symbol, the following error is triggered. Debugger entered--Lisp error: (wrong-type-argument listp t) apply(debug error (wrong-type-argument listp t)) edebug(error (wrong-type-argument listp t)) signal(wrong-type-argument (listp t)) edebug-signal(wrong-type-argument (listp t)) semantic-parse-stream-default(((symbol 1 . 4) (symbol 5 . 6) (symbol 7 . 10)) nil) semantic-parse-stream(((symbol 1 . 4) (symbol 5 . 6) (symbol 7 . 10)) nil) semantic-repeat-parse-whole-stream(((symbol 1 . 4) (symbol 5 . 6) (symbol 7 . 10)) nil nil) semantic-parse-region-default(1 10 nil nil nil) semantic-parse-region-simple-mode(1 10 nil nil nil) semantic-parse-region(1 10) (edebug-after (edebug-before 0) 5 (semantic-parse-region (edebug-after ... 2 ...) (edebug-after ... 4 ...))) (lambda nil (edebug-after (edebug-before 0) 5 (semantic-parse-region ... ...)))() edebug-enter(ok-parser nil (lambda nil (edebug-after (edebug-before 0) 5 (semantic-parse-region ... ...)))) edebug-enter(ok-parser nil (lambda nil (edebug-after (edebug-before 0) 5 (semantic-parse-region ... ...)))) ok-parser() I ran the function call through edebug, and I was able to isolate the occurance of the error to the last bit of this piece of code: (defun semantic-repeat-parse-whole-stream (stream nonterm &optional returnonerror) "Iteratively parse the entire stream STREAM starting with NONTERM. Optional argument RETURNONERROR indicates that the parser should exit with the current results on a parse error. This function returns semantic tags without overlays." (let ((result nil) (case-fold-search semantic-case-fold) nontermsym tag) (while stream (setq nontermsym (semantic-parse-stream stream nonterm) ;; *snip* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error appears when this is evaluated But `semantic-parse-stream' is defined with a `define-overload', so I didn't think I could edebug it. But then I *did* edebug it, and was able to push on a little bit further into the code. I got the same error as above, as well as the message Parse error @ 1 The edebug process now runs through ;; *pins* tag (car (cdr nontermsym))) (if (not nontermsym) (error "Parse error @ %d" (car (cdr (car stream))))) ;; *snip* The problem seems to be that nontermsym comes up as nil. I'm not sure how to control this or where to turn next for further debugging. The only change in my setup was the change in `semantic-default-simple-setup' documented above. Maybe you can help me figure out why nontermsym is coming up nil? For the record, here is my wisent file again. ;;; simple.wy -- LALR grammar for (much simplified) Tiger %package simple-wy ;; apparently not useful for wisent? %start expr %type <punctuation> %token <punctuation> PLUS "+" %type <symbol> %token <symbol> symbol "[A-Za-z][_A-Za-z0-9]*" %% expr : ;; empty | symbol (quote $1) | symbol PLUS symbol (quote (+ $1 $3)) ; |