The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
No, I've never used those tools. Usually I start something that grows organically, at which point it's too late to use them. But even if they might help, I'd rather write the code from scratch than search for a tool, read its manual, get it running, and maybe discover, after investing lots of time on it, that it has show-stopping deficiencies. Mostly it's because I hate spending time configuring stuff.
those scanner generators are really easy to use once you know how. the issue i have building my own tokenizer/scanner by hand is they get awfully complicated for real world languages as you've probably found. I prefer to use regex to define my lexemes/terminal tokens as it makes it easier - less code i have to write and debug. regex is like nothing to me. I'd almost rather write my own scanner generator and then use that than write my own scanner by hand.
I have an unrelated question for you.
I have two options with respect to parsing C#: I can parse in two passes, parsing only as far as types the first time, just to get type information completely so i can parse the rest accurately (i need type information to disambiguate the parse, just like you do to parse C only worse)
My other option - and what i've done with the hand rolled parser, is simply punt *correcting* the AST after the fact, rather than touching the parse tree. basically *after* I've finished building my AST out of my parse tree, then i go back and correct the AST with type information.
I have this nasty method called "Patch" which visits my entire tree, with type info, looking for bits in the tree it needs to patch. Currently it's slow, but i have some ideas to speed it up.
The first way might be more efficient, but it also might be a dead end. I've never tried it?
Any thoughts? What would you do?
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
This is after a rather large dinner with wine, so I hope it helps.
I don't understand the difference between the parse tree and the AST. I only have one tree, but maybe that's because I'm only doing C++ whereas you're converting one language to another.
Once I have a subtree for something that is "executable" (e.g. an enum, typedef, data declaration or definition, function declaration or definition), I invoke a virtual EnterBlock function on its root, which is like invoking an interpreter. Each node invokes EnterBlock on its descendants, so it proceeds depth first. A QualName (a possibly qualified name) or DataSpec (a QualName tagged with pointers, references, and/or const) implements this by resolving its name based on the current scope. I hope this is what you mean by "getting the type information". It also causes stuff to be pushed onto the operand (types) and operator stacks.
Could this wait until all of the code is parsed? I don't see why not, and I don't see how it would be more or less efficient. In fact, name resolution can occur later if there are errors during the parsing or interpretation. If you run the >check tool on the code, one of the things it does (to clean up #include lists) is to ask each file for all of the things that it uses. Any nodes that have names but that weren't "interpreted" because an error caused them to be skipped will then try to resolve their names.
A human being should be able to change a diaper, plan an invasion, butcher a hog, navigate a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects! - Lazarus Long
If you ever reach MVP / MVE on CP, you'll know that Sean does indeed exist. And has the most deplorable taste in "clothes".
Mankinis are not a good look, and when he is standing there on your doorstep to deliver eth Certificate dressed only in a red mankini and a thin layer of oil, you do begin to wish he perhaps didn't. He is the reason why "Casual Friday" was banned in Toronto after just one week.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
And the place for those news is: The Insider News[^] just in case you want to thank him personally.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.