Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-hosted compiler: tokenizing hello world #232

Merged
merged 18 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ jobs:
git status --ignored
exit 1
fi

tokenizers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo apt install -y llvm-13-dev clang-13 make valgrind
- run: LLVM_CONFIG=llvm-config-13 make
- run: ./tokenizers.sh
14 changes: 14 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,17 @@ jobs:
shell: bash
- run: cd "test dir" && ./runtests.sh --verbose
shell: bash

tokenizers:
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: windows-zip
- run: unzip jou.zip
- run: mv tokenizers.sh self_hosted jou
shell: bash
- run: (cd jou && ./tokenizers.sh)
shell: bash
25 changes: 25 additions & 0 deletions self_hosted/errors_and_warnings.jou
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from "stdlib/process.jou" import exit
from "stdlib/io.jou" import stdout, stderr, fprintf, fflush

struct Location:
path: byte* # Not owned. Points to a string that is held elsewhere.
lineno: int

def fail(location: Location, message: byte*) -> void:
# When stdout is redirected to same place as stderr,
# make sure that normal printf()s show up before our error.
fflush(stdout)
fflush(stderr)

fprintf(stderr, "compiler error in file \"%s\"", location.path)
if location.lineno != 0:
fprintf(stderr, ", line %d", location.lineno)
fprintf(stderr, ": %s\n", message)

exit(1)

# TODO: doesn't really belong here
def assert(b: bool) -> void:
if not b:
fprintf(stderr, "assertion failed\n")
exit(1)
Loading