lizard 1.17.20__tar.gz → 1.17.22__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lizard-1.17.20 → lizard-1.17.22}/PKG-INFO +2 -1
- {lizard-1.17.20 → lizard-1.17.22}/README.rst +1 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard.egg-info/PKG-INFO +2 -1
- {lizard-1.17.20 → lizard-1.17.22}/lizard.egg-info/SOURCES.txt +1 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/version.py +1 -1
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/__init__.py +2 -0
- lizard-1.17.22/lizard_languages/perl.py +315 -0
- {lizard-1.17.20 → lizard-1.17.22}/LICENSE.txt +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard.egg-info/dependency_links.txt +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard.egg-info/entry_points.txt +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard.egg-info/requires.txt +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard.egg-info/top_level.txt +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/__init__.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/auto_open.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/csvoutput.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/default_ordered_dict.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/extension_base.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/htmloutput.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/keywords.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardboolcount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardcomplextags.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardcpre.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizarddependencycount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizarddumpcomments.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardduplicate.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardduplicated_param_list.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardexitcount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardgotocount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardignoreassert.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardio.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardmccabe.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardmodified.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardnd.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardnonstrict.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardns.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardoutside.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardstatementcount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/lizardwordcount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_ext/xmloutput.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/clike.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/code_reader.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/csharp.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/erlang.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/fortran.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/gdscript.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/go.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/golike.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/java.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/javascript.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/js_style_language_states.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/js_style_regex_expression.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/jsx.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/kotlin.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/lua.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/objc.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/php.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/python.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/ruby.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/rubylike.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/rust.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/scala.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/script_language.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/solidity.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/swift.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/tnsdl.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/tsx.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/ttcn.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/typescript.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/vue.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/lizard_languages/zig.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/setup.cfg +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/setup.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testApplication.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testAssertionExtension.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testBasicFunctionInfo.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testCOutsideComplexity.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testCPreprocessorExtension.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testCommentOptions.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testCyclomaticComplexity.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testExtension.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testFilesFilter.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testFunctionDependencyCount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testFunctionExitCount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testFunctionGotoCount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testFunctionStatementCount.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testHelpers.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testLanguages.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testMcCabe.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testNestedStructures.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testNestingDepth.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testOutput.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testOutputCSV.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testOutputFile.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testOutputHTML.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/testTokenizer.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/test_analyzer.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/test_auto_open.py +0 -0
- {lizard-1.17.20 → lizard-1.17.22}/test/test_options.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lizard
|
|
3
|
-
Version: 1.17.
|
|
3
|
+
Version: 1.17.22
|
|
4
4
|
Summary: A code analyzer without caring the C/C++ header files. It works with Java, C/C++, JavaScript, Python, Ruby, Swift, Objective C. Metrics includes cyclomatic complexity number etc.
|
|
5
5
|
Home-page: http://www.lizard.ws
|
|
6
6
|
Download-URL: https://pypi.python.org/lizard/
|
|
@@ -70,6 +70,7 @@ A list of supported languages:
|
|
|
70
70
|
- Solidity
|
|
71
71
|
- Erlang
|
|
72
72
|
- Zig
|
|
73
|
+
- Perl
|
|
73
74
|
|
|
74
75
|
By default lizard will search for any source code that it knows and mix
|
|
75
76
|
all the results together. This might not be what you want. You can use
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lizard
|
|
3
|
-
Version: 1.17.
|
|
3
|
+
Version: 1.17.22
|
|
4
4
|
Summary: A code analyzer without caring the C/C++ header files. It works with Java, C/C++, JavaScript, Python, Ruby, Swift, Objective C. Metrics includes cyclomatic complexity number etc.
|
|
5
5
|
Home-page: http://www.lizard.ws
|
|
6
6
|
Download-URL: https://pypi.python.org/lizard/
|
|
@@ -70,6 +70,7 @@ A list of supported languages:
|
|
|
70
70
|
- Solidity
|
|
71
71
|
- Erlang
|
|
72
72
|
- Zig
|
|
73
|
+
- Perl
|
|
73
74
|
|
|
74
75
|
By default lizard will search for any source code that it knows and mix
|
|
75
76
|
all the results together. This might not be what you want. You can use
|
|
@@ -24,6 +24,7 @@ from .solidity import SolidityReader
|
|
|
24
24
|
from .jsx import JSXReader
|
|
25
25
|
from .tsx import TSXReader
|
|
26
26
|
from .vue import VueReader
|
|
27
|
+
from .perl import PerlReader
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
def languages():
|
|
@@ -52,6 +53,7 @@ def languages():
|
|
|
52
53
|
JSXReader,
|
|
53
54
|
TSXReader,
|
|
54
55
|
VueReader,
|
|
56
|
+
PerlReader,
|
|
55
57
|
]
|
|
56
58
|
|
|
57
59
|
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Language parser for Perl
|
|
3
|
+
'''
|
|
4
|
+
|
|
5
|
+
from .code_reader import CodeReader, CodeStateMachine
|
|
6
|
+
from .script_language import ScriptLanguageMixIn
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PerlCommentsMixin(object):
|
|
10
|
+
@staticmethod
|
|
11
|
+
def get_comment_from_token(token):
|
|
12
|
+
if token.startswith('#'):
|
|
13
|
+
return token # Return the entire comment including #
|
|
14
|
+
return None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PerlReader(CodeReader, ScriptLanguageMixIn):
|
|
18
|
+
# pylint: disable=R0903
|
|
19
|
+
|
|
20
|
+
ext = ['pl', 'pm']
|
|
21
|
+
language_names = ['perl']
|
|
22
|
+
_conditions = set(['if', 'elsif', 'unless', 'while', 'until', 'for', 'foreach', '&&', '||', '?', ':', 'when', 'given', 'default', 'do'])
|
|
23
|
+
|
|
24
|
+
def __init__(self, context):
|
|
25
|
+
super(PerlReader, self).__init__(context)
|
|
26
|
+
self.parallel_states = [PerlStates(context)]
|
|
27
|
+
|
|
28
|
+
def preprocess(self, tokens):
|
|
29
|
+
comment = None
|
|
30
|
+
for token in tokens:
|
|
31
|
+
if comment is not None:
|
|
32
|
+
if token == '\n':
|
|
33
|
+
yield comment
|
|
34
|
+
comment = None
|
|
35
|
+
yield token
|
|
36
|
+
else:
|
|
37
|
+
comment += token
|
|
38
|
+
elif token == '#':
|
|
39
|
+
comment = token
|
|
40
|
+
else:
|
|
41
|
+
yield token
|
|
42
|
+
if comment is not None:
|
|
43
|
+
yield comment
|
|
44
|
+
|
|
45
|
+
def _state(self, token):
|
|
46
|
+
current_state = self.parallel_states[-1]
|
|
47
|
+
if token == '\n':
|
|
48
|
+
return
|
|
49
|
+
return current_state.state(token)
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def get_comment_from_token(token):
|
|
53
|
+
if token.startswith('#'):
|
|
54
|
+
# For forgiveness comments, return the entire comment
|
|
55
|
+
stripped = token.lstrip('#').strip()
|
|
56
|
+
if stripped.startswith('lizard forgives') or stripped.startswith('#lizard forgives'):
|
|
57
|
+
return '#lizard forgives' # Return standardized forgiveness comment
|
|
58
|
+
return stripped # Return the stripped comment for other cases
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
@staticmethod
|
|
62
|
+
def generate_tokens(source_code, addition='', token_class=None):
|
|
63
|
+
return ScriptLanguageMixIn.generate_common_tokens(source_code, addition, token_class)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class PerlStates(CodeStateMachine):
|
|
67
|
+
_conditions = set(['if', 'elsif', 'unless', 'while', 'until', 'for', 'foreach', '&&', '||', '?', ':', 'when', 'given', 'default', 'do'])
|
|
68
|
+
|
|
69
|
+
def __init__(self, context):
|
|
70
|
+
super(PerlStates, self).__init__(context)
|
|
71
|
+
self.function_name = ''
|
|
72
|
+
self.package_name = ''
|
|
73
|
+
self.variable_name = ''
|
|
74
|
+
self.brace_count = 0
|
|
75
|
+
self.paren_count = 0
|
|
76
|
+
self.in_attribute = False
|
|
77
|
+
self.anonymous_count = 0
|
|
78
|
+
self._state = self._state_global
|
|
79
|
+
|
|
80
|
+
def _state_global(self, token):
|
|
81
|
+
if token == 'package':
|
|
82
|
+
self.next(self._state_package_dec)
|
|
83
|
+
elif token == 'sub':
|
|
84
|
+
self.function_name = ''
|
|
85
|
+
self.next(self._state_function_dec)
|
|
86
|
+
elif token == '{':
|
|
87
|
+
self.brace_count += 1
|
|
88
|
+
elif token == '}':
|
|
89
|
+
self.brace_count -= 1
|
|
90
|
+
elif token == '(':
|
|
91
|
+
self.paren_count += 1
|
|
92
|
+
self.next(self._state_function_call)
|
|
93
|
+
elif token == '$' or token == 'my' or token == 'our' or token == 'local':
|
|
94
|
+
self.variable_name = ''
|
|
95
|
+
self.next(self._state_variable)
|
|
96
|
+
|
|
97
|
+
def _state_package_dec(self, token):
|
|
98
|
+
if not token.isspace():
|
|
99
|
+
self.package_name = token
|
|
100
|
+
self.next(self._state_global)
|
|
101
|
+
|
|
102
|
+
def _state_variable(self, token):
|
|
103
|
+
if token == '$':
|
|
104
|
+
# Skip the $ in variable names
|
|
105
|
+
pass
|
|
106
|
+
elif token == '=':
|
|
107
|
+
self.next(self._state_assignment)
|
|
108
|
+
elif token == ';':
|
|
109
|
+
self.variable_name = ''
|
|
110
|
+
self.next(self._state_global)
|
|
111
|
+
elif not token.isspace() and self.variable_name == '':
|
|
112
|
+
self.variable_name = token
|
|
113
|
+
|
|
114
|
+
def _state_assignment(self, token):
|
|
115
|
+
if token == 'sub':
|
|
116
|
+
self.next(self._state_anon_sub)
|
|
117
|
+
elif token == ';':
|
|
118
|
+
self.variable_name = ''
|
|
119
|
+
self.next(self._state_global)
|
|
120
|
+
|
|
121
|
+
def _state_function_call(self, token):
|
|
122
|
+
if token == 'sub':
|
|
123
|
+
# Inline anonymous subroutine as argument
|
|
124
|
+
self.anonymous_count += 1
|
|
125
|
+
full_name = f"<anonymous>"
|
|
126
|
+
if self.package_name:
|
|
127
|
+
full_name = f"{self.package_name}::{full_name}"
|
|
128
|
+
|
|
129
|
+
self.context.try_new_function(full_name)
|
|
130
|
+
self.context.confirm_new_function()
|
|
131
|
+
self.next(self._state_anon_brace_search)
|
|
132
|
+
elif token == ')':
|
|
133
|
+
self.paren_count -= 1
|
|
134
|
+
if self.paren_count == 0:
|
|
135
|
+
self.next(self._state_global)
|
|
136
|
+
elif token == '(':
|
|
137
|
+
self.paren_count += 1
|
|
138
|
+
|
|
139
|
+
def _state_anon_sub(self, token):
|
|
140
|
+
if token == '{':
|
|
141
|
+
self.brace_count = 1
|
|
142
|
+
full_name = '<anonymous>'
|
|
143
|
+
# Use variable name if available for more readable function names
|
|
144
|
+
if self.variable_name:
|
|
145
|
+
full_name = '$' + self.variable_name
|
|
146
|
+
|
|
147
|
+
if self.package_name:
|
|
148
|
+
full_name = f"{self.package_name}::{full_name}"
|
|
149
|
+
|
|
150
|
+
self.context.try_new_function(full_name)
|
|
151
|
+
self.context.confirm_new_function()
|
|
152
|
+
self.next(self._state_function_body)
|
|
153
|
+
|
|
154
|
+
def _state_function_dec(self, token):
|
|
155
|
+
if token == '{':
|
|
156
|
+
self.brace_count = 1
|
|
157
|
+
if self.function_name:
|
|
158
|
+
full_name = self.function_name
|
|
159
|
+
if self.package_name:
|
|
160
|
+
full_name = f"{self.package_name}::{self.function_name}"
|
|
161
|
+
self.context.try_new_function(full_name)
|
|
162
|
+
self.context.confirm_new_function()
|
|
163
|
+
self.next(self._state_function_body)
|
|
164
|
+
elif token == ':':
|
|
165
|
+
self.in_attribute = True
|
|
166
|
+
elif token == ';':
|
|
167
|
+
# Forward declaration like "sub func_name;"
|
|
168
|
+
if self.function_name:
|
|
169
|
+
full_name = self.function_name
|
|
170
|
+
if self.package_name:
|
|
171
|
+
full_name = f"{self.package_name}::{self.function_name}"
|
|
172
|
+
self.context.try_new_function(full_name)
|
|
173
|
+
self.context.confirm_new_function()
|
|
174
|
+
# Empty function body
|
|
175
|
+
self.context.end_of_function()
|
|
176
|
+
self.next(self._state_global)
|
|
177
|
+
elif token == 'sub':
|
|
178
|
+
# Handle anonymous subroutine like 'callback(sub { ... })'
|
|
179
|
+
self.anonymous_count += 1
|
|
180
|
+
full_name = f"<anonymous>"
|
|
181
|
+
if self.package_name:
|
|
182
|
+
full_name = f"{self.package_name}::{full_name}"
|
|
183
|
+
self.context.try_new_function(full_name)
|
|
184
|
+
self.context.confirm_new_function()
|
|
185
|
+
self.next(self._state_anon_brace_search)
|
|
186
|
+
elif not token.isspace():
|
|
187
|
+
if not self.in_attribute:
|
|
188
|
+
self.function_name = token
|
|
189
|
+
else:
|
|
190
|
+
# Skip attribute name
|
|
191
|
+
self.in_attribute = False
|
|
192
|
+
|
|
193
|
+
def _state_anon_brace_search(self, token):
|
|
194
|
+
if token == '{':
|
|
195
|
+
self.brace_count = 1
|
|
196
|
+
self.next(self._state_function_body)
|
|
197
|
+
elif token == '(':
|
|
198
|
+
self.paren_count += 1
|
|
199
|
+
elif token == ')':
|
|
200
|
+
self.paren_count -= 1
|
|
201
|
+
if self.paren_count == 0:
|
|
202
|
+
self.next(self._state_global)
|
|
203
|
+
|
|
204
|
+
def _state_function_body(self, token):
|
|
205
|
+
if token == '{':
|
|
206
|
+
self.brace_count += 1
|
|
207
|
+
elif token == '}':
|
|
208
|
+
self.brace_count -= 1
|
|
209
|
+
if self.brace_count == 0:
|
|
210
|
+
self.context.end_of_function()
|
|
211
|
+
self.next(self._state_global)
|
|
212
|
+
elif token == '?':
|
|
213
|
+
# Ternary operator increases complexity
|
|
214
|
+
self.context.add_condition()
|
|
215
|
+
elif token == ':':
|
|
216
|
+
# Colon part of ternary operator also increases complexity
|
|
217
|
+
self.context.add_condition()
|
|
218
|
+
elif token == 'sub':
|
|
219
|
+
# Check if it's a nested named subroutine or anonymous
|
|
220
|
+
self.next(self._state_nested_sub_dec)
|
|
221
|
+
elif token == '(':
|
|
222
|
+
# Track function calls inside function body
|
|
223
|
+
self.paren_count += 1
|
|
224
|
+
self.next(self._state_nested_call)
|
|
225
|
+
|
|
226
|
+
def _state_nested_sub_dec(self, token):
|
|
227
|
+
if token.isspace():
|
|
228
|
+
return
|
|
229
|
+
elif token == '{':
|
|
230
|
+
# Anonymous sub
|
|
231
|
+
self.brace_count += 1
|
|
232
|
+
self.anonymous_count += 1
|
|
233
|
+
anon_name = f"<anonymous>"
|
|
234
|
+
if self.package_name:
|
|
235
|
+
anon_name = f"{self.package_name}::{anon_name}"
|
|
236
|
+
self.context.add_condition() # Count sub as a condition
|
|
237
|
+
self.next(self._state_function_body)
|
|
238
|
+
else:
|
|
239
|
+
# Named nested sub
|
|
240
|
+
nested_func_name = token
|
|
241
|
+
full_name = nested_func_name
|
|
242
|
+
if self.package_name:
|
|
243
|
+
full_name = f"{self.package_name}::{nested_func_name}"
|
|
244
|
+
|
|
245
|
+
# Save current function state
|
|
246
|
+
saved_func_context = self.context
|
|
247
|
+
|
|
248
|
+
# Create a new function for the nested sub
|
|
249
|
+
self.context.try_new_function(full_name)
|
|
250
|
+
self.context.confirm_new_function()
|
|
251
|
+
self.next(self._state_nested_named_sub_brace_search)
|
|
252
|
+
|
|
253
|
+
def _state_nested_named_sub_brace_search(self, token):
|
|
254
|
+
if token == '{':
|
|
255
|
+
self.brace_count = 1
|
|
256
|
+
self.next(self._state_nested_sub_body)
|
|
257
|
+
elif token.isspace():
|
|
258
|
+
return
|
|
259
|
+
elif token == ':':
|
|
260
|
+
# Handle attributes in nested sub
|
|
261
|
+
self.in_attribute = True
|
|
262
|
+
return
|
|
263
|
+
elif token == ';':
|
|
264
|
+
# Forward declaration
|
|
265
|
+
self.context.end_of_function()
|
|
266
|
+
self.next(self._state_function_body)
|
|
267
|
+
|
|
268
|
+
def _state_nested_sub_body(self, token):
|
|
269
|
+
if token == '{':
|
|
270
|
+
self.brace_count += 1
|
|
271
|
+
elif token == '}':
|
|
272
|
+
self.brace_count -= 1
|
|
273
|
+
if self.brace_count == 0:
|
|
274
|
+
# End the nested function
|
|
275
|
+
self.context.end_of_function()
|
|
276
|
+
# Return to parent function
|
|
277
|
+
self.next(self._state_function_body)
|
|
278
|
+
|
|
279
|
+
def _state_nested_call(self, token):
|
|
280
|
+
if token == 'sub':
|
|
281
|
+
# Inline anonymous subroutine as argument
|
|
282
|
+
self.anonymous_count += 1
|
|
283
|
+
full_name = f"<anonymous>"
|
|
284
|
+
if self.package_name:
|
|
285
|
+
full_name = f"{self.package_name}::{full_name}"
|
|
286
|
+
|
|
287
|
+
self.context.try_new_function(full_name)
|
|
288
|
+
self.context.confirm_new_function()
|
|
289
|
+
self.next(self._state_nested_anon_search)
|
|
290
|
+
elif token == ')':
|
|
291
|
+
self.paren_count -= 1
|
|
292
|
+
if self.paren_count == 0:
|
|
293
|
+
self.next(self._state_function_body)
|
|
294
|
+
elif token == '(':
|
|
295
|
+
self.paren_count += 1
|
|
296
|
+
|
|
297
|
+
def _state_nested_anon_search(self, token):
|
|
298
|
+
if token == '{':
|
|
299
|
+
self.brace_count += 1
|
|
300
|
+
self.next(self._state_nested_anon_body)
|
|
301
|
+
elif token == '(':
|
|
302
|
+
self.paren_count += 1
|
|
303
|
+
elif token == ')':
|
|
304
|
+
self.paren_count -= 1
|
|
305
|
+
if self.paren_count == 0:
|
|
306
|
+
self.next(self._state_function_body)
|
|
307
|
+
|
|
308
|
+
def _state_nested_anon_body(self, token):
|
|
309
|
+
if token == '{':
|
|
310
|
+
self.brace_count += 1
|
|
311
|
+
elif token == '}':
|
|
312
|
+
self.brace_count -= 1
|
|
313
|
+
if self.brace_count == 1: # Back to outer function level
|
|
314
|
+
self.context.end_of_function()
|
|
315
|
+
self.next(self._state_function_body)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|