{"id":30113734,"url":"https://github.com/luxluth/gcompiler","last_synced_at":"2025-08-10T07:27:48.327Z","repository":{"id":203112989,"uuid":"703597824","full_name":"luxluth/gcompiler","owner":"luxluth","description":"A simple compiler for the G description language for simple graphs","archived":false,"fork":false,"pushed_at":"2023-10-20T08:08:30.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-10-23T15:29:10.311Z","etag":null,"topics":["compiler","graphics","mathematics","programming-language","svg"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luxluth.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}},"created_at":"2023-10-11T14:38:45.000Z","updated_at":"2023-10-23T15:29:11.850Z","dependencies_parsed_at":null,"dependency_job_id":"62427968-6674-4795-87b1-94110edfc7e0","html_url":"https://github.com/luxluth/gcompiler","commit_stats":null,"previous_names":["luxluth/gcompiler"],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/luxluth/gcompiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxluth%2Fgcompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxluth%2Fgcompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxluth%2Fgcompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxluth%2Fgcompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luxluth","download_url":"https://codeload.github.com/luxluth/gcompiler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxluth%2Fgcompiler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269692888,"owners_count":24460216,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["compiler","graphics","mathematics","programming-language","svg"],"created_at":"2025-08-10T07:27:47.417Z","updated_at":"2025-08-10T07:27:48.298Z","avatar_url":"https://github.com/luxluth.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gcompiler\n\nA simple compiler for the G description language for simple graphs, written in Rust.\n\n**Table of Contents**\n- [gcompiler](#gcompiler)\n  - [What is G?](#what-is-g)\n  - [G Descriptions](#g-descriptions)\n    - [Functions](#functions)\n      - [`@line`](#line)\n      - [`@point`](#point)\n      - [`@graph`](#graph)\n  - [Comments](#comments)\n  - [Usage](#usage)\n  - [License](#license)\n\n\n## What is G?\n\nG is a simple language for describing graphs. It is a simple language that is easy to read and write, and is designed to generate graphs output in svg format and png format. Can be used to generate graphs for use in documentation (i.e. Markdown files), or for use in other applications.\n\nThe **gcompiler** compile G files into svg or png files.\n\n## G Descriptions\n\nEach `.g` files contains a `#root` declaration and a defined `x` and `y` axis.\n\nA simple graph description looks like this:\n\n```oz\n#define x\n    min 0\n    max 100\n    name \"x\"\n#end\n\n#define y\n    min 0\n    max 100\n    name \"y\"\n#end\n\n#root\n    box 0, 0, 100, 100\n    color 0xebdbb2\n    background 0x282828\n    axis x, y\n#end\n\n% optional grid %\n\n#grid\n    color 0x3c3836\n    step 10\n    alpha 1\n#end\n```\n\nThis will generate a graph with a box of size 100x100, with the x and y axis defined by the `x` and `y` definitions.\n\nThe `x` and `y` definitions define the axis of the graph. They are defined by the `min` and `max` values, and the `name` of the axis. The `name` is used to label the axis.\n\nThe `min` value is optional, and defaults to 0. The `max` value is not optional, and must be defined.\n\nThe `#root` declaration defines the root of the graph. It is required, and must be defined.\n\nThe `box` declaration defines the size of the graph. It is required, and must be defined.\n\nThe `axis` declaration defines the axis of the graph. It is required, and must be defined.\n\nThe `#grid` declaration defines the grid of the graph. It is optional, and can be defined.\n\n\u003cfigure\u003e\n\u003cdiv align=\"center\"\u003e\n\n[![Simple Graph](examples/simple.svg)](examples/simple.g)\n\u003cfigcaption\u003e \n\n*Simple Graph* \n\u003c/figcaption\u003e\n\n\u003c/div\u003e\n\u003c/figure\u003e\n\n### Functions\n\nThe G description language supports functions. You can't define your own functions, but you can use the built-in functions.\n\nThe built-in functions are:\n  - `@line` Draws a line from one point to another.\n  - `@point` Draws a point at a given point.\n  - `@graph` Draws a graph of a given function.\n\n#### `@line`\n\nThe `@line` function draws a line from one point to another.\n\n```oz\n@line\n    from 0, 0\n    to 50, 100\n    name \"line\"\n    color 0xebdbb2\n#end\n```\n\n- `from` is either an `INT` or a `FLOAT`\n\n- `to` is either an `INT` or a `FLOAT`. \n\n- `name` is optional\n\n- `color` is optional.\n\n\u003cfigure\u003e\n\u003cdiv align=\"center\"\u003e\n\n[![Line Graph](examples/line.svg)](examples/line.g)\n\u003cfigcaption\u003e\n\n*Line Graph*\n\u003c/figcaption\u003e\n\n\u003c/div\u003e\n\u003c/figure\u003e\n\n#### `@point`\n\nThe `@point` function draws a point at a given point.\n\n```oz\n@point\n    at 50, 50\n    color 0xcc241d\n#end\n```\n\n- `at` is either an `INT` or a `FLOAT`\n- `name` is optional\n- `color` is optional\n\n\u003cfigure\u003e\n\u003cdiv align=\"center\"\u003e\n\n[![Point Graph](examples/point.svg)](examples/point.g)\n\u003cfigcaption\u003e\n\n*Point Graph*\n\u003c/figcaption\u003e\n\u003c/div\u003e\n\u003c/figure\u003e\n\n#### `@graph`\n\nThe `@graph` function draws a graph of a given function.\n\n```oz\n@graph\n    color 0xfabd2f\n    func \"sin(x * 0.1) * 40 + 40\"\n#end\n```\n\n- `name` is optional\n- `color` is optional\n- `thickness` is optional\n- `func` is required. It is a string that is a valid mathematical function. The function can use the following operators:\n  - `+` Addition\n  - `-` Subtraction\n  - `*` Multiplication\n  - `/` Division\n  - `^` Exponentiation\n  - `()` Parentheses\n  - `x` The x value\n\n\u003e see [exmex](https://github.com/bertiqwerty/exmex/) for more information on valid mathematical functions.\n\n\u003cfigure\u003e\n\u003cdiv align=\"center\"\u003e\n\n[![Graph Graph](examples/graph.svg)](examples/graph.g)\n\u003cfigcaption\u003e\n\n*Graph Graph*\n\u003c/figcaption\u003e\n\u003c/div\u003e\n\u003c/figure\u003e\n\n## Comments\n\nComments are supported in G files. Comments are started and ended with `%`\n\n```oz\n% This is a comment %\n```\n\n## Usage\n\nA simple command line interface is provided for compiling G files.\n\n```bash\ngcompiler compile examples/simple.g\n```\n\n\n## License\n\nApache-2.0 license. See [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxluth%2Fgcompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluxluth%2Fgcompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxluth%2Fgcompiler/lists"}