Skip to content

Commit

Permalink
fix: C++ comments after #include
Browse files Browse the repository at this point in the history
Fixes #841
  • Loading branch information
alecthomas committed Sep 9, 2023
1 parent 40542a6 commit c4527e8
Show file tree
Hide file tree
Showing 7 changed files with 426 additions and 421 deletions.
8 changes: 4 additions & 4 deletions Makefile
Expand Up @@ -13,11 +13,11 @@ tokentype_string.go: types.go
go generate

chromad:
rm -f chromad
rm -rf build
esbuild --bundle cmd/chromad/static/index.js --minify --outfile=cmd/chromad/static/index.min.js
esbuild --bundle cmd/chromad/static/index.css --minify --outfile=cmd/chromad/static/index.min.css
(export CGOENABLED=0 ; cd ./cmd/chromad && go build -ldflags="-X 'main.version=$(VERSION)'" -o ../../chromad .)
(export CGOENABLED=0 ; cd ./cmd/chromad && go build -ldflags="-X 'main.version=$(VERSION)'" -o ../../build/chromad .)

upload: chromad
scp chromad root@swapoff.org: && \
upload: build/chromad
scp build/chromad root@swapoff.org: && \
ssh root@swapoff.org 'install -m755 ./chromad /srv/http/swapoff.org/bin && service chromad restart'
1 change: 1 addition & 0 deletions bin/.svu-1.11.0.pkg
1 change: 1 addition & 0 deletions bin/svu
2 changes: 1 addition & 1 deletion lexers/embedded/c++.xml
Expand Up @@ -84,7 +84,7 @@
</rule>
</state>
<state name="macro">
<rule pattern="(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)">
<rule pattern="(include)(\s+)(&quot;[^&quot;]+?&quot;|&lt;[^&gt;]+?&gt;)">
<bygroups>
<token type="CommentPreproc"/>
<token type="Text"/>
Expand Down
4 changes: 2 additions & 2 deletions lexers/testdata/cpp.actual
@@ -1,5 +1,5 @@
#include "a"
#include <b>
#include "a" // comment
#include <b> // comment

[[nodiscard]] void foo() noexcept;
void foo();
Expand Down
7 changes: 5 additions & 2 deletions lexers/testdata/cpp.expected
Expand Up @@ -2,10 +2,13 @@
{"type":"CommentPreproc","value":"#include"},
{"type":"Text","value":" "},
{"type":"CommentPreprocFile","value":"\"a\""},
{"type":"CommentPreproc","value":"\n#include"},
{"type":"CommentPreproc","value":" "},
{"type":"CommentSingle","value":"// comment\n"},
{"type":"CommentPreproc","value":"#include"},
{"type":"Text","value":" "},
{"type":"CommentPreprocFile","value":"\u003cb\u003e"},
{"type":"CommentPreproc","value":"\n"},
{"type":"CommentPreproc","value":" "},
{"type":"CommentSingle","value":"// comment\n"},
{"type":"Text","value":"\n"},
{"type":"NameAttribute","value":"[[nodiscard]]"},
{"type":"Text","value":" "},
Expand Down

0 comments on commit c4527e8

Please sign in to comment.