Author Topic: select-code-block for Ada?  (Read 5089 times)

witness9

  • Community Member
  • Posts: 54
  • Hero Points: 2
select-code-block for Ada?
« on: October 23, 2006, 02:27:03 PM »
Is it possible to make the select-code-block feature work with Ada?

Thanks!
witness9

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: select-code-block for Ada?
« Reply #1 on: October 25, 2006, 11:23:50 AM »
Is it possible to make the select-code-block feature work with Ada?

Thanks!
witness9

Probably not, but if you can write a pseudo algorithm to parse code blocks in ADA, it's probably not hard to create a Slick C macro that selects a code block . e.g. the algorithm could be something like

find previous word until one of [begin,for,if,while,whatever]
_select_char() // - slick C code to start a selection
find-end-of-block(...)
_select_char()    // slick c code to end the selection


Procedure find-end-of-block(int block-type)
{
    loop
        get-next-word
        if word-is-end-of-block(block-type)
            return
        else if word-is-start-of-block
            find-end-of-block(...)   // recursive call
        end if
    end loop
}

get-next-word would handle skipping comments.  You could use the above code for a "find-matching-perenthesis" mechanism too.

Graeme

Dennis

  • Senior Community Member
  • Posts: 3955
  • Hero Points: 515
Re: select-code-block for Ada?
« Reply #2 on: October 25, 2006, 03:38:57 PM »
Sure, all you have to do is implement the "selectCodeBlock_ada()" Slick-C hook function.  Look at "selectCodeBlock_cob()" for an example.