« first day (1006 days earlier)      last day (2174 days later) » 

04:00
when you push, the commits get to the remote repository
So I can save (Ctrl+S) but that still doesn't mean they are committed?
exactly
Ok. Understood.
Thanks for that.
ideally you make small, targeted commits
VBALexer.g4 open
04:01
every commit requires a comment/description
and it looks all foreign to me
it's ANTLR's language
this is the lexer grammar
This may take me a while but I'll try.
the difference between a lexer and a parser it how they work with tokens
the lexer creates them out of fragments; the parser uses them in parser rules
the syntax is pretty simple:
what is a token?
04:04
we have a string that contains the code of a given module, we got that from the VBIDE API
if the best we can do is searches in that string, we're doomed ;-)
so what we do instead is, we tokenize it
Is that a good explanation?
:thumbsup:
Basically: 'Parsers work at the grammatical level, lexers work at the word level.'
04:06
yeah. the lexer grammar defines a set of lexer rules
IIUC, "End" is a keyword, but depending on context, it can be an "End" statement token, or an "End" Property token, or an "End" If token etc.
RULENAME : {match pattern}
actually, scroll all the way to the bottom
the smallest parse unit in the grammar is a fragment
:boom: Oh man.... It just hit the fan and got real messy in here!
the lexer rules use these fragments
 fragment A:('a'|'A');
fragment JANUARY : J A N U A R Y;
there's a rule for everything you could possibly see in a VBA program
NEWLINE : '\r' '\n' | [\r\n\u2028\u2029];
SINGLEQUOTE : '\'';
UNDERSCORE : '_';
WS : [ \t];
well, one we can parse anyway
a WS lexer token is either a space or a tab
04:10
\r \n are the unicode characters?
WS = WhiteSpace
'\' denotes the escape character?
as in regex
@IvenBach exactly
so WS : [<space>\t];
as far as Rubberduck gives a duck, yeah
04:12
In laymans terms. WS is taken to mean either a <space> or <tab character>
yep
then you scroll up and you get the whole list of VB keywords and operators
NEWLINE is taken to mean <return> <newline> or either [<return>,<newline>,<u2028>,<u2029>]
Think I'm understanding
lexer rules are always SCREAM_CASE
04:14
So anything thats a fragment can be to be something that can later be built upon?
fragments are always all_lowercase
exactly
as are lexer tokens themselves
EXIT_DO : E X I T (WS | LINE_CONTINUATION)+ D O;
EXIT_FOR : E X I T (WS | LINE_CONTINUATION)+ F O R;
EXIT_FUNCTION : E X I T (WS | LINE_CONTINUATION)+ F U N C T I O N;
EXIT_PROPERTY : E X I T (WS | LINE_CONTINUATION)+ P R O P E R T Y;
EXIT_SUB : E X I T (WS | LINE_CONTINUATION)+ S U B;
I never thought one could put a line continuation there
EXIT_SUB : E X I T (WS | LINE_CONTINUATION)+ S U B; the <+> symbol at the end denotes 1 or more?
exactly
* denotes any number
HAHAHA. Who would put a LINE_CONTINUATION character between Exit and Sub
04:16
Now I understand you you @Comintern @ThunderFrame were talking about.
// Apparently END_ENUM and END_TYPE don't allow line continuations (in the VB editor)
END_ENUM : E N D WS+ E N U M;
Sub Foo()
    Exit _
 _
 _
 _
 _
 _
    Sub
    Debug.Print "Does not print."
End Sub
Or for that matter a single individual, myself included.
so far so good?
04:18
I think so.
that's all there is to the lexer really
bring up VBAParser.g4
For END_ENUM : <Stuff in here>
does everything have to be separated by a space? Always?
yes - E N D is the E fragment, the N fragment, the D fragment
The 'E N D ...` are fragments.
They're specified that way so they can be case-insensitive.
04:19
fragment E:('e'|'E');
and the fragments (e|E) (n|N) (d|D) constitute END
exactly
which itself is a fragment that 'could' be further built upon.
See you are explaining this fine.
It's the monkey you're teaching that has to take it slowly.
propertyGetStmt :
    (visibility whiteSpace)? (STATIC whiteSpace)? PROPERTY_GET whiteSpace functionName (whiteSpace? argList)? (whiteSpace asTypeClause)? endOfStatement
    block
    END_PROPERTY
