Replies: 5 comments 14 replies
-
Hi @svallory, I took the freedom to enable Discussions on this repository and transferred your contribution to it. I hope that's ok for you. I've been active in the ANTLR community for a long time. I have written a parser in Java to convert some resource files for UIs. I have used previous ANTLR versions over many years (also in commercial products like MySQL Workbench and MySQL Shell for VS Code) and even have written the C++ runtime for ANTL4 (supported by Dan McLaughlin and David Sisson). So, I have quite a deep knowledge about the tool. On the other hand I never heard about Langium before. Your question is the first time I came across this tool. From the description it seems to be a very powerful tool and is certainly good for many people needing the feature set it provides. Though, as you can imagine, I have no reason to switch, given that ANTLR4 is very active and has such a huge community. Regarding antlr4ts: this is a bit of a special relationship. I'm using this runtime for years already and it has served me very well over that time. But it is kind of special. It does not live in the main ANTLR4 eco system, it's not updated anymore and in alpha state for a long time already. It contains some very special optimisations which are not in the official ANTLR4 runtime and require extra work to make that runtime compatible with ATNs created by the official ANTLR4 tool (antlr4ts comes with an own tool build). Additionally, there seems to be no interest to develop antlr4ts further (I asked) and I am interested in converting ANTLR4 entirely to Typescript, out of curiosity. That would allow me to generate parsers in my VS Code extension w/o requiring Java to be installed. |
Beta Was this translation helpful? Give feedback.
-
I don't mind you moving the discussion at all! Firstly, thank you for taking the time to write back, and with so many details. I really appreciate it! The main reason I asked is that I saw that ANTLR generates the lexer, parser, listener, and visitor base classes. I don't think with all that it would take much to implement an LSP for semantic highlighting, type-checking, and auto-complete suggestions, am I wrong? If so, maybe I should switch now to the ANTLR4 grammar, and infrastructure, rather than later. The language I'm designing is of a higher order than programming languages and it tries to be as close to English as possible without ceasing to be a context-free, formal language. To give you an idea, it is so flexible that you can actually write poems in it and turn them into code.
Not that it should be encouraged in a system specification! We are already using disl to specify projects where I work and it looks like this: An entire system was specified here last week to put a project from a group of mentees in order (so don't mind the mess, they are still learning) The reason I'm showing you all this is to give you a sense of what I'm up against and humbly ask for advice on tools or pitfalls ahead since you have so much experience with parsers. I've been designing this language for five years and have the rules in my head but I only started actually implementing it a month or so ago. Also, I would love to hear what you think about the idea and ergonomics of the languages. |
Beta Was this translation helpful? Give feedback.
-
You can use ANTLR4 definitely for a language server. I haven't written one so far, but created language support libraries in different tools (2 mentioned above, another is my VS Code extension for ANTLR4, which provides language support for ANTLR4 grammars, including code completion, syntax highlighting, code hints etc.). When it comes to designing a new programming language you should have a good idea for whom this might be interesting. It's not like there aren't many programming languages already in the world and a new one needs to have something really compelling, to be of interest. The idea of a programming language, which sounds like a natural language has been around for many decades already, without really taking shape. This might have to do with the fact that a programming language must be really clear and straightforward. Natural languages tend to be the opposite. |
Beta Was this translation helpful? Give feedback.
-
Agreed! And disl 1 has a clear focus: project managers and team leaders. And its first goal isn't to be a programming language, but, even though the second example goes to a very concrete level, the goal is to be a specification language.
I realize that. That's why I'm focusing on an area where the competition is low: project specification. The options I know to tackle that problem are English and some diagrams (not all are easily understood by clients). Which leads to a lot of misunderstanding from the client regarding the scope and features. Then there's ContextMapper which is completely focused on programmers and I think that, even being a programmer, if you don't know DDD well, you'll have a hard time understanding it. I imagine the following use case:
I guess that's basically it... project scope, documentation, feature specification, and diagrams all from a single source of truth. That's the mountain I'm trying to climb LOL
I think you may be right about the reason. I'm avoiding that complexity mainly by having sensible synonyms for operators so you can tense and pluralize them (is/are/to be) and treating natural language in statements as decoration only. The syntax highlighter has some issues, but those words are colored and treated like comments. Other tricks are spaces in class names, special char sequences and function calls not needing Thank you again! I'll check your extension. But back to As far as I get it, you are creating a TS runtime so you can use it to use data generated by ANTLR to parse a file in the language you generated the data for and provide language features. Is that it?
Looks like your extension does most of what an LSP does. I imagine you are using separate VS code APIs for each feature. Did chose not to implement an LSP for any reason or was it just how things happened to be? Finally, thank you for all the time. The project looks really interesting. Is there anything I can help you with? |
Beta Was this translation helpful? Give feedback.
-
Yes, good points. It's tricky to schedule in a certain manner as it often happens that you have to jump on a different file and fix that first before you can go back and finish the original one. Sometimes this even goes in loops. So I wonder if you would mind to work on the JREE unit tests instead. They are in a different repository. You need both repos currently anyway, because you have to link the lib folder in the a4tstool repo to the lib folder in the other repo (or copy it, but that is not a good idea). |
Beta Was this translation helpful? Give feedback.
-
Hi!
I'm just starting to learn more about parsers, compilers, etc. I've been designing a language for the last 4 years.
About 3 years ago I started to implement it with PegJS, which was easy, but only gave me the parser, I would have to do all the rest by hand.
So I moved to Xtext because it seemed to provide a lot more just from the grammar. That actually made me give up for a long time. Xtext ecosystem is too complex and cumbersome for someone that is not familiar with the Java ecosystem.
Near the end of last year, I started looking into it again and found Langium which is what I'm using now.
But Langium is a new project and I've been looking around. I intend to contribute (as soon as I have a bit of free time) to whatever project I'm using.
So here's my honest question: why port ANTLR4 instead of supporting Langium (which is also open source) or picking up
antlr4ts
where it was left off?Beta Was this translation helpful? Give feedback.
All reactions