1 package c
2
3 import (
4 . "github.com/alecthomas/chroma"
5 "github.com/alecthomas/chroma/lexers/internal"
6 )
7
8
9 var Coq = internal.Register(MustNewLazyLexer(
10 &Config{
11 Name: "Coq",
12 Aliases: []string{"coq"},
13 Filenames: []string{"*.v"},
14 MimeTypes: []string{"text/x-coq"},
15 },
16 coqRules,
17 ))
18
19 func coqRules() Rules {
20 return Rules{
21 "root": {
22 {`\s+`, Text, nil},
23 {`false|true|\(\)|\[\]`, NameBuiltinPseudo, nil},
24 {`\(\*`, Comment, Push("comment")},
25 {Words(`\b`, `\b`, `Section`, `Module`, `End`, `Require`, `Import`, `Export`, `Variable`, `Variables`, `Parameter`, `Parameters`, `Axiom`, `Hypothesis`, `Hypotheses`, `Notation`, `Local`, `Tactic`, `Reserved`, `Scope`, `Open`, `Close`, `Bind`, `Delimit`, `Definition`, `Let`, `Ltac`, `Fixpoint`, `CoFixpoint`, `Morphism`, `Relation`, `Implicit`, `Arguments`, `Set`, `Unset`, `Contextual`, `Strict`, `Prenex`, `Implicits`, `Inductive`, `CoInductive`, `Record`, `Structure`, `Canonical`, `Coercion`, `Theorem`, `Lemma`, `Corollary`, `Proposition`, `Fact`, `Remark`, `Example`, `Proof`, `Goal`, `Save`, `Qed`, `Defined`, `Hint`, `Resolve`, `Rewrite`, `View`, `Search`, `Show`, `Print`, `Printing`, `All`, `Graph`, `Projections`, `inside`, `outside`, `Check`, `Global`, `Instance`, `Class`, `Existing`, `Universe`, `Polymorphic`, `Monomorphic`, `Context`), KeywordNamespace, nil},
26 {Words(`\b`, `\b`, `forall`, `exists`, `exists2`, `fun`, `fix`, `cofix`, `struct`, `match`, `end`, `in`, `return`, `let`, `if`, `is`, `then`, `else`, `for`, `of`, `nosimpl`, `with`, `as`), Keyword, nil},
27 {Words(`\b`, `\b`, `Type`, `Prop`), KeywordType, nil},
28 {Words(`\b`, `\b`, `pose`, `set`, `move`, `case`, `elim`, `apply`, `clear`, `hnf`, `intro`, `intros`, `generalize`, `rename`, `pattern`, `after`, `destruct`, `induction`, `using`, `refine`, `inversion`, `injection`, `rewrite`, `congr`, `unlock`, `compute`, `ring`, `field`, `replace`, `fold`, `unfold`, `change`, `cutrewrite`, `simpl`, `have`, `suff`, `wlog`, `suffices`, `without`, `loss`, `nat_norm`, `assert`, `cut`, `trivial`, `revert`, `bool_congr`, `nat_congr`, `symmetry`, `transitivity`, `auto`, `split`, `left`, `right`, `autorewrite`, `tauto`, `setoid_rewrite`, `intuition`, `eauto`, `eapply`, `econstructor`, `etransitivity`, `constructor`, `erewrite`, `red`, `cbv`, `lazy`, `vm_compute`, `native_compute`, `subst`), Keyword, nil},
29 {Words(`\b`, `\b`, `by`, `done`, `exact`, `reflexivity`, `tauto`, `romega`, `omega`, `assumption`, `solve`, `contradiction`, `discriminate`, `congruence`), KeywordPseudo, nil},
30 {Words(`\b`, `\b`, `do`, `last`, `first`, `try`, `idtac`, `repeat`), KeywordReserved, nil},
31 {`\b([A-Z][\w\']*)`, Name, nil},
32 {"(\u03bb|\u03a0|\\|\\}|\\{\\||\\\\/|/\\\\|=>|~|\\}|\\|]|\\||\\{<|\\{|`|_|]|\\[\\||\\[>|\\[<|\\[|\\?\\?|\\?|>\\}|>]|>|=|<->|<-|<|;;|;|:>|:=|::|:|\\.\\.|\\.|->|-\\.|-|,|\\+|\\*|\\)|\\(|&&|&|#|!=)", Operator, nil},
33 {`([=<>@^|&+\*/$%-]|[!?~])?[!$%&*+\./:<=>?@^|~-]`, Operator, nil},
34 {`\b(unit|nat|bool|string|ascii|list)\b`, KeywordType, nil},
35 {`[^\W\d][\w']*`, Name, nil},
36 {`\d[\d_]*`, LiteralNumberInteger, nil},
37 {`0[xX][\da-fA-F][\da-fA-F_]*`, LiteralNumberHex, nil},
38 {`0[oO][0-7][0-7_]*`, LiteralNumberOct, nil},
39 {`0[bB][01][01_]*`, LiteralNumberBin, nil},
40 {`-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)`, LiteralNumberFloat, nil},
41 {`'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'`, LiteralStringChar, nil},
42 {`'.'`, LiteralStringChar, nil},
43 {`'`, Keyword, nil},
44 {`"`, LiteralStringDouble, Push("string")},
45 {`[~?][a-z][\w\']*:`, Name, nil},
46 },
47 "comment": {
48 {`[^(*)]+`, Comment, nil},
49 {`\(\*`, Comment, Push()},
50 {`\*\)`, Comment, Pop(1)},
51 {`[(*)]`, Comment, nil},
52 },
53 "string": {
54 {`[^"]+`, LiteralStringDouble, nil},
55 {`""`, LiteralStringDouble, nil},
56 {`"`, LiteralStringDouble, Pop(1)},
57 },
58 "dotted": {
59 {`\s+`, Text, nil},
60 {`\.`, Punctuation, nil},
61 {`[A-Z][\w\']*(?=\s*\.)`, NameNamespace, nil},
62 {`[A-Z][\w\']*`, NameClass, Pop(1)},
63 {`[a-z][a-z0-9_\']*`, Name, Pop(1)},
64 Default(Pop(1)),
65 },
66 }
67 }
68
View as plain text