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 C lexer #815

Merged
merged 1 commit into from
Aug 18, 2023
Merged

Add C lexer #815

merged 1 commit into from
Aug 18, 2023

Conversation

gandarez
Copy link
Contributor

This PR adds C lexer as well its analyzer as implemented in Pygments.

https://github.com/pygments/pygments/blob/master/pygments/lexers/c_cpp.py#L313

@alecthomas alecthomas merged commit de3a9c2 into alecthomas:master Aug 18, 2023
2 checks passed
@alecthomas
Copy link
Owner

I wonder if it might not be a good idea to extend the XML format to include something like:

<analyzer regex="..." score="0.2" />

@gandarez gandarez deleted the feature/c-lexer branch August 18, 2023 12:51
@gandarez
Copy link
Contributor Author

 regex="..." score="0.2"

What do you mean by score? The result of AnalyzeText may vary according to some checks.

@alecthomas
Copy link
Owner

Yes I'm aware of what it can do, I'm saying that for the common case where you have a couple of regexes and corresponding scores, that could easily be defined declaratively in the XML without having to write a Go wrapper.

@gandarez
Copy link
Contributor Author

Some analyzer don't use regular expressions, like for BBC Basic:

if strings.HasPrefix(text, "10REM >") || strings.HasPrefix(text, "REM >") {
	return 0.9
}

return 0

alecthomas added a commit that referenced this pull request Aug 21, 2023
The `<analyse>` element contains a regex to match against the input, and
a score if the pattern matches.

The scores of all matching patterns for a lexer are summed.

Replaces #815, #813 and #826.
alecthomas added a commit that referenced this pull request Aug 21, 2023
The `<analyse>` element contains a regex to match against the input, and
a score if the pattern matches.

The scores of all matching patterns for a lexer are summed.

Replaces #815, #813 and #826.
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.

2 participants