mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-29 11:06:05 -05:00
parser: Detect function declaration (#580)
This commit is contained in:
parent
21f80c825a
commit
ba8f2b1c0f
3 changed files with 24 additions and 0 deletions
|
@ -78,6 +78,11 @@ class ParserError(Enum):
|
|||
# they annotate are different.
|
||||
WRONG_STRING = 205
|
||||
|
||||
# ERROR: This lineref FUNCTION marker is next to a function declaration or
|
||||
# forward reference. The correct place for the marker is where the function
|
||||
# is implemented so we can match with the PDB.
|
||||
NO_IMPLEMENTATION = 206
|
||||
|
||||
|
||||
@dataclass
|
||||
class ParserAlert:
|
||||
|
|
|
@ -487,6 +487,9 @@ def read_line(self, line: str):
|
|||
):
|
||||
self._function_starts_here()
|
||||
self._function_done()
|
||||
elif self.function_sig.endswith(");"):
|
||||
# Detect forward reference or declaration
|
||||
self._syntax_error(ParserError.NO_IMPLEMENTATION)
|
||||
else:
|
||||
self.state = ReaderState.WANT_CURLY
|
||||
|
||||
|
|
|
@ -695,3 +695,19 @@ def test_static_variable_incomplete_coverage(parser):
|
|||
# Failed for TEST module
|
||||
assert len(parser.alerts) == 1
|
||||
assert parser.alerts[0].code == ParserError.ORPHANED_STATIC_VARIABLE
|
||||
|
||||
|
||||
def test_header_function_declaration(parser):
|
||||
"""This is either a forward reference or a declaration in a header file.
|
||||
Meaning: The implementation is not here. This is not the correct place
|
||||
for the FUNCTION marker and it will probably not match anything."""
|
||||
|
||||
parser.read_lines(
|
||||
[
|
||||
"// FUNCTION: HELLO 0x1234",
|
||||
"void sample_function(int);",
|
||||
]
|
||||
)
|
||||
|
||||
assert len(parser.alerts) == 1
|
||||
assert parser.alerts[0].code == ParserError.NO_IMPLEMENTATION
|
||||
|
|
Loading…
Reference in a new issue