{"id":19326625,"url":"https://github.com/dzangfan/basic-cc","last_synced_at":"2026-03-02T11:02:50.413Z","repository":{"id":186424624,"uuid":"674919408","full_name":"dzangfan/basic-cc","owner":"dzangfan","description":"YA compiler compiler in Racket","archived":false,"fork":false,"pushed_at":"2023-08-19T12:31:25.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T06:22:36.465Z","etag":null,"topics":["compiler","racket","yacc"],"latest_commit_sha":null,"homepage":"","language":"Racket","has_issues":true,"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/dzangfan.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-05T06:59:40.000Z","updated_at":"2023-08-06T00:45:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"d30d83c3-37bb-4d88-9bc5-be6c2687fc16","html_url":"https://github.com/dzangfan/basic-cc","commit_stats":null,"previous_names":["dzangfan/basic-cc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dzangfan/basic-cc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzangfan%2Fbasic-cc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzangfan%2Fbasic-cc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzangfan%2Fbasic-cc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzangfan%2Fbasic-cc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dzangfan","download_url":"https://codeload.github.com/dzangfan/basic-cc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzangfan%2Fbasic-cc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29999231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T09:59:02.300Z","status":"ssl_error","status_checked_at":"2026-03-02T09:59:02.001Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["compiler","racket","yacc"],"created_at":"2024-11-10T02:14:21.185Z","updated_at":"2026-03-02T11:02:50.373Z","avatar_url":"https://github.com/dzangfan.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"* basic-cc -- An academic compiler compiler\n\nThis repo contains a series of tools for building compilers, including lexer, parser (LL, LR(0), LR(1)), and debugger. This library aims to keep the complexity at a low level and provide intuitive interfaces, meaning that it is quite theoretical rather than practical.\n\n#+begin_src racket\n  #lang racket\n\n  (require basic-cc/language)\n\n  (define-language s-exp\n    \"\\\\s+\"                                ; Ignore characters matching this pattern\n    (L \"\\\\(\") (R \"\\\\)\") (SYM \"\\\\w+\")      ; Name of token must be [A-Z]+\n    (form SYM (L items R) (L R))          ; form -\u003e SYM | L items R | L R\n    (items form (items form)))\n\n  (define source \"(flatten (() (1 (2))))\")\n\n  (s-exp-cut source)\n  ;; #(#\u003cL: \"(\"\u003e #\u003cSYM: \"flatten\"\u003e #\u003cL: \"(\"\u003e #\u003cL: \"(\"\u003e #\u003cR: \")\"\u003e\n  ;;   #\u003cL: \"(\"\u003e #\u003cSYM: \"1\"\u003e #\u003cL: \"(\"\u003e #\u003cSYM: \"2\"\u003e #\u003cR: \")\"\u003e\n  ;;   #\u003cR: \")\"\u003e #\u003cR: \")\"\u003e #\u003cR: \")\"\u003e #\u003cEOF: #f\u003e)\n\n  (s-exp-read source)\n  ;; (form #\u003cL: \"(\"\u003e\n  ;;       (items\n  ;;        (items (form #\u003cSYM: \"flatten\"\u003e))\n  ;;        (form #\u003cL: \"(\"\u003e\n  ;;              (items\n  ;;               (items (form #\u003cL: \"(\"\u003e #\u003cR: \")\"\u003e))\n  ;;               (form #\u003cL: \"(\"\u003e\n  ;;                     (items (items (form #\u003cSYM: \"1\"\u003e))\n  ;;                            (form #\u003cL: \"(\"\u003e\n  ;;                                  (items (form #\u003cSYM: \"2\"\u003e))\n  ;;                                  #\u003cR: \")\"\u003e))\n  ;;                     #\u003cR: \")\"\u003e))\n  ;;              #\u003cR: \")\"\u003e))\n  ;;       #\u003cR: \")\"\u003e)\n#+end_src\n\nThe macro ~define-language~ will define a set of variables and functions to accomplish syntactic parsing. As shown above, ~s-exp-cut~ and ~s-exp-read~ play important roles in this process. Both of them have the same signature:\n\n#+begin_src racket\n  (language-cut/read in #:file filename)\n#+end_src\n\nwhere ~in~ is either a ~input-port~ or a string and ~filename~ is a string pointing to source of the input as metadata. Besides, ~define-language~ defines the following variables, though you can ignore them completely.\n\n- ~s-exp/lexicon~ Internal lexer object\n- ~s-exp/grammar~ Classical context-free grammar defined by 4-tuple\n- ~s-exp/automaton~ LR(1) automaton derived from ~s-exp/grammar~\n- ~s-exp/table~ General LR table for syntax parsing\n- ~s-exp/language~ 4-tuple of variables above\n\nThree options are provided for further control:\n\n- ~(#:enable-EOL)~ Generate EOL token for newline (default not)\n- ~(#:allow-conflict)~ Prevent the compiler compiler from raising exception when syntactic conflicts are found\n- ~(#:driver driver)~ Specify the parsing method, where driver is ~LR.0~ or ~LR.1~\n\nA bigger example can be found [[https://github.com/dzangfan/juhz/blob/79af5d2ba7a417e5000e144fd8944519f537d6e4/language.rkt][here]].\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzangfan%2Fbasic-cc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdzangfan%2Fbasic-cc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzangfan%2Fbasic-cc/lists"}