c272 / iro4cli Goto Github PK
View Code? Open in Web Editor NEWAn open-source rewrite of Iro, a grammar generator, supporting automatic VSCode & Atom extension generation.
License: GNU General Public License v3.0
An open-source rewrite of Iro, a grammar generator, supporting automatic VSCode & Atom extension generation.
License: GNU General Public License v3.0
I think it should be easy since it looks similar to the Atom spec.
See here: https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json
This variant is more readable and better for maintenance.
I saw that you have CLI version releases for different platforms. However, people without any of the mentioned OSs have to use .NET. I wanted to go through the installation of the CLI version using .NET but didn't find any. So, I was seeking for help. What should I do to install the CLI after having .NET 6? I would use this CLI to build a VSCode extension, so if there any other altenative without the CLI, let me know too.
Thank you, I will appreciate your help!
Hi, are there any plans on adding Sublime3 support? What is the technical work involved in adding support for Sublime3 exporter? (Hoping I may be able to contribute in some way towards this)
PS: Appreciate the CLI effort for iro. Seems like an awesome tool :)
Hi,
Thanks for the great work on this project. Would you consider placing it under a permissive license? It appears to me that this is currently license-free software, and is effectively proprietary.
Thanks!
Even though I would remove this flag for different reasons,
I suggest you to change this to something like --gen-vscode-extension
or similar.
Being only --vscode
makes me think, the output is a vscode compatible spec somewhat.
Hello! This is a great project you have here. I seem to have a problem though in my tests of this tool. Namely, that regex look-ahead appears to be registered as a "capture group" by this tool.
Consider the following .iro file: https://pastebin.com/7k2aP8w6
This is the default example on eeyo.io/iro, but with one small change on line 119:
regex \= (\")(?=h)
Which forces quotes to need the letter 'h' after it. This works great on eeyo.io/iro,
But iro4cli seems to not be able to parse it:
[WARN] Compile - Some top-level flags are missing and/or not implemented yet.
[ERROR] Compile Failed - Mismatch between capture groups and number of styles for inline push with regex '(\")(?=h)'.
I was trying to use Hex colors in 0.4.1, until I realized the latest commit is not in a release. could you tag a new release with the binaries?
Do you have any opinions on making a VS Code extension part of this project's road map? I understand that it's currently CLI-focused, though an extension to make authoring Iro grammars easy would be excellent. While this could be done separately, being made part of this repo directly would allow it to leverage, and stay in sync with, the ANTLR grammar directly, which seems ideal.
Thoughts?
Using hex color codes causes "invalid statement provided"
.comment : style {
color = #aaffaa
color = "#aaffaa"; // doesn't work either
textmate_scope = comment
}
#################################################################
## Iro
################################################################
##
## * Press Ctrl + '+'/'-' To Zoom in
## * Press Ctrl + S to save and recalculate...
## * Documents are saved to web storage.
## * Only one save slot supported.
## * Matches cannot span lines.
## * Unicode chars must be defined in \u0000 to \uffff format.
## * All matches must be contained by a single group ( ... )
## * Look behinds not permitted, (?<= or (?<!
## * Look forwards are permitted (?= or (?!
## * Constants are defined as __my_const = (......)
## * The \= format allows unescaped regular expressions
## * Constants referenced by match \= $${__my_const}
## * Constants can reference other constants
## * You are free to delete all the default scopes.
## * Twitter : ainslec , Web: http://eeyo.io/iro
##
################################################################
name = mysample
file_extensions [] = mysample;
################################################################
## Constants
################################################################
__MY_CONSTANT \= (\b[a-z][a-z0-9]*)
################################################################
## Styles
################################################################
styles [] {
.comment : style {
color = #aaffaa
italic = true
ace_scope = comment
textmate_scope = comment
pygments_scope = Comment
}
.keyword : style {
color = cyan
ace_scope = keyword
textmate_scope = keyword
pygments_scope = Keyword
}
.numeric : style {
color = gold
ace_scope = constant.numeric
textmate_scope = constant.numeric
pygments_scope = Number
}
.punctuation : style {
color = red_2
ace_scope = punctuation
textmate_scope = punctuation
pygments_scope = Punctuation
}
.text : style {
color = brown
ace_scope = text
textmate_scope = text
pygments_scope = String
}
.illegal : style {
color = white
background_color = red
ace_scope = invalid
textmate_scope = invalid
pygments_scope = Generic.Error
}
}
#################################################
## Parse contexts
#################################################
contexts [] {
##############################################
## Main Context - Entry point context
##############################################
main : context {
: pattern {
regex \= $${__MY_CONSTANT}
styles [] = .keyword;
}
: include "numeric" ;
: inline_push {
regex \= (\{)
styles [] = .punctuation;
: pop {
regex \= (\})
styles [] = .punctuation;
}
: include "main" ;
}
: pattern {
regex \= (;)
styles [] = .punctuation;
}
: inline_push {
regex \= (\")
styles [] = .punctuation;
default_style = .text
: pop {
regex \= (\")
styles [] = .punctuation;
}
}
: inline_push {
regex \= (\()
styles [] = .punctuation;
: pop {
regex \= (\))
styles [] = .punctuation;
}
: include "numeric" ;
: pattern {
regex \= (,)
styles [] = .punctuation;
}
}
: include "multi_line_comment" ;
: pattern {
regex \= (//.*)
styles [] = .comment;
}
: pattern {
regex \= ([^\s])
styles [] = .illegal;
}
}
#################################################
## End of Contexts
#################################################
###########################################
## Numeric Context
###########################################
numeric : context {
: pattern {
regex \= (\b\d+)
styles [] = .numeric;
}
}
###########################################
## Multi Line Comment Context
###########################################
multi_line_comment : context {
description = multiline
: inline_push {
regex \= (/\*)
styles [] = .comment;
default_style = .comment
: pop {
regex \= (\*/)
styles [] = .comment;
}
}
}
}
Error:
line 40:25 extraneous input '=' expecting {'[]', '}', ':', IDENTIFIER}
[ERROR] Line 40 - Invalid statement provided, unrecognized.
Using some online tools like https://www.bottlecaps.de/rr/ui and https://www.bottlecaps.de/convert/ we can have a nice navigable railroad diagram.
Copy and paste the EBNF
shown bellow on https://www.bottlecaps.de/rr/ui on the tab Edit Grammar
the click on the tab View Diagram
to see/download a navigable railroad diagram.
/* converted on Wed May 24, 2023, 09:27 (UTC+02) by antlr_4-to-w3c v0.64 which is Copyright (c) 2011-2023 by Gunther Rademacher <[email protected]> */
compileUnit
::= block* EOF
block ::= statement
| sys_set
statement
::= attribute
| set
| include
attribute
::= IDENTIFIER definition
sys_set ::= IDENTIFIER '[]'? '{' statement* '}'
set ::= IDENTIFIER? '[]'? ':' typed_set
typed_set
::= IDENTIFIER ( '{' statement* '}' | statement+ ';' )
include ::= ':' IDENTIFIER '"' IDENTIFIER '"' ';'
definition
::= '[]'? ( '=' | '\=' ) ( definition_ident | HEX_VALUE | regex | constant_ref | array ) ';'?
definition_ident
::= '"'? IDENTIFIER '"'?
array ::= IDENTIFIER ( ',' IDENTIFIER )+
regex ::= REGEX
constant_ref
::= '$' '$' '{' IDENTIFIER '}'
_ ::= COMMENT
| WS
| ENDL
/* ws: definition */
<?TOKENS?>
REGEX ::= '(' ( [^()#xa#xd] | '\(' | '\)' | REGEX )* ')' ( '|' | '?' | '*' | '+' )* REGEX?
ESCAPED_BRACKET
::= '\('
| '\)'
IDENTIFIER
::= [A-Za-z0-9_.#x2D]+
HEX_VALUE
::= '#' [0-9A-Za-z]+
COMMENT? ::= '#' .* #xA
WS ::= [ #xd#x9]+
ENDL ::= #xA
UNKNOWN_SYMBOL
::= .
EOF ::= $
Hello @c272,
I have been working on an Iro grammar for my FOSS project.
It is a combination of JS, JSON and some custom syntax.
The definition works OK in Iro's web editor (screenshot below):
However, when I run the same in iro4cli
(after fixing various minor errors/warnings), I get the following Runtime unhandled exception:
[WARN] Compile - Some top-level flags are missing and/or not implemented yet.
Unhandled exception. System.NotImplementedException: The method or operation is not implemented.
at iro4cli.Compile.Compiler.ProcessContext(String contextName, IroSet context, IroSet contexts)
at iro4cli.Compile.Compiler.Compile(Dictionary`2 vars, ICompileTarget[] targets)
at iro4cli.Program.Run(IroCLIOptions opts)
at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
at iro4cli.Program.Main(String[] args)
Aborted (core dumped)
Please find the grammar in the file: lama2.txt
Presently, I am able to get the generated outputs from the web-editor. However, it'll be really great to know your thoughts on why the particular grammar might be failing.
Thanks again, for your efforts :)
Hi!
I was wondering how hard would it be to support ANTLR 4 or Langium grammars as input or to at least generate one of them as output.
The reason for the question is that both are used to create Language Servers. Langium is especially helpful to create VS Code extensions with language servers.
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?
The official build of Iro allows for use of Textmate or Pygments scopes when lacking an Ace/Rouge scope explicitly. When missing these, the compiler should check for a Textmate scope, and then assign it accordingly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.