{"id":26237697,"url":"https://github.com/nbingham1/cog","last_synced_at":"2026-04-29T04:32:51.246Z","repository":{"id":86205251,"uuid":"139349987","full_name":"nbingham1/cog","owner":"nbingham1","description":"Compiler for a C-like systems programming language with interfaces.","archived":false,"fork":false,"pushed_at":"2020-06-21T22:24:51.000Z","size":117,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-31T22:44:34.410Z","etag":null,"topics":["c-like","compiler","systems-programming"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nbingham1.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-01T17:58:06.000Z","updated_at":"2023-01-31T22:48:27.000Z","dependencies_parsed_at":"2023-03-05T13:30:49.949Z","dependency_job_id":null,"html_url":"https://github.com/nbingham1/cog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nbingham1/cog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbingham1%2Fcog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbingham1%2Fcog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbingham1%2Fcog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbingham1%2Fcog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nbingham1","download_url":"https://codeload.github.com/nbingham1/cog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbingham1%2Fcog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32411181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T03:46:11.172Z","status":"ssl_error","status_checked_at":"2026-04-29T03:37:55.317Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["c-like","compiler","systems-programming"],"created_at":"2025-03-13T05:29:00.454Z","updated_at":"2026-04-29T04:32:51.238Z","avatar_url":"https://github.com/nbingham1.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cog\n\n\u003e Cog is under active development. Not all documented language features have been implemented.\n\nCog is a C-like systems programming language intented to maximize modular design with simple features for enforcing and testing correctness.\n\n1. [Examples](#examples)\n2. [Benchmarks](#benchmarks)\n3. [Syntax](#syntax)\n   1. [Program Logic](#program-logic)\n      * [Comments](#comments)\n      * [Variables](#variables)\n      * [Static Arrays](#static-arrays)\n      * [Dynamic Arrays](#dynamic-arrays)\n      * [Pointers](#pointers)\n      * [Expressions](#expressions)\n      * [Implicit Casting Rules](#implicit-casting-rules)\n      * [If Statements](#if-statements)\n      * [While Loops](#while-loops)\n      * [Functions](#functions)\n      * [Inline Assembly](#inline-assembly)\n   2. [Source Files](#source-files)\n      * [Structures](#structures)\n   3. [Interface Files](#interface-files)\n      * [Interfaces](#interfaces)\n      * [Protocols](#protocols)\n      * [Encodings](#encodings)\n   4. [Test Files](#test-files)\n      * [Mocks](#mocks)\n      * [Tests](#tests)\n   5. [Program Files](#program-files)\n   6. [Metaprogramming](#metaprogramming)\n      * [Templates](#templates)\n      * [Dependencies](#dependencies)\n      * [Constraints](#constraints)\n4. [Compiler](#compiler)\n5. [Debugger](#debugger)\n6. [Documenter](#documenter)\n\n## Examples\n\n## Benchmarks\n\n\u003e No benchmarks have been run at this time.\n\n## Syntax\n\nA formal specification of the grammar follows:\n* [Lex Specificiation](src/Lexer.l)\n* [Yacc Grammar](src/Parser.y)\n\n### Program Logic\n\n#### Comments\n\nCog implements C-like comments.\n```\n// This is a line comment\n/*\nThis is\na block\ncomment\n*/\n```\n\n#### Variables\n\n\u003e Primitives except for character encodings have been implemented.\n\u003e Variable declaration currently limited to one variable with no inline assignment.\n\u003e Pointers and Arrays have not yet been implemented.\n\nVariables are declared and assigned using a C-like syntax.\n\n```\ntype name;\ntype name = value;\ntype name0, name1, name2;\ntype name0 = value0, name1 = value1, name2 = value2;\n```\n\nHowever, variable assignment returns void and must be separate statements.\n\n\u003ctable\u003e\n\u003ctr\u003e\u003cth\u003eOperator\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\u003cth\u003eImplemented\u003c/th\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003edirect assignment\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea+=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace add\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea-=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace subtract\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea\u0026#42;=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace multiply\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea/=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace divide\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea%=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace remainder\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea\u0026lt;\u0026lt;=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace left shift\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea\u0026gt;\u0026gt;=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace logical right shift\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea\u0026gt;\u0026gt;\u0026gt;=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace arithmetic right shift\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea\u0026lt;\u0026lt;\u0026gt;=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace rotate left\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea\u0026gt;\u0026gt;\u0026lt;=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace rotate right\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea\u0026=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace bitwise AND\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea^=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace bitwise XOR\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea|=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace bitwise OR\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea and=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace boolean AND\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea xor=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace boolean XOR\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003ea or=b;\u003c/code\u003e\u003c/td\u003e\u003ctd\u003einplace boolean OR\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\nThe usual primitive types are supported with added support for fixed point numbers. Here, `\u003cn\u003e` represents the bitwidth of the type and `\u003cm\u003e` represents it's power of 2 exponent. For example, `int32` is a 32 bit signed integer. `fixed32e-5` is a 32 bit fixed point decimal with a five bit fractional precision. `int\u003cn\u003e`, `uint\u003cn\u003e`, `fixed\u003cn\u003ee\u003cm\u003e`, and `ufixed\u003cn\u003ee\u003cm\u003e` all support arbitrary values for `\u003cn\u003e` and `\u003cm\u003e`. However, `float\u003cn\u003e` is implemented by the smallest of 16, 32, 64, or 128 sufficient for `\u003cn\u003e`.\n\n```\nbool\nint\u003cn\u003e\nuint\u003cn\u003e\nfixed\u003cn\u003ee\u003cm\u003e\nufixed\u003cn\u003ee\u003cm\u003e\nfloat\u003cn\u003e\n```\n\nBoth integer and decimal constants are encoded as fixed point numbers with arbitrary precision. This means that all constant expressions will evaluate at compile time without any rounding errors. Once all constant expressions are evaluated, the results are implicitly cast to and stored as the type that they are assigned in the program. Constants may be specified in base 10 as decimal values with a base 10 exponent or in base 16 or base 2 as integers.\n\n```\n578\n63e-4\n3.2e6\n0x88af\n0b1001\n```\n\n#### Static Arrays\n\n\u003e This feature is not yet implemented.\n\nStatic arrays are declared the same as in C++, the array dimensions are specified after the variable name in the declaration and may only be compile time constants. They are also indexed similary to C++. Static arrays also carry with them compile-time size attributes which may be accessed directly.\n\n```\nint32 myArr[32][6][3];\n\nmyArr[3][2][1] = 5;\n\nint32 width = myArr.size[0];\nint32 height = myArr.size[1];\nint32 depth = myArr.size[2];\n```\n\n#### Dynamic Arrays\n\n\u003e This feature is not yet implemented.\n\nDynamically allocated arrays are specified separately from pointers in Cog with empty array brackets. They may then be allocated as multidimensional arrays then used as expected. Finally, they must be deleted after use. Dynamic arrays carry with them size attributes that are set upon allocation.\n\n```\nint32 myArr[][][];\n\nmyArr = new int32[32][6][3];\n\nmyArr[3][2][1] = 5;\n\nint32 width = myArr.size[0];\nint32 height = myArr.size[1];\nint32 depth = myArr.size[2];\n\ndelete myArr;\n```\n\n#### Pointers\n\n\u003e This feature is not yet implemented.\n\nPointers may only point to a single value.\n\n```\nMyStruct myPtr*;\n\nmyPtr = new MyStruct();\n\nint32 valuePtr*;\nvaluePtr = myPtr*.myMember\u0026;\nvaluePtr* = 3;\n\nint32 myValue = myPtr*.myMember;\n\ndelete myPtr;\n```\n\n#### Expressions\n\nThe following table lists the precedence and associativity of all supported operators in descending precedence.\n\n\u003ctable\u003e\n\u003ctr\u003e\u003cth\u003ePrecedence\u003c/th\u003e\u003cth\u003eOperator\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\u003cth\u003eAssociativity\u003c/th\u003e\u003cth\u003eImplemented\u003c/th\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e1\u003c/th\u003e\u003ctd\u003e\u003ccode\u003e(a)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eparenthesis\u003c/td\u003e\u003ctd\u003e\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e2\u003c/th\u003e\u003ctd\u003e\u003ccode\u003ea::b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003escope resolution\u003c/td\u003e\u003ctd\u003eleft to right\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003e3\u003c/th\u003e\n\u003ctd\u003e\u003ccode\u003ea()\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea[]\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea\u0026#42;\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea\u0026amp;\u003c/code\u003e\u003cbr\u003e\u003ccode\u003etype(b)\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea.b\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003efunction call\u003cbr\u003esubscript\u003cbr\u003epointer dereference\u003cbr\u003eaddress-of\u003cbr\u003etypecast\u003cbr\u003emember access\u003c/td\u003e\n\u003ctd\u003eleft to right\u003c/td\u003e\n\u003ctd\u003eyes\u003cbr\u003eno\u003cbr\u003eno\u003cbr\u003eno\u003cbr\u003eno\u003cbr\u003eno\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003e4\u003c/th\u003e\n\u003ctd\u003e\u003ccode\u003e~a\u003c/code\u003e\u003cbr\u003e\u003ccode\u003enot a\u003c/code\u003e\u003cbr\u003e\u003ccode\u003e-a\u003c/code\u003e\u003cbr\u003e\u003ccode\u003enew a\u003c/code\u003e\u003cbr\u003e\u003ccode\u003edelete a\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003ebitwise not\u003cbr\u003eboolean not\u003cbr\u003enegative\u003cbr\u003eallocate memory\u003cbr\u003edeallocate memory\u003c/td\u003e\n\u003ctd\u003eright to left\u003c/td\u003e\n\u003ctd\u003eyes\u003cbr\u003eyes\u003cbr\u003eyes\u003cbr\u003eno\u003cbr\u003eno\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003e5\u003c/th\u003e\n\u003ctd\u003e\u003ccode\u003ea\u0026#42;b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea/b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea%b\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003emultiplication\u003cbr\u003edivision\u003cbr\u003eremainder\u003c/td\u003e\n\u003ctd\u003eleft to right\u003c/td\u003e\n\u003ctd\u003eyes\u003cbr\u003eyes\u003cbr\u003eyes\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003e6\u003c/th\u003e\n\u003ctd\u003e\u003ccode\u003ea+b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea-b\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eaddition\u003cbr\u003esubtraction\u003c/td\u003e\n\u003ctd\u003eleft to right\u003c/td\u003e\n\u003ctd\u003eyes\u003cbr\u003eyes\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003e7\u003c/th\u003e\n\u003ctd\u003e\u003ccode\u003ea\u0026lt;\u0026lt;b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea\u0026gt;\u0026gt;b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea\u0026gt;\u0026gt;\u0026gt;b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea\u0026lt;\u0026lt;\u0026gt;b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea\u0026gt;\u0026gt;\u0026lt;b\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eleft shift\u003cbr\u003elogical right shift\u003cbr\u003earithmetic right shift\u003cbr\u003erotate left\u003cbr\u003erotate right\u003c/td\u003e\n\u003ctd\u003eleft to right\u003c/td\u003e\n\u003ctd\u003eyes\u003cbr\u003eyes\u003cbr\u003eyes\u003cbr\u003eyes\u003cbr\u003eyes\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e8\u003c/th\u003e\u003ctd\u003e\u003ccode\u003ea\u0026amp;b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003ebitwise AND\u003c/td\u003e\u003ctd\u003eleft to right\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e9\u003c/th\u003e\u003ctd\u003e\u003ccode\u003ea^b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003ebitwise XOR\u003c/td\u003e\u003ctd\u003eleft to right\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e10\u003c/th\u003e\u003ctd\u003e\u003ccode\u003ea|b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003ebitwise OR\u003c/td\u003e\u003ctd\u003eleft to right\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003e11\u003c/th\u003e\n\u003ctd\u003e\u003ccode\u003ea\u0026lt;b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea\u0026gt;b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea\u0026lt;=b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea\u0026gt;=b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea==b\u003c/code\u003e\u003cbr\u003e\u003ccode\u003ea!=b\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eless than\u003cbr\u003egreater than\u003cbr\u003eless or equal\u003cbr\u003egreater or equal\u003cbr\u003eequal to\u003cbr\u003enot equal to\u003c/td\u003e\n\u003ctd\u003eleft to right\u003c/td\u003e\n\u003ctd\u003eyes\u003cbr\u003eyes\u003cbr\u003eyes\u003cbr\u003eyes\u003cbr\u003eyes\u003cbr\u003eyes\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e12\u003c/th\u003e\u003ctd\u003e\u003ccode\u003ea and b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eboolean AND\u003c/td\u003e\u003ctd\u003eleft to right\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e13\u003c/th\u003e\u003ctd\u003e\u003ccode\u003ea xor b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eboolean XOR\u003c/td\u003e\u003ctd\u003eleft to right\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e14\u003c/th\u003e\u003ctd\u003e\u003ccode\u003ea or b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eboolean OR\u003c/td\u003e\u003ctd\u003eleft to right\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\n#### Implicit Casting Rules\n\nPrimitive types are implicitly cast when doing so would not lose significant bits. This means that implicit casts can cause loss in precision.\n\n#### If Statements\n\nIf statements have the usual C syntax and behave as one might expect. Spacing doesn't matter, but the conditions must be wrapped in parenthesis. While single line statements in the body of an if don't need curly brackets, multiline statement blocks do.\n```\nif (x \u003c 5) {\n  // Do things\n} else if (x \u003e 20) {\n  // Do other things\n} else\n  // Do one statement\n```\n\n#### While loops\n\nWhile loops also have the usual C syntax. Same rules as if statements apply.\n```\nwhile (i \u003c 100) {\n  // Do things\n}\n\nwhile (j \u003c 20)\n  // Do one statement\n```\n\n#### Functions\n\n\u003e Member functions are not yet implemented.\n\nFunctions are declared using syntax similar to C++ but with behavior similar to Go. The receiver is specified with a scope resolution operator. However functions cannot be defined inside a structure. They must be explicitly defined outside. Functions without the receiver are defined like any other function in C++.\n\n```\nstruct MyStruct\n{\n}\n\nint32 MyStruct::myFunc(int32 myArg, int32 myArg2)\n{\n\t// Do things.\n}\n\nint32 myFunc2(int32 myArg, int32 myArg2)\n{\n\t// Do Things.\n}\n```\n\n#### Inline Assembly\n\n\u003e This feature is unstable.\n\nInline assembly uses AT\u0026T syntax. Each line specifies an instruction, and each instruction has a list of comma separated operands. Registers are denoted by `%name`, constants by `$value`, and program variables by their name.\n\n```\nint32 count = 5;\nint32 value = 1;\n\nasm {\n\tmov value, %eax\n\tmov count, %ebx\nloop:\n\tmul $2, %eax\n\tdec %ebx\n\tjnz %ebx, loop\n\tmov %eax, value\n}\n\nfixed32 inv_value = 1/fixed32(value);\n```\n\n### Interface Files\n\n`.ifc` files specify limited interfaces designed for specific purposes. These represent the only way that programs may be linked, ensuring that any structure in a code base may be swapped out for something else while guaranteeing correct functionality.\n\nBelow shows an example of an interface file for a simple stack. The first line declares a templated type `ValueType` and two interfaces that use that type, `Node` and `Stack`. Finally, it specifies a function `pop()` that is only dependent upon the functionality provided by the interface and therefore automatically implemented for all structures that implement the `Stack` interface.\n\n**Stack.ifc**\n```\ntypename ValueType;\n\ninterface Node\u003cValueType\u003e\n{\n\tconstruct(ValueType value, Node\u003cValueType\u003e prev*);\n\n\tvoid push(Node\u003cValueType\u003e list*);\n\tNode\u003cValueType\u003e* pop();\n\tValueType get();\n}\n\ninterface Stack\u003cValueType\u003e\n{\n\tvoid push(ValueType value);\n\tvoid drop();\n\tValueType get();\n}\n\nValueType Stack\u003cValueType\u003e::pop()\n{\n\tValueType result = get();\n\tdrop();\n\treturn result;\n}\n```\n\n#### Interfaces\n\n\u003e This feature is not yet implemented.\n\n#### Protocols\n\n\u003e This feature is not yet implemented.\n\n\n\n#### Encodings\n\n\u003e This feature is not yet implemented.\n\nThis defines a character encoding to be used for strings. \n\n```\nencode ascii\n{\n\t'\\NULL': 0,\n\t'\\SOH': 1,\n\t'\\STX': 2,\n\t...\n\t'0-9': 48,\n\t...\n}\n```\n\n### Source Files\n\n`.cog` files each contain a structure that implements a set of interfaces. These files may import `.ifc` files and create dependent types that are eventually linked in the `.prg` file.\n\nInterface files may be imported in two ways. The `import` directive imports everything from the file and puts it all in the file's namespace while the 'as' directive sets the space's name. Alternatively, elements from may be imported directly via the `from` directive. \n\n**Node.cog**\n```\ntypename ValueType;\n\nstruct Node\u003cValueType\u003e\n{\n\tValueType value;\n\tNode\u003cValueType\u003e *prev;\n};\n\nkeep Node\u003cValueType\u003e implements Node\u003cValueType\u003e from \"Stack.ifc\";\n\nNode\u003cValueType\u003e::new(ValueType value, Node\u003cValueType\u003e *prev)\n{\n\tthis-\u003evalue = value;\n\tthis-\u003eprev = prev;\n}\n\nNode\u003cValueType\u003e::delete()\n{\n\tif (prev)\n\t\tdelete prev;\n}\n\nvoid Node\u003cValueType\u003e::push(Node\u003cValueType\u003e list*)\n{\n\tassert not prev;\n\tprev = list;\n}\n\nNode\u003cValueType\u003e* Node\u003cValueType\u003e::pop()\n{\n\tNode\u003cValueType\u003e result* = prev;\n\tprev = null;\n\treturn result;\n}\n\nValueType Node\u003cValueType\u003e::get()\n{\n\treturn value;\n}\n```\n\n**Stack.cog**\n```\nimport \"Stack.ifc\" as StackIfc;\n\ntypename ValueType;\n\nstruct Stack\u003cValueType\u003e\n{\n\tdepend Node implements StackIfc::Node\u003cValueType\u003e;\n\tsuggest Node = Node\u003cValueType\u003e from \"Node.cog\";\n\n\tNode *last;\n}\n\nkeep Stack\u003cValueType\u003e implements StackIfc::Stack\u003cValueType\u003e;\n\nStack\u003cValueType\u003e::new()\n{\n}\n\nStack\u003cValueType\u003e::delete()\n{\n\tif (last)\n\t\tdelete last;\n}\n\nvoid Stack\u003cValueType\u003e::push(ValueType value)\n{\n\tNode *node = new Node(value, last);\n\tlast = node;\n}\n\nvoid Stack\u003cValueType\u003e::drop()\n{\n\tNode *node = last;\n\tlast = last-\u003epop();\n\tdelete node;\n}\n\nValueType Stack\u003cValueType\u003e::get()\n{\n\treturn last-\u003eget();\n}\n\n```\n\n#### Structures\n\n\u003e This feature is not yet implemented.\n\n### Test Files\n\n`.tst` test files specify an array of tests on interfaces, structures, and functions that check their implementation.\n\n\n**Stack.tst**\n```\ndepend IntStack implements Stack\u003cint32\u003e from \"Stack.ifc\";\n\ntest(\"myStackTest\")\n{\n\tIntStack stack;\n\tstack.push(5);\n\tstack.push(3);\n\tstack.push(6);\n\tassert stack.get() == 6;\n\tassert stack.pop() == 6;\n\tstack.drop();\n\tassert stack.pop() == 5;\n}\n```\n\n#### Mocks\n\n\u003e This feature is not yet implemented.\n\nMocks are like structures in that they implement functionality of a given set of interfaces, except that they implement only the functionality necessary to execute the tests.\n\n```\nmock MockNode\n{\n};\n```\n\n#### Tests\n\n\u003e This feature is not yet implemented.\n\nTests specify a contained set of logic that exercises specific functionality of structures or interfaces.\n\n```\ntest(\"My Test\")\n{\n\t// Do things.\n}\n```\n\n### Program Files\n\n`.prg` programs specify a the final import and link configurations, and the main behavior of a binary.\n\n```\ntypename ValueType;\n\nimport Stack\u003cValueType\u003e from \"Stack.cog\" {\n\t// This dependency resolution isn't necessary\n\t// because of the suggest in Stack.cog\n\tNode = Node\u003cValueType\u003e from \"Node.cog\";\n}\n\nvoid main()\n{\n\t// Do something\n}\n```\n\n### Metaprogramming\n\n#### Templates\n\n\u003e This feature is not yet implemented.\n\nTemplated typenames may be specified at the global scope of a file, constrained for specific uses, and then used throughout the file. Interfaces, Protocols, Structures, Functions, Mocks, and Tests may all be templated. This is done with the templating operator `\u003ctypes...\u003e` after their names.\n\n```\ntypename myType1;\nkeep MyType in [int32, float32];\n\ntypename myType2;\nkeep MyType2 implements MyInterface;\n\nstruct MyStruct\u003cMyType, MyType2\u003e\n{\n\tMyType value0;\n\tMyType2 value1;\n};\n\nvoid myFunc\u003cMyType, MyType2\u003e(MyType a, MyType2 b)\n{\n}\n```\n\n#### Dependencies\n\n\u003e This feature is not yet implemented.\n\n\n\n#### Constraints\n\n\u003e This feature is not yet implemented.\n\nStatic constraints proven at compile time. \n\n```\nkeep x \u003c y;\nkeep z in [a, b, c];\nfor (int8 i = 0; i \u003c 10; i++) {\n\tkeep a[i] \u003c b[i];\n}\n```\n\nDynamic constraints checked at run-time during tests and debugging, but excluded from production.\n\n```\nassert x \u003c y;\nassert z in [a, b, c];\n```\n\n## Compiler\n\n## Debugger\n\n## Documenter\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbingham1%2Fcog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnbingham1%2Fcog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbingham1%2Fcog/lists"}