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

build: Make scanner.c build with clang #22

Merged
merged 1 commit into from
Dec 1, 2023
Merged

Conversation

vadorovsky
Copy link
Contributor

isascii is a GCC extension, not present in clang.

`isascii` is a GCC extension, not present in clang.
@nordlow
Copy link
Contributor

nordlow commented Dec 1, 2023

The file scanner.c is generated by tree-sitter right? If so why modify the code?

@nordlow
Copy link
Contributor

nordlow commented Dec 1, 2023

The file scanner.c is generated by tree-sitter right? If so why modify the code?

Ahh, so it's hand-written. Why is this needed? For performance?

@vadorovsky
Copy link
Contributor Author

Oh, I didn't know it's auto-generated. In that case, I'm happy to apply the fix in tree-sitter.

This change is needed for me to be able to build Helix (which pulls tree-sitter-d as a dependency) with clang as C compiler. isascii is not present in clang, so trying to build it fails with the following errors:

  Failure 2/2: d Parser compilation failed.
  Stdout:
  Stderr: /home/vadorovsky/repos/helix/runtime/grammars/sources/d/src/scanner.c:70:9: error: call to undeclared function 'isascii'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     70 |                         if (!isascii(lexer->lookahead) ||
        |                              ^
  /home/vadorovsky/repos/helix/runtime/grammars/sources/d/src/scanner.c:81:9: error: call to undeclared function 'isascii'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     81 |                         if (!isascii(lexer->lookahead) ||
        |                              ^
  /home/vadorovsky/repos/helix/runtime/grammars/sources/d/src/scanner.c:92:9: error: call to undeclared function 'isascii'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     92 |                         if (!isascii(lexer->lookahead) ||
        |                              ^
  /home/vadorovsky/repos/helix/runtime/grammars/sources/d/src/scanner.c:126:9: error: call to undeclared function 'isascii'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    126 |                         if (!isascii(lexer->lookahead) ||

I had to patch tree-sitter-d with what I submitted here to make it build.

@gdamore
Copy link
Owner

gdamore commented Dec 1, 2023

The file scanner.c is generated by tree-sitter right? If so why modify the code?

No, scanner.c is not auto-generated-- parse.c is.

@gdamore
Copy link
Owner

gdamore commented Dec 1, 2023

The reason is hand-coded is partly for performance, but partly for simplicity -- some aspects of the D grammar are best done at lexing time -- trying to specify the lexing part of the grammar in tree-sitter itself would greatly explode the grammar, and complicate the rule set. D is already complex enough as it is. :-)

@gdamore gdamore merged commit c313189 into gdamore:main Dec 1, 2023
@gdamore gdamore mentioned this pull request Dec 1, 2023
@vadorovsky vadorovsky deleted the clang branch December 4, 2023 00:42
vadorovsky added a commit to vadorovsky/helix that referenced this pull request Dec 6, 2023
One of the included changes is gdamore/tree-sitter-d#22 which
fixes the build of Helix when using clang as `CC`.
pascalkuthe pushed a commit to helix-editor/helix that referenced this pull request Dec 13, 2023
One of the included changes is gdamore/tree-sitter-d#22 which
fixes the build of Helix when using clang as `CC`.
dgkf pushed a commit to dgkf/helix that referenced this pull request Jan 30, 2024
One of the included changes is gdamore/tree-sitter-d#22 which
fixes the build of Helix when using clang as `CC`.
mtoohey31 pushed a commit to mtoohey31/helix that referenced this pull request Jun 2, 2024
One of the included changes is gdamore/tree-sitter-d#22 which
fixes the build of Helix when using clang as `CC`.
Vulpesx pushed a commit to Vulpesx/helix that referenced this pull request Jun 7, 2024
One of the included changes is gdamore/tree-sitter-d#22 which
fixes the build of Helix when using clang as `CC`.
smortime pushed a commit to smortime/helix that referenced this pull request Jul 10, 2024
One of the included changes is gdamore/tree-sitter-d#22 which
fixes the build of Helix when using clang as `CC`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants