00:53:16 -!- WildHalcyon has quit (Read error: 110 (Connection timed out)). 03:46:19 -!- e-kyle has joined. 03:54:09 -!- e-kyle has quit. 04:17:25 -!- kosmikus|away has quit (bear.freenode.net irc.freenode.net). 04:18:57 -!- kosmikus|away has joined. 07:59:59 -!- clog has quit (ended). 08:00:00 -!- clog has joined. 09:25:45 -!- kosmikus|away has changed nick to kosmikus. 16:08:46 -!- fizzie has quit (Remote closed the connection). 16:08:47 -!- fizzie has joined. 16:59:51 -!- ChanServ has quit (Shutting Down). 17:08:43 -!- ChanServ has joined. 17:08:43 -!- irc.freenode.net has set channel mode: +o ChanServ. 17:35:56 -!- kosmikus has changed nick to kosmikus|away. 20:52:37 -!- mtve has left (?). 20:53:22 -!- mtve has joined. 20:58:37 -!- calamari_ has joined. 20:58:42 hi 20:59:19 been thinking about the c parsing and ran into a difficulty 21:00:32 parsing of = is right to left.. i.e. a = b[c] = d is really a = (b[c] = d), not (a = b[c]) = d 21:00:50 yes 21:02:01 is there an easy way to deal with that (I'm using something similar to recursive descent, using a stack rather than recursive calls) 21:02:21 in other words I'm converting to rpn 21:04:32 usually it's a recursive parser that returns tree of operations. then you build your code by walking the tree. 21:04:52 right, but it builds the wrong tree 21:05:02 it's broken then :) 21:05:07 it does (a = b[c]) = d, which is wrong 21:05:34 hard to help you with seeing the code (or at least pseudocode). 21:05:36 right, it's broken because it assumes everything is left to right 21:05:45 no, this is theoretical 21:06:23 I haven't written any code yet, still planning 21:06:35 I just know that it will not be right 21:07:24 the best I have come up with is to scan forward and add parenthesis 21:08:04 but that seems like a kludge 21:08:19 search for some example code. the good one was kernighan and pike calculator afair. 21:08:48 doubtful that a calculator would involve the situation I'm describing 21:09:40 since in that case, the correct order is given by the person operating the calculator 21:09:42 right, they use lex. 21:10:03 That really depends on the complexity of the calculator. 21:10:51 anyway there is miriad of simple lectures about parsing, and lots of good books online. 21:11:17 most simple tutorials don't get into associativity of operators 21:11:41 the more complex ones assume use of flex & bison or such 21:12:44 Well, the calculator is an excellent example here. Exponentiation is a bothersome operation, associativity-wise. 21:12:47 so, adding the parenthesis is the best idea so far, I guess. bummer 21:13:07 it's very easy, i guess you just havn't did it before. 21:13:16 what's very easy? 21:13:22 adding the parenthesis? 21:13:31 Parsing? :) 21:13:39 parsing of left and right associative operators. 21:14:09 it doesn't seem easy to me 21:15:37 perhaps you can offer the easy solution? 21:18:37 a = b[c = d] = e 21:19:20 a = ( b[c = ( d ) ] = ( e ) ) 21:20:14 Wow. 21:20:30 just thinking aloud 21:21:03 I'll probably just go ahead and add parenthesis.. I'll let someone add the "easy" solution later :) 21:22:26 This isn't entirely related, but it's a nifty way of parsing infix: http://article.gmane.org/gmane.comp.lang.lightweight/285 21:22:49 I'm mainly stating it so I can find it more quickly the next time :P 21:25:31 just untested pseudocode: 21:25:38 void read_lvl1(void) { read_lvl2(); if(token=='=') { eat_token(); read_lvl1(); op(PUSH POP=POP); } } // level 1 is right associative 21:25:38 void read_lvl2(void) { read_lvl3(); while(token=='+') { eat_token(); read_lvl3(); op(PUSH POP+POP); } } // level 2 is left associative 21:26:58 s/level/precedence/ 21:34:34 What language are you writing the compiler in? 21:36:26 c 21:36:33 but I won't be using recursive calls 21:36:52 Not to preach, but why C? 21:37:09 so that I can compile the compiler 21:37:30 What for? 21:37:36 Oh, to BF: 21:37:38 :) 21:37:39 yeah 21:43:54 what I should do is stop trying to make this non-recursive thing work.. write it recursive then rescue it from recursion later 21:44:09 then I can use BNF 21:48:18 mtve: btw, thanks.. why does if make it right and while make it left? 21:48:46 oh wait 21:48:48 note also read_lvl1 is self recursive 21:48:55 yeah just noticed that 21:49:37 code looks pretty natural to me. same way as human parses such a code. 21:49:51 such a grammar i mean. 21:50:35 Taaus' link is interesting too. 21:51:14 hmm, I think I came up with a way to simulate private variables .. then I can use recursion 21:51:25 it allows excellent things like changing operators and meaning of language on-the-fly while parsing. 21:52:07 that would be nifty.. because I'll want to change a[b] to *(&a+b) 21:52:17 recursion can always be rewritten with static variables (basically the same way underlying processor works with memory) 21:52:50 yeah, I did that when working on the bf golf set problem 21:53:20 used a memory array to simulate the recursion 21:53:59 since all my variables are global, I didn't want to use recursion, but I think I can get around it 21:54:08 recursion is harder for computers, its purpose is only to make life easier for a human :) 22:28:04 -!- calamari- has joined. 22:28:11 -!- calamari_ has quit (Read error: 104 (Connection reset by peer)). 22:30:41 -!- calamari has joined. 22:30:41 -!- calamari- has quit (Read error: 104 (Connection reset by peer)). 22:36:53 storm coming in.. gotta go 22:37:05 thanks for your help and ideas 22:37:08 -!- calamari has quit ("Leaving").