{"id":19362960,"url":"https://github.com/ciavash/simple-c-parser","last_synced_at":"2025-04-23T13:31:43.659Z","repository":{"id":147482293,"uuid":"11122707","full_name":"CIAvash/simple-c-parser","owner":"CIAvash","description":"A simple parser for C language.","archived":true,"fork":false,"pushed_at":"2013-07-02T10:40:36.000Z","size":176,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T07:27:22.932Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://codeberg.org/CIAvash/simple-c-parser","language":"Perl","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CIAvash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-02T10:38:34.000Z","updated_at":"2024-11-20T09:58:30.000Z","dependencies_parsed_at":"2023-03-25T15:03:11.956Z","dependency_job_id":null,"html_url":"https://github.com/CIAvash/simple-c-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CIAvash%2Fsimple-c-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CIAvash%2Fsimple-c-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CIAvash%2Fsimple-c-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CIAvash%2Fsimple-c-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CIAvash","download_url":"https://codeload.github.com/CIAvash/simple-c-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250440092,"owners_count":21430950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T07:31:50.362Z","updated_at":"2025-04-23T13:31:43.357Z","avatar_url":"https://github.com/CIAvash.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"Simple C Parser\n===============\n\nThis is a simple C parser script I wrote for a university project (Principles of Compiler Design course).\n\nscanner.pl and parser.pl are separate and do not depend on each other. A simplified version of scanner.pl is used in parser.pl.\n\nScanner does the lexical analysis(using regular expressions) and Parser does the syntax analysis.\n\nThe simple C grammar along with FIRST and FOLLOW sets and parse table are in the `documents` directory. The LL(1) C grammar is the LL(1) version of Simple C grammar you get after left factoring and left recursion removal.\n\nText::SimpleTable module is required for drawing symbol table and output of parser. You can install it with cpanminus:\n\n`sudo cpanm Text::SimpleTable`\n\nUsage\n-----\n\nPerl scripts should be marked as executable. You can achieve this with the following command:\n\n`chmod +x scanner.pl parser.pl`\n\nScanning C source code:\n\n`./scanner.pl [file_name]`\n\nParsing C source code:\n\n`./parser.pl [-s] [file_name]`\n\n`-s` option tells the script to print the symbol table.\n\nIf you want to type the C code directly, don't enter the file name. When you finished entering C code, hit Ctrl-D.\n\nIf you can't see the whole output in the terminal, pipe it to `less`:\n\n`./parser.pl [-s] [file_name] | less`\n\nHere is some dummy code to show you what can be parsed and scanned:\n\nFor scanner:\n\n    /* Multi-line\n    comment */\n    int main() {\n        int i = 2.56e+2;\n        // Comment\n        char ch = 'a';\n        i++;\n        i--;\n        i*=5;\n        i/=2;\n        return 0;\n    }\n\nFor parser:\n\n    main() {\n        int a[10];\n        int i;\n        int j;\n        i = 4;\n        j=i*6;\n        if(j\u003c10) {\n            j = j - 1;\n        }\n        return 0;\n    }","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fciavash%2Fsimple-c-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fciavash%2Fsimple-c-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fciavash%2Fsimple-c-parser/lists"}