flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > FASM:s parser

Author
Thread Post new topic Reply to topic
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
What kind of parser does FASM employ?

_________________
This is a block of text that can be added to posts you make.
Post 14 Oct 2010, 05:27
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
What kinds are there?
Post 14 Oct 2010, 17:10
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
Top-down, bottom-up, shift-reducing, I don't know all..
Post 14 Oct 2010, 17:16
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Well, it takes all symbols/numbers/whatever one by one and translates them to internal "tokens" which are easier to work with than text. Not sure where that stands in your scheme.
Post 14 Oct 2010, 17:45
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
vid wrote:
Well, it takes all symbols/numbers/whatever one by one and translates them to internal "tokens" which are easier to work with than text.
What you described is the job of lexical analyser, and in fasm the lexical analyser is integrated into preprocessor. Parser is the next stage and is a little bit more complex. And fasm's parser is abit specific one, because it only recognizes some general constructs, leaving some additional analysis of operand structures to still be done later by assembler module.
Post 14 Oct 2010, 17:54
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
I would believe that the assembly instructions don't need a powerful parser, but evaluating expressions and perhaps macros would call for a more powerful recursive parser, perhaps a shift-reducing one.

I'm thinking of writing an 6502 assembler for my thesis, that's my I'm wondering.
Post 15 Oct 2010, 06:56
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
mindcooler wrote:
I would believe that the assembly instructions don't need a powerful parser, but evaluating expressions and perhaps macros would call for a more powerful recursive parser, perhaps a shift-reducing one.
Evaluating macros is in fasm done by preprocessor, so it is in fact another separate parser, since fasm's preprocessor language is completely separate from the assembly. Also, fasm's preprocessor is generally top-down with only minor exceptions (like "rept" directive expression calculator).
As for the main parser of fasm, it is more complex, and could be perhaps characterized as a mix of top-down and bottom-up approaches if you tried to categorize it in this way. But I feel that this terminology only suits well the general theoretical cases, and not a highly specialized one, like the fasm's parser. In fact, fasm's parser module is just a translator, which translates the preprocessed source (which is already tokenized) into a language of assembler module, which is then interpreted in multiple passes by assembler module (and some of the syntax checking and analysis still is left to be done upon interpretation by assembler, parser just translates it regardless of it being nonsense or not).
Post 15 Oct 2010, 13:22
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.