Re: senator-next-tag: Buffer was not parsed by Semantic.
"Eric M. Ludlam" <[email protected]>
| Newsgroups | gmane.emacs.cedet |
|---|---|
| Message-ID | <[email protected]> |
On 07/02/2014 03:28 PM, Oleg Sivokon wrote:
> Hi list,
> I'm getting this message:
>
> senator-next-tag: Buffer was not parsed by Semantic.
>
> After I thought I've compiled a simple grammar for a mode that I'm
> trying to test. Below is the initialization mode stuff:
>
> (define-derived-mode fmt-mode fundamental-mode
> "Common Lisp Format mode"
> "Major for highlighting of Common Lisp format mini-language
> This mode uses its own keymap:
> \\{fmt-mode-map}"
> (kill-all-local-variables)
> (setq major-mode 'fmt-mode)
> (use-local-map fmt-mode-map)
> (setf mode-name "Common Lisp Format")
> (run-hooks 'fmt-mode-hook)
> (semantic-mode 1))
>
> Nothing fancy, I'm sure it reaches the (semantic-mode 1) call.
Hi Oleg,
`semantic-mode' only needs to be called once when you start Emacs. To
get your mode setup for parsing via Semantic you need to add your setup
function to `semantic-new-buffer-setup-functions'. I suppose you could
also just call your setup function directly from your mode too if you
wanted, but then your mode would depend on Semantic directly.
For a fresh new mode, you would need 3 files:
blah-mode.el - The standard Emacs mode for your mode.
blah.wy & blah-wy.el - The parser and generated file.
semantic-blah.el or wisent-blah.el - The hand written support code for
the parser.
The support file will have your -setup function. The setup function
will call your --install-parser function, setup any special variables
needed when Semantic is active (such as which lexer to use and any
override variables such as how to convert tag classes into nice strings.
You could look at SRecode's template mode as an example. It has
everything together in that case there is:
srt.wy
srt-wy.el
template.el - hand written support file
>
> I can require fmt-wy allright (it gives some warnings, but they don't
> seem to be important) But now parsing seems to be happening in the test
> file I'm trying to edit. What did I have to do beside what I've done?
>
> Also, how would I debug reduce conflicts? Is there any way to make
> Semantic more verbose when reporting them? The report of having a reduce
> conflic is really like pointing a finger at the sky... unless you give a
> hint about what terminals or rules are in conflict.
Hopefully the message will help identify the problem. There is a short
section in the 'wisent' doc for how to fix them. You could also check
Bison's doc, as the technique is the same. Sadly it is more by code
inspection than a debugger.
> Lastly, sorry I put many issues together! Is there a way to create
> character classes, such as, for example "any character but tilda"? Well,
> actually, negation would help my case too, but just for general
> knowledge I'd like, if possible, to know the answer to the character
> classes question too!
You will need to create a custom lex rule. That uses Emacs regex rules.
Thus you could create "[^~]" for anything but tilde, or "[~]" for
only tilde's. Check the elisp manual for all the fun regexp rules.
Good Luck
Eric
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft