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

Add support for Wren language #2271

Merged
merged 16 commits into from Nov 29, 2022
Merged

Add support for Wren language #2271

merged 16 commits into from Nov 29, 2022

Conversation

PureFox48
Copy link
Contributor

This PR adds syntax highlighting support for the Wren programming language.

Wren's github
Wren's website

Copy link
Collaborator

@Anteru Anteru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Please check the comments to (dramatically) reduce the number of generated tokens, at the moment, you're matching character-by-character in various places which produces enormous amounts of tokens.

pygments/lexers/wren.py Show resolved Hide resolved
pygments/lexers/wren.py Outdated Show resolved Hide resolved
pygments/lexers/wren.py Outdated Show resolved Hide resolved
pygments/lexers/wren.py Outdated Show resolved Hide resolved
pygments/lexers/wren.py Outdated Show resolved Hide resolved
pygments/lexers/wren.py Outdated Show resolved Hide resolved
pygments/lexers/wren.py Show resolved Hide resolved
pygments/lexers/wren.py Show resolved Hide resolved
pygments/lexers/wren.py Outdated Show resolved Hide resolved
@Anteru
Copy link
Collaborator

Anteru commented Nov 13, 2022

Can you please take a look at the failing test? --randomly-seed=2087311863? I presume it generated some input which led to an infinite number of tokens being generated.

@PureFox48
Copy link
Contributor Author

Unfortunately, I don't have a working Windows machine - I only use Linux these days - so I've no idea why the first Windows test is failing. Possibly, it doesn't like the prefixes I've used - r'(?<!\.)' in the keywords section. I could change those to r'\b' without difficulty because, syntactically, keywords can't be used as method names in Wren.

Do you have any clue what the problem could be from past experience?

Incidentally, on my own machine (Ubuntu 22.04), 'make test' runs fine - 4131 passed, 4 skipped.

As regards 'check (pull_request)` failing, this is my first docstring:

"""
    pygments.lexers.wren
    ~~~~~~~~~~~~~~~~~~~~
    Lexer for Wren.
    :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

Looking at other lexers, I suspect I need to insert a blank line before and after 'Lexer for Wren'.

My second docstring looks like this but I can't see anything wrong with it at all:

    """
    For Wren source code, version 0.4.0.

    .. versionadded:: 2.14.0
    """

@birkenfeld
Copy link
Member

You're correct regarding the module docstring. It also should begin in line 1, not line 2.

As for the Windows test, the tests have a random component (testing well-behavedness with a random sequence of input characters), so it should be reproducible regardless of OS with the pytest argument that @Anteru provided.

@PureFox48
Copy link
Contributor Author

OK, thanks.

I'll change the module docstring and see if I can get to the bottom of the other problem by running pytest myself with that random seed though I only have Python 3.10.6 installed.

Corrected module docstring.
@PureFox48
Copy link
Contributor Author

I've corrected the module docstring but other issue not yet resolved.

Hopefully, fixes the problem with the random test.
@PureFox48
Copy link
Contributor Author

PureFox48 commented Nov 14, 2022

Hopefully, I've fixed the failing test by adding another regex at the end of 'root' to catch an arbitrary series of characters.

I've also taken this opportunity to reclassify 'this' as an ordinary keyword (analogous to 'super') rather than a named built-in as it wasn't really highlighting properly before.

@jeanas jeanas self-assigned this Nov 28, 2022
@jeanas
Copy link
Contributor

jeanas commented Nov 29, 2022

Hopefully, I've fixed the failing test by adding another regex at the end of 'root' to catch an arbitrary series of characters.

This was papering over the problem, skipping the positions where it would occur ... The underlying problem was non-terminating behavior with unmatched closing parentheses. Your approach assumed popping when seeing (?=\)) would go to 'parenthesized' or 'interpolation', but that was not true in case of invalid input like this (validating input is not a goal, but always terminating is). I've pushed a solution for this to your branch that is also simpler, making use of include. Let me know if it looks OK to you, as this was the last point to check for me before merging this.

@PureFox48
Copy link
Contributor Author

Ah, I see now where the problem was.

Yes, it looks OK to me and is working fine.

Thanks for your help in finally resolving this issue :)

@jeanas jeanas merged commit a47833d into pygments:master Nov 29, 2022
@jeanas
Copy link
Contributor

jeanas commented Nov 29, 2022

Happy to help. Merged now.

@PureFox48 PureFox48 deleted the wren-branch branch November 29, 2022 14:19
@Anteru Anteru added this to the 2.14.0 milestone Dec 30, 2022
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

Successfully merging this pull request may close these issues.

None yet

4 participants