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
Original file line number Diff line number Diff line change
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 [email protected]: && \
upload: build/chromad
scp build/chromad [email protected]: && \
ssh [email protected] '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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit c4527e8

Please sign in to comment.