Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Additional support for sublime-syntax grammar #50

Closed
gandm opened this issue Jul 7, 2015 · 21 comments
Closed

Additional support for sublime-syntax grammar #50

gandm opened this issue Jul 7, 2015 · 21 comments

Comments

@gandm
Copy link

gandm commented Jul 7, 2015

Sublime text 3 has implemented a new grammar format that seems much better than the traditional textmate grammar. Is there any chance this can be implemented?

It is described here https://www.sublimetext.com/docs/3/syntax.html

@Alhadis
Copy link
Contributor

Alhadis commented Apr 3, 2016

Seems to be a duplicate of #36.

@winstliu
Copy link
Contributor

winstliu commented Apr 3, 2016

Thanks @Alhadis.

@winstliu winstliu closed this as completed Apr 3, 2016
@gandm
Copy link
Author

gandm commented Apr 3, 2016

No it's not!

@Alhadis
Copy link
Contributor

Alhadis commented Apr 3, 2016

How? It seems to be syntactic sugar around the standard TextMate-grammar parsing.

@gandm
Copy link
Author

gandm commented Apr 3, 2016

No it's has a concept of state.

@Alhadis
Copy link
Contributor

Alhadis commented Apr 3, 2016

What do you mean, a concept of state?

@gandm
Copy link
Author

gandm commented Apr 3, 2016

For example you can match a single char, say a + sign and then follow this by pushing a number of contexts onto the stack. E.g. variable name, numeric number,... only one will pop the stack. This is hard in normal grammar as the only code that spans multiple lines is begin/end and you have to know what ends it before you start.

@gandm
Copy link
Author

gandm commented Apr 3, 2016

Having said that, I am not too bothered if the issue is closed.

@Alhadis
Copy link
Contributor

Alhadis commented Apr 3, 2016

It's possible through nested patterns, although ugly. So... theoretically, that's still syntactic sugar over what's already possible now.

@winstliu
Copy link
Contributor

winstliu commented Apr 3, 2016

Thanks for explaining further @gandm - perhaps I should actually scroll down the link next time. There is also variable support, which I don't think CSON has, so I'm going to re-open this.

@winstliu winstliu reopened this Apr 3, 2016
@gandm
Copy link
Author

gandm commented Apr 3, 2016

All I can say is this would have made my life easier when I wrote language-babel

@borela
Copy link

borela commented Feb 12, 2017

I wouldn't consider "just a syntax sugar" when it makes writing syntaxes a way easier than the traditional tmLanguage. Also you can have different control paths with push vs set and include external files which is perfect when dealing with lists of words like so: https://github.com/borela/naomi/blob/master/syntaxes/fjsx15/reactjs.sublime-syntax

@gandm
Copy link
Author

gandm commented Oct 14, 2017

tree-sitter soon available so closing.

@borela
Copy link

borela commented Mar 8, 2018

@gandm Can the sublime-syntax be converted to tree sitter?

@Arcanemagus
Copy link

For reference, @borela's question is answered in tree-sitter/tree-sitter#139 😉.

@borela
Copy link

borela commented Mar 8, 2018

@Arcanemagus So far arguments in favor of tree sitter I heard only apply to limitations in the tmLanguage, you can assign the correct meaning to tokens using sublime syntax.

@gandm
Copy link
Author

gandm commented Mar 8, 2018

I think tree-sitter is vastly superior. Fast, accurate with additional intelligence. You cannot create a true language parser using sublime-syntax nor textmate. Certainly not JavaScript.

@Arcanemagus
Copy link

@borela There is a major difference between a true parser such as what tree-sitter provides, and the attempts to hack together a similar result as is done in TextMate grammars... or Sublime Text's new format. I'd recommend reading up on parsers of context free grammars and if you still have questions feel free to follow up over in tree-sitter/tree-sitter#139.

@borela
Copy link

borela commented Mar 8, 2018

@Arcanemagus that's what I was not getting, to me looked like tree sitter was just generating a tree which could be done by analyzing the scopes generated by the sublime syntax.

It didn't occur to me that tree sitter was also parsing.

@Alhadis
Copy link
Contributor

Alhadis commented Mar 9, 2018

Certainly not JavaScript.

... lol, what the hell.

@borela
Copy link

borela commented Mar 9, 2018

@gandm You can assign the correct scopes using sublime syntax and even distinguish whether /abc/ is a regex literal or something divided by abc depending on whats before it, I did exactly that on https://github.com/borela/naomi, other packages does the same, the only limitation is the per line regex, but that's sublime's limitation.

But as I talked to Max, he did convinced me to use Tree Sitter for more complex languages (C++, MQL5, etc...) because I often have to deal with badly formatted code that spans across multiple lines.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants