OK!  I followed most of that!  =)

I took your skeleton and was able to add a lot of functionality I think I would have left off on the first try.

Yes, I am getting a nil when I first try bovinate.  I'm assuming I'm supposed to be focused in the LSL source code window and not the  lexer output window when I try that.  But I've tried it both ways and get nil, regardless.

I'm not sure how to use wisent-debug-on-entry.  I'll need to play around with that and do some reading.

I'm not entirely sure I'm creating my wy file correctly.  What I was hoping to do was to create the barest minimum, such as a global 'integer', and then start adding in a piece at a time.  Does that approach make sense or should I try to start with a chunk, like defining what a block looks like?

The most minimal, valid LSL script I can think of would look something like this:

default
{
  state_entry()
  {
    llOwnerSay("state_entry");
  }
}

but as global variables are valid, I was thinking I could start with just:

integer value = 1;

and see if that'll parse correctly.  I haven't tried this yet, but would it be a valid approach?


On Wed, Feb 13, 2013 at 1:42 PM, David Engster <deng@randomsample.de> wrote:
Corysia Taware writes:
> 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.

You need to add some boilerplate code to set up your lexer and hook the
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:

http://www.randomsample.de/cedetdocs/semantic/lang-support-guide/

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. :-)

-David


-------------------------------------------------------------------
(require 'semantic)
(require 'semantic/wisent/YOURLANGUAGE-wy)
(require 'backquote)

;; Depending on what elements you include specialized support for
(eval-when-compile
  (require 'semantic/ctxt)
  (require 'semantic/imenu)
  (require 'semantic/senator))

;;; Code:

;; 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
(define-lex semantic-YOURLANGUAGE-lexer
  "Lexical Analyzer for YOURLANGUAGE code."
  semantic-lex-ignore-whitespace
  semantic-lex-ignore-newline
  ;; Analyzers auto-generated from grammar.
  wisent-YOURLANGUAGE-wy--<number>-regexp-analyzer
  wisent-YOURLANGUAGE-simple-wy--<keyword>-keyword-analyzer
  wisent-YOURLANGUAGE-wy--<symbol>-regexp-analyzer
  wisent-YOURLANGUAGE-wy--<punctuation>-string-analyzer
  ;; Signal error on unhandled syntax.
  semantic-lex-default-action)


;; 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."
  nil)

;;; Override methods & Variables
;;
;;(defcustom-mode-local-semantic-dependency-system-include-path
;;  YOURLANGUAGE-mode semantic-makefile-dependency-system-include-path
;;  nil
;;  "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
;;
;;;###autoload
(defun semantic-default-YOURLANGUAGE-setup ()
  "Set up a buffer for semantic parsing of the YOURLANGUAGE language."
  (wisent-YOURLANGUAGE-wy--install-parser)
  ;; 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-tag-expand-function 'semantic-YOURLANGUAGE-expand-tag
        ;;semantic-lex-extensions semantic-lex-YOURLANGUAGE-extensions
        ;;semantic-dependency-include-path semantic-default-YOURLANGUAGE-path
        imenu-create-index-function 'semantic-create-imenu-index
        semantic-type-relation-separator-character '(".")
        semantic-command-separation-character ";"
        ;; 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)

(provide 'semantic/wisent/YOURLANGUAGE)
--------------------------------------------------------------------------