ridiculousfish / cdecl-blocks Goto Github PK
View Code? Open in Web Editor NEWThe venerable cdecl, with Apple blocks support
The venerable cdecl, with Apple blocks support
Entering [declare funcptr as pointer to function (pointer to const int, const pointer to char) returning int
prints out int (*funcptr)(const int *, char * const )
](int (*funcptr)(const int *, char * const )). This is good.
Entering int (*funcptr)(const int *, char * const )
prints out syntax error
. This is wrong. It should print declare funcptr as pointer to function (pointer to const int, const pointer to char) returning int
.
Dropping the const
s from the arguments prints correctly.
It seems that rvalue reference syntax is not supported.
int&& foo
declares a rvalue reference of an int. But it is parsed as "declare foo as reference to reference to int" by cdecl. There is no such thing as "reference to reference".
Some info about rvalue reference:
https://stackoverflow.com/questions/5590978/reference-of-reference-in-c
make cdecl.shar
got:
make: *** No rule to make target 'makefile', needed by 'cdecl.shar'. Stop.
In the Makefile
, ALLFILES
should be:
ALLFILES= Makefile cdgram.y cdlex.l cdecl.c cdecl.1 testset testset++
Is there any chance that variable length arrays (c99) might be supported some time in the future? thanks.
Mac Homebrew used to build cdecl from the source at http://cdecl.org/files/cdecl-blocks-2.5.tar.gz
, but the file has disappeared. Where are you now hosting the 2.5 release source?
I report this in detail at paul-j-lucas/cdecl#17.
I suddenly had a need for this tool while trying to figure out some hairy logic elsewhere.
The infamous, hard-to-read C standard signal() function
void (*signal(int sig, void(*handler)(int) ))(int)
results in syntax error in https://cdecl.org/
Expected result (just an example): declare signal as function (int, void(*)(int)) returning pointer to function (int) returning void
typedef void (*ParseFn)(bool done);
I pasted a program into cdecl and it told me syntax error
https://github.com/Leurak/MEMZ/blob/master/WindowsTrojan/Source/Destructive/ProcessWatchdog.c
I want to know why.
(((Thread_Local_Variables * ) ((char * ) & scheme_thread_locals_space + scheme_tls_delta ) ) -> scheme_current_thread_ ) -> gmp_tls
the
Thread_Local_Variables
scheme_thread_locals_space
scheme_tls_delta
scheme_current_thread_
gmp_tls
is definition in project,in that case ,can I can't use this tool ?
// syntax error
#define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
// bad character '-'
((struct tcp_skb_cb *)&((__skb)->cb[0]))
The above snippet was copied from Understanding Linux Network Internals.
It is a type cast for writing data to a socket buffer control buffer.
The excellent cdecl.org webapp currently says "by Ridiculous Fish". Would be better to also say "based on a tool by Graham Ross". The README should also credit him, as the source code correctly does.
(Graham was a classmate of mine at Reed; I used his new tool in the early 1980s.)
The C99 restrict
keyword is currently not supported.
int (*(*functionReturningFunction)(int a, int b))(int c, int d);
These work fine:
cast foo into pointer to pointer to const int
↔ (const int **)foo
cast foo into pointer to function (void) returning pointer to array 3 of int
(int (*(*)(void ))[3])foo
cast foo into const pointer to pointer to const int
→ (const int ** const )foo
cast foo into pointer to const pointer to const int
→ (const int * const *)foo
cast foo into pointer to function (void) returning const pointer to array 3 of int
(int (* const (*)(void ))[3])foo
These cause syntax errors (the inverse of the last three cases shown above):
Hello 👋 . I'm a maintainer for the Homebrew project. We noticed the cdecl archive which was located at https://cdecl.org/files/cdecl-blocks-2.5.tar.gz has been removed. I wanted to see if there was an alternate way to fetch this archive.
Related to
Homebrew/homebrew-core#125712
#3
It doesn't understand int i(5);
int declare;
is perfectly valid C++ code but the parser fails, saying "syntax error".
Also fails on declare declare as int
The parser should accept declare
as an identifier.
I'm probably not using this properly, but any code I try doesn't work. Even something as simple as
int a = 1;
on the site tells me
bad character '='
Hi,
void*(*f)(size_t)
is recognized as
declare f as pointer to function (size_t) returning pointer to void
but
void*(*)(size_t)
isn't recognized. I'm not sure if this is a bug or not, both valid C. Is there a reason why not support function pointers without identifiers?
Very long English sentences, without punctuation and replete with conjunctions, can have more than one unintentional meanings. Consider the current example sentence. It can be interpreted as, or at least I find it interpretable as,
declare x as array 3 of pointer (to function returning pointer to array 5 of char)
declare x as array 3 of pointer to function, returning pointer to array 5 of char
As you can see, putting some basic punctuation can have a significant effect on the meaning.
Is it possible to support punctuation in such cases?
using a variable name "ret" causes syntax error, such as: int ret
void (*f)(const void)
yields:
declare f as pointer to function (const void) returning void
but it is not allowed to use const in this situation.
I'm getting an error for:
`c++decl> explain auto operator "" _numch(const char *ch, std::size_t size) noexcept -> std::size_t;
^
23: syntax error: """: cast or declaration expected
`
void (*fun)(int)
is completely correct however void void (*func)(int)
is completely wrong.
This is very tedious because the linux man calls most of function pointers func
const volatile unsigned long long int*const&&(*const&& b)(const volatile unsigned long long int*const*const*const(*const*const*const&&v)[0x1fb]);
Using explain int *(*foo)[5];
works, however using explain int *(*ptr)[5];
results to a Syntax error.
Any clue about the issue?
The combination of "static" and "volatile" seems to be problematic, as tested on http://cdecl.org :
"static volatile int asdf" => syntax error
constexpr in a;
shows syntax error.
Maybe the tool is purely C, and doesn't support C++.
This will not be a bug then.
Is there a similar tool for C++?
Simple googling didn't help.
as said above. If you input "char arra" it works, but if you input "char array" it gives syntax error.
The declaration
int (*a[])();
Prints "declare a as array of pointer to function returning int." It would make more grammatical sense if it were "declare a as an array of pointers to functions returning int."
Though, it's understandable if it's too tricky to integrate plurals into the translation.
I can understand why bool
give a syntax error, but _Bool
has been a builtin since C99.
For reference, this is the example I've tried:
_Bool (*f)(void *, void *)
If I replace that with:
int (*f)(void *, void *)
Then everything works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.