Skip to content

Commit

Permalink
Merge pull request #41 from JuliaDocs/mh/julia-syntax-updates
Browse files Browse the repository at this point in the history
Update Julia syntax.
  • Loading branch information
MichaelHatherly authored Dec 4, 2020
2 parents 6db0259 + 5667949 commit 34bb556
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 91 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
- '1.0'
- '1'
- 'nightly'
os:
- ubuntu-latest
- windows-latest
- macos-latest
arch:
- x64
include:
- os: ubuntu-latest
version: '1'
arch: x86
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
show-versioninfo: true
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info

docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: julia --project=docs --color=yes docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

*A source code highlighter for Julia.*

| **Documentation** | **Build Status** |
|:-------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|
| [![][docs-stable-img]][docs-stable-url] [![][docs-latest-img]][docs-latest-url] | [![][travis-img]][travis-url] [![][appveyor-img]][appveyor-url] [![][codecov-img]][codecov-url] |
| **Documentation** | **Build Status** |
|:-------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------:|
| [![][docs-stable-img]][docs-stable-url] [![][docs-latest-img]][docs-latest-url] | ![CI](https://github.com/JuliaDocs/Highlights.jl/workflows/CI/badge.svg) [![][codecov-img]][codecov-url] |



## Installation
Expand Down Expand Up @@ -44,12 +45,6 @@ then feel free to ask for help in the [Gitter chat room][gitter-url].
[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg
[docs-stable-url]: https://juliadocs.github.io/Highlights.jl/stable

[travis-img]: https://travis-ci.org/JuliaDocs/Highlights.jl.svg?branch=master
[travis-url]: https://travis-ci.org/JuliaDocs/Highlights.jl

[appveyor-img]: https://ci.appveyor.com/api/projects/status/qnphq3a8eph3o979/branch/master?svg=true
[appveyor-url]: https://ci.appveyor.com/project/MichaelHatherly/highlights-jl/branch/master

[codecov-img]: https://codecov.io/gh/JuliaDocs/Highlights.jl/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/JuliaDocs/Highlights.jl

Expand Down
44 changes: 0 additions & 44 deletions appveyor.yml

This file was deleted.

3 changes: 2 additions & 1 deletion src/lexers/julia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ julia_is_triple_string_macro(ctx::Context) = julia_is_string_macro(ctx, 3)

(julia_is_symbol, STRING_CHAR),
(r"\b(?<![_.])in\b", KEYWORD_PSEUDO),
(r"\b(?<![_.])end\b", KEYWORD),
(r"\b(?<![_.])where\b", KEYWORD_PSEUDO),
(r"\b(?<![_.])(begin|end)\b", KEYWORD),
(r"\b(?<![_.])(true|false)\b", KEYWORD_CONSTANT),
(r"\b(?<![_.])(local|global|const)\b", KEYWORD_DECLARATION),
(words(keywords, prefix = "\\b(?<![_.])", suffix = "\\b"), KEYWORD),
Expand Down
68 changes: 68 additions & 0 deletions test/lexers/julia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,37 @@ tokentest(
PUNCTUATION => "]",
)

tokentest(
Lexers.JuliaLexer,
"a[begin]",
NAME => "a",
PUNCTUATION => "[",
KEYWORD => "begin",
PUNCTUATION => "]",
)

tokentest(
Lexers.JuliaLexer,
"a[begin:end]",
NAME => "a",
PUNCTUATION => "[",
KEYWORD => "begin",
OPERATOR => ":",
KEYWORD => "end",
PUNCTUATION => "]",
)

tokentest(
Lexers.JuliaLexer,
"a[begin-1]",
NAME => "a",
PUNCTUATION => "[",
KEYWORD => "begin",
OPERATOR => "-",
NUMBER_INTEGER => "1",
PUNCTUATION => "]",
)

tokentest(
Lexers.JuliaLexer,
"(1,2.0)",
Expand Down Expand Up @@ -254,6 +285,43 @@ tokentest(
KEYWORD => "end",
)

tokentest(
Lexers.JuliaLexer,
"struct Empty{T} where T <: S end",
KEYWORD => "struct",
TEXT => " ",
NAME_FUNCTION => "Empty",
PUNCTUATION => "{",
NAME => "T",
PUNCTUATION => "}",
TEXT => " ",
KEYWORD_PSEUDO => "where",
TEXT => " ",
NAME => "T",
TEXT => " ",
OPERATOR => "<:",
TEXT => " ",
NAME => "S",
TEXT => " ",
KEYWORD => "end",
)

tokentest(
Lexers.JuliaLexer,
"primitive type Float16 <: AbstractFloat 16 end",
KEYWORD => "primitive type",
TEXT => " ",
NAME => "Float16",
TEXT => " ",
OPERATOR => "<:",
TEXT => " ",
NAME => "AbstractFloat",
TEXT => " ",
NUMBER_INTEGER => "16",
TEXT => " ",
KEYWORD => "end",
)

tokentest(
Lexers.JuliaLexer,
"""
Expand Down
13 changes: 9 additions & 4 deletions test/samples/julia
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Multiline comments...
[1, 3, 3, 4][1:end]
(1, 2, 1.0)[1:2]
[(1, 3), (3, 4)][end - 1]
[(1, 3), (3, 4)][begin]
[(1, 3), (3, 4)][begin:2]
[(1, 3), (3, 4)][begin:end]

# Keywords.
if x in y
Expand All @@ -29,9 +32,9 @@ end
module M end
baremodule M end

typealias T A
abstract A <: T
type Point{T}
const T = A
abstract type A <: T end
mutable struct Point{T} where T <: Number
x::T
y::T

Expand All @@ -42,7 +45,9 @@ type Point{T}
end
end

immutable Empty{T} end
struct Empty{T} end

primitive type Float16 <: AbstractFloat 16 end

macro something(x...)
# ...
Expand Down

0 comments on commit 34bb556

Please sign in to comment.