Anyway to catch module with comments in module header?

All questions regarding lexer highlighting schemes are discussed here...
Locked
runsun
Posts: 15
Joined: 16.12.2015 01:43

Anyway to catch module with comments in module header?

Post by runsun »

How can I catch modules having the following 2 structures :

Code: Select all

    module m1(a,b){
         ......
    }

    module m2(a,b) // comment
    {
         ...... 
    }
I setup the block header rule conditions like this:

Code: Select all

    0  =  <symbol> = { 
    1  =  <symbol> = )
    2 Skip all other tokens
    3  = <symbol> = (
    4  = <identifier> 
    5  = <identifier> = module
This catches the first case (m1), but not m2.

I also tried adding a skip <comment> but it doesn't work:

Code: Select all

    0  =  <symbol> = { 
    1  Skip <comment>   // <==== added 
    2  =  <symbol> = )
    3 Skip all other tokens
    4  = <symbol> = (
    5  = <identifier> 
    6  = <identifier> = module
I also tried using Grammar (don't know if that's possible), but examples on Grammar is hard to find (I searched all lexers and found only C# and Pascal have very limited examples).

.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

grammar is **final try if noone works. try C lexer for this file with m1/m2. it works and shows m1/m2 in tree. it has rule for {....} and new rule for func- not 1 rule for "func{..}"
and rule "func" is "init closed".
runsun
Posts: 15
Joined: 16.12.2015 01:43

Post by runsun »

Alexey wrote:grammar is **final try if noone works. try C lexer for this file with m1/m2. it works and shows m1/m2 in tree. it has rule for {....} and new rule for func- not 1 rule for "func{..}"
and rule "func" is "init closed".
If I use one for {...} and one for module{...}, then a single module will have two blocks:

Code: Select all

   module m(a,b)
   {
        blah blah 
   }

  [+]------- module m(a,b)    // fully folded

  [-]------- module m(a,b)    // first click to unfold module{...}
   '--[+]--- {...}

  [-]------- module m(a,b)   // second click to unfold {...}
   | [-]--- {
   |  |        blah blah 
   '---'---- }
Users have to click twice to open it. This is something I want to avoid. That's why the block head is designed to cover module <id> (...) {.
runsun
Posts: 15
Joined: 16.12.2015 01:43

Post by runsun »

I think I got it to work. First create a

module <id> (...) {

then

module <id> (...) <comment> {

where <comment> and ... are tokens to skip. Place the 2nd one in the bottom of rules.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

>then a single module will have two blocks
It is solved if u use "init closed block".Set init closed for "mod" and it is not folded
Locked