OK! I followed most of that! =)
Corysia Taware writes:You need to add some boilerplate code to set up your lexer and hook the
> I've stubbed out a few keywords and a rule. My wisent-indra-wy.el gets
> generated and I can byte compile the elisp.
> What can I do to try to hook it in and validate what I've done? I've a lot
> more of the wy to write and I'd like to make sure I'm on the right track.
parser into the language's major mode. Take a look at the example in
etc/semantic/bovine/skel.el. This is for the Bovine parser, but it's
essentially the same for Wisent. I've pasted an example below.
The important thing to get working first is the lexer. Depending on what
%token's you've included in your grammar, it should have generated
lexers for keywords, numbers, punctuation, etc.. You have to put these
"sub-lexers" alongside others you might need into the main lexer (see
the define-lex statement below). For more information regarding what you
can put there and how to write your own lexer functions, see the
"Semantic Language Writer's guide" in the CEDET documentation. It should
be available through 'info' (C-h i), or just look here:
You can test the lexer by loading a file, go to the beginning and call
`semantic-lex-debug'. What you see then is what will get fed into the
generated parser, so if the lexer does not work correctly, nothing will.
As soon as the lexer works, you can start calling `bovinate' to see what
tags get generated. If you just get 'nil', you should start debugging
your grammar with stuff like `wisent-debug-on-entry'. If you're hitting
a wall, just come back here. :-)
;; Depending on what elements you include specialized support for
;; Create a lexical analyzer for your language. You can use
;; both the provided analyzers, and your own custom analyzers
;; that let you take short-cuts in your language.
;; Define the lexial analyzer
"Lexical Analyzer for YOURLANGUAGE code."
;; Analyzers auto-generated from grammar.
;; Signal error on unhandled syntax.
;; You do not need to use this function unless you have compound
;; definitions. For example, in C, the following is expanded:
;; int x, y;
(defun semantic-YOURLANGUAGE-expand-tag (nonterm)
"Expand NONTERM into a list of equivalent nonterminals, or nil."
;;; Override methods & Variables
;; YOURLANGUAGE-mode semantic-makefile-dependency-system-include-path
;; "The system include path used by YOURLANGUAGE language.")
;; Add methods to the override table here. See
;; `semantic-install-function-overrides' for more details.
;;; Setup function
(defun semantic-default-YOURLANGUAGE-setup ()
"Set up a buffer for semantic parsing of the YOURLANGUAGE language."
;; Commented out lines below are generally considered optional
;; See the Emacs Doc for the symbols used below
(setq semantic-symbol->name-assoc-list '( (variable . "Variables")
(type . "Types")
(function . "Functions")
(include . "Includes")
(package . "Exports"))
;; Semantic navigation inside 'type children
senator-step-at-tag-classes '(function variable)
(setq semantic-lex-analyzer #'semantic-YOURLANGUAGE-lexer)
;; Loading this file will install the parser. Add this line
;; to a .emacs file, or other setup file along with an autoload
;; for the setup function to dynamically install the parser
;; when a file of that type is read into Emacs.
(add-hook 'YOURLANGUAGE-mode-hook 'semantic-default-YOURLANGUAGE-setup)