Coder Social home page Coder Social logo

Comments (5)

dmfay avatar dmfay commented on August 29, 2024 1

Tree-sitter regexes are single-line by default so I think the explicit newline is actually throwing it off. Other grammars like JS, Python or Bash use .* sans newline for single-line comments; the Java grammar has what seems like an unnecessary negative (anything but a newline) character class.

I've created #74 , please check it out!

from tree-sitter-sql.

DerekStride avatar DerekStride commented on August 29, 2024

Could a lazy /.*?\n/ do the trick?

Yeah I think that would do it, want to open a PR for it?

from tree-sitter-sql.

LeoniePhiline avatar LeoniePhiline commented on August 29, 2024

I tried locally and couldn't make it work. Am I doing something wrong?

Here's what I do, using helix:

  • In $HELIX_RUNTIME/grammars run rm sql.so
  • In $HELIX_RUNTIME/grammars/sources/sql edit grammar.js
  • Run hx --grammar build
  • Open a fresh hx instance to check if it changed something.

It confirms rebuilding sql - but my changes to grammar.js appear to have no effect at all. (Even if I change "--" for something bogus, comments in the SQL file are still highlighted as comments.)

Could you try verifying the fix?

from tree-sitter-sql.

matthias-Q avatar matthias-Q commented on August 29, 2024

I have tested it on my machine and the suggested regex does not fix the issue:

comment: _ => seq('--', /.*?\n/),

with following SQL:

--
CREATE TABLE tx_digibordauthentication_activity_log
(
  uid int(11) unsigned NOT NULL auto_increment,
);

produces this AST:

(program [0, 0] - [5, 0]
  (comment [0, 0] - [2, 0])
  (ERROR [2, 0] - [4, 2]
    (keyword_not [3, 23] - [3, 26])
    (keyword_null [3, 27] - [3, 31])
    (keyword_auto_increment [3, 32] - [3, 46])))
playground.sql	0 ms	(ERROR [2, 0] - [4, 2])

from tree-sitter-sql.

LeoniePhiline avatar LeoniePhiline commented on August 29, 2024

Fixed by #74

from tree-sitter-sql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.