|
Yep. Basically all C family languages do. It's part of the spec. Getting the parser to do it though?
With an LR parser all you do is override a shift reduce conflict.
With LL it's a bit more difficult. I ended up writing the parse for it by hand. I'm sure I didn't have to, but i didn't want to spend the extra time figuring out the )%)@$$ grammar constructs i could get it to actually eat
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 actually can't think of any language that doesn't.
Python doesn't count.
|
|
|
|
|
Visual basic effectively disallows it because of the end if syntax (i think. i don't touch VB)
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.
|
|
|
|
|
Which is correct according to the documentation.
|
|
|
|
|
So now with Parsley parsers can call other parsers. You can import several grammars and delegate different parts of parse to them, like a compositional/composing parser would.
But unlike a compositional setup, it doesn't force you to use it, meaning that rather than forcing you to define your entire grammar like legos, you can just factor where you need to.
For example, I have slang's parsing broken up into expressions, statements, members/typedecls, and namespace/compile units.
This is awesome. For starters it allows you to use it such that you can parse individual statements and expressions as well as whole compile inits.
Second, and perhaps most importantly, this allows you to break your parse up into several different "parse tables"
This means that rules from expressions will not interfere or conflict with rules from statements, nor members and such.
This is super important for LL(1) parsing where it's easy to run into conflicts as soon as things get at all non-trivial.
I'm excited about this. I'm not sure if it's a totally new idea or not but I've never seen a parser generator that could do this.
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.
|
|
|
|
|
Another article methinks for us mere mortals
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
I'm a bit of a ways from that. bugs and such
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.
|
|
|
|
|
OK, I just really want to understand the reason you write this sort of code ( my lack of comprehension kicks in here )
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
I wrote this to parse slang because my hand written parser was too buggy and took too much work to maintain.
It's obviously not limited to that, but there it is.
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.
|
|
|
|
|
Are you doing all of this for a job?
Or do you have a research grant?
Or is this what you're doing for a hobby, and your day job is even more complicated?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Upvoted as Question of the Month.
I think we can rule out (a) because I wonder if there's an outfit on the face of the planet that would fund something like this. It could be skunkworks on the part of an enlightened lower-level manager, hidden from overseers. But then it would also be unlikely to be yapped about on this site, for various reasons.
I think we can rule out (b) because few people in an academic setting do useful things at this scale. It looks like a serious effort, not some toy experiment.
I think the answer is (c), part one. There isn't time for this and a day job short of taking lots of backlogged vacation.
|
|
|
|
|
This is what i do because I am too mad to work in software anymore.
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.
|
|
|
|
|
Surely there's a great backstory to this, so please vent about your experiences working in software. You don't have to name names when describing idiocy. Please note the "Rant" button that the site designers so thoughtfully provided.
I thought this[^] was a really good post, so I added a couple of things to it. It sounds like you could too.
|
|
|
|
|
There's not much to tell. I went crazy in 2016. Schizoaffective.
That's not really an easy one to live with. My executive functioning is shot, I'm paranoid of other people, and agoraphobic as a result.
Consequently, I can't work much at all anymore - though i do some - much less in software, but I've been coding since i was 8, so i still do it, despite my short term memory issues which can make it challenging.
That's a long way of saying i'm a mental case shutin who knows C++ and C#.
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.
|
|
|
|
|
Wow, that's not what I was expecting. It's great that you can joke about it. I hope you recover, but it seems like you'll produce things of greater value while not working in software.
|
|
|
|
|
Yeah probably. Otherwise i'd get stuck doing bizdev for some website backend
There is no cure for my condition, but I have a very supportive and patient spouse, so i'm fortunate in that.
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 just do it for love.
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.
|
|
|
|
|
: Continues to bang head against some bad HTML... :
|
|
|
|
|
This leads to some interesting thoughts.
This enables a kind of language extension capability, or even a level of language integration.
Think of something like LINQ, an extension to C# that added the Query capability and the syntactic sugar to make it easy to read/write. Imagine being able to integrate your own libraries to C# in the same way.
We also see something similar happening in the Web space, where a single source file contains CSS, Javascript and HTML to make a component. This is a parsing strategy that allows this level of plugin-ness at a source level.
In this space, the transition between languages is indicated through tags whereas in the LINQ example it is instead integrated into the grammar definition of C# explicitly.
Interesting to see where this goes. (As someone who wrestles too often with Python Pandas and it's lack of expressive integrated syntactic sugar to avoid writing function calls for everything)
|
|
|
|
|
Yay someone grokked it!
The only trick is making sure your subparser knows when to terminate its expression. It's easy to do once you get used to it.
It's also a lot less complicated for me to develop than an LL(k) parser generator, so there's that.
I have to believe someone has thought of this before. Or if they haven't, it's only because next to nobody writes parser generators that generate *recursive descent* parsing 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.
|
|
|
|
|
I am not sure I understand what a subparser is other then a recognizer for the input string derived from a given non-terminal?
Do you then mean generated - either table driven or recursive descent - parsers for these non-terminals
If that is the case then can you elaborate on the foreseen difficulties in finding the proper place to terminate recognition of a subparse? Is it more that handing over the followset to
the subparser?
Anyway, app 45 years ago we had some compiler stuff (in and for some long forgotten languages) where a syntax directed - hand written - parser called from time to time an LALR based table driven parser to recognize expressions and I do not recall any (serious) problem (but then, that is a long time ago).
Why is it that we do not see you on a compiler forum (comp. compilers moderated by John Levine).
It seems to me that from such a forum you (can) get more feedback than here and you have the
chance to elaborate on you work, and we get a chance to follow what you are actually doing
|
|
|
|
|
A subparser is exactly what you said. The only thing that makes it special is nothing. It's just a parser. But the other parser knows how to call it. That's important, because the other parser delegates to it.
They share the same lexer and symbol table but different parse tables.
And yes, effectively, all a follows does as i'm meaning it here is augment the follows set (in this case for the start production) - this is so the master parser can use the subparser during its own parse. So the follows set addition is so you can stop the subordinate parse when you need to, such as terminating a type declaration on a trailing } so it can appear inside a namespace
As far as why i'm not on usenet i dunno. maybe i should be
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.
|
|
|
|
|
Hey, she's our witch.
We want to keep her.
|
|
|
|
|
It used to be, I had to download a few DLL's, maybe a sys or an ini, inf or a vxd, dump them somewhere, and install like that.
Boom, my nvidia card works.
Now my drivers try to sell me games while I install them.
Please can i subscribe to your service? jerks.
I will not buy things that are forced upon me. I don't game anyway much (except for fallout) so they probably don't care, but whatever.
/annoyed
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.
|
|
|
|
|
Quote: I will not buy things that are forced upon me.
That's a tautology.
Buy => freedom of choice (consumer)
Forced => can't say no (e.g. protection money, taxes--but I repeat myself)
|
|
|
|