<stikonas>argh, macro functions are a bit annoying... <stikonas>I might be able to easily get simple case working, but then mes also uses them recursively... <stikonas>well, maybe it will just work by accident... <oriansj>stikonas: it is ok to not to implement a function <oriansj>also you can be insanely inefficient too <stikonas>oriansj: well, if we want to build mes-m2 then we should implement it, but yes, it can be inefficient <stikonas>anyway, reading info and matching variables to arguments in define is easy, I have those lists <oriansj>What if you do a state machine for define? <stikonas>oriansj: I just added one more member to the struct <stikonas>struct macro_list had next, symbol, expansion and I've added another token_list* arguments <oriansj>but how do most C preprocessors do it? <oriansj>because I have suspicion that it is probably something really simple we are missing <stikonas>although, I wouldn't say those first two commits that I have are complicated... <stikonas>although, it might be that my data structures are not the best <stikonas>well, I think we'll have to do without #define concat(a,b) a ## b <stikonas>and stuff like #define function_mac () something might be incompatible with gcc... <stikonas>but we don't need to get 100% compatibility with gcc preprocessor <oriansj>I vote we never do a full C macro processor in M2-Planet and just demand basic sanity from downstream projects? <stikonas>well, even if we can't implement "Function Argument Pre-expansion" that shouldn't be too hard to patch out in mes <oriansj>I wonder if peer pressure would be enough to convince janneke to save us the trouble... <stikonas>those things can be preexpanded manually <stikonas>at least defines without recursive pre-expansion should be doable <oriansj>yeah just banning DEFER, OBSTRUCT and EXPAND right now <oriansj>infinitely recursive macro definitions that require lazy evaluation to implement <oriansj>basically one needs to do a half a haskell, just to deal with what one can do with that. <oriansj>no wonder people thought bootstrapping C was impossible <stikonas>well, tcc preprocessor is as large as the whole M2-Planet... <stikonas>hmm, and I"ll have to fix my commits to handle cases like #define A (1) which is not a macro function... <oriansj>looks like we could just do a simple walk apply for #defines <stikonas>I guess that's why that whitespace matters between define and paranthesis <oriansj>but that isn't collected by M2-Planet so <oriansj>and honestly we can restrict ourselves to 3 cases <oriansj>#define foo 1 #define bar(x) thing_with_[x].car and #define caar(x) bar(bar(x)) <oriansj>if no ( after the first token we do only first case <oriansj>and the other two are just straight application of match first token and ( then use what is between the ( and ) as x and replace acordingly <stikonas>yes, I think those 3 cases are good enough... <stikonas>but then need to be careful with stuff like <oriansj>just exit(FAILURE) with line_error and a sterm message <oriansj>and if so, no logical reason not to fix it <stikonas>but I think tcc might be too advanced for M2-Planet... <oriansj>well yes, M2-Planet is just a stepping stone ***smartin1 is now known as smartin
***stikonas_ is now known as stikonas
<stikonas>oriansj: I did get macro functions somewhat working now <stikonas>although I think it's still struggling with include/mes/macros.h <stikonas>and struggling a bit with #define M2_CELL_SIZE (3 * sizeof(long)) <stikonas>so either workaround is needed, e.g. #define M2_CELL_SIZE 0 + (3 * sizeof(long)) <stikonas>or "#define A (a)" needs to be implemented