Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/otmanedaoudi/c-complex-declarations-parser
A program that converts a complex C declaration into a human readable text.
https://github.com/otmanedaoudi/c-complex-declarations-parser
c compiler-design syntax-analysis syntax-tree
Last synced: about 2 months ago
JSON representation
A program that converts a complex C declaration into a human readable text.
- Host: GitHub
- URL: https://github.com/otmanedaoudi/c-complex-declarations-parser
- Owner: OtmaneDaoudi
- License: gpl-3.0
- Created: 2022-11-03T16:25:23.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-23T11:55:07.000Z (5 months ago)
- Last Synced: 2024-08-23T13:04:19.690Z (5 months ago)
- Topics: c, compiler-design, syntax-analysis, syntax-tree
- Language: C
- Homepage:
- Size: 1.84 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is an exercise from the book: [The ANSI C Programming Language](https://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628), but with a more advanced implementation.
I extended the grammar by eliminating left recursivity and applying left factoring.
# Grammer:
```
dcl ==> A dirdcl
A ==> * A | epsilon
dirdcl ==> id dirdcl1 | ( dcl ) dirdcl1
dirdcl1 ==> ( ) dirdcl1 | [ dirdcl2 | epsilon
dirdcl2 ==> ] dirdcl1 | number ] dirdcl1```
# LL(1) table:
| | * | ( | ) | [ | ] | number | id | $ |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| dcl | dcl ==> A dirdcl | dcl ==> A dirdcl | | | | | dcl ==> A dirdcl | |
| A | A ==> * A | A ==> epsilon | | | | | A ==> epsilon | |
| dirdcl | | dirdcl ==> ( dcl ) dirdcl1 | | | | | dirdcl ==> id dirdcl1 | |
| dirdcl1 | | dirdcl1 ==> ( ) dirdcl1 | dirdcl1 ==> epsilon | dirdcl1 ==> [ dirdcl2 | | | | dirdcl1 ==> epsilon |
| dirdcl2 | | | | | dirdcl2 ==> ] dirdcl1 | dirdcl2 ==> number ] dirdcl1 | | |# Notes:
- The program only supports identifiers with one character.
- Supports one-digit array lengths.
- No support for function args.
- No support for constants declaration.# Examples:
![examples](https://user-images.githubusercontent.com/63020343/201544807-5da66464-ce43-4afc-87b6-eecb0c3550ca.png)