public inbox for sourcenav@sourceware.org
 help / color / mirror / Atom feed
* New Parser/highlighter howto
@ 2001-04-02 10:59 Richard F Weber
  2001-04-02 12:06 ` Mo DeJong
  0 siblings, 1 reply; 4+ messages in thread
From: Richard F Weber @ 2001-04-02 10:59 UTC (permalink / raw)
  To: sourcenav

Jason Andrews wrote:

> Richard,
> 
> Good questions, I had the same ones when I created my own 
> Verilog parser.
> 
>> 1) How does the color highlighter exactly work for SN?  Does it use the 
>> parser to identify what is a comment, what is a function, etc?  Or do I 
>> have to code the syntax checking in separately (ala VIM)
> 
> 
> The colors are not at all related to the parser.
> You have to hook into snavigator/hyper/highlight.c and create
> your own flex .l  file to specify what keywords to highlight.
> I used ch_high.l as a template.
> 
> You also have to find and edit sninit.tcl to turn it on, this was the trick
> for me to get it working.

Hey, that was easy.  Now my ada code is color coded.  But I do have to 
ask why other languages aren't included for color-coding.  I mean adding 
support was _really_ easy (unless I really messed it up).  But this does 
raise another question below:

> 
>> 2) Testing parser offline.  Is there a way to test the parser offline to 
>> make sure the database is getting what I think it's getting? 
> 
> 
> Create a file with the list of files you want to parse and feed this
> to your parser. My verilog parser is named snvp so I run
> 
> % snvp -y files.f -p /bin/more
> 
> Now I can see what goes into the database and I can also debug
> easier using gdb

Thanks.  Now I can see the first line going into the DB, but it decides 
to stop parsing after that line.  I'm sure I'm just doing something 
stupid though.

After perusing through the lists, I saw that there is plans to have a 
new system to dynamically load the highlighters(ala .so's & .dll's).  So 
my question now is:

1) How is the new system going to be different with regards to the 
highlighter.  I wouldn't imagine too different, but...

2) How is the new system going to be different with regards to the parser. 

I'd hate to have to dump a lot of time into working on a 
parser/highlighter if the syntax is just going to change in a few months 
(that is when v5.0 is getting released. right?) 

Thanks for the help

--Rich

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: New Parser/highlighter howto
  2001-04-02 10:59 New Parser/highlighter howto Richard F Weber
@ 2001-04-02 12:06 ` Mo DeJong
  0 siblings, 0 replies; 4+ messages in thread
From: Mo DeJong @ 2001-04-02 12:06 UTC (permalink / raw)
  To: sourcenav

On Mon, 2 Apr 2001, Richard F Weber wrote:

> Hey, that was easy.  Now my ada code is color coded.  But I do have to 
> ask why other languages aren't included for color-coding.  I mean adding 
> support was _really_ easy (unless I really messed it up).  But this does 
> raise another question below:

Because nobody has actually sat down and done it.

> After perusing through the lists, I saw that there is plans to have a 
> new system to dynamically load the highlighters(ala .so's & .dll's).  So 
> my question now is:
> 
> 1) How is the new system going to be different with regards to the 
> highlighter.  I wouldn't imagine too different, but...

It would just load the .so or .dll off the system.
None of this code has been written at this point,
it is just an idea bouncing around.

> 2) How is the new system going to be different with regards to the parser. 
> 
> I'd hate to have to dump a lot of time into working on a 
> parser/highlighter if the syntax is just going to change in a few months 
> (that is when v5.0 is getting released. right?) 

Please don't avoid playing with any parser interfaces out
of fear that they will change wildly in the near future.
That is simply not the case.

Most of the 5.0 work is in "infrastructure". Basically,
we just took out all kinds of nasty stuff that had
built up over the years and replaced it with nice
clean new code. We tried to make no GUI changes and
keep the old APIs working, so 4.5 stuff should not
break. If it did, we would be really hosed since
we don't really have time to rewrite all the parsers.

Mo DeJong
Red Hat Inc

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: New Parser/highlighter howto
  2001-04-02  5:59 Richard F Weber
@ 2001-04-02  9:25 ` Jason Andrews
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Andrews @ 2001-04-02  9:25 UTC (permalink / raw)
  To: Richard F Weber, sourcenav

Richard,

Good questions, I had the same ones when I created my own 
Verilog parser.

> 
> 1) How does the color highlighter exactly work for SN?  Does it use the 
> parser to identify what is a comment, what is a function, etc?  Or do I 
> have to code the syntax checking in separately (ala VIM)

The colors are not at all related to the parser.
You have to hook into snavigator/hyper/highlight.c and create
your own flex .l  file to specify what keywords to highlight.
I used ch_high.l as a template.

You also have to find and edit sninit.tcl to turn it on, this was the trick
for me to get it working.

> 
> 2) Testing parser offline.  Is there a way to test the parser offline to 
> make sure the database is getting what I think it's getting? 

Create a file with the list of files you want to parse and feed this
to your parser. My verilog parser is named snvp so I run

% snvp -y files.f -p /bin/more

Now I can see what goes into the database and I can also debug
easier using gdb

^ permalink raw reply	[flat|nested] 4+ messages in thread

* New Parser/highlighter howto
@ 2001-04-02  5:59 Richard F Weber
  2001-04-02  9:25 ` Jason Andrews
  0 siblings, 1 reply; 4+ messages in thread
From: Richard F Weber @ 2001-04-02  5:59 UTC (permalink / raw)
  To: sourcenav

Ok, granted I'm a bit new to Source navigator and hacking on the API, 
but here it goes. 

I'm working on creating an Ada Parser/Highlighter.  I know another 
company (CAS I think) is supposed to have an Ada parser, but I've 
contacted them on numerous occasions by phone & e-mail and they don't 
seem to want to respond.  So, as a result, I'm looking to hack out an 
Ada parser on my own.

I've found the grammer9x.y & lexer9x.l files from a mirror of the 
falls-church Ada site to give a basic start as to how to parse out Ada.  
Now I'm just trying to work on actually getting something working.

So my question is:

1) How does the color highlighter exactly work for SN?  Does it use the 
parser to identify what is a comment, what is a function, etc?  Or do I 
have to code the syntax checking in separately (ala VIM)

2) Testing parser offline.  Is there a way to test the parser offline to 
make sure the database is getting what I think it's getting? 

I've got the lex code checking and handling comments right now, but the 
syntax highlighter doesn't highlight the right code as a comment.  So 
I'm not sure if I'm doing this stuff right.  Any pointers would be very 
much appreciated. 

I've kind of looked at the chill & python lexer's, but they seem a bit 
advanced for me.  Of course, if there's a perl module that interfaces 
with the SN API calls I could probobally whip something out quicker (but 
I'm not sure how to make Perl interface with C <sigh>)

Thanks in advance.

--Rich

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-04-02 12:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-02 10:59 New Parser/highlighter howto Richard F Weber
2001-04-02 12:06 ` Mo DeJong
  -- strict thread matches above, loose matches on Subject: below --
2001-04-02  5:59 Richard F Weber
2001-04-02  9:25 ` Jason Andrews

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).