|
Coffee.
And then more coffee as a chaser.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
big same, neighbor
a programmer is a machine for converting coffee into software
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.
|
|
|
|
|
codewitch honey crisis wrote: Do you get weird code related food cravings? Coffee and nicotine, in bulk. The first place where I worked featured not only great coffee, but also an ash-tray next to the keyboard.
Trying to be healthier by eating more pizza; it is part of the Mediterranean diet. Consider it freshly baked bread with lots of fruits, veggies, and cheese
Pizza, coffee, a smoke. Makes the Neanderthal in me very happy
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Sounds familiar. I even switched to a vape so i could stop going outside all the time (i won't smoke tobacco in doors - it makes stuff stink)
coffee and nicotine with my sashimi please.
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.
|
|
|
|
|
As a person who used to work across from someone who would vape at his desk all the time, vaping makes stuff stink too. Not quite as permanently as tobacco but still annoying.
Of course if you work remotely that isn't so much of a problem.
|
|
|
|
|
Stop complaining about the smell, and start talking fire-hazard
A few years ago, you'd see these half-moons on a toilet-flush-thingy where a smoke used to "wait" for its owner to finish the job. If you smoke, you buy a cheap cherry-keyboard twice a year.
And ash is like cement; it gets into your computer, it gets wet, it hardens. Not good for the fan that cools the CPU.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
No ash or tar from vaping. Water vapor, scent, and whatever other chemicals are present in the solution, which usually means nicotine among other stuff. The guy is no longer here but yeah, annoying to say the least.
|
|
|
|
|
I'm a smoker, and will not "vape", whatever that means. My lungs, my choice. No halfway sissy-solution like dragging watervapor.
If you want to hire me, you have to accept me standing outside without prior notice. That may be after a meeting, after a coding session, or after coffee. But yes, I will smoke, and yes, when I please.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I was the same way back when I smoked tobacco.
The vape thing was more of a convenience thing for me. I can stealth smoke wherever the hell i want now too even though you can't smoke indoors legally pretty much anywhere in the state except your home and private clubs.
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 work very remotely. i'm out of the field. i did my time. now it gets to be a hobby again and I can do what I *love* again. Eventually working in the field sucked the joy out of coding from me.
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.
|
|
|
|
|
codewitch honey crisis wrote: i did my time. I wasn't aware of the fact that you went to prison.
codewitch honey crisis wrote: now it gets to be a hobby again and I can do what I *love* again Eat pizza?
codewitch honey crisis wrote: Eventually working in the field sucked the joy out of coding from me. Write an article. You're not the first, and some might learn actually.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: I wasn't aware of the fact that you went to prison.
Microsoft. Same difference.
Eddy Vluggen wrote: Eat Pizza?
That too. But Microsoft had beer and pizza fridays. Although I thought that was supposed to be every day.
Eddy Vluggen wrote: Write an article. You're not the first, and some might learn actually.
I've written a few. Probably most notably A Regular Expression Engine in C#
In fact I'm about to follow it up with a more ambitious one that uses this project as a lexer for LALR and LL(1) parsers that it (the next submission) can generate.
Adding, writing parser generators is difficult. The math involved was beyond me, until it finally wasn't.
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.
|
|
|
|
|
codewitch honey crisis wrote:
I've written a few. Probably most notably A Regular Expression Engine in C# On my todo list.
codewitch honey crisis wrote: Adding, writing parser generators is difficult. The math involved was beyond me, until it finally wasn't. Implies you can explain it to a simpleton like me, no?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I can, but it's involved. You have to do it in steps, and it depends on what kind of parser you're generating.
The main thing though, after you understand the fundamentals, is generating "first" and "follows" sets which are basically what they sound like - they tell you the first symbol from a production, and they tell you what can follow a production**
** vocab will take a minute. How much time you have?
I first have to start by explaining what a Context-Free Grammar is and how the data for one is laid out.
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.
|
|
|
|
|
codewitch honey crisis wrote: vocab will take a minute. How much time you have? I make time for anyone who can teach me.
Consider time yours.
codewitch honey crisis wrote: I first have to start by explaining what a Context-Free Grammar is and how the data for one is laid out. Yup, all blank on that subject.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Okay, so parsers work generally using a method called substitution.
I'll show you. A context free grammar is a mathematical entity. It is a type-2 language on the Chomsky scale (if your ever interested in what all that means - yours to google later, but it's not necessary here)
so here's a CFG - it's a series of rules. And a start symbol. I'll explain.
A rule takes the form of (example)
binop → num + num
- in this case marking a binary expression as "num + num" (two numbers with a + inbetween them - num is defined elsewhere as a regular expression matching a series of digits)
follow so far?
obviously that doesn't represent much of a binary expression. We need to do more than add!
let's define more rules
binop → num - num
binop → num * num
binop → num / num
that's more like it!. Now you may notice that there's the same left hand side on each of those.
A group of rules with all the same left hand side are called collectively a "non-terminal"
here, binop is a nonterminal. num is not but we'll get into that
Nonterminals can have rules that can reference terminals or other non-terminals, and even themselves recursively
A CFG tells us what the rules are, and just as importantly, which non-terminal to start at (here it would obv be binop since we haven't) declared any others.
Follow so far?
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 7-May-19 16:06pm.
|
|
|
|
|
codewitch honey crisis wrote: Follow so far? Kind of. When talking parsers, I think of a "simple" interpreter-pattern.
How would you enforce the rules you declare?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
The parser does that during the parse process. It's pretty straightforward. Basically consider an LL1 parse table as a table of dictionaries nested in another dictionary. If you can't index into each dictionary successfully based on the current stack and state then it's a parse error. We'll be generating that table from the CFG (context free grammar)
in terms of building the table, i usually validate the grammar before i begin with a Validate method.
i'll keep going as far as explaining in a separate reply but i just woke up and i need some coffee
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.
|
|
|
|
|
alright, after reading my other reply, and asking any other questions you have, let's continue:
recall our grammar
binop → num + num
| num - num
| num * num
| num / num
We won't be using this one. There's no operator precedence in it. and no parenthesis
Expr = Expr '[\+\-]' Term | Term
Term = Term '[/\*] Factor | Factor
Factor = '\(' Expr '\)' | int
int = '[0-9]+'
Woah. This is more practical but
a) it's not a straight CFG
b) it looks messy and confusing
Let's take care of that.
First, all the single quoted strings are regular expressions
those are our "terminals" - they represent the leaves of the parse tree will be parsing.
CFGs care about terminals, but NOT their definitions.
Let's rewrite this to be purely a CFG - we'll separate the terminal definitions out and leave them aside:
Expr = Expr add Term | Term
Term = Term mul Factor | Factor
Factor = lparen Expr rparen | int
There we go. All the terminals are lowercase, and the non-terminals are title case (not required, just a convention we'll use here). The definitions of the terminals are gone, replaced by labels.
How can a CFG tell what's a terminal and a nonterminal just from this? simple - a non-terminal is anything that appears on the left hand side
Anyway, next we will break out this | (or) expressions into separate rules
Expr → Expr add Term
Expr → Term
Term → Term mul Factor
Term → Factor
Factor → lparen Expr rparen
Factor → int
This is how a CFG likes it. Whew. One more major step, and it's a little involved.
The last issue here is that this is left recursive. The rules reference their left non-terminal on the leftmost part of the right hand side. Some parser algorithms (the LR family is an example) can handle this but an LL can't - it would loop infinitely.
So now we have to refactor this CFG. It can be done programmatically. (My code does this)
Let's take a look at the first two rules
Expr → Expr add Term
Expr → Term
For each rule where the non-terminal on the left (Expr) of the arrow is the same as the left-side of a production on the right-hand side of the arrow (Expr add Term), we take the part of the rule without the recursive bit (which leaves us with "add Term") and move it down into its own new rule (we'll call it Expr').
Expr' → add Term
Now, after each of the new productions, add Expr' to the end.
Expr' → add Term Expr'
Still not done. Now add an extra rule with an ε (epsilon) which just means an "empty string" - matches without consuming or examining input.
Expr' → ε
Good. Now we must fix up the original Expr rules. Here, we take all of the right-hand sides that didn't start with Expr, and add Expr' to the end of them.
Expr → Term Expr'
If we do this for the Term productions as well, we get the following grammar:
Expr → Term Expr'
Expr' → add Term Expr'
Expr' → ε
Term → Factor Term'
Term' → mul Factor Term'
Term' → ε
Factor → lparen Expr rparen
Factor → int
TADA!, and we're done so far. I'll take this opportunity to stop and wait if you have questions.
I've covered a lot here so far. Some of this was ripped from this wonderful LL(1) tutorial
So once you respond and check in, we'll keep going.
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.
|
|
|
|
|
codewitch honey crisis wrote: TADA!, and we're done so far. I'll take this opportunity to stop and wait if you have questions. No questions, but I'll have to read this again tomorrow.
It's quite the chunk of information, and I'm currently a bit.. slow
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
cool. just reply after you've had a chance to digest it tomorrow or whenever. =)
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 read it three times now, and get the feeling this is a very short introduction. Did I read it correct that you are writing a longer article on the subject?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I'll be submitting some code, along with an introduction to the subject. I'm not sure how much ground I will cover there though. This stuff, even LL(1) parsing, is involved. LL(1) parsing isn't even that complicated - it's just involved.
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.
|
|
|
|
|
codewitch honey crisis wrote: I'll be submitting some code, along with an introduction to the subject. I'm not sure how much ground I will cover there though. Intro is enough; it doesn't have to be a complete book on the subject
If that's read often, you'll get enough requests for a followup and part 2
codewitch honey crisis wrote: This stuff, even LL(1) parsing, is involved. LL(1) parsing isn't even that complicated - it's just involved. That goes even for a blockchain, but that doesn't mean that everyone has one. Once you know how stuff works, it becomes obvious.
Currently learning to live without painkillers, so my attention-span is rather limited. There's a lot more people looking at the article-submission queue, so you'll have a good test-audience (and hidden peer-comments) before going live with the article.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Not really an intro to the topic, but some code, and an explanation of the algorithm I used to increase the parser's expressive power.
Newt: A Powerful C# Parser Generator in a Small Package[^]
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.
|
|
|
|
|