{"id":22116332,"url":"https://github.com/jmid/xyz-exp-ast","last_synced_at":"2025-07-25T09:32:49.547Z","repository":{"id":18239298,"uuid":"21386328","full_name":"jmid/xyz-exp-ast","owner":"jmid","description":"A simple example of using ocamllex and menhir to build an abstract syntax tree","archived":false,"fork":false,"pushed_at":"2014-08-14T08:30:14.000Z","size":140,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-15T19:14:27.044Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-01T12:10:55.000Z","updated_at":"2024-03-15T19:14:27.045Z","dependencies_parsed_at":"2022-08-04T23:30:26.505Z","dependency_job_id":null,"html_url":"https://github.com/jmid/xyz-exp-ast","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/jmid%2Fxyz-exp-ast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmid%2Fxyz-exp-ast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmid%2Fxyz-exp-ast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmid%2Fxyz-exp-ast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmid","download_url":"https://codeload.github.com/jmid/xyz-exp-ast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227556853,"owners_count":17786365,"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-12-01T12:27:03.914Z","updated_at":"2024-12-01T12:27:04.698Z","avatar_url":"https://github.com/jmid.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"XYZ expressions\n===============\n\nThis is a simple example of how ocamllex and menhir can be used to\nbuild and process an abstract syntax tree (AST) for a language.\n\nIt was developed as part of (a previous version of) the undergraduate\ncompiler course at Aarhus University.\n\nThe AST is defined in ast.ml. It is built recursively in the action\nstatements of each grammar production in parser.mly, and it is\ntraversed in both pprint.ml and eval.ml.\n\n\nSupported syntax:\n\n    exp ::=  x  |  y  |  z\n         |  exp + exp\n         |  exp - exp\n         |  exp * exp\n         |  exp / exp\n         |  ( exp )\n\n\nTo build:\n---------\n\n    $ make\n\n\nTo run:\n-------\n\nExample 1:\n\n    $ ./xyz 3 4 5   (pass a command line value for variable x,y, and z, respectively)\n    x + y - z       (then press return and Ctrl-D on Linux or MacOSX)\n    ((x+y)-z)\n    2$ \n\n(hence the string 'x + y - z' is accepted, it is parsed as ((x+y)-z),\nand it evaluates to 2 when x=3, y=4, and z=5)\n\n\nExample 2:\n\n    $ ./xyz 3 4 5\n    x + y--\n    Parser.Error\n    $\n\n(hence the string 'x + y--' is rejected by the parser)\n\n\nExample 3:\n\n    $ ./xyz 3 4 5\n    2 + 2\n    Failure in lexing: empty token\n    $\n\n(hence the string '2 + 2' is rejected by the scanner)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmid%2Fxyz-exp-ast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmid%2Fxyz-exp-ast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmid%2Fxyz-exp-ast/lists"}