Skip to content

compiler: improve label grammar correctness #198

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

Merged
merged 1 commit into from
Apr 13, 2025
Merged

Conversation

chqrlie
Copy link
Contributor

@chqrlie chqrlie commented Apr 2, 2025

  • add Stmt pointer in Label structure.
  • fix grammar for labelled statements and definitions. eg: if (cond) done: return 0; is now a single statement.
  • accept labelled definitions (generate label:;)
  • accept labels at end of block (generate label:;)
  • add tests

@bvdberg
Copy link
Member

bvdberg commented Apr 3, 2025

I think having a Decl after a label is a compiler issue. The programmer should not have to type: label: ; to fix this..

@chqrlie
Copy link
Contributor Author

chqrlie commented Apr 3, 2025

I think having a Decl after a label is a compiler issue. The programmer should not have to type: label: ; to fix this..

I agree completely. The programmer does not add the ;, the compiler does when it generates the c code.

@chqrlie chqrlie force-pushed the label branch 3 times, most recently from 662b0a6 to 582dba7 Compare April 6, 2025 14:28
* add `Stmt` pointer in `Label` structure.
* fix grammar for labelled statements and definitions. eg:
  `if (cond) done: return 0;` is now a single statement.
* accept labelled definitions (generates `label:;` in C code)
* accept labels at end of block (generates `label:;` in C code)
* add tests
@bvdberg bvdberg merged commit c99eec2 into c2lang:master Apr 13, 2025
2 checks passed
@chqrlie chqrlie deleted the label branch April 13, 2025 23:04
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.

2 participants