|
I liked it
"Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
OK, I'll take it ...
Determined
place STEAD
to not eat FAST
STEADFAST
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
YAUM
"Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
The way it works is it takes a series of tokens/lexemes from an input stream and uses pattern matching to discern whether they match various rules like:
Foobar -> "foo" "bar"
Such that when it sees "foo" followed by "bar" in the input stream it knows the result is a Foobar
The upside of this is it's got a whole lot more recognizing power than starting from the point of Foobar and then checking the input stream for "foo" followed by "bar" (basically the reverse of the aforementioned process)
The downside is it means the tree is built from leaves to the root, meaning bottom up, meaning your recursive tree building is effectively "inside out", building the children first.
That's not normally a problem but it has some important ramifications, like if there's an error token in the tree it can't readily resolve the rest of the tree once encountered.
The other issue is it's more confusing from the standpoint of the end user of the parser. Sure once it's in the tree, it's all the same, but if you're using a pull parser rather than loading everything into an in memory tree, the pull parser for a bottom up parser is just weird to use.
And then the primary issue I have with them is that the algorithms to construct the parse tables are incomprehensible. I've written them before and I still hesitate to say I understand them. I have code that does it that I won't touch because of it. It's not the fault of the code - it's the algorithm that's ugly. The math is atrocious - it feels as though designed while drunk except that it's so bloody clever - too clever to understand by mere mortals.
I don't like it. Unfortunately it's a very practical way to parse, so it can't really be overlooked.
Real programmers use butterflies
|
|
|
|
|
That's why this[^] uses a recursive descent parser. It's not as efficient as bottom-up, but it's decent enough if the possibilities are tried in probabilistic order, especially in this day and age of code that uses CPU time and memory frivolously. The code is the grammar and is usually easy to fix when a bug is found. No need to get the grammar close to right from the outset, and no need for an inscrutable algorithm to generate parse tables. Skipping over errors can still be difficult, but it depends where they occur.
|
|
|
|
|
You get most of those same advantages using LL(1).
Besides, if your grammar language is easy enough, grammars aren't so bad.
Here's one for JSON:
Json<start>= Object | Array;
Object= "{" [ Field { "," Field } ] "}";
Field= String ":" Value;
Array= "[" [ Value { "," Value } ] "]";
Value<collapsed>= String |
Number |
Object |
Array |
Boolean |
Null ;
Number= '\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee][\+\-]?[0-9]+)?';
String = '"([^\0-\x1F"\\]|\\([\\/bfnrt]|u[a-fA-F0-9]{4}))*"';
Boolean = 'true|false';
Null="null";
Lbracket<collapsed>="[";
Rbracket<collapsed>="]";
Lbrace<collapsed>="{";
Rbrace<collapsed>="}";
Colon<collapsed>=":";
Comma<collapsed>=",";
Whitespace<hidden>='[ \t\r\n\f\v]+';
See? no thing. All the attributes in there are just to prune the parse tree. "collapsed" removes items from the parse tree once they are parsed so you don't have to deal with them in your code.
Real programmers use butterflies
|
|
|
|
|
I'd never seen a JSON grammar, so thanks for that.
But the one I'm dealing with is C++, which is surely a dog's breakfast.
|
|
|
|
|
Yeah, for C++ for a number of reasons it's best to use a hand written parser.
Real programmers use butterflies
|
|
|
|
|
|
That one is definitely going on my to watch list.
// TODO: Insert something here Top ten reasons why I'm lazy
1.
|
|
|
|
|
Oh my, I had no idea they made a live-action adaptation of that anime
|
|
|
|
|
If you like it, you might like the short films of "Dust" (there are a lot of them)
M.D.V.
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.
|
|
|
|
|
It appears that the .NET 5 Windows Forms library contains a Task Dialog component.
Here's the Docs[^]
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
The Win32 libraries have had it for years.
|
|
|
|
|
|
Officer: The victims were dismembered and sacrificed on an altar made of antlers.
Detective: Dear God
Officer: Most likely yes.
The less you need, the more you have.
Even a blind squirrel gets a nut...occasionally.
JaxCoder.com
|
|
|
|
|
|
Deerly yes
modified 12-Nov-21 2:53am.
|
|
|
|
|
|
Nice pun, it's worth a buck.
GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
I don't have that much Doe on me!
Sometimes things ARE as bad as they seem.
|
|
|
|
|
I think the answer lies in this TextMate mess but everything I've found is incomprehensible or incomplete.
Preferably I'd like it to also work with VS Code. I think the TextMate stuff does but I'm not sure as I don't know where to begin, with even finding a good place to read and start with it.
This is a Visual Studio and VS Code question and I have no good place to put it.
Real programmers use butterflies
|
|
|
|
|
|
It's fine, but I want it to support my own file formats, namely XBNF and RL
I'm looking primarily to target VS rather than VS Code at first, and then take advantage of any overlap but I'll check that out. Thanks.
Real programmers use butterflies
|
|
|
|
|
For your own file formats you could write a small external tool and add it to VS with the external tools manager.
I have a log analyser where I load the plain text to a rich text box.
For each wanted color I have a list with keywords.
A simple function formats the content of the rich text box.
Then after formatting the text it shows the desired result.
|
|
|
|