MakeupCure
A Makeup lexer for the Cure programming language.
Supported Cure version
The lexer tracks the surface syntax of Cure as of v0.34.1 (see the Cure
CHANGELOG.md),
including the macro/syntax family definition surface and the bare-slash
regex literal introduced ahead of that release.
Features covered include:
- Container and type declarations:
mod,fn,rec,type,typealias,opaque,primitive,indexed,indices,interface,implementation(and legacyproto/impl),deriving,fsm,actor,sup,app,proof,quote,unsafe,precedencegroup,infix,prefix,postfix. - The
macrodefinition surface: themacro Namecontainer itself, plus its body vocabularysyntax,becomes,computed,literal,accepts,expands,explain,fail,open,contextual, and thesyntax familysub-grammar (family,includes,optional,repeated,one_or_more,by,directly). Alsolift moduleandpublic use. - Control flow and pattern matching:
if/elif/else/then,pickup(v0.33.0+ conditional dispatch),match/when,for/in,try/catch/finally,throw,return,yield,end,requires,have. - Dependent-type and proof constructs:
assert_type,rewrite,check ... else fail ...,simplify,induction, typed holes (bare?for the anonymous hole,?namefor named holes), implicit arguments, predicate identifiers (even?,is_empty?). - Operators & bitwise words: pipe
|>, string concat<>, range../..=, ellipsis..., Melquiades send<-|(and its unicode alias✉), binary-comprehension generator<-, bitstring segment specifier::, augmented assignment+=/-=/*=//=, FSM transitions--event-->, monadic/applicative operators (>>=,>>,<*>,<*,*>,<$,$>), logical (&&,||), bitwise words (band,bor,bxor,bsl,bsr,bnot), splice open$(. - Literals: integers (including
0xFF,0b1010, digit-grouped), floats, booleans, atoms, chars, backtick-quoted identifiers (`foo`), strings with#{...}interpolation, bare/pattern/flagsregexes (contextual, like division vs. regex in JavaScript —/only opens a regex where an expression can start, e.g. after= -> => ( [ { , : ; | |>orreturn), maps%{...}, tuples%[...], binaries<<...>>. - Comments: plain
#, single-line doc##, fenced multi-line###...###(the last two are highlighted as:string_doc).
Stdlib-defined field names inside macro-generated DSL blocks (e.g. an actor's
on_start/on_message/on_stop) are not language keywords — they are
ordinary identifiers chosen by whichever syntax family schema is in use, so
they are lexed and highlighted as plain names.
Installation
Add makeup_cure to your list of dependencies in mix.exs:
def deps do
[
{:makeup_cure, "~> 0.2"}
]
end
The lexer will be automatically registered in Makeup for
the language name "cure" and the file extension .cure.
Usage
Once installed, ExDoc and any other tool using Makeup will automatically
syntax-highlight Cure code blocks (tagged with cure as the language).
You can also use it directly:
alias Makeup.Lexers.CureLexer
CureLexer.lex("fn add(a: Int, b: Int) -> Int = a + b")
License
MIT—see LICENSE for details.