Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commented out stuff can be imported #175

Open
Dragorn421 opened this issue Nov 13, 2022 · 1 comment
Open

Commented out stuff can be imported #175

Dragorn421 opened this issue Nov 13, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Dragorn421
Copy link
Contributor

Confirmed for at least scene importing, by ZeeRoX
I assume this bug generalizes to most (all?) imports

Even if data is commented out in a .c, it can still be imported by fast64.

I think this is kind of expected behavior from a code perspective since C parsing is entirely regex-based afaik,
but it's confusing from a user perspective

An easy solution may be to strip comments from source before parsing (note: some stuff relies on comments for parsing, like the sm64 "keep block" thing I forgot the name of, maybe other stuff)

@Dragorn421 Dragorn421 added the bug Something isn't working label Nov 14, 2022
@jesusyoshi54
Copy link
Collaborator

When parsing C, I have taken on this convention to strip all comments and cleanup the lines before parsing:

    dat.seek(0)  # so it may be read multiple times
    InlineReg = "/\*((?!\*/).)*\*/"  # filter out inline comments
    ldat = dat.readlines()
    for l in ldat:
          comment = l.rfind("//")
          # double slash terminates line basically
          if comment:
              l = l[:comment]
          # remove inline comments from line
          l = re.sub(InlineReg, "", l)
# do processing here

This sort of thing can be added easily to a utility function if needed to remove comments. Multi line comments and macros are not caught here either, but those will require a much more complicated parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants