Decomp parser: indirect globals and string markers (#446)

* Enable string annotations and indirect globals

* Adding some STRING annotations

* Library functions
This commit is contained in:
MS
2024-01-17 06:56:34 -05:00
committed by GitHub
parent 6af0c6cb1a
commit aaa18bc9e2
28 changed files with 738 additions and 93 deletions

View File

@@ -10,6 +10,7 @@ from isledecomp.parser.util import (
is_blank_or_comment,
get_class_name,
get_variable_name,
get_string_contents,
)
@@ -158,3 +159,18 @@ variable_name_cases = [
@pytest.mark.parametrize("line,name", variable_name_cases)
def test_get_variable_name(line: str, name: str):
assert get_variable_name(line) == name
string_match_cases = [
('return "hello world";', "hello world"),
('"hello\\\\"', "hello\\"),
('"hello \\"world\\""', 'hello "world"'),
('"hello\\nworld"', "hello\nworld"),
# Only match first string if there are multiple options
('Method("hello", "world");', "hello"),
]
@pytest.mark.parametrize("line, string", string_match_cases)
def test_get_string_contents(line: str, string: str):
assert get_string_contents(line) == string