Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilsol committed Dec 21, 2020
0 parents commit 277c834
Show file tree
Hide file tree
Showing 20 changed files with 2,481 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: build

on: [push, pull_request]

jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
file: go-mlog-linux-amd64
args: --best --lzma
strip: true
cgo: 0
- os: windows-latest
file: go-mlog-win-amd64.exe
args: -9
strip: false
cgo: 1
- os: macos-latest
file: go-mlog-osx-amd64
args: --best
strip: false
cgo: 1
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.15

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build
run: go build -ldflags="-s -w" -v -o ${{ matrix.file }} .
env:
CGO_ENABLED: ${{ matrix.cgo }}

analyze:
name: Analyze
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.15

- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2

- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: go

- name: Build
run: go build -ldflags="-s -w" -v -o go-mlog .
env:
CGO_ENABLED: 0

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: release

on:
push:
tags:
- v*

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.15

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116 changes: 116 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Created by https://www.gitignore.io/api/go,jetbrains+all
# Edit at https://www.gitignore.io/?templates=go,jetbrains+all

### Go ###
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

### Go Patch ###
/vendor/
/Godeps/

### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### JetBrains+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

# Sonarlint plugin
.idea/sonarlint

# End of https://www.gitignore.io/api/go,jetbrains+all

*.wasm
samples/
*.mlog
*.masm
43 changes: 43 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
before:
hooks:
- go mod download

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- 386
- arm
- arm64
- ppc64le
- s390x
goarm:
- 6
- 7

archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
allow_different_binary_count: true

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# go-mlog

Go to MLOG transpiler.

## Web IDE

```
// TODO
```

## Supports

* Functions
* Multiple function parameters/arguments
* `return` from functions
* `for` loops
* `if`/`else if`/`else` statements
* Binary and Unary math
* Function level variable scopes

## Roadmap

* Documentation
* `break` out of loops
* `switch` statement
* Full variable block scoping
* `print`/`println` multiple arguments
* Errors with context
* Extensions
* Variable argument count functions
* Multiple function return values

## Design Limitations

* Only hardcoded (translated) imports allowed
* Single file support only
* No recursion ([more info here](RECURSION.md))

## Endgame Roadmap

* Transpilation optimizations
* MLOG Runtime

## Usage

```
Usage:
go-mlog transpile [flags] <program>
Flags:
-h, --help help for transpile
Global Flags:
--colors Force log output with colors
--comments Output comments
--debug Write to debug memory cell
--log string The log level to output (default "info")
--numbers Output line numbers
--output string Output file. Outputs to stdout if unspecified
```
10 changes: 10 additions & 0 deletions RECURSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Issues with recursion

We cannot use variables to store data, as they would be overwritten on the next depth pass of the function.
That forces us to use memory cells/banks.

Currently, the game does not support writing objects to memory cells/banks.
That means we would be unable to support any functions that return any object types.

It is planned in the future to implement recursion support, but if any function would call any function
that returns an object, it would instantly panic out of the transpiler.
Loading

0 comments on commit 277c834

Please sign in to comment.