-
Notifications
You must be signed in to change notification settings - Fork 663
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
CFamilyLexer: refuse quotes between parentheses for function definiti… #2208
Conversation
…ons and declarations Something like id id2("){ ... }"); is no longer wrongly recognized as a "function" id id2(") { ... } "); As the difference in the tests shows, this has the unfortunate side effect that we no longer highlight something like int f(param="default"); as a function declaration, but it is hard to imagine another way to fix this (cf. “most vexing parse” problem). Fixes pygments#2207
Yeah we can't pretend to be a C++ parser. |
Looks great! |
@jean-abou-samra thanks for your prompt efforts here. This is an improvement for our documentation. There is one regression with this change:
now fails. The full file is at https://github.com/ucam-department-of-psychiatry/camcops/blob/master/tablet_qt/qcustomplot/qcustomplot.h I realise this could end up as a game of C++ lexer whac-a-mole and one failiure is better than seven. I appreciate it's never going to be perfect and I'm going to add the ability to skip problematic files in our docs build. |
TLDR: I don't have a fix, but I am sharing my findings on what happens wrong with the lexer when lexing @martinburchell's code. It is a little hard to spot. In @martinburchell's snippet this entire part is somehow lexed as a function declaration:
More specifically:
It appears that this line in the 'functions' regex is what captures the above code block. |
Aaah, it also needs to exclude parentheses. Because
Like with BTW, this doesn't look like a regression introduced by this PR to me, I already see an error token before. |
Oh! Thanks for explaining that And yes, this is not a regression. |
This fixes an issue where in code like this: ``` int foo(float bar) // hello() {} ``` The lexer would match `(float bar) // hello()` as the parameters of the function `foo`, instead of just `(float bar)`. In addition, a similar test case to what was originally reported in pygments#2208 is added.
This fixes an issue where in code like this: ``` int foo(float bar) // hello() {} ``` The lexer would match `(float bar) // hello()` as the parameters of the function `foo`, instead of just `(float bar)`. In addition, a similar test case to what was originally reported in #2208 is added.
By “failure”, do you mean you’re getting error tokens? (I’m not at a computer right now.)
… Le 15 août 2022 à 11:46, Martin Burchell ***@***.***> a écrit :
@jean-abou-samra thanks for your prompt efforts here.
This is an improvement for our documentation. There is one regression with this change:
class QCP_LIB_DECL QCPLayer : public QObject
{
Q_OBJECT
/// \cond INCLUDE_QPROPERTIES
Q_PROPERTY(LayerMode mode READ mode WRITE setMode)
/// \endcond
public:
/*!
Defines the different rendering modes of a layer. Depending on the mode, certain layers can be
replotted individually, without the need to replot (possibly complex) layerables on other
layers.
\see setMode
*/
enum LayerMode { lmLogical ///< Layer is used only for rendering order, and shares paint buffer with all other adjacent logical layers.
,lmBuffered ///< Layer has its own paint buffer and may be replotted individually (see \ref replot).
};
};
now fails. The full file is at https://github.com/ucam-department-of-psychiatry/camcops/blob/master/tablet_qt/qcustomplot/qcustomplot.h
I realise this could ending up as a game of C++ lexer whac-a-mole and one failiure is better than seven. I appreciate it's never going to be perfect and I'm going to add the ability to skip problematic files in our docs build.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Yes, but I believe this is fixed in the next release isn't it?
|
…ons and declarations
Something like
id id2("){ ... }");
is no longer wrongly recognized as a "function"
id id2(") {
...
}
");
As the difference in the tests shows, this has the unfortunate side
effect that we no longer highlight something like
int f(param="default");
as a function declaration, but it is hard to imagine another way to
fix this (cf. “most vexing parse” problem).
Fixes #2207