You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Over the past few days I started the VBAPackager project which intends to provide means to embed VBA source code into an xlsm/docm file without the need for the VBE. It intends to be a stepping stone for moving VBA out of the VBE and into external IDEs like VSCode. This ontop of #5176 could pave the way for VBA as a language of the future. (P.S. The project is a long way off being in a working state)
But this got me thinking, what features am I actually missing in VBA? Lambda expressions, stack traces, line numbers (for errors), reflection, multiline strings to name a few.
Historically I've tried adding these in the "brute force way" by hooking into vb runtime, or by making BNF/CFG classes to parse lambda("$1+$2") (also not completed this 😛). However lambdas really could be a result of transpilation:
How easy would it be to take the existing RubberDuck Parser and add language features like the above by pushing and popping nodes into/out of the AST and transpile back down to VBA afterwards?
In theory something like lambda(head(a1,a2)=a1+a2) is already valid syntax, so I imagine this would be relatively easy? Adding new syntax would require modification of the grammar, which would likely be less viable in a dynamic way I assume?
I understand this isn't really in the scope of the Rubberduck IDE, at least for now unless VBE is deprecated, but this could do to VBA what babel has done to JavaScript...
In general it would be cool to get a setup like the following going:
Source --> AST --> plugins --> AST --> Source
Main question is how easy would it be to achieve? And is Rubberduck.Parsing simply drag and drop? Or does it require the VBE? What classes/methods do I need/need to watch out for?
The text was updated successfully, but these errors were encountered:
sancarn
added
the
support
Whether you're using Rubberduck or you've forked it and have questions, never hesitate to ask!
label
May 10, 2020
We've tried to confine the part of Rubberduck that relies on the VBE into the Rubberduck.VBEEditor, Rubberduck.VBEditor.VB6 and Rubberduck.VBEditor.VBA projects.
The problem is that Rubberduck.Parsing directly depends on that VBEEditor project to obtain the source for parsing. So it's not a simple drop-in by any stretch of the imagination.
The parser itself theoretically supports parsing VBA code from raw text input and will give you an AST, but that's where it gets hairy again.
The AST node classes are generated from the grammar file at build time and if you want to modify these classes you won't get around modifying the grammar.
Theoretically it should be possible to extend the AST capabilities by writing custom classes derived from the ANTLR baseclass for contexts, but it's probably not the easiest way to go about this ...
From what I can tell you've gotten yourself in at the deep end... If you want the fully resolved ParserState that rubberduck is working off of, you'll have to deal with the ParseCoordinator, which handles the different steps of the parsing process. If you just want an AST, you could try looking into IStringParser and its implementations. With a bit of luck that allows you to not deal with the VBE at all.
As it is, the Parsing setup we have for Rubberduck is probably significantly too complex for your purposes, though...
Hi All, it's me again.
Over the past few days I started the VBAPackager project which intends to provide means to embed VBA source code into an xlsm/docm file without the need for the VBE. It intends to be a stepping stone for moving VBA out of the VBE and into external IDEs like VSCode. This ontop of #5176 could pave the way for VBA as a language of the future. (P.S. The project is a long way off being in a working state)
But this got me thinking, what features am I actually missing in VBA? Lambda expressions, stack traces, line numbers (for errors), reflection, multiline strings to name a few.
Historically I've tried adding these in the "brute force way" by hooking into vb runtime, or by making BNF/CFG classes to parse
lambda("$1+$2")
(also not completed this 😛). However lambdas really could be a result of transpilation:-->
This would be significantly more optimal than parsing and evaluating at runtime! P.S. stdCallback is something I have completed
Similarly with line numbers and stack tracing:
--> Okay it looks ugly but:
This is where rubberduck comes in, I'm hoping.
How easy would it be to take the existing RubberDuck Parser and add language features like the above by pushing and popping nodes into/out of the AST and transpile back down to VBA afterwards?
In theory something like
lambda(head(a1,a2)=a1+a2)
is already valid syntax, so I imagine this would be relatively easy? Adding new syntax would require modification of the grammar, which would likely be less viable in a dynamic way I assume?I understand this isn't really in the scope of the Rubberduck IDE, at least for now unless VBE is deprecated, but this could do to VBA what babel has done to JavaScript...
In general it would be cool to get a setup like the following going:
Source --> AST --> plugins --> AST --> Source
Main question is how easy would it be to achieve? And is Rubberduck.Parsing simply drag and drop? Or does it require the VBE? What classes/methods do I need/need to watch out for?
The text was updated successfully, but these errors were encountered: