0

I have a JavaScript functionList parser which works, however it can't see the function if there are spaces before the brackets or if there is a comment in the function line:

 function parserworks(){ 
 function parserfails (){
 function parserfails(){//comments make the parsing fail 
 function parserfails ( v1:int; v2:byte ):int{

How can I detect and parse any word starting with "function" and ending with "(", so anything of the kind "function foo ( v1:int; v2:byte ):int // ,regardless of what's written after the (?

This is the parsing definition in .xml:

        <parser id="js_function" displayName="Javascript" commentExpr="((/\*.*?\*)/|(//.*?$))">
            <function
                mainExpr="((^|[\s]+|[;\}\.])([_A-Za-z][\w_]*\.)*[_A-Za-z][\w_]*[\s]*[=:]|^|[\s;\}]+)[\s]*function([\s]+[_A-Za-z]?[\w_]*\([^\)\(]*\)|\([^\)\(]*\))[\n\s]*\{"
                displayMode="$className->$functionName">
                <functionName>
                    <nameExpr expr="[_A-Za-z][\w_]*[\s]*[=:]|[_A-Za-z]?[\w_]*[\s]*\("/>
                    <nameExpr expr="[_A-Za-z]?[\w_]*"/>
                </functionName>
                <className>
                    <nameExpr expr="([_A-Za-z][\w_]*\.)*[_A-Za-z][\w_]*\."/>
                    <nameExpr expr="([_A-Za-z][\w_]*\.)*[_A-Za-z][\w_]*"/>
                </className>
            </function>
        </parser>

1 Answer 1

1
    /function.*(\s+\()|(\/\/)/

try that one

Sign up to request clarification or add additional context in comments.

1 Comment

And he mentioned so anything of the kind "function foo ( v1:int; v2:byte ) //

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.