Menu

#613 Function list for C#

Next_major_release
closed
nobody
None
6
2014-12-20
2014-10-03
No

Hi All,

Suggesting my function list parser for C# classes, structures and interfaces to include to base functionList.xml:

...
<association langID="4" id="cs_function"/>
...
<parser id="cs_function" displayName="C# Class" commentExpr="((/\*.*?\*)/|(//.*?$))">
    <classRange
        mainExpr="^[\t ]*((public|protected|private|internal)[\s]+)?([\w]+[\s]*)?(class|struct|interface)[\t ]+[^\{]+\{"
        openSymbole = "\{"
        closeSymbole = "\}"
        displayMode="node">
        <className>
            <nameExpr expr="(class|struct|interface)[\t ]+[\w]+"/>
            <nameExpr expr="[\t ]+[\w]+"/>
            <nameExpr expr="[\w]+"/>
        </className>
        <function
            mainExpr="^[^\S\r\n]*(?<modifier1>(?:public|protected|internal|private)\s*)?(?<modifier2>(?:new|static|virtual|sealed|override|abstract|extern)\s*)?(partial\s*)?(?<type>(?!(return|if|else))\w+(?<genericType><[\w,\s<>]+>)?\s+)(?<name>\w+(?<genericNameType><[\w,\s<>]+>)?\s?)\((?<params>[\w\s,<>\[\]\:=\.]*)\)(?<ctorChain>\s*\:\s*(?:base|this)\s*\((?<ctorParams>[\w\s,<>\[\]\:=\.]*)\))?[\w\s<>\:,\(\)\[\]]*(?:\{|;)">
            <functionName>
                <funcNameExpr expr="(\w+(<[\w,\s<>]+>)?\s?)\("/>
                <funcNameExpr expr="(\w+(<[\w,\s<>]+>)?\s?)"/>
            </functionName>
        </function>
    </classRange>
    <function mainExpr="">
    </function>
</parser>

It is able to parse constructor chains, generic methods and types as to C# Language Specification 5.0. I've added named groups for easier reading.

Cheers,
Max

Discussion

  • Don HO

    Don HO - 2014-10-21

    Thank you for the contribution.
    However the xml node you provide is not valid xml.
    All the < and > are replaced by & lt ; and & gt ; respectively, in order to make it valid.

    Don

     

    Last edit: Don HO 2014-10-21
  • Don HO

    Don HO - 2014-10-21
    • status: open --> accepted
    • Priority: 5 --> 6
     
  • Don HO

    Don HO - 2014-12-20
    • Status: accepted --> closed
     
MongoDB Logo MongoDB