-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(syntax): basic syntax highlighting
- Loading branch information
1 parent
9d0a93a
commit bf524e9
Showing
8 changed files
with
180 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: CI | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: jcs090218/setup-emacs@master | ||
with: | ||
version: 29.4 | ||
- run: make .PHONY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/*~ | ||
**/\#*\# | ||
**/*.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
NAME = jule-mode | ||
|
||
EMACS ?= emacs | ||
JULEC = julec | ||
|
||
.PHONY: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
|
||
;;; jule-mode.el --- Official Jule mode for Emacs | ||
|
||
;; Author: Adam Perkowski <adas1per@protonmail.com> | ||
;; Version: 0.0.1 | ||
;; Keywords: languages | ||
;; URL: https://github.com/julelang/jule-mode.el | ||
;; Package-Requires: ((emacs "29.4")) | ||
|
||
;; This file is distributed under the terms of the BSD 3-Clause License. | ||
;; See the LICENSE file for details. | ||
;; It is not part of GNU Emacs. | ||
|
||
;;; Commentary: | ||
|
||
;; This package provides a major mode for editing Jule code. | ||
|
||
;;; Code: | ||
(defconst jule-keywords | ||
'("chan" "map" "error" "use" "fn" "struct" "byte" "rune" "enum" "unsafe" | ||
"let" "match" "defer" "if" "else" "for" "in" "impl" "trait" "break" | ||
"continue" "goto" "cpp" "type" "ret" "fall" "co" "let" "select")) | ||
|
||
(defconst jule-types | ||
'("int" "uint" "uintptr" "i8" "i16" "i32" "i64" "u8" "u16" "u32" "u64" "f32" "f64" "bool" "str" "any" "byte" "rune")) | ||
|
||
(defconst jule-storage | ||
'("static" "const" "mut" "self")) | ||
|
||
(defconst jule-constants | ||
'("true" "false" "nil")) | ||
|
||
(defvar jule-font-lock-keywords | ||
(append | ||
`( | ||
;; directives (e.g. `#pass`) | ||
;; regex: a `#` followed by a sequence of word characters | ||
(,(rx bol "#" (1+ word)) . font-lock-preprocessor-face) | ||
|
||
;; code keywords | ||
(,(regexp-opt jule-keywords 'symbols) . font-lock-keyword-face) | ||
|
||
;; type keywords | ||
(,(regexp-opt jule-types 'symbols) . font-lock-type-face) | ||
|
||
;; storage keywords | ||
(,(regexp-opt jule-storage 'symbols) . font-lock-keyword-face) | ||
|
||
;; constants | ||
(,(regexp-opt jule-constants 'symbols) . font-lock-constant-face) | ||
|
||
;; function names | ||
;; regex: a word followed by either `(` or `[`, but not including `(` or `[` | ||
(,(rx word-start (group (1+ word)) word-end (0+ space) "(") 1 font-lock-function-name-face) | ||
(,(rx word-start (group (1+ word)) (0+ space) "[" (0+ nonl) "]" (0+ space) "(") 1 font-lock-function-name-face) | ||
|
||
;; numbers | ||
;; regex: regex: a sequence of 0 or 1 digits starting with `0b`, possibly separated by `_` | ||
(,(rx word-start "0b" (group (1+ (or "0" "1" "_"))) word-end) . font-lock-constant-face) | ||
;; regex: regex: a sequence of 0-7 digits starting with `0o`, possibly separated by `_` | ||
(,(rx word-start "0o" (group (1+ (or (any "0-7") "_"))) word-end) . font-lock-constant-face) | ||
;; regex: a sequence of 0-9 digits and letters `a-f` or `A-F` starting with `0x` | ||
(,(rx word-start "0x" (group (1+ (or (or any "0-9" "a-f" "A-F") "_"))) word-end) . font-lock-constant-face) | ||
;; regex: a sequence of digits, possibly separated by `_`, followed by a dot, | ||
;; followed by a sequence of digits, possibly separated by `_`, followed by an | ||
;; optional exponent (e.g. `123.456`, `123_456.789`, `123.456e789`, `123.456e+789`) | ||
(,(rx word-start | ||
(group (1+ (or digit "_")) (opt (seq "." (1+ (or digit "_"))))) | ||
(opt (seq (any "eE") (opt (any "-+")) (1+ digit))) | ||
word-end) | ||
. font-lock-constant-face) | ||
|
||
;; strings | ||
;; regex: a sequence of characters enclosed in single quotes | ||
(,(rx "'" (group (0+ (not (any "'")))) "'") . font-lock-string-face) | ||
;; regex: a sequence of characters enclosed in double quotes | ||
(,(rx "\"" (group (0+ (not (any "\"")))) "\"") . font-lock-string-face) | ||
;; regex: a sequence of characters enclosed in backticks | ||
(,(rx "`" (group (0+ (not (any "`")))) "`") . font-lock-string-face) | ||
))) | ||
|
||
(define-derived-mode jule-mode prog-mode "jule" | ||
"Major mode for editing Jule code." | ||
(setq indent-tabs-mode t) | ||
(setq font-lock-defaults '(jule-font-lock-keywords))) | ||
|
||
;;;###autoload | ||
(add-to-list 'auto-mode-alist '("\\.jule\\'" . jule-mode)) | ||
|
||
(provide 'jule-mode) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* this file tests the syntax highlighting */ | ||
|
||
#pass "-v" // this is a comment :) | ||
|
||
const TEST_DATA: str = "test data" | ||
const _0 = "test data\n" | ||
const _1 = 'h' | ||
const _2 = `world\n` | ||
|
||
// number tests | ||
const _3 = 123 | ||
const _4 = 123.456 | ||
const _5 = 123_456 | ||
const _6 = 123_456.789e012 | ||
const _7 = 0b0101 | ||
const _8 = 0b0101_01 | ||
const _9 = 0o123 | ||
const _10 = 0o123_456 | ||
const _11 = 0xfff | ||
const _12 = 0xfff_0a1 | ||
|
||
fn main() { | ||
thoseGuys(TEST_DATA) | ||
println(TEST_DATA) | ||
} | ||
|
||
fn thoseGuys[T](test: T) {} |