Reputation
59,349
Next tag badge:
187/100 score
18/20 answers
Badges
12 176 258
Newest
 Enlightened
Impact
~2.0m people reached

Jan
8
comment Circular dependencies: Recursive grammar parser (e.g. json)
@donquixote: If the exact grammar rules aren't known at compile time, you'd want to use a different parser generator. Something like OMeta, which is more complicated and slower than ANTLR, but highly dynamic and customizable. You can plug in new rules very easily with it. I don't know why you keep trying to come back around to this idea of "composing smaller parsers into larger ones" but it really sounds like a disaster waiting to happen! My advice is, just don't do it.
Jan
8
comment Circular dependencies: Recursive grammar parser (e.g. json)
@donquixote: It's a parser generator, a very good one. You write up some special source code in ANTLR format which describes the grammar of the language you're trying to parse, and feed it into ANTLR, and it generates a parser from that. The generated parser is pretty complicated and it's essentially a black box, (even though the entire thing is open-source,) but it's widely used and well-tested.
Jan
8
comment Circular dependencies: Recursive grammar parser (e.g. json)
@donquixote If the grammar is too complex to easily get right in a simple, hand-written RDP, my advice would be "use ANTLR", not "split it up into multiple parsers." The bigger and more complex a grammar is, the more likely it is to contain mutually-recursive grammatical elements like in this example, which means your problem never goes away.
Jan
8
answered Circular dependencies: Recursive grammar parser (e.g. json)
Jan
8
awarded  Guru
Jan
8
awarded  Good Answer
Jan
8
awarded  Nice Answer
Jan
7
awarded  Nice Answer
Jan
7
comment Given a herd of horses, how do I find the average horn length of all unicorns?
Of course, this assumes that the only difference between an ordinary horse and a unicorn is the horn. If this is not the case, then things get a lot more complicated very quickly.
Jan
7
comment Given a herd of horses, how do I find the average horn length of all unicorns?
Downvote removed after the update
Jan
7
answered Does this class design violate the single responsibility principle?
Jan
7
comment Given a herd of horses, how do I find the average horn length of all unicorns?
@DavidPacker: There is no Horse.HornLength property. The question simply raised the possibility of adding one, and the author pointed out that he's uncomfortable with the idea.
Jan
7
comment Given a herd of horses, how do I find the average horn length of all unicorns?
@ScottWhitlock: In the absence of real-world unicorns, who's to say that the unicorns in question are not, in fact, a magical sub-species of horse?
Jan
7
comment Given a herd of horses, how do I find the average horn length of all unicorns?
The scenario in question in no way violates the LSP. See "complete lack of understanding about the nature of inheritance or how it works," above.
Jan
7
comment Given a herd of horses, how do I find the average horn length of all unicorns?
-1 for gibberish that demonstrates a complete lack of understanding about the nature of inheritance or how it works.
Jan
7
comment Given a herd of horses, how do I find the average horn length of all unicorns?
Please forgive me if my lambda syntax isn't right; I'm not much of a C# coder and I can never keep arcane details like this straight. It should be clear what I mean, though.
Jan
7
comment Given a herd of horses, how do I find the average horn length of all unicorns?
@StephenP: That wouldn't work mathematically for this case; all those 0s would skew the average.
Jan
7
answered Given a herd of horses, how do I find the average horn length of all unicorns?
Jan
6
comment Should I avoid using unsigned int in C#?
"Seldom does a real-world numeric range correspond to a number between zero and 2^32-1." In my experience, if you're going to need a number larger than 2^31, you're very likely to end up also needing numbers larger than 2^32, so you might as well just move up to (signed) int64 at that point.
Jan
1
answered Are a class's methods a type of closure?