{"id":27171251,"url":"https://github.com/dykstrom/jcc","last_synced_at":"2025-04-09T08:32:24.213Z","repository":{"id":52829656,"uuid":"71986621","full_name":"dykstrom/jcc","owner":"dykstrom","description":"A collection of toy compilers built using ANTLR4 and flat assembler","archived":false,"fork":false,"pushed_at":"2025-02-02T15:52:26.000Z","size":2419,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T16:28:17.649Z","etag":null,"topics":["antlr4","assembunny","basic","compiler","fasm","tiny"],"latest_commit_sha":null,"homepage":"","language":"Java","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/dykstrom.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":"2016-10-26T09:16:16.000Z","updated_at":"2025-02-02T15:52:26.000Z","dependencies_parsed_at":"2024-08-17T15:34:22.196Z","dependency_job_id":"e89cf779-b32c-44b9-8dbc-ebc18abd09a1","html_url":"https://github.com/dykstrom/jcc","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dykstrom%2Fjcc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dykstrom%2Fjcc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dykstrom%2Fjcc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dykstrom%2Fjcc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dykstrom","download_url":"https://codeload.github.com/dykstrom/jcc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248003015,"owners_count":21031715,"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":["antlr4","assembunny","basic","compiler","fasm","tiny"],"created_at":"2025-04-09T08:31:11.140Z","updated_at":"2025-04-09T08:32:24.194Z","avatar_url":"https://github.com/dykstrom.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JCC\n\n[![linux build](https://github.com/dykstrom/jcc/actions/workflows/linux.yml/badge.svg)](https://github.com/dykstrom/jcc/actions/workflows/linux.yml)\n[![macos build](https://github.com/dykstrom/jcc/actions/workflows/macos.yml/badge.svg)](https://github.com/dykstrom/jcc/actions/workflows/macos.yml)\n[![build windows](https://github.com/dykstrom/jcc/actions/workflows/windows.yml/badge.svg)](https://github.com/dykstrom/jcc/actions/workflows/windows.yml)\n[![Open Issues](https://img.shields.io/github/issues/dykstrom/jcc)](https://github.com/dykstrom/jcc/issues)\n[![Latest Release](https://img.shields.io/github/v/release/dykstrom/jcc?display_name=release)](https://github.com/dykstrom/jcc/releases)\n![Downloads](https://img.shields.io/github/downloads/dykstrom/jcc/total)\n![License](https://img.shields.io/github/license/dykstrom/jcc)\n![Top Language](https://img.shields.io/github/languages/top/dykstrom/jcc)\n[![JDK compatibility: 17+](https://img.shields.io/badge/JDK_compatibility-17+-blue.svg)](https://adoptium.net)\n\nJCC, the Johan Compiler Collection, is a collection of toy compilers built using [ANTLR4](http://www.antlr.org) and [flat assembler](http://flatassembler.net). The current version of JCC compiles three programming languages: [Tiny](https://github.com/antlr/grammars-v4/tree/master/tiny), [Assembunny](http://adventofcode.com/2016/day/12), and a subset of [BASIC](https://en.wikipedia.org/wiki/BASIC).\n\nJCC also has experimental support for [using LLVM as backend](docs/LLVM.md) instead of flat assembler.\n\n## System Requirements\n\n* Windows\n* Java 17 or later\n\nYou can download the Java runtime from [Adoptium](https://adoptium.net).\n\nExecutables created with JCC depend on the library [msvcrt.dll](https://en.wikipedia.org/wiki/Microsoft_Windows_library_files), which is a part of Windows. BASIC executables also depend on the BASIC standard library, jccbasic.dll, that is distributed together with JCC.\n\n## Installation\n\nDownload the latest zip file from the GitHub [releases page](https://github.com/dykstrom/jcc/releases), \nand unzip it somewhere on your hard drive. Add the bin directory of the JCC distribution \nto the Path environment variable for your account.\n\nPlease note that while JCC itself is licensed under GPLv3, the included version of\n[flat assembler](http://flatassembler.net) is licensed under a specific license.\nA copy of this license can be found in the fasm subdirectory of the project.\n\n## Usage\n\nWith JCC in your Path, you can run it like this:\n\n```\njcc \u003csource file\u003e\n```\n\nTo get help, type:\n\n```\njcc --help\n```\n\nThis will print a message similar to this:\n\n```\nUsage: jcc [options] \u003csource file\u003e\n  Options:\n    --help\n      Show this help text\n    --version\n      Show compiler version\n    -O, -O1\n      Optimize output\n      Default: false\n    -S\n      Compile only; do not assemble\n      Default: false\n    -Wall\n      Enable all warnings\n      Default: false\n    -Wundefined-variable\n      Warn about undefined variables\n      Default: false\n    -assembler\n      Use \u003cassembler\u003e as the backend assembler\n      Default: fasm\n    -assembler-include\n      Set the assembler's include directory to \u003cdirectory\u003e\n    -initial-gc-threshold\n      Set the number of allocations before first garbage collection\n      Default: 100\n    -o\n      Place output in \u003cfile\u003e\n    -print-gc\n      Print messages at garbage collection\n      Default: false\n    -save-temps\n      Save temporary intermediate files permanently\n      Default: false\n    -v\n      Verbose mode\n      Default: false\n```\n\n## Supported Languages\n\n### Assembunny\n\n[Assembunny](http://adventofcode.com/2016/day/12) is a made up programming language from the programming challenge [Advent of Code 2016](http://adventofcode.com/2016). It is a small assembly language with only four instructions: _inc_, _dec_, _cpy_, and _jnz_. To make the language more interesting I have also added support for the _outn_ instruction from the Assembunny extension [Assembunny-Plus](https://github.com/broad-well/assembunny-plus/blob/master/doc/spec.md).\n\nThis is an example of Assembunny code:\n\n```\ncpy 3 a\ninc a\noutn a\n```\n\nAssembunny files end with the file extension \".asmb\".\n\n### BASIC\n\n[BASIC](https://en.wikipedia.org/wiki/BASIC) was invented in the sixties, and became very popular on home computers in the eighties. JCC BASIC is inspired by\n[Microsoft QuickBASIC](https://en.wikipedia.org/wiki/QuickBASIC) 4.5 from 1988. The current version of JCC implements a subset of BASIC. It does, however, come with a mark-and-sweep garbage collector to keep track of dynamic strings.\n\nThe example below is a short program to compute prime numbers:\n\n```BASIC\n' Calculate all primes less than a number N\n\nCONST N = 100\n\nDIM index AS INTEGER\nDIM isPrime AS INTEGER\nDIM maxIndex as INTEGER\nDIM number AS INTEGER\nDIM primes(N) AS INTEGER\n\nnumber = 2\nWHILE number \u003c N\n\n    ' Check if number is prime\n    isPrime = 1\n    index = 0\n    WHILE isPrime AND index \u003c maxIndex\n        ' If number is dividable by any prime found so far, it is not prime\n        isPrime = number MOD primes(index)\n        index = index + 1\n    WEND\n\n    ' Print number if prime\n    IF isPrime THEN\n        PRINT number\n        primes(maxIndex) = number\n        maxIndex = maxIndex + 1\n    END IF\n\n    number = number + 1\nWEND\n```\n\nThis table specifies the BASIC constructs that have been implemented so far:\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eData Types\u003c/td\u003e\n    \u003ctd\u003e\n        DOUBLE (64-bit)\u003cbr/\u003e\n        INTEGER (64-bit)\u003cbr/\u003e\n        STRING\u003cbr/\u003e\n        Static arrays of the types above. Dynamic arrays are not supported.\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eArithmetic Operators\u003c/td\u003e\n    \u003ctd\u003e^ + - * / \\ MOD\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eRelational Operators\u003c/td\u003e\n    \u003ctd\u003e= \u003c\u003e \u003e \u003e= \u003c \u003c=\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eBitwise Operators\u003c/td\u003e\n    \u003ctd\u003eAND, EQV, IMP, NOT, OR, XOR\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eControl Structures\u003c/td\u003e\n    \u003ctd\u003e\n        GOSUB-RETURN\u003cbr\u003e\n        GOTO\u003cbr\u003e\n        IF-GOTO\u003cbr\u003e\n        IF-THEN-ELSE (including ELSEIF)\u003cbr\u003e\n        ON-GOSUB-RETURN\u003cbr\u003e\n        ON-GOTO\u003cbr\u003e\n        WHILE-WEND\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eStatements\u003c/td\u003e\n    \u003ctd\u003e\n        CLS\u003cbr\u003e\n        CONST\u003cbr\u003e\n        DEFDBL\u003cbr\u003e\n        DEFINT\u003cbr\u003e\n        DEFSTR\u003cbr\u003e\n        DIM\u003cbr\u003e\n        END\u003cbr\u003e\n        LET\u003cbr\u003e\n        LINE INPUT\u003cbr\u003e\n        OPTION BASE\u003cbr\u003e\n        PRINT\u003cbr\u003e\n        RANDOMIZE\u003cbr\u003e\n        REM\u003cbr\u003e\n        SLEEP\u003cbr\u003e\n        SWAP\u003cbr\u003e\n        SYSTEM\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eFunctions\u003c/td\u003e\n    \u003ctd\u003e\n        abs, asc, atn, cdbl, chr$, cint, command$, cos, cvd, cvi, date$, exp, fix, hex$, inkey$, \n        instr, int, lbound, lcase$, left$, len, log, ltrim$, mid$, mkd$, mki$, oct$, right$, \n        rnd, rtrim$, sgn, sin, space$, sqr, str$, string$, tan, time$, timer, ubound, \n        ucase$, val\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eUser-defined Functions\u003c/td\u003e\n    \u003ctd\u003e\n        DEF FN expression functions\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nBASIC files end with the file extension \".bas\". BASIC executables require the BASIC standard library to run. This library is distributed together with JCC in the form of a DLL file: jccbasic.dll.\n\n### Tiny\n\n[Tiny](https://github.com/antlr/grammars-v4/tree/master/tiny) is a small programming language, designed for educational purposes.\n\nA typical Tiny program looks like this:\n\n```\nBEGIN\n    READ a, b\n    c := a + b\n    WRITE c\nEND\n```\n\nTiny files end with the file extension \".tiny\".\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdykstrom%2Fjcc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdykstrom%2Fjcc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdykstrom%2Fjcc/lists"}