< 1089593596 0 :WildHalcyon!unknown@unknown.invalid QUIT :Read error: 110 (Connection timed out) < 1089603979 0 :e-kyle!~kyle@CPE00045add4864-CM014260028983.cpe.net.cable.rogers.com JOIN :#esoteric < 1089604449 0 :e-kyle!unknown@unknown.invalid QUIT : < 1089605845 0 :kosmikus|away!unknown@unknown.invalid QUIT :bear.freenode.net irc.freenode.net < 1089605937 0 :kosmikus|away!~andres@kosmikus.developer.gentoo JOIN :#esoteric < 1089619199 0 :clog!unknown@unknown.invalid QUIT :ended < 1089619200 0 :clog!unknown@unknown.invalid JOIN :#esoteric < 1089624345 0 :kosmikus|away!unknown@unknown.invalid NICK :kosmikus < 1089648526 0 :fizzie!unknown@unknown.invalid QUIT :Remote closed the connection < 1089648527 0 :fizzie!fis@sesefras.tky.hut.fi JOIN :#esoteric < 1089651591 0 :ChanServ!unknown@unknown.invalid QUIT :Shutting Down < 1089652123 0 :ChanServ!ChanServ@services. JOIN :#esoteric < 1089652123 0 :irc.freenode.net!unknown@unknown.invalid MODE #esoteric :+o ChanServ < 1089653756 0 :kosmikus!unknown@unknown.invalid NICK :kosmikus|away < 1089665557 0 :mtve!unknown@unknown.invalid PART #esoteric :? < 1089665602 0 :mtve!mtve@mtve.vm.jvds.com JOIN :#esoteric < 1089665917 0 :calamari_!JeffryJohn@as07-pho-az-205-186-110-232.rasserver.net JOIN :#esoteric < 1089665922 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :hi < 1089665959 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :been thinking about the c parsing and ran into a difficulty < 1089666032 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :parsing of = is right to left.. i.e. a = b[c] = d is really a = (b[c] = d), not (a = b[c]) = d < 1089666050 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :yes < 1089666121 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :is there an easy way to deal with that (I'm using something similar to recursive descent, using a stack rather than recursive calls) < 1089666141 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :in other words I'm converting to rpn < 1089666272 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :usually it's a recursive parser that returns tree of operations. then you build your code by walking the tree. < 1089666292 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :right, but it builds the wrong tree < 1089666302 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :it's broken then :) < 1089666307 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :it does (a = b[c]) = d, which is wrong < 1089666334 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :hard to help you with seeing the code (or at least pseudocode). < 1089666336 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :right, it's broken because it assumes everything is left to right < 1089666345 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :no, this is theoretical < 1089666383 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :I haven't written any code yet, still planning < 1089666395 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :I just know that it will not be right < 1089666444 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :the best I have come up with is to scan forward and add parenthesis < 1089666484 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :but that seems like a kludge < 1089666499 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :search for some example code. the good one was kernighan and pike calculator afair. < 1089666528 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :doubtful that a calculator would involve the situation I'm describing < 1089666580 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :since in that case, the correct order is given by the person operating the calculator < 1089666582 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :right, they use lex. < 1089666603 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :That really depends on the complexity of the calculator. < 1089666651 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :anyway there is miriad of simple lectures about parsing, and lots of good books online. < 1089666677 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :most simple tutorials don't get into associativity of operators < 1089666701 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :the more complex ones assume use of flex & bison or such < 1089666764 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :Well, the calculator is an excellent example here. Exponentiation is a bothersome operation, associativity-wise. < 1089666767 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :so, adding the parenthesis is the best idea so far, I guess. bummer < 1089666787 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :it's very easy, i guess you just havn't did it before. < 1089666796 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :what's very easy? < 1089666802 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :adding the parenthesis? < 1089666811 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :Parsing? :) < 1089666819 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :parsing of left and right associative operators. < 1089666849 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :it doesn't seem easy to me < 1089666937 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :perhaps you can offer the easy solution? < 1089667117 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :a = b[c = d] = e < 1089667160 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :a = ( b[c = ( d ) ] = ( e ) ) < 1089667214 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :Wow. < 1089667230 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :just thinking aloud < 1089667263 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :I'll probably just go ahead and add parenthesis.. I'll let someone add the "easy" solution later :) < 1089667346 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :This isn't entirely related, but it's a nifty way of parsing infix: http://article.gmane.org/gmane.comp.lang.lightweight/285 < 1089667369 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :I'm mainly stating it so I can find it more quickly the next time :P < 1089667531 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :just untested pseudocode: < 1089667538 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :void read_lvl1(void) { read_lvl2(); if(token=='=') { eat_token(); read_lvl1(); op(PUSH POP=POP); } } // level 1 is right associative < 1089667538 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :void read_lvl2(void) { read_lvl3(); while(token=='+') { eat_token(); read_lvl3(); op(PUSH POP+POP); } } // level 2 is left associative < 1089667618 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :s/level/precedence/ < 1089668074 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :What language are you writing the compiler in? < 1089668186 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :c < 1089668193 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :but I won't be using recursive calls < 1089668212 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :Not to preach, but why C? < 1089668229 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :so that I can compile the compiler < 1089668250 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :What for? < 1089668256 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric :Oh, to BF: < 1089668258 0 :Taaus!unknown@unknown.invalid PRIVMSG #esoteric ::) < 1089668259 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :yeah < 1089668634 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :what I should do is stop trying to make this non-recursive thing work.. write it recursive then rescue it from recursion later < 1089668649 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :then I can use BNF < 1089668898 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :mtve: btw, thanks.. why does if make it right and while make it left? < 1089668926 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :oh wait < 1089668928 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :note also read_lvl1 is self recursive < 1089668935 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :yeah just noticed that < 1089668977 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :code looks pretty natural to me. same way as human parses such a code. < 1089668991 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :such a grammar i mean. < 1089669035 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :Taaus' link is interesting too. < 1089669074 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :hmm, I think I came up with a way to simulate private variables .. then I can use recursion < 1089669085 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :it allows excellent things like changing operators and meaning of language on-the-fly while parsing. < 1089669127 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :that would be nifty.. because I'll want to change a[b] to *(&a+b) < 1089669137 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :recursion can always be rewritten with static variables (basically the same way underlying processor works with memory) < 1089669170 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :yeah, I did that when working on the bf golf set problem < 1089669200 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :used a memory array to simulate the recursion < 1089669239 0 :calamari_!unknown@unknown.invalid PRIVMSG #esoteric :since all my variables are global, I didn't want to use recursion, but I think I can get around it < 1089669248 0 :mtve!unknown@unknown.invalid PRIVMSG #esoteric :recursion is harder for computers, its purpose is only to make life easier for a human :) < 1089671284 0 :calamari-!JeffryJohn@as07-pho-az-205-186-110-232.rasserver.net JOIN :#esoteric < 1089671291 0 :calamari_!unknown@unknown.invalid QUIT :Read error: 104 (Connection reset by peer) < 1089671441 0 :calamari!JeffryJohn@as07-pho-az-205-186-110-232.rasserver.net JOIN :#esoteric < 1089671441 0 :calamari-!unknown@unknown.invalid QUIT :Read error: 104 (Connection reset by peer) < 1089671813 0 :calamari!unknown@unknown.invalid PRIVMSG #esoteric :storm coming in.. gotta go < 1089671825 0 :calamari!unknown@unknown.invalid PRIVMSG #esoteric :thanks for your help and ideas < 1089671828 0 :calamari!unknown@unknown.invalid QUIT :"Leaving"