-
Hi. I'm a student on a compilers course and out of interest of cpp2 I wanted to write a compiler for a language which is inspired by cpp2 syntax. While designing how expressions should be parsed I have been testing the rule:
I wrote a small test program to test how different cases are parsed. The full test is at end of this post but in summary it uses type
Now for a object
I have two remarks about this: Maybe I don't understand something but with this quote from design note: Postfix operators:
I find it interesting that What if, in the spirit of maximal munch, the rule would be changed to:
Like maximal much this would be applied from left to right. Going trough the list again we see that now all cases have unambiguous meaning without changing meaning of the ones that compiled:
These are just some simple examples but I would be interested to hear counterarguments to this rule. Here is the full source code for the test program:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Could you also test when the type is a a pointer-pointer or more? That is, |
Beta Was this translation helpful? Give feedback.
-
@hsutter I think that this points out that https://github.com/hsutter/cppfront/wiki/Design-note:-Postfix-operators
was not updated after https://github.com/hsutter/cppfront/wiki/Design-note:-Postfix-unary-operators-vs-binary-operators was created. Here is further discussion on that topic: #152 (comment)
|
Beta Was this translation helpful? Give feedback.
-
Thanks! This commit's change has been bugging me ever since I did it, especially not being able to write So I just reverted that change, and everything seems to be fine, plus simple things like
Since you wrote a great lengthy test case, I've massaged it slightly. All the cases now print "Dereferenced! Dereferenced! Multiply!" :) Here's the output:
Here's the code:
|
Beta Was this translation helpful? Give feedback.
@hsutter I think that this points out that https://github.com/hsutter/cppfront/wiki/Design-note:-Postfix-operators
was not updated after https://github.com/hsutter/cppfront/wiki/Design-note:-Postfix-unary-operators-vs-binary-operators was created. Here is fur…