15 releases

Uses new Rust 2024

new 0.3.1 May 4, 2025
0.3.0 May 3, 2025
0.2.3 May 2, 2025
0.2.2 Apr 29, 2025
0.1.11 Apr 25, 2025

#66 in Programming languages

Download history 461/week @ 2025-04-13 648/week @ 2025-04-20 444/week @ 2025-04-27

1,553 downloads per month

Apache-2.0

62KB
1.5K SLoC

Jsonpiler - JSON Syntax Programming Language

Jsonpiler is a compiler for the JSON syntax programming language and its compiler.

This program converts a JSON-based program to GNU assembly, compiles it, and executes the result.

What's New

  • Json objects now allow duplicate keys.
  • Objects are now treated as function calls:
    Each key in a JSON object is interpreted as a function name, and its corresponding value is treated as the function argument.
  • It is no longer allowed to assign a user-defined function to a variable name that already exists as a built-in function.
  • Arrays now leave the result of evaluating all elements.:
  • Supports multiple key-function entries.:
    When an object contains multiple keys, each is evaluated in order; the last function result is returned.
  • Square brackets can now be omitted when a single argument is not an array.
  • The begin function was removed because it can now be represented by a column of objects.

Project History and Plans

Prerequisites

Make sure the following tools are installed and available in your PATH environment variable:

  • ld (from MinGW-w64)
  • as (from MinGW-w64)

The following DLLs must be present in C:\Windows\System32\ for the program to work correctly:

  • kernel32.dll
  • user32.dll
  • ucrtbase.dll

Installation & Usage

cargo install jsonpiler
jsonpiler (input_json_file (UTF-8)) [arguments of .exe ...]

Replace (input_json_file) with the actual JSON file you want to compile.

Example

Examples

{ "=": ["a", "title"], "message": [{"$": "a"}, "345"] }

Execution order:

The jsonpiler code consists of a single JSON object.

Expressions are evaluated sequentially.

The variable "a" is assigned the string "title" using "=".

A message box appears with the title (from the variable "a") and the body "345" as specified by "message".

The program returns the integer ID of the button pressed in the message box (currently only 1 is supported, which corresponds to IDOK in C/C++), as the final value of the begin block.

Error message

{ "message": ["title", ["$", "not_exist"]] }
Compilation error: Undefined variables: `not_exist`
Error occurred on line: 1
Error position:
{ "message": ["title", ["$", "not_exist"]] }
                             ^^^^^^^^^^^

Function Documentation

Function Reference (Markdown)

Language Documentation

Language Reference (Markdown)

Execution

graph TD
  A[file.json] --> B{Jsonpiler}
  B -->|Parse| C([AST])
  C -->|Compile| D[file.s]
  D --> |Assembling with GNU AS| E[file.obj]
  E --> |Linking with GNU LD| F[file.exe]
  S[C:\Windows\System32\] --> KERNEL32[kernel32.dll] --> F[file.exe]
  S --> USER32[user32.dll] --> F[file.exe]
  S --> UCRTBASE[ucrtbase.dll] --> F[file.exe]
  F --> Execute[(Execute!)]

No runtime deps