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

[pull] master from carp-lang:master #10

Merged
merged 3 commits into from
Mar 30, 2022
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
11 changes: 5 additions & 6 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
- name: Install Stack
run: scoop install stack

- name: Install LLVM
run: |
scoop install llvm
echo "C:\Users\runneradmin\scoop\apps\llvm\current\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- uses: actions/cache@v1
name: Cache stack dependencies
with:
Expand All @@ -44,12 +49,6 @@ jobs:
- name: Run Compiler Tests
run: stack test

# Disabling sanitize-addresses because it fails with following error:
# https://github.com/actions/virtual-environments/issues/4978
- name: Disable Debug.sanitize-addresses
shell: bash
run: find ./test ./examples -type f -name '*.carp' | xargs sed 's/^\((Debug.sanitize-addresses)\)/; \1/g' -i

- name: Run Carp Tests
shell: bash
run: ./scripts/run_carp_tests.sh --no_sdl
10 changes: 9 additions & 1 deletion core/IO.carp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ module are wrappers around the C standard library.")
(register SEEK-END Int "SEEK_END")
(doc ftell "gets the position indicator of a file (thin wrapper for the C standard library).")
(register ftell (Fn [(Ptr FILE)] Int) "ftell")
(register feof (Fn [(Ptr FILE)] Bool) "feof")
(register ferror (Fn [(Ptr FILE)] Bool) "ferror")
)

(doc println "prints a string ref to stdout, appends a newline.")
Expand All @@ -90,7 +92,13 @@ module are wrappers around the C standard library.")
(doc get-line "gets a line from stdin.")
(register get-line (Fn [] String))
(doc fgetc "gets a character from a file pointer (thin wrapper for the C standard library).")
(register fgetc (Fn [(Ptr FILE)] Char)) ; TODO: check EOF handling (see carp_io.h)!
(defn fgetc [file]
(let [char (IO.Raw.fgetc file)]
(if (IO.Raw.feof file)
(Result.Error @"couldn't read char from file, EOF reached")
(if (IO.Raw.ferror file)
(Result.Error @"error while reading char from file")
(Result.Success (Char.from-int char))))))

(doc open-file "opens a file by name using a mode (e.g. [r]ead, [w]rite, [a]ppend), [rb] read binary...). See fopen() in the C standard library for a detailed description of valid parameters.")
(defn open-file [filename mode]
Expand Down
2 changes: 2 additions & 0 deletions src/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ commandConsLast ctx x xs =
pure $ case xs of
XObj (Lst lst) i t ->
(ctx, Right (XObj (Lst (lst ++ [x])) i t)) -- TODO: should they get their own i:s and t:s
XObj (Arr arr) i t ->
(ctx, Right (XObj (Arr (arr ++ [x])) i t))
_ -> evalError ctx "Applying 'cons-last' to non-list or empty list." (xobjInfo xs)

commandAppend :: BinaryCommandCallback
Expand Down