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.

Reason.sublime-syntax 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. %YAML 1.2
  2. ---
  3. # http://www.sublimetext.com/docs/3/syntax.html
  4. name: Reason
  5. file_extensions:
  6. - re
  7. - rei
  8. scope: source.reason
  9. contexts:
  10. main:
  11. - include: reason_comment_doc_block
  12. - include: reason_comment_block
  13. - include: reason_named_arg
  14. - include: reason_module
  15. - include: reason_lifetime
  16. - include: reason_self
  17. - include: reason_string
  18. - include: reason_raw_string
  19. - match: '\''([^\''\\]|\\(x[0-9A-Fa-f]{2}|u\{[0-9A-Fa-f]{1,6}\}|.))\'''
  20. scope: string.quoted.single.source.reason
  21. - match: '\b(fun)\s+([a-zA-Z_][a-zA-Z0-9_]?[\w\:,+ \''<>?]*)\s*(?:\()'
  22. scope: meta.function.source.reason
  23. captures:
  24. 1: keyword.source.reason
  25. 2: entity.name.function.source.reason
  26. - match: '(let|and)\s+(module\s+)(rec\s+)?([[:alpha:]_][[:alnum:]_]*)\s*(:[^=]*)?(=?)'
  27. comment: This matches the 'let x = val' style of variable intitialization.
  28. scope: meta.initialization.reason
  29. captures:
  30. 1: keyword.source.reason
  31. 2: keyword.source.reason
  32. 3: keyword.source.reason
  33. 4: variable.other.reason
  34. 5: storage.type.source.reason
  35. 6: keyword.operator.reason
  36. - match: '(let)\s+(rec\s+)?([[:alpha:]_][[:alnum:]_]*)\s*(:[^=]*)?(=?)'
  37. comment: This matches the 'let x = val' style of variable intitialization.
  38. scope: meta.initialization.reason
  39. captures:
  40. 1: keyword.source.reason
  41. 2: keyword.source.reason
  42. 4: storage.type.source.reason
  43. 5: keyword.operator.reason
  44. - match: (extern\s+crate)\s+(\w+)
  45. scope: meta.import.reason
  46. captures:
  47. 1: keyword.source.reason
  48. 2: support
  49. - match: '\b(macro_rules!)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*(?:\{)'
  50. scope: meta.macro.source.reason
  51. captures:
  52. 1: keyword.source.reason
  53. 2: entity.name.macro.source.reason
  54. - match: \b(as|box|break|claim|const|continue|copy|Copy|crate|do|drop|then|else|extern|for|if|impl|in|let|and|loop|switch|fun|open|include|mod|move|mutable|Owned|priv|pub|pure|ref|return|unsafe|use|while|mod|Send|static|trait|struct|enum|exception|type|module|rec|where)\b
  55. scope: keyword.source.reason
  56. - match: \b(Self|m32|m64|m128|f80|f16|f128|int|uint|isize|usize|float|char|bool|u8|u16|u32|u64|f32|f64|i8|i16|i32|i64|str|Option|Either|c_float|c_double|c_void|FILE|fpos_t|DIR|dirent|c_char|c_schar|c_uchar|c_short|c_ushort|c_int|c_uint|c_long|c_ulong|size_t|ptrdiff_t|clock_t|time_t|c_longlong|c_ulonglong|intptr_t|uintptr_t|off_t|dev_t|ino_t|pid_t|mode_t|ssize_t)\b
  57. scope: storage.type.source.reason
  58. - match: \bself\b
  59. scope: variable.language.source.reason
  60. - match: \b(true|false|Some|None|Ok|Err)\b
  61. scope: constant.language.source.reason
  62. - match: \b(EXIT_FAILURE|EXIT_SUCCESS|RAND_MAX|EOF|SEEK_SET|SEEK_CUR|SEEK_END|_IOFBF|_IONBF|_IOLBF|BUFSIZ|FOPEN_MAX|FILENAME_MAX|L_tmpnam|TMP_MAX|O_RDONLY|O_WRONLY|O_RDWR|O_APPEND|O_CREAT|O_EXCL|O_TRUNC|S_IFIFO|S_IFCHR|S_IFBLK|S_IFDIR|S_IFREG|S_IFMT|S_IEXEC|S_IWRITE|S_IREAD|S_IRWXU|S_IXUSR|S_IWUSR|S_IRUSR|F_OK|R_OK|W_OK|X_OK|STDIN_FILENO|STDOUT_FILENO|STDERR_FILENO)\b
  63. scope: support.constant.source.reason
  64. - match: '#!?\['
  65. push:
  66. - meta_scope: comment.block.attribute.reason
  67. - match: '\]'
  68. pop: true
  69. - include: reason_string
  70. - include: reason_raw_string
  71. - match: '\b(([0-9][0-9_]*)|([0-9][0-9_]*(usize|u8|u16|u32|u64))|([0-9][0-9_]*(isize|i8|i16|i32|i64)))\b'
  72. scope: constant.numeric.integer.source.reason
  73. - match: '\b((0x[a-fA-F0-9_]+)|(0x[a-fA-F0-9_]+(usize|u8|u16|u32|u64))|(0x[a-fA-F0-9_]+(isize|i8|i16|i32|i64)))\b'
  74. scope: constant.numeric.hex.source.reason
  75. - match: '\b((0b[01_]+)|(0b[01_]+(usize|u8|u16|u32|u64))|(0b[01_]+(isize|i8|i16|i32|i64)))\b'
  76. scope: constant.numeric.binary.source.reason
  77. - match: '\b(([0-9][0-9_]*(f32|f64|f))|([0-9][0-9_]*([eE][+-]=[0-9_]+))|([0-9][0-9_]*([eE][+-]=[0-9_]+)(f32|f64|f))|([0-9][0-9_]*\.[0-9_]+)|([0-9][0-9_]*\.[0-9_]+(f32|f64|f))|([0-9][0-9_]*\.[0-9_]+%([eE][+-]=[0-9_]+))|([0-9][0-9_]*\.[0-9_]+%([eE][+-]=[0-9_]+)(f32|f64|f)))\b'
  78. scope: constant.numeric.float.source.reason
  79. - match: "(=>)|(->)|[-:=*,!.+|%/&~@<>;]"
  80. scope: keyword.operator.reason
  81. - match: \b_\b
  82. scope: support.function.reason
  83. - match: \b(\w+)\b(?=\()
  84. scope: support.function.reason
  85. - match: \b(\w+!)(?=\()
  86. scope: support.macro.reason
  87. - match: '\b(\w+)::'
  88. scope: meta.namespace-block.reason
  89. - match: '\b(\w+!)\s*[({\[]'
  90. scope: meta.macro.source.reason
  91. captures:
  92. 1: meta.preprocessor.reason
  93. - match: '(\[|\]|{|}|\(|\))'
  94. scope: punctuation.definition.bracket.reason
  95. - match: \b(Box|Vec|StrBuf|Path|Option|Result|Reader|Writer|Stream|Seek|Buffer|IoError|IoResult|Sender|SyncSender|Receiver|Cell|RefCell|Any)\b
  96. scope: support.class.std.source.reason
  97. - match: \b(Send|Sized|Copy|Share)\b
  98. scope: support.type.kind.source.reason
  99. - match: \bbox\b
  100. scope: storage.modifier.box.source.reason
  101. - match: \brec\b
  102. scope: storage.modifier.rec.source.reason
  103. - match: \bmodule\b
  104. scope: storage.modifier.module.source.reason
  105. reason_comment_block:
  106. - match: /\*
  107. push:
  108. - meta_scope: comment.block.source.reason
  109. - match: \*/
  110. pop: true
  111. - include: reason_comment_block
  112. reason_comment_doc_block:
  113. - match: '/\*[!\*][^\*]'
  114. push:
  115. - meta_scope: comment.block.documentation.source.reason
  116. - match: \*/
  117. pop: true
  118. - include: reason_comment_doc_block
  119. reason_escaped_character:
  120. - match: '\\(x[0-9A-Fa-f]{2}|u\{[0-9A-Fa-f]{1,6}\}|.)'
  121. scope: constant.character.escape.source.reason
  122. reason_lifetime:
  123. - match: '\''([a-zA-Z_][a-zA-Z0-9_]*)(?!\'')\b'
  124. scope: storage.modifier.lifetime.source.reason
  125. captures:
  126. 1: entity.name.lifetime.source.reason
  127. reason_module:
  128. - match: '\b([A-Z][a-zA-Z0-9_]*)\b'
  129. captures:
  130. 1: variable.other.reason
  131. reason_named_arg:
  132. - match: '(@([a-zA-Z_][a-zA-Z0-9_]*))\b'
  133. captures:
  134. 1: storage.modifier.lifetime.source.reason
  135. 2: entity.name.lifetime.source.reason
  136. reason_raw_string:
  137. - match: r(#*)"
  138. push:
  139. - meta_scope: string.quoted.double.raw.source.reason
  140. - match: '"(\1)'
  141. pop: true
  142. reason_self:
  143. - match: \bself\b
  144. scope: variable.language.source.reason
  145. reason_string:
  146. - match: '"'
  147. push:
  148. - meta_scope: string.quoted.double.source.reason
  149. - match: '"'
  150. pop: true
  151. - include: reason_escaped_character