|
So distinguishing between a cast expression and a standard parenthesized subexpression in C# requires backtracking!
I whipped up a backtracking IEnumerator<T> class, ironed out the kinks with that, and then stuck that under my input to incorporate backtracking it into my parse. Whammo, now it can handle these stupid expressions, and any future backtracking requirements that crop up.
I now have a backtracking hand rolled recursive descent parser a lot like what C# uses (aside from the research compiler that was GLR based)
C#'s language structure looks deceptively clean. There's a reason it requires very modern parser and compiler technology to operate though. The grammar itself is very ambiguous. It doesn't seem like it is. It's not Perl after all, but it is actually pretty damned hard to parse without type information.
I'm using a similar approach that Microsoft's GLR C# research parser project took, and basically coding in possible alternate structures so when i parse, the parse tree i get back can reflect all of those multiple different possible constructs, but my mechanism is more hard coded and rudimentary than theirs was. Fortunately there's a limited number of cases where this has to happen.
Either way, I'm proud of what I've managed to pull off so far. This is turning out to be pretty cool.
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.
|
|
|
|
|
Sounds like article time to me
"We can't stop here - this is bat country" - Hunter S Thompson - RIP
|
|
|
|
|
Maybe by christmas
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.
|
|
|
|
|
Parse about the codedom go
Make the types in shadow show
All the ways in which they know
When witch will be and gone they go.
Double, double toil and trouble;
Fire burn and cauldron bubble...
|
|
|
|
|
That sounds about right.
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.
|
|
|
|
|
Tim Deveaux wrote: Double, double toil and trouble;
VB burn and sorting bubble...
FTFY!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I used to create some graphics to my kids for birthday parties and special blessings and such...
I look for some free stuff, use it to build my own, and credit the source, which actually makes it look more professional like...
Yesterday did the same for sime upcoming Hanukka pary, but Google returned only payed sites in the result. I had to go to the 5th page to find something free...
Made me wonder...
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
Maybe, we need to rename the Google search algorithm as "Paid Page Rank", instead of just "Page Rank".
|
|
|
|
|
I think just "Rank" (as in stinks) sums it up much better
|
|
|
|
|
I guess you need to compare with DuckDuckGo.
The reason Google has stayed in business this long ids that they've manage fairly well so far to keep the ads non-intrusive. This might be nearing its end.
Remember Altavista? It was the leading search engine until DEC sold it, and the streamlined interface was no more.
|
|
|
|
|
Interesting - it brings totally different results for the same query... And the difference is between the free and the payed...
I may duck Google search...
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
So I use Is and Has differently on my property and field names, depending on what they do.
Is implies the state of something, whereas Has implies containing something.
I've even had to use both for the same item. On my FSM code I have IsAccepting and HasAccepting, the first indicates whether the state is accepting, the second indicates whether itself or any states it contains is accepting- basically if it has any accepting states. Heavily commented in that case, and is fortunately the only place I've ever had that happen.
But it leads me to weird things like "IsEnded" instead of "HasEnded"
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.
|
|
|
|
|
If a State object can be accepting when its IsAccepting property is true , I recommend renaming HasAccepting to HasAcceptingStates .
#readability
/ravi
|
|
|
|
|
I considered that too. It conflicted with another method that operates on a collection of otherwise potentially unrelated states, but then I ended up renaming it later to HasAnyAcceptingStates()
The api is kind of confusing because of the self-repeating, fractally nature of state machines like this. There are all kinds of subtly different but highly related operations on them. Even shoring up the API and naming took me going back to it over the years, never 100% satisfied, but it's more or less frozen at this point.
And, given what I've seen of the other similar APIs out there (usually in Java), mine is far cleaner. They're all nasty. Mine at least reins in the crazy somewhat, but then I'm sure everyone thinks that about their own 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.
|
|
|
|
|
this is strange... and has some weirdness to it too!
|
|
|
|
|
IsNull or HasValue?
|
|
|
|
|
I'd prefer IsNull or IsEmpty (depending on what it was)
but actually for those things I typically sidestep it altogether with
bool TryGetValue(...,out T value)
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.
|
|
|
|
|
Use YodaNaming: "EndedItIs" and "EndedItHas" - that way masked nicely any confusion is.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
they would match my yoda conditionals like
if(null!=str) ...
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.
|
|
|
|
|
States
GetStates(State state) => IEnumerable<State>
GetAcceptingStates(State state) => IEnumerable<State>
GetNonAcceptingStates(State state) => IEnumerable<State>
GetStateStatus(State state) => enum
SetStateStatus(State state) => bool ? or error code ?
HasAcceptingStates(State state) => bool
IsStateAccepting(State state) => bool
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
That's very close to how it ended up.
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.
|
|
|
|
|
Is this simply confusion with IS_A and HAS_A ?
|
|
|
|
|
I WOULDN'T EVEN NAME MY CONSTANTS LIKE 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.
|
|
|
|
|
Those are concepts; not code.
|
|
|
|
|
I'm just messing with you.
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.
|
|
|
|