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

Add support for Red #958

Closed
wants to merge 10 commits into from
Closed
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
44 changes: 44 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:
build_and_test:
runs-on: ubuntu-22.04
env:
platform: linux-musl
channel: stable
target: x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Download cross binary
run: ci/download_cross.bash $target $platform
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set Rust version
run: ci/set_rust_version.bash $channel $target
- name: Build
run: ci/build.bash $PWD/cross $target
- name: Run tests
run: ci/test.bash $PWD/cross $target
- name: Trigger lines of code counter re-deploy
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: ci/redeploy_lines_of_code_counter.bash
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOWS_PAT }}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ request. Languages are defined in [`languages.json`](./languages.json), and you
read how to add and test your language in our [CONTRIBUTING.md](./CONTRIBUTING.md).

```
8th
Abap
ActionScript
Ada
Expand Down Expand Up @@ -434,6 +435,7 @@ KakouneScript
Kotlin
Lean
Less
LFE
LinkerScript
Liquid
Lisp
Expand Down Expand Up @@ -466,6 +468,7 @@ Pascal
Perl
Perl6
Pest
Smalltalk
Php
Poke
Polly
Expand All @@ -477,6 +480,7 @@ Prolog
Protobuf
PSL
PureScript
Pyret
Python
Qcl
Qml
Expand Down Expand Up @@ -540,6 +544,7 @@ VisualStudioSolution
Vue
WebAssembly
Wolfram
Wren
Xaml
XcodeConfig
Xml
Expand Down
6 changes: 6 additions & 0 deletions ci/download_cross.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Script for downloading cross.
set -e

gh release download --repo cross-rs/cross --pattern "*$2*"
tar -xvzf cross-$1.tar.gz
5 changes: 5 additions & 0 deletions ci/redeploy_lines_of_code_counter.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Script for triggering deploy of lines of code counter.
set -e

gh workflow run deploy.yml --repo exercism/lines-of-code-counter
38 changes: 37 additions & 1 deletion languages.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"languages": {
"_8th": {
"name": "8th",
"line_comment": ["\\\\ ", "-- "],
"multi_line_comments": [["(*", "*)"]],
"nested": true,
"quotes": [["\\\"", "\\\""]],
"extensions": ["8th"]
},
"Abap": {
"name": "ABAP",
"line_comment": ["*", "\\\""],
Expand Down Expand Up @@ -830,6 +838,14 @@
"extensions": ["less"],
"quotes": [["\\\"", "\\\""], ["'", "'"]]
},
"Lfe": {
"name": "LFE",
"line_comment": [";"],
"multi_line_comments": [["#|", "|#"]],
"quotes": [["\\\"", "\\\""], ["'", "'"]],
"nested": true,
"extensions": ["lfe"]
},
"Liquid": {
"name": "Liquid",
"quotes": [["\\\"", "\\\""], ["'", "'"]],
Expand Down Expand Up @@ -1140,6 +1156,13 @@
"multi_line_comments": [["{-", "-}"]],
"extensions": ["purs"]
},
"Pyret": {
"line_comment": ["#"],
"multi_line_comments": [["#|", "|#"]],
"quotes": [["\\\"", "\\\""], ["'", "'"]],
"extensions": ["arr"],
"nested": true
},
"Python": {
"line_comment": ["#"],
"doc_quotes": [["\\\"\\\"\\\"", "\\\"\\\"\\\""], ["'''", "'''"]],
Expand Down Expand Up @@ -1228,6 +1251,12 @@
"multi_line_comments": [["<!--", "-->"], ["@*", "*@"]],
"extensions": ["cshtml"]
},
"Red": {
"line_comment": [";"],
"multi_line_comments": [["comment [", "]"], ["comment {", "}"]],
"quotes": [["\\\"", "\\\""], ["{", "}"]],
"extensions": ["red"]
},
"Redscript": {
"name": "Redscript",
"line_comment": ["//", "///"],
Expand Down Expand Up @@ -1341,7 +1370,7 @@
"name": "Smalltalk",
"quotes": [["'", "'"]],
"multi_line_comments": [["\\\"", "\\\""]],
"extensions": ["cs.st", "pck.st"]
"extensions": ["st"]
},
"Solidity": {
"name": "Solidity",
Expand Down Expand Up @@ -1647,6 +1676,13 @@
"multi_line_comments": [["(*", "*)"]],
"extensions": ["nb", "wl"]
},
"Wren": {
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"]],
"nested": true,
"quotes": [["\\\"", "\\\""]],
"extensions": ["wren"]
},
"Xaml": {
"name": "XAML",
"multi_line_comments": [["<!--", "-->"]],
Expand Down
22 changes: 22 additions & 0 deletions tests/data/_8th.8th
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
\ 22 lines 9 code 8 comments 5 blanks

(* multiline comments
(* a nested
comment *)
*
*)

-- here's a single line comment
"Hello, " var, foo -- line ending comment

\ here's another single line comment
"!" var, bar \ a different line ending comment

: hello \ s --
foo @ s:<+
bar @ s:+
. cr
;

"World" hello
bye
15 changes: 15 additions & 0 deletions tests/data/lfe.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; 15 lines 4 code 5 comments 6 blanks

(defmodule my-code
(export (hello-world 0)))

;;; Commentary:
;; Provides helper functions

;;; Code

(defun pi () 3.14) ; a constant for Π not exported

(defun hello-world () "Hello, World!")

;;; lfe.lfe ends here
22 changes: 22 additions & 0 deletions tests/data/pyret.arr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 22 lines 9 code 8 comments 5 blanks

fun single-quote():
doc: "this is a documentation string"
'foo'
end

#|
Hello, this is a multiline message
|#

# This is a line message

fun double-quotes():
"bar"
end

nested = #|
doesn't start yet
or yet
|#
"nested"
20 changes: 20 additions & 0 deletions tests/data/red.red
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Red [] ; 20 lines 10 code 6 comments 4 blanks

x: 1 ; line comment 1
x: 3 ;-- line comment 2
x: 3 ;@@ line comment 3

comment ['this
'is 'multiline
'comment]
comment {and this
as well}

function add100 [x [integer!]] [
"; this should not count as comment "
{ comment [and neither
this] }
]

comment {unfortunately, tokei does not allow regexp in comment prefix}
; so probably previous block comment is not parsed properly
22 changes: 22 additions & 0 deletions tests/data/smalltalk.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
" 22 lines 15 code 4 comments 3 blanks "

"
I will return a message containing the given name, or a default value if no name given.
"
Class {
#name : #TwoFer,
#superclass : #Object,
#category : #'Exercise@TwoFer'
}

{ #category : #translating }
TwoFer >> who [
^ self who: 'you'.
]

{ #category : #translating }
TwoFer >> who: name [
^ name isNil
ifTrue: [ self who ]
ifFalse: [ 'One for {1}, one for me.' format: {name} ].
]
17 changes: 17 additions & 0 deletions tests/data/wren.wren
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 17 lines 7 code 6 comments 4 blanks

/* multiline comments
/* can be nested */
* Right, tokei?
*/

// here's a single line comment
var PREFIX = "Hello, " // line ending comment

class Hello {
static hello(name) {
System.print(PREFIX + name + "!")
}
}

Hello.hello("World")