You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

coq.go 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package c
  2. import (
  3. . "github.com/alecthomas/chroma" // nolint
  4. "github.com/alecthomas/chroma/lexers/internal"
  5. )
  6. // Coq lexer.
  7. var Coq = internal.Register(MustNewLexer(
  8. &Config{
  9. Name: "Coq",
  10. Aliases: []string{"coq"},
  11. Filenames: []string{"*.v"},
  12. MimeTypes: []string{"text/x-coq"},
  13. },
  14. Rules{
  15. "root": {
  16. {`\s+`, Text, nil},
  17. {`false|true|\(\)|\[\]`, NameBuiltinPseudo, nil},
  18. {`\(\*`, Comment, Push("comment")},
  19. {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},
  20. {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},
  21. {Words(`\b`, `\b`, `Type`, `Prop`), KeywordType, nil},
  22. {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},
  23. {Words(`\b`, `\b`, `by`, `done`, `exact`, `reflexivity`, `tauto`, `romega`, `omega`, `assumption`, `solve`, `contradiction`, `discriminate`, `congruence`), KeywordPseudo, nil},
  24. {Words(`\b`, `\b`, `do`, `last`, `first`, `try`, `idtac`, `repeat`), KeywordReserved, nil},
  25. {`\b([A-Z][\w\']*)`, Name, nil},
  26. {"(\u03bb|\u03a0|\\|\\}|\\{\\||\\\\/|/\\\\|=>|~|\\}|\\|]|\\||\\{<|\\{|`|_|]|\\[\\||\\[>|\\[<|\\[|\\?\\?|\\?|>\\}|>]|>|=|<->|<-|<|;;|;|:>|:=|::|:|\\.\\.|\\.|->|-\\.|-|,|\\+|\\*|\\)|\\(|&&|&|#|!=)", Operator, nil},
  27. {`([=<>@^|&+\*/$%-]|[!?~])?[!$%&*+\./:<=>?@^|~-]`, Operator, nil},
  28. {`\b(unit|nat|bool|string|ascii|list)\b`, KeywordType, nil},
  29. {`[^\W\d][\w']*`, Name, nil},
  30. {`\d[\d_]*`, LiteralNumberInteger, nil},
  31. {`0[xX][\da-fA-F][\da-fA-F_]*`, LiteralNumberHex, nil},
  32. {`0[oO][0-7][0-7_]*`, LiteralNumberOct, nil},
  33. {`0[bB][01][01_]*`, LiteralNumberBin, nil},
  34. {`-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)`, LiteralNumberFloat, nil},
  35. {`'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'`, LiteralStringChar, nil},
  36. {`'.'`, LiteralStringChar, nil},
  37. {`'`, Keyword, nil},
  38. {`"`, LiteralStringDouble, Push("string")},
  39. {`[~?][a-z][\w\']*:`, Name, nil},
  40. },
  41. "comment": {
  42. {`[^(*)]+`, Comment, nil},
  43. {`\(\*`, Comment, Push()},
  44. {`\*\)`, Comment, Pop(1)},
  45. {`[(*)]`, Comment, nil},
  46. },
  47. "string": {
  48. {`[^"]+`, LiteralStringDouble, nil},
  49. {`""`, LiteralStringDouble, nil},
  50. {`"`, LiteralStringDouble, Pop(1)},
  51. },
  52. "dotted": {
  53. {`\s+`, Text, nil},
  54. {`\.`, Punctuation, nil},
  55. {`[A-Z][\w\']*(?=\s*\.)`, NameNamespace, nil},
  56. {`[A-Z][\w\']*`, NameClass, Pop(1)},
  57. {`[a-z][a-z0-9_\']*`, Name, Pop(1)},
  58. Default(Pop(1)),
  59. },
  60. },
  61. ))