Re: Regular Expression Explanation for 'function.lang'

Peter Willis <[email protected]> Tue, 24 May 2011 08:27:45 -0700
Newsgroups gmane.comp.gnu.source-highlight.general
Message-ID <[email protected]>
On 5/23/2011 7:10 AM, Lorenzo Bettini wrote:

> (?=\()
>
> checks whether after the name there's a ( but does not consume it
>
> can the syntax of your procedure definition be identified with a regular
> expression?
>
> Can you make some examples of procedures?
>
> cheers
> Lorenzo


Hello,

In 'IDL' procedures are *called* in the following way:

PROCEDURE_NAME , ARGUMENT_1, ARGUMENT_2, ARGUMENT_3, .... , ARGUMENT_N

As you can see no brackets or parenthesis are used. The problem here is
a regex would need to deal with only the first case of the
comma positioned after 'PROCEDURE_NAME' and ignore all other groupings
until the end of the statement.

There is also on other problem in that statements can use continuation
where a '$' indicates the current statement continues on to the
next line:

PROCEDURE_NAME , ARGUMENT_1, $
ARGUMENT_2, ARGUMENT_3, $
.... , ARGUMENT_N

In this case regex needs to distinguish between the case of
'PRODEDURE_NAME' and cases where the statement has been continued.
ie: not highlight 'ARGUMENT_2' due to the comma following there.


Declarations for *both* functions and procedures are written in
similar ways. The difference is only the 'RETURN' value in the case
of functions:

FUNCTION function_name, arg_1, arg_2 $
                         arg_3, arg_4, ...., arg_n
	....<PROGRAM STATEMENTS>...

    RETURN, some_value
END


PRO procedure_name, arg_1, arg_2 arg_3, arg_4, ....,$
                     arg_n
	....<PROGRAM STATEMENTS>...
END



Best Regards,


Peter