Let's build a transpiler! Part 50
This is the fiftieth post in a series of building a transpiler.You can find the previous ones here.
When you're less than a cog
I started working at my previous job in 2012.I had to deal with an offshore team daily. It started with only two members but, over time, it grew to around 15 people.
I'm not good with names. Talking to faceless people thousands of miles away did not help.
So, I came up with an idea: People should introduce themselves by e-mail with a picture, and I was the first to do that.
Not long after it started, I've sent an e-mail making fun of me, then it progressed to a kinda newsletter making fun of everyone.
(I consulted a foreign fellow to make sure I was not offending anyone, though.)
There were six of these newsletters. After it was over, our offshore manager told me they missed it because it was a stress reliever.
Due to this initiative and others, I was promoted from technical leader to team leader after some six months.
In my new position, I had all the obligations and none of the powers (but it came with a salary hike, so yay, I guess?)
One of my new duties was to attend bi-weekly meetings with our client SMEs. They were four at the time.
There was the guy for whom everything had the highest priority - what made me understand that nothing had real priority.
Two other guys were OK, although one of them was dumb.
He did two things that stuck with me:
- One of my offshore teammates once asked dumb-dumb what were the addresses of some servers.
From the context, it was clear they were talking about IP addresses, but dumb-dumb responded with "Oh, they're in some partner's building, at street address... - To do our tasks, we had a non-official, non-approved user with admin power.
Being the kind of man I am, I thought we should have a properly approved admin user, so I asked for one.
None of the SMEs addressed my request, but my fellow team-mates and I would learn what dumb-dumb did a few weeks later:
Several automated services started failing for no reason. After investigating the root cause, we found out their users have been disabled.
What happened is that dumb-dumb went on a rampage of disabling "unknown" users - aiming to find the one we used - resulting in several services not running for weeks, something that caused some pain to his company.
She was very, very strict. She was fast at pointing at any mistake our team did, no matter how little it was.
But she was fair, or so I thought.
Mind you, my company was/is the second larger IT provider in its country.
Our customer was a worldwide chemical and seeds company later acquired by the Chinese.
One morning I received a customer's internal communication warning that a protest was being scheduled to happen near our workplace.
(Protest against the government, not the company.)
It recommended we should leave earlier to avoid any risks.
Three thoughts occurred to me when I read it:
- How our customer cared about its employees in recommending that;
- How my company didn't care about its employees, as I have never seen any such communication during my tenure there;
- Oh, shoot, I have a bi-weekly meeting with nameless woman this afternoon!
"Hey, did you see the company's e-mail? It is recommending we leave early to avoid a possible riot. I suppose we can postpone our meeting?"
Her answer? "No way, we are going to have our meeting."
I left thinking how low she considered her safety and mine, but, oh well.
I supposed I could hide inside the building if needed and leave when it was safe, maybe?
To lunch I went, then waited until our appointed meeting time, and then sat at her desk waiting for nameless woman.
And waited.
And waited.
She did not attend it.
It took me some time to figure out what probably happened:
When I talked to her, she most certainly has not read that particular e-mail yet. So she was not aware of the danger.
When the realization came to her, she took her personal belongings and left without a trace, not caring to let me know about it.
It was a nice "Frak you, I'm saving my ass" message from her.
I was reminded of this episode by reading A megacorp is not your dream job.
I'm glad I don't have to put up with this kind of BS any more.
Back to business
Last time I said we'll take a step back. Let me explain what happened:It's been over a month I did not touch anything related to our transpiler.
I've started a new project with my partner in hopes to sell it. So, far, hope is all we have.
As things did not happen the way we wanted them to, my partner asked me why I would not try to develop further a side-project I have, so we could integrate it with our system to make it more "sellable."
So, I've put that second project with my partner on hold to re-start this third one.
My prototype was made entirely of SQL scripts, with no user interface.
I choose to use Blazor for that, so I could learn it as I went on.
Let me tell you, it is not an easy journey. My feeling is that the tech is not mature enough. Its debugging experience is among the top three worst I have had so far.
But I was able to create something that works, even though my interface is ugly and outdated as hell.
It is not complete yet, though, because while working on it I had an idea of a project that would be fun to work on.
So, I stopped working on that third project and started a fourth one. 😊
To make a long story short, I've worked on it until I saw I was able to do what I've planned to, but it was clear I would not be able to complete it.
It depends on having several pictures available, and roughly 40% of them were missing.
Even though, the ones I have are over 20,000, and I kinda went through them one by one.
I've put this fourth project on hold. Maybe I'll get back to it later if my brother can provide those missing pieces he said he could.
Regarding the third project, it is not a priority. I've created some GUI components in it that I can adapt to JavaScript and may turn into a post or two.
Back to the second project, things seem to be gaining a little traction again, so maybe I'll need to jump back to it.
So... back to business, again
My last iteration with the transpiler left me without a pretty printer among other things (I could not complete some code validation, for instance.)To get used to the project again - remember, it's been over a month since the last I saw it - I choose to start another new VBScript version, to get it pretty-printing my code again.
This time, I would not take shortcuts. I'd do what I thought it should be done, but for one reason or another, I didn't in my previous deeds.
I worked on it for three days. It can do a good job, but it has a fatal flaw: It cannot print comments.
I'm still thinking about what can I do to fix it.
While I could not solve it yet, I did improve our transpiler a bit.
For starters, I finally collected Scanner's messages and put them into class Messages.
Then, I noticed I was dealing with compiler directives while parsing classes, modules, and procedures bodies, but not while parsing the procedure area. I've fixed that, and while I was at it, I also made it possible to have compiler directives inside compiler directives working.
You can see the changes here.
I'm also supporting the Exit <value> statement, even though in a half-baked way.
I'm transforming Exit <value> inside a function, say, MyFunction, to MyFunction = <value>.
The problem is I'm not able yet to tell if the value is a reference or not, so I could transform it properly to Set MyFunction = <value>.
So far it is a WIP. Its fixes are here.
I even fixed a couple of bugs!
When reading identifiers, I read one character too far so I can check whether it is a data type suffix or not.
But, if there's no next character, I would put the last read identifier's last character back to the reading buffer, then I would read it again and complain about it not being a proper keyword.
As I am swallowing BOMs when reading files, I'm using it to mark the EOF and avoid this mistake.
The second one has to do with removing an item from a KeyedList.
I keep the last item inserted in the aptly named Last_ variable, but failed to update it when removing the last item...
Here are the fixes.
Speaking of reading files, now we can have them encoded in UTF-8, UTF-16, or OEM.
To enable it, I created a class to read command-line arguments.
It allowed me to not only receive what the files' encoding is but also compiling-time constants.
The additions and changes needed to have it working are here.
Next week I'll try to go back to transpiling code for real. Let's see how it goes.
Andrej Biasic
2021-09-08