-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFunction.regex.txt
19 lines (18 loc) · 1.26 KB
/
Function.regex.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Matches Open SCAD Functions
(?m) # Set Multiline mode. Then,
(?<Comments>//[\s.]{0,}?$(?>\r\n|\n)){0,}^function # match the literal 'function'
\s+ # and the obligitory whitespace.
(?<Name>\w+) # Then match and extract the .Name
\s{0,} # Then, there may be whitespace.
# The .Parameters are within ()
(?<Parameters>
\( # An open parenthesis
(?> # Followed by...
[^\(\)]+| # any number of non-parenthesis character OR
\((?<Depth>)| # an open parenthesis (in which case increment depth) OR
\)(?<-Depth>) # a closed parenthesis (in which case decrement depth)
)*(?(Depth)(?!)) # until depth is 0.
\) # followed by a closing parenthesis
)\s{0,} # Then, there may be whitespace.
\=\s{0,} # Then, there may be whitespace.
(?:.|\s){0,}?(?=\z|;)