|
It seems you have an interest in the basics of parsers/compilers. There are of course hundreds of books written on the subject (if not thousands). Some of them hard, others simple to understand.
Maybe the book the link is to gives a very gentle introduction in its chapter 3 to parsing, lots of practical stuff, minimum of theory that might be helpful for you further developing your SLR and LL software. Reading it shall convince you that the "theory" behind SLR and LALR is
slightly different, but both are elegant.
Of course one may wonder why not address full LR (1), since - other than on a 64K PDP-11 oe requivalent - there are hardly limitations in tablesize.
http://hjemmesider.diku.dk/~torbenm/Basics/basics_lulu2.pdf[^]
There are others as well of course.
Note however that while 30 to 40 years ago compiler writing was a "hot" topic for lots of people working in the field of CS, it is now a subject for a handful of specialists. Front end aspects of compilers are (reasonably) well understood, the real hot topics now are in optimization/code generation for a myriad of target architectures. Just look at the main topics in the development of the GNU compiler suite of the Clan folks: it is all optimization and code analysis.
For analysis and code generation more advances matching techniques are needed than simple CFG's.
Few compilers nowadays are simple "single person" projects, due to all the phases in the mapping parts from a parse tree to an architecture, compilers tend to be large. Note the difference with e.g. a Pascal compiler in the 70-ties, just a few thousand lines of Pascal code. But then,
there compilers were basically front end handlers for a simple language (and of course
using a handwritten recursive descent parser). Languages like e.g. C++ - and to a lesser extent C,
are hard to model using LR techniques, due to the interconnection between the meaning of the symbols and the syntax. So, in general front ends for such languages are using: yes, again hard crafted recursive descent techniques.
Whether you like it or not, do not expect many people to be interested in how a basic toolset is being developed, either in C#, assembler C Lisp of whatever language.
That being said. Be aware that there is an enormous amount of readable compiler literature, also lots of free books on the internet. I think you should be encouraged to continue development of a toolset, since although theoretically well understood, having the idea of understanding some theory does not always implies having the capabilities of creating a clean implementation.
And even if - in the CP community - there would be no interest in the subject, in my - humble - opinion it is a worthwhile exercise that at least would be read and studied by me.
|
|
|
|
|
Thanks for your input. I think on balance, you've given me a lot to think about, but also if only one person is interested or gains insight from something I write, it's still worth it. It's a labor of love. I love writing, and I love writing code. =)
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.
|
|
|
|
|
With the trend today of txt speak and the appalling grammar used by some (quite a few) so called citizen journalists I would have thought a grammar parser an impossible task.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
haha, well i'm not ambitious enough to try to process natural language. =) I'll leave that to my betters.
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.
|
|
|
|
|
Because I haven't had a single one since yesterday - over 20 hours ago - and that' very unusual.
I didn't get anything from Codewitch in the stop smoking thread below for example.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Same here - nothing!
|
|
|
|
|
I've stuck it up on S&B, but it's nice to know I'm not the only one!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Quote: it's nice to know I'm not the only one
Yes! I thought I had committed some sin!
|
|
|
|
|
And ... I got an email for that one, but not the one before!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Weird man!
|
|
|
|
|
|
Yep: looks like I woke the hamsters by posting in S&B.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OK, my emails started getting through as well. Maybe the hamsters slept in late this Sunday?
|
|
|
|
|
i am
Edit: never mind, I no longer am
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.
modified 24-Nov-19 9:17am.
|
|
|
|
|
I got emails on my 'Rings a bell' post. That was avout 22 hours before... Also got from Sander about his exam abou 6 hours ago...
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
Same here Paul
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
..written a heavily commented, factored chunk of code that does some important, complicated task, and no matter how you structure or document it, it doesn't make sense to anyone but the computer?
not even you?
I've done that at least once this year, with LALR(1) parsing and it looks like I'll probably be doing it again (but with fa->regex conversion) within the next week or 3 depending on how long this takes.
I hate it, but that's what I get for punching above my weight class.
Sometimes code only works through sheer force of will.
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.
|
|
|
|
|
|
Sander Rossel wrote: I've written code that didn't make sense to anyone INCLUDING the computer!
That's where I'm currently at
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.
|
|
|
|
|
I only write nicely written, formatted and readable code. For my future self, when looking for some strange bugs
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Some code is based around algorithms that themselves are very messy.
For example, generating LALR(1) parse tables: LALR(1) Parsing[^]
Or doing DFA the state removal algorithm (easy to visualize, hard to code): regex - State Elimination DFA to Regular Expression - Stack Overflow[^]
It's the algorithms themselves that are the problem.
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.
|
|
|
|
|
I'm quitting smoking. Idle hands being what they are I need to stay busy with stuff, and so that means CP contributions.
I've recently built a relatively in depth tutorial on building a feature rich regex engine.
Now I'm going to do one on building a full featured tokenizer with it.
And then the same for a parser - LL(1)
And then *maybe* a second parser round covering LALR(1)
Covering more than the basics, since I've already covered those here before.
PCK, my Parser Construction Kit[^] is built, but basically, building it again, with partitioned heavily commented code, and an article explaining it.
That's much harder and more time consuming but hopefully it will get some interest here.
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.
|
|
|
|
|
Good for you! Hope it goes well.
Are you "going cold turkey", patches, tablets, or gum?
I did it 15 years ago with the patches (via an NHS stop-smoking service) and it wasn't easy but was worth it. One suggestion from the service I used was to put cash in a jar: if you smoke 20 a day, put the cost of a pack in there every day. At the end of the first month, spend the money on a treat for yourself and only yourself. It's surprising how fast it builds up! Keep stuffing cash in there, and after six months, buy yourself an even bigger treat - with a pack averaging around £10 each in the UK, that's a significant bonus to look forward to, and it can help focus you on the long term / medium term advantages of giving up.
Another was to change where you go: break away from the locations where you have a habit of smoking. So if you goto a particular pub and smoke there, go to a different pub. If you smoke at your desk, move your computer to a different room. Stopping the "association" with smoking can really heklp reduce the craving.
Let us know how it's going - I'm sure all us ex-smokers here will support and encourage you to get through this.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks. I'm trying the inhaler device because the patches give me a rash and chantix isn't for crazies like me.
I never could stand the gum.
I quit for 5 years at one point, so I know it's doable for me. It's just not easy. I'm kicking myself for starting up again, but I had moved a smoker in with me, and that was too much being around that all day.
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.
|
|
|
|
|
That sounds exactly the same as I went through many years ago. I finally quit one day when my heart and mind agreed, "no more".
|
|
|
|