Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hudson-newey/2lang
[Work in progress] An assembler for the 2Lang programming language
https://github.com/hudson-newey/2lang
assembly assembly-language binary compiler language programming-language
Last synced: 4 days ago
JSON representation
[Work in progress] An assembler for the 2Lang programming language
- Host: GitHub
- URL: https://github.com/hudson-newey/2lang
- Owner: hudson-newey
- Created: 2023-09-04T00:07:23.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-04T12:19:40.000Z (2 months ago)
- Last Synced: 2024-09-05T13:44:51.051Z (2 months ago)
- Topics: assembly, assembly-language, binary, compiler, language, programming-language
- Language: Rust
- Homepage:
- Size: 111 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 2 Lang
The worlds most efficient systems programming language
## Reserved Symbols & Words
### Comments
```C
// this is a comment and will be ignored/*
This is a block comment and will be ignored
it can span multiple lines
*/
```### Doc-gen Comments
Doc comments can be used to automatically generate documentation for a file
or a set of files.The format is heavily inspired by Java Doc & JavaScript's JSDoc
```ts
/**
* @summary
* This is a short description of a macro / function
*
* @description
* This is a longer description of the macro / function
* it can be multiple lines long
*
* @author First Last
* @version 1.0.0
*
* @since 1.0.0
* @see 2lang.awt
*
* @deprecated As of version 1.0
*
* @param fn An inner function to be executed
* @param converter A converter function that will be applied to the output
*
* @returns A new value
*/
```### Pre-Processor Macros
```C
#macroKey value
```Is a macro. At compile time, it will replace all instances of #key with the `value`.
You can also define interpolated functions in this manner as all arguments will be accessible via the `$` symbol
e.g.
```c
#printNewLine PRINT "$1\n"
```By using currying, you are able to create functions which take two arguments.
### Imports
```sh
@/path/fileName.2
```Will import a file to be used
### Pre-Processor Code Execution (Using Shell STDOUT)
Alternatively, if you (understandably) don't want to create binary macros
for the pre-processor, it is possible to use shebangs to specify an interpreter.Any output captured in STDOUT will be interpolated into the pre-processors
source input.```python
@!/usr/bin/env python3{
for i in range(65, 122):
ascii_character = char(i)
print(f"#${ascii_character} {i}")
}
```## Examples
Localized macro example
```C
#MY_MACRO 11011001
MY_MACRO
```will produce
```C
11011001
```---
Macro with parameter example
```C
#USE_PARAMETER 0000 $
USE_PARAMETER 1111
```should replace _$_ with 1111
## Command Line Options
- `--run` automatically runs the program after compilation
### Compiler Options
- `-b`, `--generate-intermediate` takes an intermediary output (_.bin_) file produced by the pre-processor
- `-d`, `--debug` Run in debug mode (log file reads, etc...)
- `-s`, `--stdout` Output the final file contents to stdout
- `-o`, `--output` Specify the output file name### Pre-Processor Options
- `-p`, `--preserve-intermediate` preserve the output produced by the pre-processor
- `--preserve-linked` Preserves the statically linked file (without macros expanded)
- `--no-expand-strings` Does not expand strings to their binary representation### Optimizer Options
- `--skip-optimizer` Does not run the optimizer on the output source code