Re: senator-next-tag: Buffer was not parsed by Semantic.
Eric M. Ludlam <eric <at> siege-engine.com>
2014-07-12 01:40:11 GMT
I'm not sure how to debug the fcns you posted below. I think they are
ok. Since you appear to be defining your own mode, let me instead
annotate through how the the parsing for "dot" works which is found in
and generated file
I picked this mode because it is pretty simple, just enough to get the
layout code of COGRE working. It is also not installed by default in
Lets start in dot-mode.el:
Note the syntax table. This part is critical for the lexer to work. If
you duplicated some other mode, you probably have one of these.
In cogre-dot-mode which is named such to avoid conflict with other dot
modes. Note it sets up comment-start and comment-start-skip - these are
important for the lexer also.
Also note the hook running at the end.
Note the auto-mode-alist modification.
Lastly, note the mode-local-parent stuff. That is setup to make sure
that cogre-dot-mode is in agree with graphviz-dot-mode. You don't need
anything like this if your mode is standalone.
Next is wisent-dot.wy.
At the beginning is the langauage-mode setting that matches, in this
case, the core graphviz mode which I had to make optional. I think you
did this correctly already.
At the end after the %% is a lexer definition. This uses a bunch of
default stuff, plus lexers defined in the language for keywords, etc.
You can then compile this grammar into wisent-dot-wy.el. If you are in
a compile debug cycle, you need to then enter wisent-dot-wy.el, and
force eval with C-M-x several tables because the defvars carefully save
old values if you just eval the buffer causing a no-op. :(
Last is the key piece: wisent-dot.el
Note that this pulls in wisent-dot-wy, plus wisent itself and any
sources to functions you need to override.
The override for semantic-tag-components is important to implement if
you have ANY tags that are compound, such as a class with fields, etc.
Note wisent-dot-setup-parser. It installs the parser using a function
from wisent-dot-wy.el. That is how the parser gets pulled in.
It also sets up the lexer, extra syntax mods needed, and a few other
rndom things such as command separators and how to convert your tag
classes into text strings. On the whole, the first statement and the
first 2 variables are the most important. The rest is optional.
Lastly are hooks to run the parser setup.
These hooks can be replaced by adding the setup function to
Feel free to start with the hook, and use the setup function when you
want to make semantic support optional with your mode.
If you already did all this, it could be that your parser is broken, or
parser recompiles are not getting loaded in correctly. Fire up a new
emacs and load your code and test it to avoid the recompile issue. If
that helps, you need to hand load variable changes from generated files.
Another good trick is to use semantic-show-parser-state-mode. this
shows symbols in the mode line to tell you how the parser is doing. It
will either refuse to start if the parser is not installed, or show % if
the parser is broken, or if the buffer you are parsing is just not complete.
Another fun one is semantic-highlight-edits-mode which shows how the
buffer is edited and reparsed which is helpful if the incremental parser
is broken with your language parser.
Lastly use semantic-show-unmatched-syntax-mode to see if the parser is
just tagging your whole buffer as unparsable. If this happens, you need
to work on your parser some more.
I hope this helps.