{"id":13425630,"url":"https://github.com/pzbitskiy/tealang","last_synced_at":"2025-03-15T20:30:50.200Z","repository":{"id":42034010,"uuid":"211954054","full_name":"pzbitskiy/tealang","owner":"pzbitskiy","description":"Tealang - high level language for Algorand ASC1 and TEAL","archived":false,"fork":false,"pushed_at":"2022-04-16T19:20:49.000Z","size":783,"stargazers_count":37,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-01-25T04:52:46.807Z","etag":null,"topics":["algorand","antlr4","antlr4-go","antlr4-grammar","avm","blockchain","compiler","go","golang","smart-contracts","teal"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pzbitskiy.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":"2019-09-30T20:48:06.000Z","updated_at":"2023-12-18T20:49:38.000Z","dependencies_parsed_at":"2022-08-12T03:00:35.990Z","dependency_job_id":null,"html_url":"https://github.com/pzbitskiy/tealang","commit_stats":null,"previous_names":["pzbitskiy/tl"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pzbitskiy%2Ftealang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pzbitskiy%2Ftealang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pzbitskiy%2Ftealang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pzbitskiy%2Ftealang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pzbitskiy","download_url":"https://codeload.github.com/pzbitskiy/tealang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243790938,"owners_count":20348378,"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":["algorand","antlr4","antlr4-go","antlr4-grammar","avm","blockchain","compiler","go","golang","smart-contracts","teal"],"created_at":"2024-07-31T00:01:15.801Z","updated_at":"2025-03-15T20:30:49.715Z","avatar_url":"https://github.com/pzbitskiy.png","language":"Go","funding_links":[],"categories":["Development \u0026 Tools","Development Tools"],"sub_categories":["Smart Contract Development","Other Development Tools"],"readme":"# Tealang\n\nHigh-level language for Algorand Smart Contracts at Layer-1 and its low-level **TEAL v6** language.\nThe goal is to abstract the stack-based **Algorand Virtual Machine** and provide imperative Go/JS/Python-like syntax.\n\n## Language Features\n\n* Integer and bytes types\n\n* Variables and constants\n```\nlet var1 = 1\nlet var2 = 0x123\nconst myaddr = addr\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ\"\n```\n\n* All binary and unary operations from **TEAL**\n```\nlet a = (1 + 2) / 3\nlet b = ~a\n```\n\n* Functions\n```\ninline function sample1(a) {\n    return a - 1\n}\n\nfunction sample2(a) {\n    return a + 1\n}\n\nfunction noop() void {\n    return\n}\n\nfunction logic() {\n    return sample1(2) + sample2(3)\n}\n```\n\n* Condition statements and expressions\n```\nfunction condition(a) {\n    let b = if a == 1 { 10 } else { 0 }\n\n    if b == 0 {\n        return a\n    }\n    return 1\n}\n```\n\n* Loops\n```\nlet y= 2;\nfor y\u003e0 { y=y-1 }\n```\n\n* Type checking\n```\nfunction get_string() {\n    return \"\\x32\\x33\\x34\"\n}\n\nfunction logic() {\n    let a = 1\n    a = get_string()  // \u003c- type check error\n    return a\n}\n```\n\n* Accounts state access\n```\nfunction approval() {\n    let x = accounts[1].Balance\n    return 1\n}\n```\n\n* Globals and txn data access\n```\nfunction logic() {\n    let s = global.GroupSize\n    let idx = 1\n    let a = gtxn[s-1].ApplicationArgs[idx+2];\n    return a != \"\\x01\"\n}\n```\n\n* Modules\n```\nimport stdlib.const\n```\n\n* Antlr-based parser\n* [syntax highlighter](https://github.com/pzbitskiy/tealang-syntax-highlighter) for vscode.\n\n## Language guide\n\nCheck the [language documentation](GUIDE.md)!\n\n## Usage\n\n* Tealang to bytecode\n    ```sh\n    tealang mycontract.tl -o mycontract.tok\n    ```\n\n* Tealang to TEAL\n    ```sh\n    tealang -c mycontract.tl -o mycontract.teal\n    ```\n* Tealang logic one-liner to bytecode\n    ```sh\n    tealang -l '(txn.Sender == \"abc\") \u0026\u0026 global.MinTxnFee \u003e 2000' -o mycontract.tok\n    ```\n* stdin to stdout\n    ```sh\n    cat mycontract.tl | tealang -s -r - \u003e mycontract.tok\n    ```\n* Dryrun / trace\n    ```sh\n    tealang -s -c -d '' examples/basic.tl\n    ```\n\n## Build from sources\n\n### Prerequisites\n\n1. Set up **ANTLR4**\n    ```sh\n    make antlr-install\n    ```\n    Refer to the [documentation](https://www.antlr.org/) in case of problems.\n2. Install runtime for Go\n    ```sh\n    go get -u github.com/antlr/antlr4/runtime/Go/antlr\n    ```\n3. Install and setup **go-algorand**\n    ```sh\n    make algorand-install\n    ```\n    Check the [Algorand README](https://github.com/algorand/go-algorand/blob/master/README.md) for detailed build instructions if encounter any issues.\n\n### Build and test\n```sh\nmake \u0026\u0026 make test\n```\n\n### Optionally build and run Java AST visualizer\n```sh\nmake java-gui ARGS=examples/basic.tl\n```\n\n## Roadmap\n\n1. Constant folding.\n2. Improve errors reporting.\n3. Code gen: do not use temp scratch in \"assign and use\" case.\n4. Code gen: keep track scratch slots and mark as available after freeing with `load`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpzbitskiy%2Ftealang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpzbitskiy%2Ftealang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpzbitskiy%2Ftealang/lists"}