flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Advanced PARSING and data retrieval |
Author |
|
gandalf 01 Apr 2009, 15:38
Here you can find some macros I wrote for parsing data.
From wikipedia: Quote: In computer science and linguistics, parsing, or, more formally, syntactic analysis, is the process of analyzing a sequence of tokens (for example, words) to determine their grammatical structure with respect to a given (more or less) formal grammar. The parsing macros are in the file parsing.inc, whereas parsing_test.asm contains some examples. The last example is composed of three simple macros: proc, retp and endp. It shows how parsing macros can be used to do something we are all familiar with. You can find the tutorial in the file parsing.txt (to be updated soon, but already 99.9% up to date).
Last edited by gandalf on 05 Apr 2009, 15:40; edited 2 times in total |
|||||||||||||||||||||||||||||||
01 Apr 2009, 15:38 |
|
revolution 01 Apr 2009, 15:46
Thanks for the nice macros.
Do you have a working example where this is used? |
|||
01 Apr 2009, 15:46 |
|
revolution 01 Apr 2009, 19:28
Actually, I meant an example where the macros are used. I saw the test vectors at the bottom, but I think that is not really using them.
Since you went to the trouble to write them I thought that perhaps you had some application in mind? |
|||
01 Apr 2009, 19:28 |
|
DJ Mauretto 02 Apr 2009, 09:48
Ottimo Lavoro , io di macro non ci ho mai capito niente
in genere linguaggi ad alto livello per me sono una sorta di enigma, è possibile avere qualche esempio funzionale per capire a cosa serve quello che hai fatto stò leggendo il file parsing.txt ma per me è come leggere il corano in lingua originale Excellent Job usually high-level languages for me are a kind enigma, it is possible to have a few functional example to understand what what you did I'm Reading the file parsing.txt but for me is like reading the Koran in the original language _________________ Nil Volentibus Arduum |
|||
02 Apr 2009, 09:48 |
|
gandalf 02 Apr 2009, 14:05
revolution wrote: Actually, I meant an example where the macros are used. I saw the test vectors at the bottom, but I think that is not really using them. If you read parsing.txt you'll realize you can do anything with them. I had no specific application in mind if not parsing and data retrieval. If "match" is asm, my macros are language C. What you'll do with C is up to you. My last example takes an algebraic expression and rewrites it in Polish notation. That's not so trivial. |
|||
02 Apr 2009, 14:05 |
|
gandalf 02 Apr 2009, 14:52
DJ Mauretto wrote: Ottimo Lavoro , io di macro non ci ho mai capito niente Hmm, I'm not sure longer and more complex examples would help. My macros are very general so I can't make them specific. If you have trouble with parsing.txt you'll probably need to read something about parsing. What I can say is that versatile macros need to behave according to complex input. The input must be parsed and "understood". My macros are of great help in that regard. |
|||
02 Apr 2009, 14:52 |
|
DJ Mauretto 02 Apr 2009, 15:31
Io di solito programmo in asm puro,conosco e capisco solo
quello ,ma ero incuriosito da quello che avevi fatto cmq l'importante è che ti sei capito da solo I usually program in pure asm, I know and understand only that, but I was intrigued by what you had done however, the important thing is that you have understood only by yourself _________________ Nil Volentibus Arduum |
|||
02 Apr 2009, 15:31 |
|
gandalf 02 Apr 2009, 18:29
DJ Mauretto wrote: however, the important thing is that you have understood only by yourself I said that *the macro* needs to understand its input, not you! |
|||
02 Apr 2009, 18:29 |
|
gandalf 03 Apr 2009, 10:49
revolution wrote: Thanks for the nice macros. I hope the example I've just written satisfies you I wrote my macros to create "everyday" macros in less time and with less effort. Moreover, algebraic expression are quite maintainable. |
|||
03 Apr 2009, 10:49 |
|
revolution 03 Apr 2009, 10:58
Thanks for the example. But no endp!
When I get some time I want to have a look at this. |
|||
03 Apr 2009, 10:58 |
|
DJ Mauretto 03 Apr 2009, 11:18
ma che significa !!! Asm and High Level (Macro ) are 2 opposites poles I don't understand because who write assembler lose oneself with High Level Language, it's a waste of time and space _________________ Nil Volentibus Arduum |
|||
03 Apr 2009, 11:18 |
|
gandalf 03 Apr 2009, 12:34
revolution wrote: Thanks for the example. But no endp! Here it is: macro endp { } In that example you need to use 'retp'. It's more efficient this way, because 'retp' doesn't have to jump to the epilogue ('retp' *contains* the epilogue!) |
|||
03 Apr 2009, 12:34 |
|
revolution 03 Apr 2009, 12:52
endp is supposed to restore all the equ's though. endp isn't for epilogue.
|
|||
03 Apr 2009, 12:52 |
|
gandalf 03 Apr 2009, 17:08
revolution wrote: endp is supposed to restore all the equ's though. endp isn't for epilogue. Ok. If we want to restore all the equ, I need to modify the parsing macros. For instance, these macros update curExpr many times, so I can't restore curExpr with just a single restore. A clearVars would clear them completely, but what happen if someone else is using them? Anyway, since my macros don't rely on "restore" it's not difficult to modify the code so that every variable is first restored and then written to. This would solve the problem. But is it worth it? (not a rhetoric question) |
|||
03 Apr 2009, 17:08 |
|
Madis731 03 Apr 2009, 21:56
So you can do Prolog simulation with FASM macros? It seems that way.
Btw, it eats a lot of memory 131072 was the safe setting. RegExp is NICE! and I finally got the #16 example - the RPN. I had forgotten how to do that |
|||
03 Apr 2009, 21:56 |
|
revolution 03 Apr 2009, 23:15
gandalf wrote: But is it worth it? (not a rhetoric question) |
|||
03 Apr 2009, 23:15 |
|
gandalf 04 Apr 2009, 09:17
Madis731 wrote: So you can do Prolog simulation with FASM macros? It seems that way. That's a problem I'll solve ASAP. EDIT: No, the "problem" CAN'T be solved by me. It depends on how FASM handles things. Madis731 wrote: RegExp is NICE! and I finally got the #16 example - the RPN. I had forgotten how to do that I'm glad you took the time to read the entire txt file! Last edited by gandalf on 05 Apr 2009, 15:47; edited 1 time in total |
|||
04 Apr 2009, 09:17 |
|
gandalf 05 Apr 2009, 15:45
revolution wrote:
Now the parsing macros are as clean as they can be (have a look at the proc-endp example). |
|||
05 Apr 2009, 15:45 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.