@@ -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
327367func (s * UpdateService ) downloadOcaml (ctx context.Context , g * Grammar ) {
328368 fileMapping := map [string ]string {
0 commit comments