source: node_modules/refractor/lang/antlr4.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.9 KB
Line 
1'use strict'
2
3module.exports = antlr4
4antlr4.displayName = 'antlr4'
5antlr4.aliases = ['g4']
6function antlr4(Prism) {
7 Prism.languages.antlr4 = {
8 comment: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
9 string: {
10 pattern: /'(?:\\.|[^\\'\r\n])*'/,
11 greedy: true
12 },
13 'character-class': {
14 pattern: /\[(?:\\.|[^\\\]\r\n])*\]/,
15 greedy: true,
16 alias: 'regex',
17 inside: {
18 range: {
19 pattern: /([^[]|(?:^|[^\\])(?:\\\\)*\\\[)-(?!\])/,
20 lookbehind: true,
21 alias: 'punctuation'
22 },
23 escape:
24 /\\(?:u(?:[a-fA-F\d]{4}|\{[a-fA-F\d]+\})|[pP]\{[=\w-]+\}|[^\r\nupP])/,
25 punctuation: /[\[\]]/
26 }
27 },
28 action: {
29 pattern: /\{(?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*\}/,
30 greedy: true,
31 inside: {
32 content: {
33 // this might be C, C++, Python, Java, C#, or any other language ANTLR4 compiles to
34 pattern: /(\{)[\s\S]+(?=\})/,
35 lookbehind: true
36 },
37 punctuation: /[{}]/
38 }
39 },
40 command: {
41 pattern:
42 /(->\s*(?!\s))(?:\s*(?:,\s*)?\b[a-z]\w*(?:\s*\([^()\r\n]*\))?)+(?=\s*;)/i,
43 lookbehind: true,
44 inside: {
45 function: /\b\w+(?=\s*(?:[,(]|$))/,
46 punctuation: /[,()]/
47 }
48 },
49 annotation: {
50 pattern: /@\w+(?:::\w+)*/,
51 alias: 'keyword'
52 },
53 label: {
54 pattern: /#[ \t]*\w+/,
55 alias: 'punctuation'
56 },
57 keyword:
58 /\b(?:catch|channels|finally|fragment|grammar|import|lexer|locals|mode|options|parser|returns|throws|tokens)\b/,
59 definition: [
60 {
61 pattern: /\b[a-z]\w*(?=\s*:)/,
62 alias: ['rule', 'class-name']
63 },
64 {
65 pattern: /\b[A-Z]\w*(?=\s*:)/,
66 alias: ['token', 'constant']
67 }
68 ],
69 constant: /\b[A-Z][A-Z_]*\b/,
70 operator: /\.\.|->|[|~]|[*+?]\??/,
71 punctuation: /[;:()=]/
72 }
73 Prism.languages.g4 = Prism.languages.antlr4
74}
Note: See TracBrowser for help on using the repository browser.