Skip to content
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

Do not require space by the incrementation operator #2

Closed
phoe opened this issue Jan 1, 2019 · 4 comments
Closed

Do not require space by the incrementation operator #2

phoe opened this issue Jan 1, 2019 · 4 comments

Comments

@phoe
Copy link

phoe commented Jan 1, 2019

Your reader macro, after collecting all the tokens, can iterate over all of them and check if any of them are of form FOO++ (same thing for ++FOO and --). If so, it can split that token into FOO and ++.

This should be enough to type the ++ operator in a more natural style - without any spaces between the variable name and the operator.

@y2q-actionman
Copy link
Owner

I see. I have thought only the reader splits and makes tokens.
Your suggestion is meaningful. I'll try to consider it. Thank you.

@phoe
Copy link
Author

phoe commented Apr 18, 2019

I see. I have thought only the reader splits and makes tokens.

That is correct, the reader will see FOO++ as a single token. Nobody prevents you from adding a post-processing step though, that will accept raw input from the reader and split FOO++ into a pair of tokens that are FOO and ++ in the result.

@y2q-actionman
Copy link
Owner

y2q-actionman commented Apr 22, 2019

Sorry, I am very late for responding.

I implemented a new pass for splitting token including ++, --, or unary *, &. (commit 7d87cea).
And I rewrote examples in README. The example of "Duff’s Device" now looks prettier.

Additionally, I plan to add some features in future:

  • Extending this treatment for some operators; When I write C, I use !, ~, -> without spaces. I think they are good candidates.
  • Trying to look local bindings using variable-information of CLtL2, because I want to use with-c-syntax in anywhere.

Thank for your suggestion!

@phoe
Copy link
Author

phoe commented Apr 22, 2019

I've added two comments at 7d87cea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants