|
The parallax is hiding it, so you must be holding it wrong.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Question for iPhone users, why?
|
|
|
|
|
Greg Utas in particular, you may find this of interest. Sorry I forgot how to tag. Someone explained it once.
To recap, Slang is a subset of C# that is CodeDOM compliant. It's maybe 60-70% of the language.
So I originally was parsing Slang by hand.
I wrote the Parsley parser generator so I could write a grammar and generate a parser to parse Slang that way instead.
My generated parser was 939k vs about 100k for my initial hand rolled parser, and was about twice as slow, and took at least twice as much memory to execute, by my back of the napkin estimations. Still, it was fine for this scenario.
The trouble is, and Greg, as per our earlier exchanges, you may want to know this - the out of band "preprocessor directives" and comments - skipping them entirely is easy, but conditionally ignoring them is much more challenging for the generated parser.
In the end, I couldn't make the generated parser handle it. I tried skip lists and it didn't work, as it was eating trailings - I'm going to write an article that covers this in detail. Greg I think it's not feasible. You need an explicit preproc step.
In the end I decided to go back to a hand written parsing method, but I still had the problem of maintenance and intelligibility.
Well, fortunately, I have this generated parser with a grammar that goes with it. So I added a /noparser option to Parsley which goes through all the steps of processing the grammar, and generating any associated lexers and constants, but skips the actual parser generation.
Now I'm coding by hand, but to the grammar I made before which makes it much easier to understand where i am and what I'm doing.
I'm testing my parser *against the generated parser* woo! which really helps.
And so there it is. I've mitigated some of my hand rolled headaches by generating a parser even though I won't use that parser in production.
And I think Parsley won me a prize here so it isn't a failure scenario at all.
Greg, you might want to consider this approach in building your parsers, as having your grammar in front of you in a BNF variant form plus making that available as documentation can really help both you and whomever uses your parser.
Plus definitely using a lexer would cut your effort and make your error handling more robust, i pretty much guarantee you - that's why almost everyone does it.
Anyway, yay Parsley, even though I didn't use it for production code.
hack everything.
|
|
|
|
|
I was about to pack it in for the night when I saw this. I don't know how to alert someone on these boards either, so that makes two of us.
Much like you do with C#, I parse the subset of C++ that I use. I don't know much about C#, but are you actually saying that a new language kept this preprocessor excrement? The first thing that comes to mind is Monty Python and finding a dull spoon to geld those who were responsible.
My problem is twofold. First, I don't know where to get the BNF for C++. I'm sure it exists, but it must be worse than a dog's breakfast. Second, I "interpret" the code after parsing it. It's the only way to support some of the "Scott Myers code inspection" capabilities. So if I went with a generated parser, I'd have to modify generated code to support the interpreter phase. From the bloat that you've described, I'll pass.
With regard to the preprocessor, I support some things in my single-pass compiler, and a few other things should be added. But it's exactly as you say: to support all of it, a true preprocessor phase is needed. But I have no intention of supporting all of it. If someone else is willing, great. But there are some things that I find repugnant and won't countenance: stringification (# ), concatenation (## ), function macros, and code fragment aliases. If someone wants to use the tool but their code contains these things, they'd have to rework them, and I'd be doing the world a favor. Another one is #undef , which is tricky when all the code is compiled together, without any notion of "translation units". It could probably be supported, but would it be worth it?
Another reason I don't want a preprocessing phase is that I have an editor that can interactively fix about half of those Scott Myers recommendations. With a preprocessor phase, you get two versions of the code. There's probably a way to deal with this, but my initial reaction is, "Will the real source code please stand up!"
I wonder if a generated lexer would help. Mine isn't very large and was repeatedly refactored to keep the parser code tight. The debug version of my "compiler" is about the same speed as MSFT's real compiler, so I'm not losing sleep. Of course, it's not a true apples-to-apples comparison, but it does what it needs to do.
|
|
|
|
|
Greg Utas wrote: ut it's exactly as you say: to support all of it, a true preprocessor phase is needed. But I have no intention of supporting all of it. If someone else is willing, great.
That's exactly my situation. I needed to support some of it.
C# is light on preprocessor stuff at least. There's only a few directives, and one of them merely provides source code formatting (you can collapse #region/#endregion blocks in the source editor)
I'm not suggesting you go the preprocessor route so much as warning about picking up comments in a generated parser if you do not.
I agree with you in your situation about the generated parser. The thing is, I didn't end up using one either in the end. But I *am* using a generated lexer, which keeps my parser code simpler.
I am suggesting that creating some BNF for your C++ subset might not be such a bad thing.
Unlike C#, there's a ton of grammars online for C++ Comp 11 C++ Grammar[^]
hack everything.
|
|
|
|
|
honey the codewitch wrote: whomever uses your parser My Markely parser rejects this as unknown syntax.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
*files a bug*
Steve Wozniak is the only thing at Apple that isn't evil.
|
|
|
|
|
honey the codewitch wrote: Sorry I forgot how to tag. Someone explained it once.
Prefix the account name with an atsign: '@'
You can get the account name from the user home page, or from the avatar hover popup.
For example: @code-witch
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
oh is that all? cool thanks
hack everything.
|
|
|
|
|
thanks
|
|
|
|
|
Legendary golf course architect Pete Dye passed away Thursday, Jan 9 at 94.
modified 11-Jan-20 14:00pm.
|
|
|
|
|
don't know who he is, but he's off on the eternal 19th hole
I'd rather be phishing!
|
|
|
|
|
Administer a soft layer (5)
|
|
|
|
|
Administer
a A
soft P (from music notation, "Piano" or "P" == "Softly")
layer PLY
APPLY
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
yep
|
|
|
|
|
When did you last hear from me? The day before christmas? Well, that's because I almost completely loast my eyesight over the holidays. One eye completely useless,the other down to the bare minimum, just enough to vaguely see where I am going. The doctors in the hospital very quickly gave me appointments for a little eye surgery, one appointment two days ago and another for the other eyw next week.
Now I can atleast see something one one eye and even watch tv or type something on the computer again, Maybe this is the right time for a glass of strong alcohol now. I don't have any Rum, even if I look like a pirate right now...
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Holy cr@p! What happened?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
A blood vessel hat burst in each eye and the fluid in the eyes got murky with additional splats of blood floating around. As a bonus they also corrected my lens while they were at it.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Blood vessels burst in both eyes at the same time?
I hope they checked your blood pressure at the same time, or at least have a reason for it occurring. That's not something you want to happen again (or even once, if I'm honest).
Here's hoping you make a full recovery quickly, and to say you'll be in our thoughts until you are back to normal.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
The blood pressure seems to be ok. It's more likely that the blood vessels already got weakened during what happened a year before.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
That happened a few years ago to my son, caused by long term type 1 diabetes. Do you suffer from the same condition? Either way, I hope you recover soon.
|
|
|
|
|
Not directly. The last five years were quite tough and I still feel more than a little stressed. A year ago my immune system failed and a small infection very quickly became a huge infection. They had to operate five times in six days to get everything out and during that time everything including blood sugar was through the roof. It's very likely that the eye problem began then. The good news are that I now don't need any medication anymore and I have minimal body fat left. Just a little training and I can pose for statues of greek gods again.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
If not as a Greek god, then maybe you can pose as a Cyclope
Best wishes!
|
|
|
|
|
That is the sort of challenge that few of us could even begin to understand. I wish you the best of luck for the future.
|
|
|
|
|
Sorry to hear that, man.
Accident or disease?
|
|
|
|
|