Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update php to v0.22.4 #160

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions _automation/grammars.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,11 @@
"url": "https://github.com/tree-sitter/tree-sitter-php",
"files": [
"parser.c",
"scanner.cc"
"scanner.c",
"scanner.h"
],
"reference": "v0.19.0",
"revision": "3ef0d5c253affe4b7fb46d9505db6df143db565a",
"reference": "v0.22.4",
"revision": "58054be104db0809ea6f119514a4d904f95e5b5c",
"updateBasedOn": "tag"
},
{
Expand Down Expand Up @@ -322,4 +323,4 @@
"revision": "6129a83eeec7d6070b1c0567ec7ce3509ead607c",
"updateBasedOn": "tag"
}
]
]
40 changes: 40 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,44 @@ 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()

treeSitterFiles := []string{"parser.h", "array.h", "alloc.h"}

for _, f := range treeSitterFiles {
s.downloadFile(
ctx,
fmt.Sprintf("%s/%s/php/src/tree_sitter/%s", url, g.Revision, f),
fmt.Sprintf("%s/tree_sitter/%s", g.Language, f),
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