help-source-highlight
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-source-highlight] Regular Expression Explanation for 'function


From: Peter Willis
Subject: Re: [Help-source-highlight] Regular Expression Explanation for 'function.lang'
Date: Tue, 24 May 2011 08:27:45 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]