{"id":22551100,"url":"https://github.com/michel-leonard/turtle","last_synced_at":"2025-03-28T10:11:43.074Z","repository":{"id":62806810,"uuid":"562656497","full_name":"michel-leonard/Turtle","owner":"michel-leonard","description":"Turtle Language Interpreter using C, Flex (lexical analysis) and Bison (parsing).","archived":false,"fork":false,"pushed_at":"2022-11-08T16:51:52.000Z","size":4118,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T10:35:04.303Z","etag":null,"topics":["bison-flex","grammar-parser","lexical-analysis"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michel-leonard.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":"2022-11-07T01:09:29.000Z","updated_at":"2024-01-20T21:13:27.000Z","dependencies_parsed_at":"2022-11-07T01:45:29.766Z","dependency_job_id":null,"html_url":"https://github.com/michel-leonard/Turtle","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/michel-leonard%2FTurtle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michel-leonard%2FTurtle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michel-leonard%2FTurtle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michel-leonard%2FTurtle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michel-leonard","download_url":"https://codeload.github.com/michel-leonard/Turtle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246009078,"owners_count":20708881,"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":["bison-flex","grammar-parser","lexical-analysis"],"created_at":"2024-12-07T17:09:48.721Z","updated_at":"2025-03-28T10:11:43.050Z","avatar_url":"https://github.com/michel-leonard.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":" # What is this C project ?\n\nIn computer science, when you have \"inputs\" sharing the same grammar, it is useful to make them understandable by your programs. We can turn the input into an Abstract Syntax Tree, then go through the tree performing any needed process, this project is a basic example about it. \n\nThe hardest part of the work, which are lexing and parsing are done using the well known tools Flex and Bison. We can write efficient, clear and readable programs using Flex and Bison, it's not easy to do the same job without them, especially in low level languages (C have no automatic memory management).\n\nThis project take Turtle programs as input, they are files.\n\n**What is this software currently used for?** This project interprets the Turtle programs provided in input and print as output the instructions that a basic drawer automaton needs. For this exercise, the drawer automaton is represented by another program called the turtle-viewer.\n\nIn case of error, when the inputs are wrong, everything should be OK, the error is detected, no output is displayed on stdout (the standard output), only a basic explanation is displayed on stderr (the error output).\n\n**What could be a real use for this type of software?** Reading configuration files to start a process.\n\n# Ubuntu usage\n\nIf you don't know how to get an executable, try to follow this procedure :\n\n- Open a **Terminal** in the downloaded  directory, for example using a right-click or the [cd](https://en.wikipedia.org/wiki/Cd_(command)) command\n- Ubuntu assures you that a C/C++ compiler is available when you run the command `sudo apt install build-essential`\n\nExecute the following installation commands :\n```sh\nsudo apt-get update \nsudo apt-get upgrade\nsudo apt install cmake flex bison\n```\nIf you plan to use the Turtle viewer also execute the following command :\n```c\nsudo apt install libsndio7.0\n```\nCompile your executable by executing the following instructions (you are still located in the downloaded directory) :\n```sh\ncmake .\nmake all\n```\nYour turltle executable is ready, it's locaded at **./turtle**. You can basically test it using `echo -e \"print random(2, 2.5)\" | ./turtle`, it should print a random number between 2 and 2.5 inclusive. Another syntax is to use `./turtle \u003c program.turtle` if you filled the `program.turtle` file with `print random(2, 2.5)`.\n\nThe command`./turtle \u003c ./default-hello.turtle` will interpret the `default-hello.turtle` file using the `turtle` executable showing you the result on the standard output (often named stdout).\n\nWhen you perform some changes in the program source, you just have to execute `make all` to keep updated your Turtle executable.\n\n# Windows usage\nIt's possible to download [Flex and Bison for Windows](https://github.com/lexxmark/winflexbison/releases/tag/v2.5.25), then to request a [JetBrains CLion](https://www.jetbrains.com/clion) demo, this IDE like some others will help you compiling your executable like as Ubuntu. Only the viewer isn't avaliable for Windows.\n\nThe versions i used during Windows development are :\n\n- flex.exe 2.6.4\n- bison (GNU Bison) 3.8.2\n\nSee the top of `CMakeLists.txt` file to manage the Flex.exe and Bison.exe paths.\n\n# How to use the viewer ?\nThe turtle viewer is avaliable for  Ubuntu users, it requires **libsndio7.0**.\n```sh\nsudo apt install libsndio7.0  \nchmod 700 ./turtle\nchmod 700 ./turtle-viewer  \n./turtle \u003c ./default-hello.turtle | ./turtle-viewer\n```\nWhere :\n-  `./turtle` is your turtle interpreter (which is compiled using the given C source code)\n- `./program.turtle` is your Turtle program that must be submited to your interpreter (samples draws are provided)\n- `./turtle-viewer` is the provided viewer\n\nIf the Ubuntu permissions are OK ([chmod](https://fr.wikipedia.org/wiki/Chmod)), you can check my own programs using the following command :\n```sh\n./turtle \u003c ./my-fougeres.turtle | ./turtle-viewer\n```\n\n# What to do ?\n\nYou can take this project as example, update its source code, and/or create your own works (turtle programs).\n\nTake a look at my [Barnsley fern](https://github.com/michel-leonard/Turtle/blob/main/my-fougeres.turtle) drawing below, it only takes 100 lines of Turtle code to display it using the turtle-viewer.\n\n![my Barnsley fern draw](https://raw.githubusercontent.com/michel-leonard/Turtle/main/default-image.png)\n\n# Thank you\n\n- my professors at University of Franche-Comté ❤️\n- GitHub users reporting issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichel-leonard%2Fturtle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichel-leonard%2Fturtle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichel-leonard%2Fturtle/lists"}