Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FunctionList update: Add parser for Pascal/Delphi #3663

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -77,6 +77,7 @@
<association id= "java_syntax" langID= "6" />
<association id= "xml_node" langID= "9" />
<!-- <association id="functionlist_syntax" langID= "9" /> -->
<association id= "pascal_syntax" langID="11" />
<association id= "batch_label" langID="12" />
<association id= "ini_section" langID="13" />
<association id= "perl_function" langID="21" />
@@ -658,6 +659,153 @@
</function>
</parser>

<!-- ========================================================= [ PAS ] -->
<parser
id ="pascal_syntax"
displayName="Pascal"
commentExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`)
(?s:\x7B.*?\x7D) # Multi Line Comment 1st variant
| (?s:\x28\x2A.*?\x2A\x29) # Multi Line Comment 2nd variant
| (?m-s:\x2F{2}.*$) # Single Line Comment
| (?s:\x27(?:[^\x27\x5C]|\x5C.)*\x27) # String Literal
"
>
<classRange
mainExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`)
(?im-s) # multi-line mode on, single-line mode off
^\h* # optional leading whitespace
(?:
CLASS\s*
)?
(?:
(?'CONSTRUCTOR_HEADER' # constructor
CONSTRUCTOR
)
| # or
(?'DESTRUCTOR_HEADER' # destructor
DESTRUCTOR
)
| # or
(?'PROCEDURE_HEADER' # procedure
PROCEDURE
)
| # or
(?'FUNCTION_HEADER' # function
FUNCTION
)
| # or
(?'OPERATOR_HEADER' # operator
OPERATOR
)
)\s+
(?'CLASS_NAME' # class/interface name
(?:[A-Z_]\w*\s*\.\s*)+
)
(?'METHOD_NAME' # method name
[A-Z_]\w*
)
(?'PARAM_LIST' # optional parameter list
\s*\( # start-of-parameter-list indicator
[^()]* # parameter list
\) # end-of-parameter-list indicator
)?
(?('CONSTRUCTOR_HEADER') # constructors don't have a return type
\s*
; # end-of-statement indicator
)
(?('DESTRUCTOR_HEADER') # destructors don't have a return type
\s*
; # end-of-statement indicator
)
(?('PROCEDURE_HEADER') # procedures don't have a return type
\s*
; # end-of-statement indicator
)
(?('FUNCTION_HEADER') # functions have a return type
\s*: # type indicator
\s*[^;]+ # type identifier
; # end-of-statement indicator
)
(?('OPERATOR_HEADER') # operators have a return type
\s*: # type indicator
\s*[^;]+ # type identifier
; # end-of-statement indicator
)
"
>
<className>
<nameExpr expr="(?i)(?:(CONSTRUCTOR|DESTRUCTOR|PROCEDURE|FUNCTION|OPERATOR)\s+)\K(?:(?:[A-Z_]\w*\s*\.\s*)+)(?:[A-Z_]\w*)" />
<nameExpr expr="(?i)(?:(?:[A-Z_]\w*\s*\.\s*)+)(?=[A-Z_])" />
<nameExpr expr="(?i)(?:(?:\s*\.\s*)?[A-Z_]\w*)+(?!\Z)" />
</className>
<function
mainExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`)
(?im-s) # multi-line mode on, single-line mode off
\s+
(?'CLASS_NAME' # class/interface name
(?:[A-Z_]\w*\s*\.\s*)+
)
(?'METHOD_NAME' # method name
[A-Z_]\w*
)
(?'PARAM_LIST' # optional parameter list
\s*\( # start-of-parameter-list indicator
[^()]* # parameter list
\) # end-of-parameter-list indicator
)?
"
>
<functionName>
<funcNameExpr expr="(?i)(?:(?:[A-Z_]\w*\s*\.\s*)+)\K(?:[A-Z_]\w*)(?:\s*\([^()]*\))*" />
<!-- comment out the following node to display the method with its parameters -->
<funcNameExpr expr="(?i)(?:[A-Z_]\w*)(?=\s|\(|\Z)" />
</functionName>
</function>
</classRange>
<function
mainExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`)
(?im-s) # multi-line mode on, single-line mode off
^\h* # optional leading whitespace
(?:
(?'FUNCTION_HEADER' # function
FUNCTION
)
| # or
(?'PROCEDURE_HEADER' # procedure
PROCEDURE
)
)\s+
(?'ROUTINE_NAME' # function/procedure name
[A-Z_]\w*
)
(?'PARAM_LIST' # optional parameter list
\s*\( # start-of-parameter-list indicator
[^()]* # parameter list
\) # end-of-parameter-list indicator
)?
(?('FUNCTION_HEADER') # functions have a return type
\s*: # type indicator
\s*[^;]+ # type identifier
; # end-of-statement indicator
)
(?('PROCEDURE_HEADER') # procedures don't have a return type
\s*
; # end-of-statement indicator
)
(?:\s*OVERLOAD\s*;)?
(?:\s*(?:REGISTER|PASCAL|CDECL|STDCALL|SAFECALL)\s*;)?
(?!\s*(?:FORWARD)\s*;) # prevent matching forward declarations
(?=\s*(?:(?R)|CONST|TYPE|VAR|LABEL|BEGIN)\s*) # only match function/procedure definitions
"
>
<functionName>
<nameExpr expr="(?i)(?:(FUNCTION|PROCEDURE)\s+)\K(?:[A-Z_]\w*)(?:\s*\([^()]*\))*" />
<!-- comment out the following node to display the routine with its parameters -->
<nameExpr expr="(?i)(?:[A-Z_]\w*)(?=\s|\(|\Z)" />
</functionName>
</function>
</parser>

<!-- ================================ [ Batch / Command Shell Script ] -->

<parser
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.