Commit
+86 -140 +/-3 browse
1 | diff --git a/grammar.js b/grammar.js |
2 | index f11c850..dd0bf12 100644 |
3 | --- a/grammar.js |
4 | +++ b/grammar.js |
5 | @@ -2,29 +2,16 @@ const NEWLINE = /\r?\n/; |
6 | const WHITE_SPACE = /[\t\f\v ]+/; |
7 | const ANYTHING = /[^\r\n]+/; |
8 | |
9 | - const PREC = { |
10 | - COMMAND: 50, |
11 | - FILE_CHANGE: 47, |
12 | - INDEX: 45, |
13 | - SIMILARITY: 43, |
14 | - FILE: 40, |
15 | - LOCATION: 35, |
16 | - ADDITION: 30, |
17 | - DELETION: 25, |
18 | - }; |
19 | - |
20 | - const COMMAND_PRELUDE = token.immediate(prec(PREC.COMMAND, "diff")); |
21 | + const COMMAND_PRELUDE = token.immediate("diff"); |
22 | const FILE_CHANGE_PRELUDE = token.immediate( |
23 | - prec(PREC.FILE_CHANGE, field("kind", choice("new", "deleted", "rename"))) |
24 | - ); |
25 | - const INDEX_PRELUDE = token.immediate(prec(PREC.INDEX, "index")); |
26 | - const SIMILARITY_PRELUDE = token.immediate(prec(PREC.SIMILARITY, "similarity")); |
27 | - const FILE_PRELUDE = token.immediate( |
28 | - prec(PREC.FILE, field("kind", choice("---", "+++"))) |
29 | + field("kind", choice("new", "deleted", "rename")) |
30 | ); |
31 | - const LOCATION_PRELUDE = token.immediate(prec(PREC.LOCATION, "@@")); |
32 | - const ADDITION_PRELUDE = token.immediate(prec(PREC.ADDITION, "+")); |
33 | - const DELETION_PRELUDE = token.immediate(prec(PREC.DELETION, "-")); |
34 | + const INDEX_PRELUDE = token.immediate("index"); |
35 | + const SIMILARITY_PRELUDE = token.immediate("similarity"); |
36 | + const FILE_PRELUDE = token.immediate(field("kind", choice("---", "+++"))); |
37 | + const LOCATION_PRELUDE = token.immediate("@@"); |
38 | + const ADDITION_PRELUDE = token.immediate("+"); |
39 | + const DELETION_PRELUDE = token.immediate("-"); |
40 | |
41 | module.exports = grammar({ |
42 | name: "gitdiff", |
43 | diff --git a/src/grammar.json b/src/grammar.json |
44 | index bb74c57..4cc6b36 100644 |
45 | --- a/src/grammar.json |
46 | +++ b/src/grammar.json |
47 | @@ -64,12 +64,8 @@ |
48 | { |
49 | "type": "IMMEDIATE_TOKEN", |
50 | "content": { |
51 | - "type": "PREC", |
52 | - "value": 50, |
53 | - "content": { |
54 | - "type": "STRING", |
55 | - "value": "diff" |
56 | - } |
57 | + "type": "STRING", |
58 | + "value": "diff" |
59 | } |
60 | }, |
61 | { |
62 | @@ -91,28 +87,24 @@ |
63 | { |
64 | "type": "IMMEDIATE_TOKEN", |
65 | "content": { |
66 | - "type": "PREC", |
67 | - "value": 47, |
68 | + "type": "FIELD", |
69 | + "name": "kind", |
70 | "content": { |
71 | - "type": "FIELD", |
72 | - "name": "kind", |
73 | - "content": { |
74 | - "type": "CHOICE", |
75 | - "members": [ |
76 | - { |
77 | - "type": "STRING", |
78 | - "value": "new" |
79 | - }, |
80 | - { |
81 | - "type": "STRING", |
82 | - "value": "deleted" |
83 | - }, |
84 | - { |
85 | - "type": "STRING", |
86 | - "value": "rename" |
87 | - } |
88 | - ] |
89 | - } |
90 | + "type": "CHOICE", |
91 | + "members": [ |
92 | + { |
93 | + "type": "STRING", |
94 | + "value": "new" |
95 | + }, |
96 | + { |
97 | + "type": "STRING", |
98 | + "value": "deleted" |
99 | + }, |
100 | + { |
101 | + "type": "STRING", |
102 | + "value": "rename" |
103 | + } |
104 | + ] |
105 | } |
106 | } |
107 | }, |
108 | @@ -136,28 +128,24 @@ |
109 | { |
110 | "type": "IMMEDIATE_TOKEN", |
111 | "content": { |
112 | - "type": "PREC", |
113 | - "value": 47, |
114 | + "type": "FIELD", |
115 | + "name": "kind", |
116 | "content": { |
117 | - "type": "FIELD", |
118 | - "name": "kind", |
119 | - "content": { |
120 | - "type": "CHOICE", |
121 | - "members": [ |
122 | - { |
123 | - "type": "STRING", |
124 | - "value": "new" |
125 | - }, |
126 | - { |
127 | - "type": "STRING", |
128 | - "value": "deleted" |
129 | - }, |
130 | - { |
131 | - "type": "STRING", |
132 | - "value": "rename" |
133 | - } |
134 | - ] |
135 | - } |
136 | + "type": "CHOICE", |
137 | + "members": [ |
138 | + { |
139 | + "type": "STRING", |
140 | + "value": "new" |
141 | + }, |
142 | + { |
143 | + "type": "STRING", |
144 | + "value": "deleted" |
145 | + }, |
146 | + { |
147 | + "type": "STRING", |
148 | + "value": "rename" |
149 | + } |
150 | + ] |
151 | } |
152 | } |
153 | }, |
154 | @@ -188,12 +176,8 @@ |
155 | { |
156 | "type": "IMMEDIATE_TOKEN", |
157 | "content": { |
158 | - "type": "PREC", |
159 | - "value": 45, |
160 | - "content": { |
161 | - "type": "STRING", |
162 | - "value": "index" |
163 | - } |
164 | + "type": "STRING", |
165 | + "value": "index" |
166 | } |
167 | }, |
168 | { |
169 | @@ -228,12 +212,8 @@ |
170 | { |
171 | "type": "IMMEDIATE_TOKEN", |
172 | "content": { |
173 | - "type": "PREC", |
174 | - "value": 43, |
175 | - "content": { |
176 | - "type": "STRING", |
177 | - "value": "similarity" |
178 | - } |
179 | + "type": "STRING", |
180 | + "value": "similarity" |
181 | } |
182 | }, |
183 | { |
184 | @@ -256,24 +236,20 @@ |
185 | { |
186 | "type": "IMMEDIATE_TOKEN", |
187 | "content": { |
188 | - "type": "PREC", |
189 | - "value": 40, |
190 | + "type": "FIELD", |
191 | + "name": "kind", |
192 | "content": { |
193 | - "type": "FIELD", |
194 | - "name": "kind", |
195 | - "content": { |
196 | - "type": "CHOICE", |
197 | - "members": [ |
198 | - { |
199 | - "type": "STRING", |
200 | - "value": "---" |
201 | - }, |
202 | - { |
203 | - "type": "STRING", |
204 | - "value": "+++" |
205 | - } |
206 | - ] |
207 | - } |
208 | + "type": "CHOICE", |
209 | + "members": [ |
210 | + { |
211 | + "type": "STRING", |
212 | + "value": "---" |
213 | + }, |
214 | + { |
215 | + "type": "STRING", |
216 | + "value": "+++" |
217 | + } |
218 | + ] |
219 | } |
220 | } |
221 | }, |
222 | @@ -289,12 +265,8 @@ |
223 | { |
224 | "type": "IMMEDIATE_TOKEN", |
225 | "content": { |
226 | - "type": "PREC", |
227 | - "value": 35, |
228 | - "content": { |
229 | - "type": "STRING", |
230 | - "value": "@@" |
231 | - } |
232 | + "type": "STRING", |
233 | + "value": "@@" |
234 | } |
235 | }, |
236 | { |
237 | @@ -321,12 +293,8 @@ |
238 | { |
239 | "type": "IMMEDIATE_TOKEN", |
240 | "content": { |
241 | - "type": "PREC", |
242 | - "value": 30, |
243 | - "content": { |
244 | - "type": "STRING", |
245 | - "value": "+" |
246 | - } |
247 | + "type": "STRING", |
248 | + "value": "+" |
249 | } |
250 | }, |
251 | { |
252 | @@ -349,12 +317,8 @@ |
253 | { |
254 | "type": "IMMEDIATE_TOKEN", |
255 | "content": { |
256 | - "type": "PREC", |
257 | - "value": 25, |
258 | - "content": { |
259 | - "type": "STRING", |
260 | - "value": "-" |
261 | - } |
262 | + "type": "STRING", |
263 | + "value": "-" |
264 | } |
265 | }, |
266 | { |
267 | diff --git a/src/parser.c b/src/parser.c |
268 | index 8734703..96238f8 100644 |
269 | --- a/src/parser.c |
270 | +++ b/src/parser.c |
271 | @@ -322,7 +322,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { |
272 | if (lookahead == 'i') ADVANCE(42); |
273 | if (lookahead == 'm') ADVANCE(47); |
274 | if (lookahead == 'n') ADVANCE(19); |
275 | - if (lookahead == 'r') ADVANCE(24); |
276 | + if (lookahead == 'r') ADVANCE(25); |
277 | if (lookahead == 's') ADVANCE(32); |
278 | if (lookahead == 't') ADVANCE(45); |
279 | if (('\t' <= lookahead && lookahead <= '\f') || |
280 | @@ -364,7 +364,6 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { |
281 | END_STATE(); |
282 | case 7: |
283 | if (lookahead == '-') ADVANCE(81); |
284 | - if (lookahead == 'g') ADVANCE(33); |
285 | END_STATE(); |
286 | case 8: |
287 | if (lookahead == '-') ADVANCE(30); |
288 | @@ -389,10 +388,10 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { |
289 | if (lookahead == 'd') ADVANCE(71); |
290 | END_STATE(); |
291 | case 15: |
292 | - if (lookahead == 'd') ADVANCE(22); |
293 | + if (lookahead == 'd') ADVANCE(23); |
294 | END_STATE(); |
295 | case 16: |
296 | - if (lookahead == 'd') ADVANCE(23); |
297 | + if (lookahead == 'd') ADVANCE(24); |
298 | END_STATE(); |
299 | case 17: |
300 | if (lookahead == 'd') ADVANCE(27); |
301 | @@ -410,22 +409,22 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { |
302 | if (lookahead == 'e') ADVANCE(71); |
303 | END_STATE(); |
304 | case 21: |
305 | - if (lookahead == 'e') ADVANCE(72); |
306 | + if (lookahead == 'e') ADVANCE(51); |
307 | END_STATE(); |
308 | case 22: |
309 | - if (lookahead == 'e') ADVANCE(53); |
310 | + if (lookahead == 'e') ADVANCE(72); |
311 | END_STATE(); |
312 | case 23: |
313 | - if (lookahead == 'e') ADVANCE(73); |
314 | + if (lookahead == 'e') ADVANCE(53); |
315 | END_STATE(); |
316 | case 24: |
317 | - if (lookahead == 'e') ADVANCE(43); |
318 | + if (lookahead == 'e') ADVANCE(73); |
319 | END_STATE(); |
320 | case 25: |
321 | - if (lookahead == 'e') ADVANCE(14); |
322 | + if (lookahead == 'e') ADVANCE(43); |
323 | END_STATE(); |
324 | case 26: |
325 | - if (lookahead == 'e') ADVANCE(51); |
326 | + if (lookahead == 'e') ADVANCE(14); |
327 | END_STATE(); |
328 | case 27: |
329 | if (lookahead == 'e') ADVANCE(54); |
330 | @@ -437,7 +436,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { |
331 | if (lookahead == 'f') ADVANCE(28); |
332 | END_STATE(); |
333 | case 30: |
334 | - if (lookahead == 'g') ADVANCE(33); |
335 | + if (lookahead == 'g') ADVANCE(35); |
336 | END_STATE(); |
337 | case 31: |
338 | if (lookahead == 'i') ADVANCE(38); |
339 | @@ -449,10 +448,10 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { |
340 | if (lookahead == 'i') ADVANCE(40); |
341 | END_STATE(); |
342 | case 33: |
343 | - if (lookahead == 'i') ADVANCE(49); |
344 | + if (lookahead == 'i') ADVANCE(36); |
345 | END_STATE(); |
346 | case 34: |
347 | - if (lookahead == 'i') ADVANCE(36); |
348 | + if (lookahead == 'i') ADVANCE(49); |
349 | END_STATE(); |
350 | case 35: |
351 | if (lookahead == 'i') ADVANCE(50); |
352 | @@ -461,18 +460,18 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { |
353 | if (lookahead == 'l') ADVANCE(12); |
354 | END_STATE(); |
355 | case 37: |
356 | - if (lookahead == 'l') ADVANCE(26); |
357 | + if (lookahead == 'l') ADVANCE(21); |
358 | if (('0' <= lookahead && lookahead <= '9') || |
359 | ('a' <= lookahead && lookahead <= 'f')) ADVANCE(62); |
360 | END_STATE(); |
361 | case 38: |
362 | - if (lookahead == 'l') ADVANCE(21); |
363 | + if (lookahead == 'l') ADVANCE(22); |
364 | END_STATE(); |
365 | case 39: |
366 | if (lookahead == 'm') ADVANCE(74); |
367 | END_STATE(); |
368 | case 40: |
369 | - if (lookahead == 'm') ADVANCE(34); |
370 | + if (lookahead == 'm') ADVANCE(33); |
371 | END_STATE(); |
372 | case 41: |
373 | if (lookahead == 'm') ADVANCE(20); |
374 | @@ -496,16 +495,16 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { |
375 | if (lookahead == 'o') ADVANCE(16); |
376 | END_STATE(); |
377 | case 48: |
378 | - if (lookahead == 'r') ADVANCE(35); |
379 | + if (lookahead == 'r') ADVANCE(34); |
380 | END_STATE(); |
381 | case 49: |
382 | - if (lookahead == 't') ADVANCE(70); |
383 | + if (lookahead == 't') ADVANCE(55); |
384 | END_STATE(); |
385 | case 50: |
386 | - if (lookahead == 't') ADVANCE(55); |
387 | + if (lookahead == 't') ADVANCE(70); |
388 | END_STATE(); |
389 | case 51: |
390 | - if (lookahead == 't') ADVANCE(25); |
391 | + if (lookahead == 't') ADVANCE(26); |
392 | END_STATE(); |
393 | case 52: |
394 | if (lookahead == 'w') ADVANCE(71); |
395 | @@ -560,8 +559,6 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { |
396 | if (eof) ADVANCE(67); |
397 | if (lookahead == '\n') ADVANCE(68); |
398 | if (lookahead == '\r') ADVANCE(1); |
399 | - if (lookahead == '+') ADVANCE(57); |
400 | - if (lookahead == '-') ADVANCE(8); |
401 | if (lookahead == '.') ADVANCE(9); |
402 | if (lookahead == '@') ADVANCE(11); |
403 | if (lookahead == 'f') ADVANCE(31); |
404 | @@ -1130,7 +1127,6 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { |
405 | [ts_builtin_sym_end] = ACTIONS(1), |
406 | [aux_sym_source_token1] = ACTIONS(1), |
407 | [anon_sym_diff] = ACTIONS(1), |
408 | - [anon_sym_DASH_DASHgit] = ACTIONS(1), |
409 | [aux_sym_file_change_token1] = ACTIONS(1), |
410 | [anon_sym_file] = ACTIONS(1), |
411 | [anon_sym_mode] = ACTIONS(1), |
412 | @@ -1145,7 +1141,6 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { |
413 | [anon_sym_AT_AT2] = ACTIONS(1), |
414 | [anon_sym_PLUS] = ACTIONS(1), |
415 | [anon_sym_DASH] = ACTIONS(1), |
416 | - [sym_linerange] = ACTIONS(1), |
417 | [sym_commit] = ACTIONS(1), |
418 | }, |
419 | [1] = { |