-
Notifications
You must be signed in to change notification settings - Fork 154
Rewrite functions, again #214
base: master
Are you sure you want to change the base?
Conversation
Wow we have literally no C++ spec coverage.
# Conflicts: # grammars/c.cson # spec/c-spec.coffee
This looks pretty good overall! Thanks for the work. The only thing I don't understand is: |
} | ||
{ | ||
'include': '#function-call' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be no function calls here at $base (only func. declarations or definitions can).
Shouldn't this be moved back in to block_innards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mostly for testing purposes so that I didn't have to constantly create the necessary scaffolding.
'begin': '''(?x) | ||
(?= | ||
[A-Za-z_]\\w* # Type modifier | ||
\\s+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not require a return type for functions.
That will break:
main()
(with noint
) convention (before C99)
(which works at the moment as below)
main() {
/* code */
return 0;
}
- Func-like macros (was mentioned in Scope floods because of macros being matched as functions. #189):
(which work at the moment as below)
A_Macro()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Then I think this will become trickier, because I've mostly been relying on the return type to figure out if it's a function or a function call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some tips for you:
- function patterns at $base are functions (which means they are either func.like macros or function definitions or forward declarations).
- function patterns inside a block are function-calls
- function patterns inside a block with return types are function initializations.
You should go according to these.
This implementation also breaks "old-style C function declarations": As I coded PR #206 I had supporting these in mind. But forgot to create specs for them. It's my bad, sorry. 😳 |
Do function declarations ( |
Function declarations do require return types. I think you should consider the problems I've stated in Issue 189 once more. I believe the "verbose" implementation you desired should be done by introducing new patterns, not by altering the current one. |
FYI: I'm going to have to put this on the backburner for a while to finish up some of my other open PRs. |
🚨 MAJOR WORK-IN-PROGRESS 🚨
Requirements
Description of the Change
This PR starts another rewrite of functions and function calls. It fixes a couple of bugs with the existing function implementation, including many cases where function calls would be tokenized as functions instead. The C implementation is based off of language-java's and language-javascript's. In order for C++ functions to tokenize correctly I added a few injections.
Alternate Designs
None.
Benefits
Fixes cases where function calls are tokenized as functions. Operator overloading will be properly supported. Probably some other things as well.
Possible Drawbacks
Pretty major change, and there's barely any C++ spec coverage. Huge possibility of regressions.
Applicable Issues
I'll check later.
/cc @alpyre