{"id":24379462,"url":"https://github.com/bruno-anjos/pseudotex","last_synced_at":"2025-04-10T21:10:00.127Z","repository":{"id":62443047,"uuid":"236059679","full_name":"bruno-anjos/PseudoTex","owner":"bruno-anjos","description":"PseudoTex is a transpiler that translates pseudocode into its LaTex representation","archived":false,"fork":false,"pushed_at":"2020-12-21T03:12:37.000Z","size":1240,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T21:09:48.983Z","etag":null,"topics":["latex","pseudocode","rust","transpiler"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/bruno-anjos.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2020-01-24T18:30:00.000Z","updated_at":"2024-12-02T19:54:38.000Z","dependencies_parsed_at":"2022-11-01T23:33:25.413Z","dependency_job_id":null,"html_url":"https://github.com/bruno-anjos/PseudoTex","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruno-anjos%2FPseudoTex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruno-anjos%2FPseudoTex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruno-anjos%2FPseudoTex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruno-anjos%2FPseudoTex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bruno-anjos","download_url":"https://codeload.github.com/bruno-anjos/PseudoTex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248298325,"owners_count":21080320,"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":["latex","pseudocode","rust","transpiler"],"created_at":"2025-01-19T07:15:38.427Z","updated_at":"2025-04-10T21:10:00.110Z","avatar_url":"https://github.com/bruno-anjos.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PseudoTex\n\u003e PseudoTex is a compiler that translates pseudocode into its LaTex representation\n\nIn university I had to do a few reports in LaTex that had pseudocode. Translating the simple pseudocode to the LaTex commands was a huge struggle so I decided to make this tool that translates a simple pseudocode language into the LaTex equivalent commands. I hope it makes your life easier :grin:.\n\nThe pseudocode that PseudoTex follows is somewhat formalized in this [paper](PseudoCodeNotes.pdf) by João Leitão (check [caveats](#Caveats)).\n\n## Installing\nFor now there are two ways of installing PseudoTex, either by using `cargo` or by downloading the latest binary release.\n\n### Using cargo\n\n```shell\nλ ~/ $ cargo install pseudotex\n```\n\n### Using latest release\n\nGo to the repository Releases page and download the binary (Linux or macOS).\n\n### Running\n\n```shell\nλ ~/ $ pseudotex --help\nPseudoTex 1.0\nBruno Anjos \u003cbruno.vale.anjos@gmail.com\u003e\npseudocode transpiler to latex representation\n\nUSAGE:\n    pseudotex [OPTIONS]\n\nFLAGS:\n    -h, --help       Prints help information\n    -V, --version    Prints version information\n\nOPTIONS:\n    -i, --input \u003cinput\u003e      file name to read content from\n    -o, --output \u003coutput\u003e    file name to write content to\n```\n\n## Caveats\n\n### Semi Colons\n\nOne main difference from the language described in the paper, is that every statement has to be followed by a semi colon. I believe this can be changed in the future, but since this made the parser easier to build i decided to take this approach.\n\n## TODO\n\n* Add more symbols\n* Add tests\n* Add test automation per commit\n* Add subscript\n\n## Contributing\n\nIf you'd like to contribute, please fork the repository and use a feature\nbranch. Pull requests are warmly welcome.\n\n## Links\n\nProject dependencies:\n- [LALRPOP](http://lalrpop.github.io/lalrpop/)\n- [clap](https://clap.rs)\n- algorithm2e LaTex Package\n\n## Example\n\nHere is a small example (check [example_protocol.pseudo](/example_protocol.pseudo))\n\n```pseudo\nstate:\n    parents // these are parents ;\n    services;\n    myId;\n    fallback;\n\nupon init do:\n    fallback = getFallback();\n    myId = randomString();\n\nupon event Receive(QUALITY_NOT_ASSURED, service, location) do:\n    newChild = getNodeClosestTo(location);\n    trigger Send(DEPLOY_SERVICE, newChild, service, myself);\n    call addChild(service, newChild);\n\nupon event Receive(DEPLOY_SERVICE, service, sender) do:\n    if service !in services:\n        services = services unite {service};\n    end\n    call updateParent(service, sender);\n\nprocedure updateParent(service, parent):\n    if service.Parent == parent:\n        return;\n    end\n    parents = parents unite {parent};\n    service.parent = parent;\n    foreach child in service.children:\n        trigger Send(GRANDPARENT, child, service, parent, myself);\n    end\n\nupon event Receive(GRANDPARENT, service, grandparent, sender) do:\n    service.grandparent = grandparent;\n\nprocedure updateChildren(service):\n    orderedChild = order(service.children);\n    foreach child in service.children:\n        trigger Send(SIBLINGS, child, service, orderedChild);\n    end\n\nprocedure addChild(service, child):\n    if child !in children:\n        children = children unite {child};\n    end\n\n    if child !in service.children:\n        service.children = service.children unite {child};\n        servicesByChild[child] = servicesByChild[child] unite {service};\n        call updateChildren(service);\n    end\n```\n\nThis pseudocode generates the following LaTeX:\n\n```Latex\n\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[ruled,vlined,linesnumbered]{algorithm2e}\n\\usepackage{amssymb}\n\\begin{document}\n{{\\DontPrintSemicolon\n\\SetAlgoNoLine\n\\LinesNumberedHidden\n\\SetFuncSty{textbf}\n\\begin{algorithm}[ht]\n\\BlankLine\n\\BlankLine\n\\BlankLine\n\n\\SetKwFunction{FunctionID}{State}\n\\SetKwProg{Fn}{}{:}{}\n\\Fn{\\FunctionID}{\nparents\n// these are parents\n\\;services\n\\;myId\n\\;fallback\n}\n\n\\;\\SetKwFunction{FunctionID}{Init}\n\\SetKwProg{Fn}{Upon }{ do:}{}\n\\Fn{\\FunctionID}{\nfallback $\\longleftarrow$ \\FuncSty{getFallback(}\\ArgSty{}\\FuncSty{)}\n\\;myId $\\longleftarrow$ \\FuncSty{randomString(}\\ArgSty{}\\FuncSty{)}\n}\n\n\\;\\SetKwFunction{FunctionID}{Receive}\n\\SetKwProg{Fn}{Upon event }{ do:}{}\n\\Fn{\\FunctionID{QUALITY\\_NOT\\_ASSURED, service, location}}{\nnewChild $\\longleftarrow$ \\FuncSty{getNodeClosestTo(}\\ArgSty{location}\\FuncSty{)}\n\\;\\FuncSty{Trigger} \\FuncSty{Send(}\\ArgSty{DEPLOY\\_SERVICE, newChild, service, myself}\\FuncSty{)}\n\\;\\FuncSty{Call addChild(}\\ArgSty{service, newChild}\\FuncSty{)}\n}\n\n\\;\\SetKwFunction{FunctionID}{Receive}\n\\SetKwProg{Fn}{Upon event }{ do:}{}\n\\Fn{\\FunctionID{DEPLOY\\_SERVICE, service, sender}}{\n\\If{service $\\notin$ services}{services $\\longleftarrow$ services $\\cup$ \\{service\\}}\n\\;\\FuncSty{Call updateParent(}\\ArgSty{service, sender}\\FuncSty{)}\n}\n\n\\;\\SetKwFunction{FunctionID}{updateParent}\n\\SetKwProg{Fn}{Procedure }{:}{}\n\\Fn{\\FunctionID{service, parent}}{\n\\If{service.Parent == parent}{return}\n\\;parents $\\longleftarrow$ parents $\\cup$ \\{parent\\}\n\\;service.parent $\\longleftarrow$ parent\n\\;\\ForEach{child $\\in$ service.children}{\\FuncSty{Trigger} \\FuncSty{Send(}\\ArgSty{GRANDPARENT, child, service, parent, myself}\\FuncSty{)}}\n}\n\n\\;\\SetKwFunction{FunctionID}{Receive}\n\\SetKwProg{Fn}{Upon event }{ do:}{}\n\\Fn{\\FunctionID{GRANDPARENT, service, grandparent, sender}}{\nservice.grandparent $\\longleftarrow$ grandparent\n}\n\n\\;\\SetKwFunction{FunctionID}{updateChildren}\n\\SetKwProg{Fn}{Procedure }{:}{}\n\\Fn{\\FunctionID{service}}{\norderedChild $\\longleftarrow$ \\FuncSty{order(}\\ArgSty{service.children}\\FuncSty{)}\n\\;\\ForEach{child $\\in$ service.children}{\\FuncSty{Trigger} \\FuncSty{Send(}\\ArgSty{SIBLINGS, child, service, orderedChild}\\FuncSty{)}}\n}\n\n\\;\\SetKwFunction{FunctionID}{addChild}\n\\SetKwProg{Fn}{Procedure }{:}{}\n\\Fn{\\FunctionID{service, child}}{\n\\If{child $\\notin$ children}{children $\\longleftarrow$ children $\\cup$ \\{child\\}}\n\\;\\If{child $\\notin$ service.children}{service.children $\\longleftarrow$ service.children $\\cup$ \\{child\\}\n\\;servicesByChild[child] $\\longleftarrow$ servicesByChild[child] $\\cup$ \\{service\\}\n\\;\\FuncSty{Call updateChildren(}\\ArgSty{service}\\FuncSty{)}}\n}\n\n\\BlankLine\n\\BlankLine\n\\BlankLine\n\\end{algorithm}\n\\end{document}\n```\n\nWhich ultimately generates the following pdf:\n\n![](small_example_image.png)\n\n## Licensing\n\nThe code in this project is licensed under GPL-3.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruno-anjos%2Fpseudotex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruno-anjos%2Fpseudotex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruno-anjos%2Fpseudotex/lists"}