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

Refactor variable and enum declarations to be statements. #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

avorobey
Copy link

Now variables can be declared within functions anywhere, not just
at the beginning, and enums can go into functions too.

The three similar declaration-parsing blocks are unified into one. The
end result is thereby negative code growth (-17 lines).

Now variables can be declared within functions anywhere, not just
at the beginning, and enums can go into functions too.
This could also easily work to support default parameter values,
simply by allowing ctx==Par and not only ctx==Loc in the condition.
Not sure how I feel about that, considering it's C and not C++...
else if (tk == Char) { next(); ty = CHAR; }
while (tk == Mul) { next(); ty = ty + PTR; }
if (tk != Id) { printf("%d: bad parameter declaration\n", line); return -1; }
if (id[Class] == Loc) { printf("%d: duplicate parameter definition\n", line); return -1; }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the impact after the removal of Line 412?

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

Successfully merging this pull request may close these issues.

None yet

2 participants