Skip to content

Commit

Permalink
update php to 0.22.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedash95 committed May 9, 2024
1 parent 8ba0365 commit aa78a5d
Show file tree
Hide file tree
Showing 6 changed files with 134,240 additions and 60,393 deletions.
6 changes: 3 additions & 3 deletions _automation/grammars.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@
"url": "https://github.com/tree-sitter/tree-sitter-php",
"files": [
"parser.c",
"scanner.cc"
"scanner.c"
],
"reference": "v0.19.0",
"revision": "3ef0d5c253affe4b7fb46d9505db6df143db565a",
"reference": "v0.22.4",
"revision": "58054be104db0809ea6f119514a4d904f95e5b5c",
"updateBasedOn": "tag"
},
{
Expand Down
36 changes: 36 additions & 0 deletions _automation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ func (s *UpdateService) downloadGrammar(ctx context.Context, g *Grammar) {
s.downloadTypescript(ctx, g)
case "yaml":
s.downloadYaml(ctx, g)
case "php":
s.downloadPhp(ctx, g)
default:
s.defaultGrammarDownload(ctx, g)
}
Expand Down Expand Up @@ -323,6 +325,40 @@ func (s *UpdateService) writeGrammarsFile(ctx context.Context) {
}
}

func (s *UpdateService) downloadPhp(ctx context.Context, g *Grammar) {
fileMapping := map[string]string{
"parser.c": "php/src/parser.c",
"scanner.c": "php/src/scanner.c",
"scanner.h": "common/scanner.h",
}

url := g.ContentURL()

s.downloadFile(
ctx,
fmt.Sprintf("%s/%s/php/src/tree_sitter/parser.h", url, g.Revision),
fmt.Sprintf("%s/parser.h", g.Language),
nil,
)

for _, f := range g.Files {
fp, ok := fileMapping[f]
if !ok {
logAndExit(getLogger(ctx), "mapping for file not found", "file", f)
}

s.downloadFile(
ctx,
fmt.Sprintf("%s/%s/%s", url, g.Revision, fp),
fmt.Sprintf("%s/%s", g.Language, f),
map[string]string{
`<tree_sitter/parser.h>`: `"parser.h"`,
`"../../common/scanner.h"`: `"scanner.h"`,
},
)
}
}

// ocaml is special since its folder structure is different from the other ones
func (s *UpdateService) downloadOcaml(ctx context.Context, g *Grammar) {
fileMapping := map[string]string{
Expand Down
Loading

0 comments on commit aa78a5d

Please sign in to comment.