;
that's a parser rule
parser rules are camelCase (aka javaCase)
It's also <thing> : <rules> syntax?
04:21
yep
this is how Rubberduck sees a module:
module :
    endOfStatement
    moduleAttributes
    moduleHeader?
    moduleAttributes
    moduleConfig?
    moduleAttributes
    moduleDeclarations
    moduleAttributes
    moduleBody
    moduleAttributes
    // A module can consist of WS as well as line continuations only.
    whiteSpace?
;
actually, this:
startRule : module EOF;
@Mat'sMug I was catching up until right about here. I've got 5484 outgoing commits showing in VS Team Explorer. It won't let me pull, the only thing I can do is push to Origin|Rubberduck-VBA|Upstream
@FreeMan you're F'd
^
Did you clone main?
04:23
I just did the merge from upstream yesterday/Sunday to pick up all the .12 changes...
Give me a bit for the RD seeing a module part
I made the couple of changes for 2803 in NonReturningFunctionInspection and wanted to keep those, so I did a commit on them, and that's what it's telling me now.
:(
github won't let you push to rubberduck-vba/Rubberduck/next
@FreeMan - It looks like you forked master instead of next.
> This branch is 5517 commits behind rubberduck-vba:master.
04:26
huh, you fork a repo, not a branch?
crap. Yup...
just saw that...
Go to your git.
Change the branch dropdown to next.
grabs popcorn
GitHub, WinGit or TeamExp
04:27
create a PR for this?
@Mat'sMug This is going to take me a little longer to digest. Working on it.
When you switch to next, it should show a commit or 2 ahead of next
This branch is 2 commits ahead of rubberduck-vba:next.
Perfect.
04:28
yup, I see that.
Delete your entire local directory
2
Then hit the green [Clone or download] button on github and copy the URL.
including the .git and other . directories?
Yup. Including the directory itself.
closes VS first
^ And any open VBE hosts.
04:30
^none at the moment.
deleted & URL in clipboard
OK, open VS as admin.
<Token>? means 0 or 1 occurences?
When it loads, go to team explorer.
then Add?
Clone
Then paste the url.
04:31
that makes more sense.
Cloning
@IvenBach isn't Antlr awesome? You can use it to define a formal grammar for any language you want.. even make a new one just for your application
Make absolutely sure you clone to the same directory path you had before.
Yup
and... done
If you don't, it screws up your registry.
OK, now open the solution.
double click & open
04:32
@Mat'sMug I'm unable to determine if there is awesome in what I'm looking at. Give me a few more minutes to get back to you on that.
Right-click on Rubberduck then properties.
you're looking at the parser grammar?
presume I don't need to install the 3rd-party Git command prompt tools, since I've already got wingit installed?
The only thing that was blown away was your startup project.
@Mat'sMug Right now and traipsing through each one to get an idea.
04:33
@FreeMan Those follow VS, not the solution.
I just can't find EOF anywhere. I know it stands for End Of File
this is the first time I've opened TE and it keeps prompting me to install them. I don't need another set of command line tools, I shouldn't think
Rubberduck, right-click, properties
Nah, don't worry about it. If you have wingit installed, you can do that anytime.
OK, in properties, go to Debug.
start external program -> Excel.exe?
@IvenBach correct. ANTLR see that and knows it can return from the startRule
04:35
@FreeMan Bingo.
Hit save after that, and then F6 to build.
You should be good to go.
I've got a general loose idea of what it's doing. Not as good as the lexer since that was much simpler but I think I'm ok to proceed. Bear with me if I don't get it all.
the startRule is the single parser rule we need to call to process an entire code file
startRule : module EOF;
huh... Mine says Ctrl-Shift-B to build
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 1 skipped ==========
04:37
each parser rule, once processed by Antlr, becomes a ParserRuleContext class
and within a parser rule, every time another parser rule is referenced, it becomes a method of that class
thanks again, @Comintern.
NP, I could do that in my sleep at this point.
so StartRuleContext.module() returns a ModuleContext
module :
    endOfStatement
    moduleAttributes
    moduleHeader?
    moduleAttributes
    moduleConfig?
    moduleAttributes
    moduleDeclarations
    moduleAttributes
    moduleBody
    moduleAttributes
    // A module can consist of WS as well as line continuations only.
    whiteSpace?
;
so the module parser rule becomes a ModuleContext object
that ModuleContext object has a method for each of these referenced rules
let's go do moduleBody
moduleBody :
    whiteSpace?
    (moduleBodyElement endOfStatement)*;

moduleBodyElement :
    functionStmt
    | propertyGetStmt
    | propertySetStmt
    | propertyLetStmt
    | subStmt
;
a module's body is made of whitespace and as many moduleBodyElement+endOfStatement as we can take
the ParserRuleContext used by Rubberduck.Common.CodeModuleExtensions.GetStmtContext which it instantiates?
04:44
@IvenBach I wouldn't worry about the code at this point.
@Comintern Don't hide the magic from me!
lol
we'll get there :)
@Mat'sMug Getting this understood right now.
The parser generates the objects, and ANTLR generates the code. If you thought our code was sausage, you should peek in VBParser.cs sometime...
^
not too long, it's a HeadacheFactory
@Comintern he meant the extension method though
(there's a GetStmtContext method generated by Antlr in the VBAParser.cs class that Antlr creates from that grammar)
04:47
gonna stop while I'm ahead. Will take another crack at #2803 tomorrow.
@Mat'sMug I've somewhat understood it. Enough to take another step.
Yep. The GetStmtContext method is using objects generated by the parser.
@IvenBach ok. Ctrl+F and search for functionStmt :
@FreeMan That one might be a bit more in depth than I thought at first glance - it's something deep in the bowels of the resolver.
functionStmt :
    (visibility whiteSpace)? (STATIC whiteSpace)? FUNCTION whiteSpace? functionName (whiteSpace? argList)? (whiteSpace? asTypeClause)? endOfStatement
    block
    END_FUNCTION
;
functionName : identifier;
now we're deep enough in the tree that we're starting to see lexer tokens (they're ALL_CAPS)
the rest are other [lower-level] parser rules
04:49
(visibility whiteSpace)? means what?
Ctrl+F whiteSpace :
whiteSpace : (WS | LINE_CONTINUATION)+;
If you see a non-lexer identifier, it's another parser rule.
visibility : PRIVATE | PUBLIC | FRIEND | GLOBAL;
@Comintern I couldn't even find what I was looking at yesterday. Def time to crash. see ya in the morning.
04:50
visibility <-- Wouldn't it have been better to use accessModifier ?
all parser rules either refer to other parser rules, or to lexer tokens
@FreeMan Give me a ping when you're working on it - we can team debug it if you want.
@IvenBach The terminology comes from the VBA language specification for the most part.
also we can't just go and rename parser rules on a whim - just renaming VisibilityContext would break the parse tree listeners handling these rules
but let's not get into listeners and tree walkers just yet
arg : (OPTIONAL whiteSpace)? ((BYVAL | BYREF) whiteSpace)? (PARAMARRAY whiteSpace)? unrestrictedIdentifier (whiteSpace? LPAREN whiteSpace? RPAREN)? (whiteSpace? asTypeClause)? (whiteSpace? argDefaultValue)?;
@Mat'sMug We gotta stay focused on making the sausage and eating it after.
04:55
lol
so parser rules are really just abstraction layers: the more parser rules, the more expressive the grammar becomes
when you're done drilling through parser rules, down at the bottom of every branch of that parse tree, is lexer tokens
the fun part is that parser rules can be recursive
// 5.6 Expressions
the # stuff at the right isn't a comment; these identifiers become derived types
AddOpContext : ExpressionContext
Starting to not follow...
| expression whiteSpace? (PLUS | MINUS) whiteSpace? expression                                  # addOp
derived types? Kind of like Base class and derived class?
04:59
exactly
so <addOP> = expression whiteSpace? (PLUS | MINUS) whiteSpace? expression

« first day (1006 days earlier)      last day (2174 days later) »