flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > macros params: parsing brackets recursively? 
Author 

l_inc
Devel99
Do you mean something like an elsematch? Code: macro mk_MATH { macro MATH op \{ mk_MATH match (b), op \\{ MATH b rept 0 \\\{ \\} match, \\{ match a(b), op \\\{ MATH b MATH a r restore r rept 0 \\\\{ \\\} match, \\\{ match (b)c, op \\\\{ MATH b MATH r c restore r rept 0 \\\\\{ \\\\} match, \\\\{ match a(b)c, op \\\\\{ ;MATH b ;not sure what this case is about match \\\\\\{ PREPROCESSING ERROR \\\\\\} rept 0 \\\\\\{ \\\\\} match, \\\\\{ match x * y, op \\\\\\{ rept 1 t:x*y \\\\\\\{ define r t display \\\\\\\`x,'*',\\\\\\\`y,'=',\\\\\\\`t,13,10 \\\\\\\} \\\\\\} match x / y, op \\\\\\{ rept 1 t:x/y \\\\\\\{ define r t display \\\\\\\`x,'/',\\\\\\\`y,'=',\\\\\\\`t,13,10 \\\\\\\} \\\\\\} match x + y, op \\\\\\{ rept 1 t:x+y \\\\\\\{ define r t display \\\\\\\`x,'+',\\\\\\\`y,'=',\\\\\\\`t,13,10 \\\\\\\} \\\\\\} match x  y, op \\\\\\{ rept 1 t:xy \\\\\\\{ define r t display \\\\\\\`x,'',\\\\\\\`y,'=',\\\\\\\`t,13,10 \\\\\\\} \\\\\\} \\\\\}\\\\}\\\}\\} purge MATH \} } mk_MATH MATH (1 + ((2 * 5)  4)) Pure preprocessor solution might be fun, but for something more practical I'd recommend you to go the way described here (irps + virtual + load). _________________ Faith is a superposition of knowledge and fallacy 

09 Dec 2015, 00:18 

Devel99
l_inc Wise ideas =) thanks much. Bookmarked that. But it turns out that prep fails on the following expression:
MATH ([eax + 6] + [ebx  8]) Straight matching with PLUS wildcard gives me "[eax" and "6] + [ebx  8]" and extra workaround required so I moved back to previously implemented MATH <<[eax + 6], +, [ebx  8]>, *, [ecx + 7]> at least that worked and produced something like this Code: mcr_LDARG [eax + 6] mcr_LDARG [ebx  8] mcr_ADD mcr_LDARG [ecx + 7] mcr_MULL mcr_STFLD ... thank you for the cool ideas I need to think of that a bit more 

09 Dec 2015, 14:01 

l_inc
Devel99
Square brackets is an operator (of dereference) same as "+","","*","/", but having the highest precedence among these. So providing support for it is not a workaround. It's a part of the design. You just need to process the operators in form of an "elsematch" (to achieve mutually exclusive processing) starting with match [a], op . And I suppose, you won't need excessive parentheses. _________________ Faith is a superposition of knowledge and fallacy 

09 Dec 2015, 14:47 

< Last Thread  Next Thread > 
Forum Rules:

Copyright © 19992020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.