-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathModule.regex.txt
28 lines (26 loc) · 1.22 KB
/
Module.regex.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Matches Open SCAD Modules
(?m) # Set Multiline mode. Then,
^module # match the literal 'module'
\s+ # and the obligitory whitespace.
(?<ModuleName>\w+) # Then match and extract the <ModuleName>.
\s{0,} # Then, there may be whitespace.
# The Module <ModuleParameters> 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.
# The Module <ModuleDefinition> is Within {}
(?<Definition>
\{ # An open {
(?> # Followed by...
[^\{\}]+| # any number of non-bracket character OR
\{(?<Depth>)| # an open curly bracket (in which case increment depth) OR
\}(?<-Depth>) # a closed curly bracket (in which case decrement depth)
)*?(?(Depth)(?!)) # until depth is 0.
\} # followed by a }
)