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

Regex for FORTRAN Throws an Error #398

Open
alicebibaud opened this issue Oct 28, 2024 · 1 comment
Open

Regex for FORTRAN Throws an Error #398

alicebibaud opened this issue Oct 28, 2024 · 1 comment

Comments

@alicebibaud
Copy link

When running lizard over a fortran file, I'm getting this error:

File ".../.venv/lib/python3.12/site-packages/lizard.py", line 567, in analyze_source_code
    for _ in reader(tokens, reader):
  File ".../.venv/lib/python3.12/site-packages/lizard_languages/code_reader.py", line 161, in __call__
    for token in tokens:
  File ".../.venv/lib/python3.12/site-packages/lizard.py", line 533, in condition_counter
    for token in tokens:
  File ".../.venv/lib/python3.12/site-packages/lizard.py", line 525, in token_counter
    for token in tokens:
  File ".../.venv/lib/python3.12/site-packages/lizard.py", line 511, in line_counter
    for token in tokens:
  File ".../.venv/lib/python3.12/site-packages/lizard.py", line 494, in comment_counter
    for token in tokens:
  File ".../.venv/lib/python3.12/site-packages/lizard_languages/fortran.py", line 54, in preprocess
    for token in tokens:
  File ".../.venv/lib/python3.12/site-packages/lizard_languages/code_reader.py", line 123, in _generate_tokens
    token_pattern = re.compile(
                    ^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/re/__init__.py", line 228, in compile
    return _compile(pattern, flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/re/__init__.py", line 307, in _compile
    p = _compiler.compile(pattern, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/re/_compiler.py", line 745, in compile
    p = _parser.parse(p, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/re/_parser.py", line 979, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/re/_parser.py", line 460, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/re/_parser.py", line 862, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/re/_parser.py", line 460, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/re/_parser.py", line 840, in _parse
    raise source.error('global flags not at the start '
re.error: global flags not at the start of the expression at position 14

It looks like this is an issue with the regex that's attempting to pull methods or functions out of this file. I'm interested in taking a stab at fixing this, but I wanted to put this here for completeness.

@terryyin
Copy link
Owner

Thanks for the report. It's fixed with the commit ff1928b please try again. Also I created a new release on pypi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants