Re: [CEDET-devel] my first (lame) stab at wisent javascript parser
Brought to you by:
zappo
From: David P. <dav...@wa...> - 2005-01-05 13:30:40
|
Hi Joakim, > I made a first stab simple wisent javascript parser. > (its lame and incomplete, so dont be too amazed) > > Now Im having difficulty testing the parser. > How do I make it execute reliably in a javascript buffer? > > I thought the %languagemode tag was supposed to set this up. > > Is it suficient to do > (wisent-javascript-jv-wy--install-parser) > from a mode hook? > > Currently I just do: > > - compile the wy file with: > (semantic-grammar-batch-build-one-package "wisent-javascript-jv.wy") > - eval the resulting .el buffer > - make a .js buffer > - ecmascript mode > - wisent-javascript-jv-wy--install-parser > > > Which doesnt work very reliably. Sometimes I get messages like "the > buffer wasnt set up for parsing" The orthodox way to setup a semantic parser is to provide a support library where you will put your language specific code. You could create a wisent-javascript-jv.el file which should at least contain the following: ----- cut here (require 'wisent-javascript-jv-wy) ;;;###autoload (defun wisent-javascript-jv-default-setup () "Hook run to setup Semantic in `ecmascript-mode'." ;; Use the Wisent LALR(1) parser to analyze Javascript sources. (wisent-javascript-jv-wy--install-parser) (setq ;; Lexical analysis semantic-lex-number-expression semantic-java-number-regexp semantic-lex-depth nil ;; Full lexical analysis semantic-lex-analyzer 'javascript-lexer )) (add-hook 'ecmascript-mode-hook 'wisent-javascript-jv-default-setup) (provide 'wisent-javascript-jv) ----- cut here After that library has been loaded, semantic should be setup in buffers opened in `ecmascript-mode'. > Since "defconst" statements are generated, I must change those to > setq:s when regenerating the grammar el file. While editing the grammar file, that should be done automatically by: M-x semantic-grammar-create-package (bound to C-c C-c) > In the end I would like this parser to: > - give me information about keywords > - complain about bad syntax > - do completion All that should be provided by the semantic core when your grammar will produce semantic tags and the necessary javascript versions of some overload functions. Looking at the semantic documentation (and helping improve it ;) ) and at the code in wisent-java.el is a good starting point. Of course you can continue to ask for help in the cedet-devel ML, and we will try to help you as our time will permit. Thanks for working on that! Good luck! David |