c272 / iro4cli

An open-source rewrite of Iro, a grammar generator, supporting automatic VSCode & Atom extension generation.
GNU General Public License v3.0
35 stars 5 forks source link

Are there existing Iro grammar files somewhere? #3

Closed skerit closed 3 years ago

skerit commented 3 years ago

I wrote a Sublime 3 syntax highlighter for my HTML-based template language a few years ago, and I've actually also been trying to port it to Iro ever since.

But I just can't get it to work, I can't even get a basic html comment context parser working, while a html comment parser in tmLanguage or sublime-syntax makes a lot more sense to me.

So does anyone know of any existing Iro grammar files that are a bit more advanced than the default example on the Iro page?

skerit commented 3 years ago

I decided to give it another go and create an HTML Iro syntax from scratch, and to not focus too much on how Sublime or existing tmlanguage files implement it.

It's still a WIP, but I'm getting there.

skerit commented 3 years ago

Ah, unfortunately Iro does not support lookbehinds... So even though parsing HTML is doable, JavaScript is not because you need lookbehinds for literal regular expressions.

c272 commented 3 years ago

@skerit Lookbehinds are not permitted in normal Iro because the lowest-common-denominator Javascript regex parsers do not support them. However, there is no such limitation at the moment for you compiling with lookbehinds using iro4cli, just note that it might break Atom and Rouge compatibility, and there's no guarantee of them working with certain regex parsers.

The file will likely be generated fine, it might just not work in some contexts. I will add a warning in iro4cli that lets you know that lookbehinds are not fully supported in Iro. 😃

Also sorry, I don't have any detailed examples of Iro grammar files on hand, but I can point you to the file I used in my toy language a while ago, which you can find here. Not exactly complex I know, sorry. 😅