flat assembler
Message board for the users of flat assembler.

Index > Windows > Fasm 1.73 How build syntax tree ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
I want parse my text line and build syntax tree.
How do this in Fasm code ?

Txt db 'print: 4*var+1',13,10,0

Somthing like this.
Image
Post 11 Aug 2020, 17:42
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 821
Location: Belarus
DimonSoft
Have you read Dragon book?
Post 11 Aug 2020, 19:40
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
Thanks.
Now reading.
Post 11 Aug 2020, 21:16
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3045
Location: vpcmipstrm
bitRAKE
Some people think the first step is tokenization. This is where the source is broken into larger abstractions. To do this you will need to construct a model of your language. For example, maybe you limit input to ASCII, or just numbers and math symbols. Maybe you have predefined symbols or more complex constructions. Find a model that can be decoded - it's possible for a language model to have built-in problems.

There are languages to describe language models: BNF, EBNF, etc ...

If you want to build a very small langauge for learning - I would say to just jump in and make mistakes. Like a simple calculator (with variables), etc ... There are tools to build parsers from a language model: YACC, etc ... It can get really complex fast.

The dragon book is getting quite dated - as are the tools I mention above. So much research has happened since then, and modern languages have also evolved. Yet, it's a great overview.

FYI: there is a section of the board specifically for language design.

_________________
¯\(°_o)/¯ unlicense.org
Post 11 Aug 2020, 22:51
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 821
Location: Belarus
DimonSoft
The disadvantage of jumping directly to parser generators skipping the lexical analysis step is that one has to deal with whitespace chunks and comments (that are allowed nearly everywhere) in the grammar which at least doubles the complexity for any decent language.

Note also that the generators tend to be quite bad at providing good diagnostic error messages except for common cases.

Still, depends on the language. For some specific tasks the disadvantages are not a problem.
Post 12 Aug 2020, 08:09
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.