tree-sitter-perl icon indicating copy to clipboard operation
tree-sitter-perl copied to clipboard

scanner.c references isnumber(); should be isdigit() ?

Open wrog opened this issue 10 months ago • 1 comments

When attempting to build the C version of the parser, we get

$ cc -fPIC -c -I. scanner.c
scanner.c: In function 'isSpecialVariableIdentifier':
scanner.c:549:5: warning: implicit declaration of function 'isnumber'; did you mean 'iswupper'? [-Wimplicit-function-declaration]
     isnumber(lexer->lookahead) // 0-9
     ^~~~~~~~
     iswupper
scanner.c: In function 'scan':
scanner.c:619:9: warning: implicit declaration of function 'isnumber'; did you mean 'iswupper'? [-Wimplicit-function-declaration]
         isnumber(lexer->lookahead)
         ^~~~~~~~
         iswupper]([url](url))

code then fails to link

$ cc -fPIC -shared *.o -o "libtree-sitter-perl.dll"
scanner.o:scanner.c:(.text+0xf3b): undefined reference to `isnumber'
scanner.o:scanner.c:(.text+0x12fe): undefined reference to `isnumber'
collect2.exe: error: ld returned 1 exit status

Though I pretty sure this doesn't matter, c compiler is gcc:

cc (Rev1, Built by MSYS2 project) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

on windows 10.

Problem is that ctype.h does not define isnumber(). My guess is you want isdigit()

(made that change and it worked, but if this is the first time anyone has tried c-compiling this, I'm guessing other stuff is going to break, so I'm going to hold off on the PR.)

wrog avatar Apr 18 '24 00:04 wrog

@wrog , I have corrected it, and also upgraded the tree-sitter-cli version. Thanks for reporting :) .

ganezdragon avatar Apr 21 '24 15:04 ganezdragon