{"id":16684279,"url":"https://github.com/aligusnet/cheasle","last_synced_at":"2025-03-13T13:14:31.288Z","repository":{"id":137799831,"uuid":"579785665","full_name":"aligusnet/cheasle","owner":"aligusnet","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-07T22:44:14.000Z","size":5905,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T09:09:25.012Z","etag":null,"topics":["bison","llvm","programming-language","re-flex"],"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/aligusnet.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-18T22:46:56.000Z","updated_at":"2022-12-27T23:02:37.000Z","dependencies_parsed_at":"2023-05-22T14:15:23.400Z","dependency_job_id":null,"html_url":"https://github.com/aligusnet/cheasle","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/aligusnet%2Fcheasle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aligusnet%2Fcheasle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aligusnet%2Fcheasle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aligusnet%2Fcheasle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aligusnet","download_url":"https://codeload.github.com/aligusnet/cheasle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243410458,"owners_count":20286403,"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","llvm","programming-language","re-flex"],"created_at":"2024-10-12T14:42:58.265Z","updated_at":"2025-03-13T13:14:31.268Z","avatar_url":"https://github.com/aligusnet.png","language":"C++","readme":"# Cheasle\n\nStronly-typed mini language built using RE-flex, bison, and llvm.\n\n## Examples\n\n### Fibonacci Sequence\n\n```python\ndef fibonacci(n: int): int {\n  if n == 0 {\n    0;\n  } else {\n    if n == 1 {\n      1;\n    } else {\n      fibonacci(n - 1) + fibonacci(n - 2);\n    }\n  }\n}\nprintf(\"%d\\n\", fibonacci(21) );\n```\n\n### Square root\n\n```python\ndef mySqrt(n: double) : double {\n  def average(a: double, b: double) : double { (a+b)/2; }\n  const eps: double = 0.0001;\n  let e: double = 1;\n  let t: double = n;\n  while |t - e| \u003e eps {\n    t = n / e;\n    e = average(e, t);\n  }\n  e;\n}\nconst arg: double = 171;\nprintf(\"%f\\n\", mySqrt(arg) - sqrt(arg) );\n```\n\n### Logical expressions\n\n```python\ndef within1(begin: double, end: double, value: double): bool {\n  value \u003e= begin and value \u003c end;\n}\n\ndef within2(begin: double, end: double, value: double): bool {\n  not (value \u003c begin or value \u003e= end);\n}\n\nconst begin: double = 5.0;\nconst end: double = 10.0;\nconst val: double = 7.0;\n\nprintf(\"%d\\n\", within1(begin, end, val) and within2(begin, end, val) );\n```\n\n## Short language description\n\n### Data Types\n\n* `bool`: supported in equality, and logical expressions\n* `int`: supported in binary, unary, equality, and comparison expressions. Implicitly covertible into double.\n* `double`: supported in binary, unary, equality, and comparison expressions.\n* `string`: supported in functions only.\n\n### Expressions\n* binary: `+`, `-`, `*`, `/`\n* unary: `|n|` - abs value, `-` - unary minus\n* equality: `==`, `!=`\n* comparison: `\u003e`, `\u003c`, `\u003e=`, `\u003c=`\n* logical: `and`, `or`, `not`\n\n\n### Variable declarations\n\nVariable can be declared as mutable using keyword `let`, e.g.:\n\n```python\nlex x: int = 10;\n```\n\nor constant, using keyword `const`:\n\n```python\nconst x: int = 10;\n```\n\n### Flow control\n\n#### if expression\n```python\nif boolean-expression {\n  expressions;\n} else {\n  expressions;\n}\n```\n* `if` is an expression, not a statement, it returns value of executed branch, therefore, both branches must return values of the same type.\n\n#### while expression\n```python\nwhile boolean-expression {\n  expressions;\n}\n```\n\n* `while` is an expression, not a statement, it returns value of latest executed expression in its body, if its body was never executed it returns a default value of type type of its body.\n\n### Block of expressions\n\n```python\n{\n  expression1;\n  expression2;\n  expression3;\n}\n```\n\nA block of statements is defined using `{` and `}`, expressions in a block are separated by `;`. The return value of a block is its latest executed expression. The latest statement defines a type of a block as well.\n\n\n### Bultin Functions\n* sqrt\n* log\n* exp\n* printf\n\n### User Defined Functions\n\n```python\ndef functionName(arg1: type, arg2: type, ...) : type {\n  function body;\n}\n```\n\n* no `return` keyword, functions return latest executed instruction,\n* function declration is also a statemnt, its type is `function`, however, this type is not allowed to be returned from any other statemnts, like `if`, `while`, etc., therefore, functions are allowed at the beginning and in the middle of an expression block, but are not allowed as the last expression in the block.\n\n## Pre requirements\n\n### macOS\n\n```\nbrew install bison\nbrew install llvm\nexport PATH=\"$(brew --prefix bison)/bin:$PATH\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faligusnet%2Fcheasle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faligusnet%2Fcheasle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faligusnet%2Fcheasle/lists"}