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

BPF Lexer #1191

Merged
merged 1 commit into from
Jun 20, 2019
Merged

BPF Lexer #1191

merged 1 commit into from
Jun 20, 2019

Conversation

pchaigno
Copy link
Contributor

The BPF bytecode is used in Linux (in its current syntax since v3.15) to extend the kernel at runtime. Clang includes a backend to compile from C. The particular syntax supported with this commit is that of LLVM's disassembler, which as far as I can see, is the most common syntax used to display BPF bytecode snippets.

I haven't specified filenames or mimetypes because there isn't a clear consensus yet. Most of the time, BPF snippets are directly posted as examples in larger texts (blog posts, emails, etc.). When that is not the case, they sometimes have a .b extension, other times an Assembly extension.

The demo files is from one of my own BPF programs, compiled from C. The sample files contains the demo file concatenated with a sample file from LLVM's repository.

I'm adding support for BPF in Rouge to be able to use it in Jekyll-based blogs. You can ping me if reviews are needed for future improvements.

Here's a preview of the result:
bpf-demo

@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Jun 17, 2019
@pyrmont
Copy link
Contributor

pyrmont commented Jun 18, 2019

Thanks for the contribution, @pchaigno! Will review in the next couple of days and let you know if there are any comments :)

Copy link
Contributor

@pyrmont pyrmont left a comment

Choose a reason for hiding this comment

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

In addition to the specific comment about /./m, would you be able to change the rule declarations that are of the form rule /... with rule %r/…? That just prevents any ambiguity errors being raised by Rubocop.

lib/rouge/lexers/bpf.rb Outdated Show resolved Hide resolved
@pyrmont pyrmont added author-action The PR has been reviewed but action by the author is needed and removed needs-review The PR needs to be reviewed labels Jun 20, 2019
@pchaigno
Copy link
Contributor Author

would you be able to change the rule declarations that are of the form rule /... with rule %r/…? That just prevents any ambiguity errors being raised by Rubocop.

Will do. Is that the convention for all lexers now? Should other lexers be changed?

The BPF bytecode is used in Linux (in its current syntax since v3.15) to
extend the kernel at runtime.  Clang includes a backend to compile from C.

The particular syntax supported with this commit is that of LLVM's
disassembler, which as far as I can see, is the most common syntax used to
display BPF bytecode snippets.

I haven't specified filenames or mimetypes because there isn't a clear
consensus yet.  Most of the time, BPF snippets are directly posted as examples
in larger texts (blog posts, emails, etc.).  When that is not the case, they
sometimes have a .b extension, other times an Assembly extension.

I'm adding support for BPF in Rouge to be able to use in Jekyll-based blogs.
You can ping me if reviews are needed for future improvements.

Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
@pchaigno
Copy link
Contributor Author

pchaigno commented Jun 20, 2019

I pushed a rebased commit with the changes. Is that what you had in mind?

@pyrmont
Copy link
Contributor

pyrmont commented Jun 20, 2019

@pchaigno wrote:

Is that the convention for all lexers now? Should other lexers be changed?

Yeah, it's a slow process but we're on the middle of transitioning all the lexers. Unfortunately, it sucks for the PRs that are outstanding because they were almost all submitted before that decision was made. Thanks for updating yours!

I push a rebased commit with the changes. Is that what you had in mind?

Looks great! Will merge in now :)

@pyrmont pyrmont merged commit ab36916 into rouge-ruby:master Jun 20, 2019
@pchaigno pchaigno deleted the bpf-lexer branch June 20, 2019 09:29
@pchaigno
Copy link
Contributor Author

Thanks!

@pyrmont
Copy link
Contributor

pyrmont commented Jun 20, 2019

Thanks @pchaigno :) You've helped make Rouge a better library!

We're operating on a two-week cadence for releases at the moment so this should be released as part of v3.5.0 next Tuesday.

@pyrmont pyrmont removed author-action The PR has been reviewed but action by the author is needed labels Jun 21, 2019
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

2 participants