-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.portugol.js
137 lines (135 loc) · 4.21 KB
/
source.portugol.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/luisgbr1el/portugol-grammar>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.por'],
names: ['portugol'],
patterns: [
{begin: '/\\*', end: '\\*/', name: 'comment.block.portugol'},
{match: '//.*', name: 'comment.double-slash.portugol'},
{begin: '"', end: '"', name: 'string.quoted.double.portugol'},
{begin: "'", end: "'", name: 'string.quoted.single.portugol'},
{
match: '\\b(para|caso|continue|senao|para|se|escolha|enquanto|e|ou)\\b',
name: 'keyword.control.portugol'
},
{
match: '\\b(inclua|biblioteca|programa)\\b',
name: 'keyword.other.portugol'
},
{
match: '\\b(=|!|<|>|&|\\+|raiz|sen|cos|mod|div|-|\\^|\\*|\\/|\\|)\\b',
name: 'keyword.operator.new.portugol'
},
{match: '\\b(\\d+|\\d+.?(f)?)\\b', name: 'constant.numeric.portugol'},
{
match: '(#)([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\\b(?!.*?(?<!@){)',
name: 'constant.rgb-value.portugol'
},
{
match: '\\b(falso|NULL|verdadeiro)\\b',
name: 'constant.language.portugol'
},
{match: '\\b(enum|struct|state|array)\\b', name: 'storage.type.portugol'},
{match: '\\b(this|parent|super)\\b', name: 'variable.language.portugol'},
{
begin: '(funcao)\\s*(\\/\\*.*\\*\\/)?\\s*(\\w+)\\s*\\(',
beginCaptures: {
1: {name: 'support.type.portugol'},
2: {name: 'comment.block.portugol'},
3: {name: 'support.function.portugol'}
},
end: '\\)(\\s*:\\s*(array\\s*<\\s*\\w+\\s*>|\\w*))?',
endCaptures: {2: {patterns: [{include: '#witcherscript-var-types'}]}},
patterns: [
{
captures: {
1: {name: 'keyword.other.portugol'},
2: {name: 'support.variable.portugol'},
3: {patterns: [{include: '#witcherscript-var-types'}]}
},
match:
'\\s*(out|optional)?\\s*(\\w+)\\s*:\\s*(array\\s*<\\s*\\w+\\s*>|\\w*|),?'
}
]
},
{
begin: '\\b(variavel)\\b\\s*',
beginCaptures: {1: {name: 'storage.type.portugol'}},
end: ':\\s*(array\\s*<\\s*\\w+\\s*>|\\w*)\\s*;',
endCaptures: {1: {patterns: [{include: '#witcherscript-var-types'}]}},
patterns: [{match: '(\\w+)\\s*,?', name: 'support.variable.portugol'}]
},
{
captures: {
1: {name: 'keyword.control.portugol'},
2: {name: 'support.variable'}
},
match: '(default)\\s*(\\w+)'
},
{
captures: {
1: {name: 'keyword.other.portugol'},
2: {name: 'support.class.portugol'}
},
match: '(escreva|leia)\\s*(\\w*)'
},
{
captures: {1: {name: 'support.class.portugol'}},
match: '\\(\\s*(\\s*[A-Z]\\w+\\s*)\\s*\\)\\s*\\('
},
{
captures: {1: {name: 'support.class.portugol'}},
match: '\\(\\s*\\(\\s*([A-Z]\\w+)\\s*\\)'
},
{
captures: {
1: {name: 'variable.language.portugol'},
2: {name: 'support.class.portugol'},
3: {name: 'variable.language.portugol'},
4: {name: 'variable.language.portugol'}
},
match: '(novo|nova)\\s*(\\w+)\\s*(in)\\s*(this)'
},
{include: '#witcherscript-data-types'}
],
repository: {
'witcherscript-data-types': {
patterns: [
{
match: '\\b(cadeia|inteiro|caractere|logico|real)\\b',
name: 'storage.type.portugol'
}
]
},
'witcherscript-object-types': {
patterns: [{match: '[A-Z]\\w+', name: 'support.class.portugol'}]
},
'witcherscript-var-types': {
patterns: [
{include: '#witcherscript-object-types'},
{
captures: {
1: {name: 'storage.type.portugol'},
2: {
patterns: [
{include: '#witcherscript-object-types'},
{include: '#witcherscript-data-types'}
]
}
},
match: '(array)\\s*<\\s*(\\w+)\\s*>'
},
{include: '#witcherscript-data-types'}
]
}
},
scopeName: 'source.portugol'
}
export default grammar