Skip to content

Commit 04d6b33

Browse files
authored
Merge pull request #160 from ahmedash95/update-php
Update php to v0.22.4
2 parents 8ba0365 + 679e829 commit 04d6b33

File tree

11 files changed

+135407
-60394
lines changed

11 files changed

+135407
-60394
lines changed

_automation/grammars.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,11 @@
200200
"url": "https://github.com/tree-sitter/tree-sitter-php",
201201
"files": [
202202
"parser.c",
203-
"scanner.cc"
203+
"scanner.c",
204+
"scanner.h"
204205
],
205-
"reference": "v0.19.0",
206-
"revision": "3ef0d5c253affe4b7fb46d9505db6df143db565a",
206+
"reference": "v0.22.4",
207+
"revision": "58054be104db0809ea6f119514a4d904f95e5b5c",
207208
"updateBasedOn": "tag"
208209
},
209210
{
@@ -322,4 +323,4 @@
322323
"revision": "6129a83eeec7d6070b1c0567ec7ce3509ead607c",
323324
"updateBasedOn": "tag"
324325
}
325-
]
326+
]

_automation/main.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ func (s *UpdateService) downloadGrammar(ctx context.Context, g *Grammar) {
237237
s.downloadTypescript(ctx, g)
238238
case "yaml":
239239
s.downloadYaml(ctx, g)
240+
case "php":
241+
s.downloadPhp(ctx, g)
240242
default:
241243
s.defaultGrammarDownload(ctx, g)
242244
}
@@ -323,6 +325,44 @@ func (s *UpdateService) writeGrammarsFile(ctx context.Context) {
323325
}
324326
}
325327

328+
func (s *UpdateService) downloadPhp(ctx context.Context, g *Grammar) {
329+
fileMapping := map[string]string{
330+
"parser.c": "php/src/parser.c",
331+
"scanner.c": "php/src/scanner.c",
332+
"scanner.h": "common/scanner.h",
333+
}
334+
335+
url := g.ContentURL()
336+
337+
treeSitterFiles := []string{"parser.h", "array.h", "alloc.h"}
338+
339+
for _, f := range treeSitterFiles {
340+
s.downloadFile(
341+
ctx,
342+
fmt.Sprintf("%s/%s/php/src/tree_sitter/%s", url, g.Revision, f),
343+
fmt.Sprintf("%s/tree_sitter/%s", g.Language, f),
344+
nil,
345+
)
346+
}
347+
348+
for _, f := range g.Files {
349+
fp, ok := fileMapping[f]
350+
if !ok {
351+
logAndExit(getLogger(ctx), "mapping for file not found", "file", f)
352+
}
353+
354+
s.downloadFile(
355+
ctx,
356+
fmt.Sprintf("%s/%s/%s", url, g.Revision, fp),
357+
fmt.Sprintf("%s/%s", g.Language, f),
358+
map[string]string{
359+
`<tree_sitter/parser.h>`: `"parser.h"`,
360+
`"../../common/scanner.h"`: `"scanner.h"`,
361+
},
362+
)
363+
}
364+
}
365+
326366
// ocaml is special since its folder structure is different from the other ones
327367
func (s *UpdateService) downloadOcaml(ctx context.Context, g *Grammar) {
328368
fileMapping := map[string]string{

0 commit comments

Comments
 (0)