Re: [CEDET-devel] Lexical analyzer problem - now parser problem
Brought to you by:
zappo
From: David E. <de...@ra...> - 2012-03-08 22:19:32
|
Alastair Rankine writes: > I'm trying to parse this: > > project(LLVM) > > Here is the relevant extract from my bovine grammar: > > > command : symbol semantic-list > (FUNCTION-TAG ,$1 nil (EXPAND $2 params)) > ; > > params : LPAREN arg RPAREN ( VARIABLE-TAG ,$2 nil nil ) > | LPAREN RPAREN ;; empty > ; > > arg : symbol > | string > | number > ; > > > The intent here is to create a function tag with name "project" and an argument list with a single variable tag "LLVM". Unfortunately I can't seem to get it to work - see backtrace: > > > Debugger entered: ((("project" function (:arguments (("LLVM") variable nil nil nil 84 90)) nil nil) 77 90)) > byte-code("\301\302!\210\303!\207" [tag message "A Rule must return a single tag-line list!" debug] 2) > semantic--tag-expand((("project" function (:arguments ...) nil nil) 77 90)) > semantic-repeat-parse-whole-stream(((symbol 77 . 84) (semantic-list 84 . 90)) nil nil) > semantic-parse-region-default(1 130 nil nil nil) > semantic-parse-region(1 130) > semantic-fetch-tags() > bovinate(nil) > > > I don't understand this error message. I think this is saying that the > argument list returned by parsing "params" has to be a list of tags, > but from what I can see, it is. > > I'm obviously doing something fundamentally wrong here - can you or > anyone else help? It's a bit hard to tell, but what strikes me is that (("LLVM") variable nil nil nil 84 90)) has the name 'LLVM' in a list, whereas it should be a plain string. So I guess in 'params' you'll need a 'car': ( VARIABLE-TAG (car $2) nil nil ) Also, I hope you know that Bovine has a stepping debugger which you can use by simply calling 'semantic-debug'. If you're unsure what exactly you're getting from all those rules, you can simply define a dummy function in *scratch* like (defun showargs (&optional one two three four) (message "debug!")) and then call that one in the grammar, like command : symbol semantic-list ( ,(showargs ,$1 (EXPAND $2 params)) ) You can then use debug-on-entry/edebug on 'showargs' and better see what kind of arguments you're actually dealing with. Maybe there's also a magic key somewhere in the bovine debugger to show that, but I don't think so. Cheers, David |