last day (15 days later) » 

8:19 PM
mb easier to just have a separate room
 
I'm keeping this for future use. I'm not sure how well I could convince them to allow me to rewrite the whole system.
Just letting you know.
 
given your description of the existing system, "It actually works" should be good enough.
 
No, see it works. Or atleast has been working for 5 and half months.
Then they started to introduce weird files. And my code has gone to shit.
 
weird how?
 
Windows CR+LF on linux.
 
8:22 PM
if they don't properly define the format what are you supposed to do, divine it?
oh
 
That's what started it all.
 
ok
 
And now as I'm continuing to figure out if I've fixed it, I'm just breaking everything now.
 
I think I can safely prove to you that my system can handle such things just fine
ahem, anyway
back to the original question
do you need to recognize integral and floating-point types separately?
 
@DeadMG Yea, probably. I have numpoints and xyz, so yea
Sorry, co-worker needed help.
 
8:32 PM
ok
numpoints and xyz?
 
int number of points
and double x y z values.
 
ok
 
Also, I am supposed to accept 1.0e-5
 
hmm
ok.
no problem
std::stringstream can recognize that, right?
 
Yep. Which is currently is.
 
8:36 PM
good stuff
so -?[0-9]+\.?[0-9]+ e-?[0-9]+
or in English
 
@DeadMG That looks reasonable.
 
(possibly a minus), some digits 0-9, and then possibly a dot and more digits 0-9, and then possibly an e (possibly a minus) and some more digits 0-9
you gotta recognize any hex/etc literals?
 
@DeadMG I'm decent with regex.
@DeadMG No. These are engineer people lol.
 
0xFFFF
ok
@Drise If you're decent with regex, you're decent with lexer. It's basically the same principle.
but can I leave you to recognize numbers? would rather start showing you parser code
 
@DeadMG I mean, I understand regex.
@DeadMG I'm not sure I'm following what ideone.com/OWM3J is doing... Hold on.
 
8:42 PM
ok
want me to guide you through it?
 
Ok, hold on. Let me see.
So.
The idea for this thing is to create a queue-like stream of parsed stuff?
 
lexed
basically, each token is like, an atom
the file is composed of the tokens in some pre-defined order/format.
like a molecule is made of atoms in some arrangement
 
Fair enough.
 
so a lexer gives you the atoms in the order in which they occur
and then a parser decides if they meet the required arrangement (and if so, usually spits out a data structure representing such)
 
Ok.
 
8:46 PM
so I match five of the seven tokens here
parsing is fairly simple if you can deal with recursion
 
@DeadMG Recursion is ok.
 
ok
so let's consider the grammar given at the top of this
actually, your grammar is so simple, it's probably regular
it is regular, lol
 
Erm.. ok
 
that means that you could match it with a regular expression.
and you don't actually need a real parser
if I re-write in EBNF it's fairly obvious
('<' identifier '>' (identifier '=' (number | identifier '.' identifier))+ '<' identifier '>')+
 
@DeadMG I think so?
 
8:53 PM
when you view it like that, you really do have a simple file format to deal with once you lex it.
and the "parser" is gonna be dead simple
 
Cool.
Oh, I forgot to mention, std::complex values are possible.
 
ok
so complex is a token type now
I have no idea what the form of a complex is like
 
They can be represented by (1,0) or 1,0 or 1 0 or 1, 0
etc
 
that's quite permissive.
 
It's supposed to deal with stupid people who don't rtfm
 
9:01 PM
you'd do yourself a favour by saying (double, double) only or something like that
but it won't be undecidable
or too nasty
 
Bleh, that was useless.
 
shouldn't be too hard to recognize in lexer, too.
 
Anyhow, it's supposed to deal with stupid people.
 
Double,Double|DoubleDouble|(Double,Double) should do as a regex
would be easier to do it as a parser rule, I think. then you won't have to deal with funky whitespace.
so the new grammar is this
 
That looks reasonable.
 
9:08 PM
but
there reaches a point where a sane person uses a parser or lexer generator, you know?
 
@DeadMG Sure lol.
 
here's my basic structure
I didn't do an awful lot of range checking, and there's a dash of pseudocode in there
but I figure you should be able to get the gist of it
 
You had to use boost lol.
 
eh
most people have to replace it with inheritance-based AST nodes
variant was just the simplest way of expressing what I wanted to
but you can of course roll any kind of type-erased thing you want.
but as you can see, both my sample lexer and sample parser are like, 60 lines of code each.
your file format is simple and recognizing it is simple
 
Yea. But people can be stupid and make it not simple.
 
9:33 PM
eh
my lexer code won't care if you use '\r\n' on Unix
 

last day (15 days later) »