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: Lorenzo Bettini
Subject: Re: [Help-source-highlight] Regular Expression Explanation for 'function.lang'
Date: Mon, 23 May 2011 16:10:44 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10

On 05/20/2011 04:57 PM, Peter Willis wrote:

Hello,


Hi Peter

I have made an IDL syntax highlight file:
rsiidl.lang

One of the included files is 'function.lang'.
This works fine for functions that return a value
since the call syntax for functions is:

VARIABLE = SOMEFUNC(variable , variable, ...)

I now want to define 'procedure.lang' where
the call syntax is:

SOMEPROC, variable, variable, ...

As you can see the call to a procedure in IDL does
not include parenthesis.


please keep in mind that source-highlight does not perform real parsing (only scanning with some state functionalities), thus it can only highlight parts of a program that can be recognized through regular expressions...


'function.lang' reads as follows:


vardef FUNCTION = '(?:[[:alpha:]]|_)[[:word:]]*[[:blank:]]*(?=\()'
function = $FUNCTION

What format (of regex ??) is being used here?
How might I change this to test just the 'procedure' case?

that regular expression uses "Forward Lookahead Asserts" (see also http://www.gnu.org/software/src-highlite/source-highlight.html#Notes-on-regular-expressions), i.e., which are included in (?= )

(?=\()

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

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net



reply via email to

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