Re: using define-lex

Arnab Chakraborty <[email protected]> Thu, 29 Oct 2015 06:18:58 +0530
Newsgroups gmane.emacs.semantic
Message-ID <CAM3RRn17GUg09ek0w7k77f_ESUpC-ty5NdZraJNNwDhvKys4Bg@mail.gmail.com>
Thanks, Eric, for the helpful tips. I am following your advice and trying
the
.wy to -wy.el path. However, I cannot get myself into the *wisent-mode*.
Googleing wisent-mode is not producing any help either. Where is this mode
defined?

I loaded *java-tags.wy* hoping that the .wy extension will automatically
bring me to the correct mode. It didn't. I manually "*load-file*"-ed
*grammar.elc* and *wisent.elc*. This allowed a new mode
semantic-grammar-mode which I turned on manually. C-c C-c was bound to
*semantic-grammar-create-package*
which looked kind of hopeful. But upon hitting that key I get
*semantic-grammar-parsetable-builder-default:
`semantic-grammar-parsetable-builder' not defined*

I am using emacs 24.1 that I "apt-get install"-ed in Ubuntu 12.10, if that
is relevant.


Thanks and regards,

Arnab

On Wed, Oct 28, 2015 at 4:57 PM, Eric Ludlam <[email protected]> wrote:

> On 10/27/2015 09:54 PM, Arnab Chakraborty wrote:
>
>> Hi Eric,
>>
>>     Thanks a lot for your help. But still some points are not clear to me.
>> Let me tell you the simple grammar I am working with.
>>
>> ;;First the grammar as a elisp structure. The language just consists of
>> lists of ;;the token "number".
>> (setq g '( (number)
>>                 ()
>>                 (line
>>                      ((number) (format "%s" $1))
>>                      ((line number) (format "%s %s" $1 $2))
>>                 )
>>               )
>> )
>>
>> ;;;Convert to an automaton
>> (setq a (wisent-grammar-compile g))
>>
>> ;;;Create a lexer
>> (define-lex mylex "" semantic-number-analyzer)
>>
>> ;;;Try to put them together (it is here that I get error, saying that
>> ;;;mylex does not fit the bill.
>> (wisent-parse a mylex)
>>
>>
>> I have not tried using a .wy file yet, because I have not yet figured
>> out how to convert a .wy file to  an elisp structure. So java.wy etc
>>   are not helping me yet.
>>
>
> I see. I'm less familiar with this level of use of wisent, and now I know
> what you meant by using a grammar without the semantic infrastructure.
>
> I'm pretty sure what you want is possible, but all the documentation, and
> what I know about it is rigged up to bind a parser into a buffer with a
> series of buffer local variables.  Then the helper functions that parse
> sections of a buffer will all have the correct context needed to start
> parsing.
>
> If your goal is to eventually parse buffer contents, then you should
> definitely start with the .wy files.  The basic process for converting a
> .wy file into a -wy.el file is bound to a key in wisent-mode, so when you
> are editing the grammar, you press C-c C-c, and it gets converted to lisp,
> and also creates all the other needed variables.  For example, you will
> need both the grammar, the keyword table, to tokens table, plus the
> individual token analyzers needed for the lexer, all of which can be
> derived directly from your .wy file.   It will also create a function to
> install your grammar into a buffer.
>
> If you still want to construct your grammar by hand, calc-wy.el is the
> simplest example in the collection that shows what variables you need, and
> how to bind it together to a buffer, and wisent-calc shows how to make sure
> the buffer is fully setup by calling misc init functions.  I don't really
> know the internals of the wisent function stack to avoid using an
> intermediate buffer.
>
> Eric
>

------------------------------------------------------------------------------

_______________________________________________
cedet-semantic mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cedet-semantic